[PATCH] D90996: [clang-format] Add --staged/--cached option to git-clang-format

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 21 01:06:38 PDT 2021


MyDeveloperDay added a comment.

FYI I doubt you'll get a response from the original clang-format code owners as they have moved on. But I can take a look

Before giving this the ok, I'd like to understand a little more.

if I make a (bad)formatting change in a file which is not already staged and run `git clang-format` it will say

  $ git clang-format
  The following files would be modified but have unstaged changes:
  M       clang/lib/Format/Format.cpp
  Please commit, stage, or stash them first.

If I make a formatting change to a file that is untracked in the current directory, then it will NOT format those files

I have to do `git add Format.cpp`  for it tol format my file

  $ git clang-format
  changed files:
      clang/lib/Format/Format.cpp

i.e. I seem to ALWAYS have to stage files in order to have `git clang-format` do anything

So I'm kind of unclear as to what doing --staged will do differently? (is it to simply ignore the `The following files would be modified but have unstaged changes:` warning?

Did I misunderstand?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90996/new/

https://reviews.llvm.org/D90996



More information about the cfe-commits mailing list