[PATCH] D126365: [clang-format] Stop ignoring changes for files with space in path

Eitot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 25 03:59:34 PDT 2022


Eitot created this revision.
Eitot added a project: clang-format.
Herald added a project: All.
Eitot requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`git-clang-format` does not format files with spaces in their path.

  % git diff -p -U0 
  diff --git a/Test/Application/AppDelegate.m b/Test/Application/AppDelegate.m
  index 8bdd8b4..3effa19 100644
  --- a/Test/Application/AppDelegate.m
  +++ b/Test/Application/AppDelegate.m
  @@ -17 +17,2 @@ @implementation AppDelegate
  -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  +{
  diff --git a/Test/Main Window/MainWindowController.m b/Test/Main Window/MainWindowController.m
  index df56059..49e1a9f 100644
  --- a/Test/Main Window/MainWindowController.m   
  +++ b/Test/Main Window/MainWindowController.m   
  @@ -16 +16,2 @@ @implementation MainWindowController
  -- (void)windowDidLoad {
  +- (void)windowDidLoad
  +{



  % git-clang-format -v
  Ignoring changes in the following files (wrong extension or symlink):
      Test/Main Window/MainWindowController.m	
  Running clang-format on the following files:
      Test/Application/AppDelegate.m
  old tree: 9cbacaf7a33dd4184bdc46ae93c6295cfef56030
  new tree: 2a60aca2e1252612dd07032151c32536fcda6758
  changed files:
      Test/Application/AppDelegate.m

The issue is not the space itself, but the tab character appended to the path (`Test/Main Window/MainWindowController.m\t`) by `git-diff`.

This has been reported before at https://bugs.llvm.org/show_bug.cgi?id=28654.

Resolves https://github.com/llvm/llvm-project/issues/29028#issue-1076357057


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126365

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
@@ -345,7 +345,7 @@
     line = convert_string(line)
     match = re.search(r'^\+\+\+\ [^/]+/(.*)', line)
     if match:
-      filename = match.group(1).rstrip('\r\n')
+      filename = match.group(1).rstrip('\r\n\t')
     match = re.search(r'^@@ -[0-9,]+ \+(\d+)(,(\d+))?', line)
     if match:
       start_line = int(match.group(1))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126365.431930.patch
Type: text/x-patch
Size: 546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220525/5e24703f/attachment-0001.bin>


More information about the cfe-commits mailing list