[clang-format] Handle spaces in filename paths in clang-format-diff.py (#135779)
This PR resolves an issue in clang-format-diff.py where
filenames containing spaces were not correctly extracted from Git diffs.
Due to the previous regex implementation, filenames were being
truncated, causing the script to fail when processing diffs with such
filenames.
Fixes #135619.
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index c82b41e..3059982 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -102,7 +102,7 @@
filename = None
lines_by_file = {}
for line in sys.stdin:
- match = re.search(r"^\+\+\+\ (.*?/){%s}(\S*)" % args.p, line)
+ match = re.search(r"^\+\+\+\ (.*?/){%s}(.+)" % args.p, line.rstrip())
if match:
filename = match.group(2)
if filename is None: