I've created a Git hook to automatically format staged C++ files before a commit.
It formats entire files but only re-stages sections of the C++ files that were already staged for commit. This preserves the functionality of git add --patch.
It turns out that this task is not trivial, but I think I've documented it fairly well. There's probably a more efficient way to do this (it currently has to do 2 passes), but I think at this point I should be investing more time into the assignment itself lol.
The pre-commit hook needs to be symlinked from.githooks into the .git/hooks directory.
I've created a Git hook to automatically format staged C++ files before a commit.
It formats entire files but only re-stages sections of the C++ files that were already staged for commit. This preserves the functionality of
git add --patch
.It turns out that this task is not trivial, but I think I've documented it fairly well. There's probably a more efficient way to do this (it currently has to do 2 passes), but I think at this point I should be investing more time into the assignment itself lol.
The pre-commit hook needs to be symlinked from
.githooks
into the.git/hooks
directory.