git-clang-format version

Hi list,

Is there a way to determine a version of clang-format from running git-clang-format?

Some background: I have a .clang_format that works for a specific clang-format version. I’d also like to be able to use git-clang-format but I would need a test to determine whether I should run it. Ideally, there would be something like

$ git-clang-format --version

which would be equivalent to

$ clang-format --version

but I didn’t see anything like that. My only workaround at this point is start querying all different variant of clang-format executables in $PATH.

Thank you.


Hi Andrey,

Functionality of `git clang-format` is provided by a python script,
which should just call the clang-format binary that is available in
your path. In other words it should use the same version as you see
when you do

$ clang-format -version

However, if for some reason you want to use a different binary, you
can pass it explicitly with

$ git clang format --binary /path/to/clang-format

For all the available options, use

$ git clang-format -h

or have a look at the underlying script [1].




Hi Jonas,

Thanks for suggestions. I knew about those options, but using them still requires extra work as instead of checking the version by doing a simple

$ git clang-format --version

I have to first determine which clang-format binary there is (depending on the way it is installed it may be called clang-format, clang-format-3.9, clang-format-mp-3.9) and then call version on it. This seems like an unnecessary busy work. Of course, once determined, I could use clangFormat.binary to remember it.