Mention git-clang-format
dblume

dblume commited on 2023-08-22 17:04:11
Showing 1 changed files, with 13 additions and 1 deletions.

... ...
@@ -74,7 +74,19 @@ Or install a newer one (replace 17 with whatever's current now) with:
74 74
     sudo ./llvm.sh 17
75 75
     sudo apt install clang-format-17
76 76
 
77
-Then, after making your edits, use the [vim integration](https://clang.llvm.org/docs/ClangFormat.html#vim-integration) or manually format with:
77
+Then, after making your edits, use the [vim integration](https://clang.llvm.org/docs/ClangFormat.html#vim-integration)
78
+or manually format in one of a couple of ways:
79
+
80
+### Use git-clang-format
81
+
82
+`git-clang-format` is installed with clang-format and will format staged files
83
+into the unstaged area.
84
+
85
+1. Stage the files you want to format.
86
+2. Run `git-clang-format-17 --style=file`, and it'll leave unstaged formatting changes.
87
+3. Review with `git difftool` and accept the desired changes or unstage.
88
+
89
+### Manually clang-format
78 90
 
79 91
     git status --porcelain | \
80 92
     awk 'match($1, "M|A") && match($2, "(c|h)(pp)?$"){print $2}' | \
81 93