diff options
author | Owen Pan <owenpiano@gmail.com> | 2024-03-27 21:23:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 21:23:37 -0700 |
commit | d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841 (patch) | |
tree | 99a6d3c94dd5d5158ba23abd8e1d8ad459a2c6b0 | |
parent | e766f87b922933d6b1aefcfd24e5111162369e2e (diff) | |
download | llvm-d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841.zip llvm-d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841.tar.gz llvm-d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841.tar.bz2 |
[clang-format] Exit clang-format-diff only after all diffs are printed (#86776)
See
https://github.com/llvm/llvm-project/pull/70883#issuecomment-2020811077.
-rwxr-xr-x | clang/tools/clang-format/clang-format-diff.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index 0a2c247..3a74b90 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -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)) @@ -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: @@ -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()) |