[clang] d9e3e11 - [clang-format] Exit clang-format-diff only after all diffs are printed (#86776)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 27 21:23:41 PDT 2024
Author: Owen Pan
Date: 2024-03-27T21:23:37-07:00
New Revision: d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841
URL: https://github.com/llvm/llvm-project/commit/d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841
DIFF: https://github.com/llvm/llvm-project/commit/d9e3e11ae57612ec61f6fcab4afc27d8d0ff5841.diff
LOG: [clang-format] Exit clang-format-diff only after all diffs are printed (#86776)
See
https://github.com/llvm/llvm-project/pull/70883#issuecomment-2020811077.
Added:
Modified:
clang/tools/clang-format/clang-format-diff.py
Removed:
################################################################################
diff --git a/clang/tools/clang-format/clang-format-
diff .py b/clang/tools/clang-format/clang-format-
diff .py
index 0a2c24743678d0..3a74b90e731578 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())
More information about the cfe-commits
mailing list