Background: I'm working on a pre-commit tool. As a developer it can be quite frustrating to pull another developer's branch and have the pre-commit hook complain loudly about files that I haven't even touched.
What I'd like to be able to do in my implementation is in a merge-commit case only run the hooks on files that were either conflicting or manually edited by me locally during the merge conflict.
What I've tried so far:
git diff --staged
- This is what the current solution does and isn't correct because it contains all of the files including the ones that merged cleanly.git diff MERGE_HEAD
- This is pretty close, but if the branch I am merging in branched from master after I did, this contains all of the changes from master that I haven't yet merged..git/MERGE_MSG
contains the list of conflicting files. This seems like a good starting point but does not contain locally edited files.- After committing,
git show --name-only
gets me exactly what I want. But that's too late (I'm implementing pre-commit after all :D)