owenpan created this revision.
owenpan added a reviewer: MyDeveloperDay.
owenpan added a project: clang-format.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

https://github.com/llvm/llvm-project/issues/53220


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117414

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===================================================================
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -161,10 +161,12 @@
       print('Running clang-format on the following files:')
       for filename in changed_lines:
         print('    %s' % filename)
+
   if not changed_lines:
     if opts.verbose >= 0:
       print('no modified files to format')
-    return
+    return 0
+
   if len(commits) > 1:
     old_tree = commits[1]
     new_tree = run_clang_format_and_save_to_tree(changed_lines,
@@ -179,10 +181,13 @@
   if opts.verbose >= 1:
     print('old tree: %s' % old_tree)
     print('new tree: %s' % new_tree)
+
   if old_tree == new_tree:
     if opts.verbose >= 0:
       print('clang-format did not modify any files')
-  elif opts.diff:
+    return 0
+
+  if opts.diff:
     print_diff(old_tree, new_tree)
   elif opts.diffstat:
     print_diffstat(old_tree, new_tree)
@@ -194,6 +199,8 @@
       for filename in changed_files:
         print('    %s' % filename)
 
+  return 1
+
 
 def load_git_config(non_string_options=None):
   """Return the git configuration as a dictionary.


Index: clang/tools/clang-format/git-clang-format
===================================================================
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -161,10 +161,12 @@
       print('Running clang-format on the following files:')
       for filename in changed_lines:
         print('    %s' % filename)
+
   if not changed_lines:
     if opts.verbose >= 0:
       print('no modified files to format')
-    return
+    return 0
+
   if len(commits) > 1:
     old_tree = commits[1]
     new_tree = run_clang_format_and_save_to_tree(changed_lines,
@@ -179,10 +181,13 @@
   if opts.verbose >= 1:
     print('old tree: %s' % old_tree)
     print('new tree: %s' % new_tree)
+
   if old_tree == new_tree:
     if opts.verbose >= 0:
       print('clang-format did not modify any files')
-  elif opts.diff:
+    return 0
+
+  if opts.diff:
     print_diff(old_tree, new_tree)
   elif opts.diffstat:
     print_diffstat(old_tree, new_tree)
@@ -194,6 +199,8 @@
       for filename in changed_files:
         print('    %s' % filename)
 
+  return 1
+
 
 def load_git_config(non_string_options=None):
   """Return the git configuration as a dictionary.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to