Skip to content

Commit

Permalink
[clang-format] Fix a bug in git-clang-format --binary (#74293)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
owenca committed Dec 4, 2023
1 parent 54c3095 commit 78940a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clang/tools/clang-format/git-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ def main():
else:
if len(commits) > 2:
die('at most two commits allowed; %d given' % len(commits))
opts.binary=os.path.abspath(opts.binary)

if os.path.dirname(opts.binary):
opts.binary = os.path.abspath(opts.binary)

changed_lines = compute_diff_and_extract_lines(commits, files, opts.staged)
if opts.verbose >= 1:
ignored_files = set(changed_lines)
Expand Down

0 comments on commit 78940a4

Please sign in to comment.