Skip to content

Commit

Permalink
[clang-format] Exit clang-format-diff only after all diffs are printed (
Browse files Browse the repository at this point in the history
  • Loading branch information
owenca authored Mar 28, 2024
1 parent e766f87 commit d9e3e11
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions clang/tools/clang-format/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def main():
)

# Reformat files containing changes in place.
has_diff = False
for filename, lines in lines_by_file.items():
if args.i and args.verbose:
print("Formatting {}".format(filename))
Expand Down Expand Up @@ -169,7 +170,7 @@ def main():

stdout, stderr = p.communicate()
if p.returncode != 0:
sys.exit(p.returncode)
return p.returncode

if not args.i:
with open(filename) as f:
Expand All @@ -185,9 +186,12 @@ def main():
)
diff_string = "".join(diff)
if len(diff_string) > 0:
has_diff = True
sys.stdout.write(diff_string)
sys.exit(1)

if has_diff:
return 1


if __name__ == "__main__":
main()
sys.exit(main())

0 comments on commit d9e3e11

Please sign in to comment.