aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/clang-format/clang-format-diff.py
diff options
context:
space:
mode:
Diffstat (limited to 'clang/tools/clang-format/clang-format-diff.py')
-rwxr-xr-xclang/tools/clang-format/clang-format-diff.py10
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())