Module: Mesa
Branch: main
Commit: fa8a2326910f2c2ea2695c147e9170e157d90d45
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa8a2326910f2c2ea2695c147e9170e157d90d45

Author: Eric Engestrom <[email protected]>
Date:   Mon Jun 19 23:46:26 2023 +0100

docs/coding-style: add pre-commit hook fallback for clang-format

Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23722>

---

 docs/codingstyle.rst | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/docs/codingstyle.rst b/docs/codingstyle.rst
index ffa5b4d0c15..6e8b6b74a5d 100644
--- a/docs/codingstyle.rst
+++ b/docs/codingstyle.rst
@@ -81,6 +81,22 @@ can't find anything (eg. on Debian/Ubuntu), refer to `this 
StackOverflow
 answer <https://stackoverflow.com/a/59850773>`__ to install clang-format
 through Emacs instead.
 
+git ``pre-commit`` hook
+***********************
+
+If your editor doesn't support this, or if you don't want to enable it, you
+can always just run ``ninja clang-format`` to format everything, or add
+a ``pre-commit`` hook that runs this automatically whenever you ``git
+commit`` by adding the following in your ``.git/hooks/pre-commit``:
+
+.. code:: sh
+
+   shopt -s globstar
+   git clang-format $upstream -- $(grep -oE '[^#]' .clang-format-include)
+   # replace $upstream with the name of the remote tracking upstream mesa
+   # if you don't know, it's probably `origin`
+
+
 Basic formatting guidelines
 ---------------------------
 

Reply via email to