Open Bug 1545276 Opened 6 years ago Updated 1 years ago

./mach clang-format Requires -p option. Using -c <changeset> -s doesn't print diffs

Categories

(Developer Infrastructure :: Lint and Formatting, defect, P3)

Tracking

(Not tracked)

People

(Reporter: haik, Unassigned)

References

Details

./mach clang-format -s doesn't print any formatting fixes for the changed files in the working dir parent changeset. Using the -c <changeset> option also doesn't seem to work. Using the -p option to specify the changed file does work. See example below where the working dir parent changeset changed dom/ipc/ContentParent.cpp. In Mercurial this is the '.' changeset which can be referred to with -c ..

$ hg parent -v|grep files
files:       dom/ipc/ContentChild.cpp dom/ipc/ContentParent.cpp xpcom/base/nsMacUtilsImpl.cpp xpcom/base/nsMacUtilsImpl.h

$ ./mach clang-format -c . -s
Wed Apr 17 14:25:28 PDT 2019

$ ./mach clang-format -s -p dom/ipc/ContentParent.cpp
Processing 1 file(s)...
--- /Users/haftandilian/r/mc/dom/ipc/ContentParent.cpp	2019-04-17 13:40:01.000000000 -0700
+++ /Users/haftandilian/r/mc/dom/ipc/ContentParent.cpp	2019-04-17 14:25:41.000000000 -0700
@@ -5718,7 +5718,7 @@
     }
 
     Unused << entry->GetKey()->SendAttachBrowsingContext(
-      child->GetIPCInitializer());
+        child->GetIPCInitializer());
   }
 
   return IPC_OK();
Wed Apr 17 14:25:41 PDT 2019

Workaround:
$ for f in `hg log -r . --template "{files % '{file}\n'}"` ; do echo clang-format -p ${f} ; ./mach clang-format -c . -p ${f} ; done

Emilio, as you implemented the -c option, is that something you could help with? Thanks

Flags: needinfo?(emilio)

It's working for me on git. Unfortunately I don't have the time to dig why it's not working on mercurial right now :(

Flags: needinfo?(emilio)
Priority: -- → P3

./mach clang-format was formatting the files in the most recent mercurial changeset for me until recently (as if it defaulted to -c .), but no longer.

Product: Firefox Build System → Developer Infrastructure
Severity: normal → S3
See Also: → 1674281

./mach clang-format, with or without --commit . is not consistent about whether it formats files changed in the parent changeset and I don't know what the pattern is.
./mach lint --rev . --linter clang-format --warnings at least notices files changed in the parent changeset in a case where ./mach clang-format did not.
Or ./mach clang-format --show --pathhg log -r . --template "{files % '{file}\n'}"` also behaves as expected.

See Also: → 1514279
You need to log in before you can comment on or make changes to this bug.