[PATCH] D129311: [clang-format] Update return code
Sridhar Gopinath via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 18 16:29:11 PDT 2022
sridhar_gopinath updated this revision to Diff 445652.
sridhar_gopinath added a comment.
Updated subprocess.call -> subprocess.run
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129311/new/
https://reviews.llvm.org/D129311
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
@@ -198,16 +198,16 @@
return 0
if opts.diff:
- print_diff(old_tree, new_tree)
- elif opts.diffstat:
- print_diffstat(old_tree, new_tree)
- else:
- changed_files = apply_changes(old_tree, new_tree, force=opts.force,
- patch_mode=opts.patch)
- if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
- print('changed files:')
- for filename in changed_files:
- print(' %s' % filename)
+ return print_diff(old_tree, new_tree)
+ if opts.diffstat:
+ return print_diffstat(old_tree, new_tree)
+
+ changed_files = apply_changes(old_tree, new_tree, force=opts.force,
+ patch_mode=opts.patch)
+ if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
+ print('changed files:')
+ for filename in changed_files:
+ print(' %s' % filename)
return 1
@@ -536,8 +536,8 @@
# We also only print modified files since `new_tree` only contains the files
# that were modified, so unmodified files would show as deleted without the
# filter.
- subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
- '--'])
+ return subprocess.run(['git', 'diff', '--diff-filter=M',
+ old_tree, new_tree, '--exit-code', '--']).returncode
def print_diffstat(old_tree, new_tree):
"""Print the diffstat between the two trees to stdout."""
@@ -548,8 +548,14 @@
# We also only print modified files since `new_tree` only contains the files
# that were modified, so unmodified files would show as deleted without the
# filter.
- subprocess.check_call(['git', 'diff', '--diff-filter=M', '--stat', old_tree, new_tree,
- '--'])
+ return subprocess.run(['git',
+ 'diff',
+ '--diff-filter=M',
+ '--stat',
+ old_tree,
+ new_tree,
+ '--exit-code',
+ '--']).returncode
def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
"""Apply the changes in `new_tree` to the working directory.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129311.445652.patch
Type: text/x-patch
Size: 2405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220718/14b52979/attachment.bin>
More information about the cfe-commits
mailing list