Skip to content

Commit bf0de88

Browse files
committed
code format checker: fix python error when the diff becomes empty
1 parent 1256ca0 commit bf0de88

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/utils/git/code-format-helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str
385385
# Each file is prefixed like:
386386
# diff --git a/file b/file
387387
for file in re.split("^diff --git ", stdout, 0, re.MULTILINE):
388-
filename = re.match("a/([^ ]+)", file.splitlines()[0])[1]
388+
lines = file.splitlines()
389+
match = re.match("a/([^ ]+)", lines[0] if lines else "")
390+
filename = match[1] if match else ""
389391
if filename.endswith(".ll"):
390392
undef_regex = r"(?<!%)\bundef\b"
391393
else:

0 commit comments

Comments
 (0)