Skip to content

Commit 78940a4

Browse files
authored
[clang-format] Fix a bug in git-clang-format --binary (#74293)
This is a rework of #74176, which erroneously changed the default clang-format filename (`clang-format`, `clang-format.exe`, etc.) to an absolute pathname. Instead, we should do that only if the name is a pathname, e.g. `./clang-format`, `llvm-project/build/bin/clang-format.exe`, etc. See also #74176 (comment).
1 parent 54c3095 commit 78940a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/tools/clang-format/git-clang-format

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def main():
153153
else:
154154
if len(commits) > 2:
155155
die('at most two commits allowed; %d given' % len(commits))
156-
opts.binary=os.path.abspath(opts.binary)
156+
157+
if os.path.dirname(opts.binary):
158+
opts.binary = os.path.abspath(opts.binary)
159+
157160
changed_lines = compute_diff_and_extract_lines(commits, files, opts.staged)
158161
if opts.verbose >= 1:
159162
ignored_files = set(changed_lines)

0 commit comments

Comments
 (0)