pocc / pre-commit-hooks

C/C++ hooks to integrate with pre-commit
Apache License 2.0
323 stars 67 forks source link

Use a clang-format file that isn't at the root of the repo #59

Open Ryanf55 opened 1 year ago

Ryanf55 commented 1 year ago
          > For clang-format, with a `.clang-format` file in the base of your repo:
  - repo: https://github.com/pocc/pre-commit-hooks
    rev: v1.3.5
    hooks:
      - id: clang-format
        args: [-i, --style=file]

Thanks for your reply. I will try it.

Originally posted by @sangshuduo in https://github.com/pocc/pre-commit-hooks/issues/50#issuecomment-1399152423

Clang-format has a limitation that it only looks in the current director, or above it, when searching for a config file.

I have multiple repositories, A, B, and C. A and B have source code. C has common configuration including the clang-format file, which is shared with B and C.

Latest clang-format has support for this: https://stackoverflow.com/a/70859277/11032285

Is there anything that I should do to use that?