0

[clang-format][NFC] Reformat git-clang-format

NOKEYCHECK=True
GitOrigin-RevId: 72540dbe01d143436be096b44deb89e625f350f7
This commit is contained in:
Owen Pan
2025-04-10 19:06:16 -07:00
committed by Copybara-Service
parent a7166c67cc
commit cb20e08f44

@@ -32,9 +32,7 @@ import re
import subprocess
import sys
usage = (
"git clang-format [OPTIONS] [<commit>] [<commit>|--staged] [--] [<file>...]"
)
usage = "git clang-format [OPTIONS] [<commit>] [<commit>|--staged] [--] [<file>...]"
desc = """
If zero or one commits are given, run clang-format on all lines that differ
@@ -236,10 +234,7 @@ def main():
if not opts.diff:
die("--diff is required when two commits are given")
elif opts.diff_from_common_commit:
die(
"--diff_from_common_commit is only allowed when two commits are "
"given"
)
die("--diff_from_common_commit is only allowed when two commits are given")
if os.path.dirname(opts.binary):
opts.binary = os.path.abspath(opts.binary)
@@ -385,10 +380,7 @@ def disambiguate_revision(value):
return False
if object_type in ("commit", "tag"):
return True
die(
"`%s` is a %s, but a commit or filename was expected"
% (value, object_type)
)
die("`%s` is a %s, but a commit or filename was expected" % (value, object_type))
def get_object_type(value):
@@ -463,9 +455,7 @@ def extract_lines(patch_file):
line_count = 1
if start_line == 0:
continue
matches.setdefault(filename, []).append(
Range(start_line, line_count)
)
matches.setdefault(filename, []).append(Range(start_line, line_count))
return matches
@@ -780,13 +770,10 @@ def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
.split("\0")
)
if not force:
unstaged_files = run(
"git", "diff-files", "--name-status", *changed_files
)
unstaged_files = run("git", "diff-files", "--name-status", *changed_files)
if unstaged_files:
print(
"The following files would be modified but have unstaged "
"changes:",
"The following files would be modified but have unstaged changes:",
file=sys.stderr,
)
print(unstaged_files, file=sys.stderr)
@@ -828,17 +815,13 @@ def run(*args, **kwargs):
if p.returncode == 0:
if stderr:
if verbose:
print(
"`%s` printed to stderr:" % " ".join(args), file=sys.stderr
)
print("`%s` printed to stderr:" % " ".join(args), file=sys.stderr)
print(stderr.rstrip(), file=sys.stderr)
if strip:
stdout = stdout.rstrip("\r\n")
return stdout
if verbose:
print(
"`%s` returned %s" % (" ".join(args), p.returncode), file=sys.stderr
)
print("`%s` returned %s" % (" ".join(args), p.returncode), file=sys.stderr)
if stderr:
print(stderr.rstrip(), file=sys.stderr)
sys.exit(2)