[PATCH] D24319: clang-format: Add a flag to limit git-clang-format's diff to a single commit

Luis Héctor Chávez via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 21:17:20 PDT 2016


lhchavez marked 3 inline comments as done.

================
Comment at: cfe/trunk/tools/clang-format/git-clang-format:93
@@ -92,1 +92,3 @@
                  help='default commit to use if none is specified'),
+  p.add_argument('--single-commit', action='store_true',
+                 help=('run clang-format on a single commit instead of against '
----------------
lhchavez wrote:
> lodato wrote:
> > nit: I find this flag confusing since it does not follow any git convention. Instead, I suggest making the interface similar to `git diff`: if two `<commit>`s are given, take the diff of those two trees to find the list of changed lines, then run clang-format on the second commit.
> > 
> > For example:
> > 
> > * `git clang-format --diff HEAD HEAD~` would tell you if HEAD was properly clang-formatted or not.
> > * `git clang-format --diff 8bf003 ae9172` would tell you if any of the lines in ae9172 that differ from 8bf003 are not properly clang-formatted.
> > 
> >  operate in this new mode only if two `<commit>`s are given.  Then the interface would be, for example, `git clang-format abcd1234 abcd1234~`.
> The thing I liked about using git-diff-tree is that you can pass a single commit and even if it's a merge-commit, it does the right thing. I'll try that idea out and allow more than two commits and see how it behaves.
Nevermind, `git diff-tree` didn't work with merge-commits if a single commit is passed. Changed to your proposal.


https://reviews.llvm.org/D24319





More information about the cfe-commits mailing list