Pre-commit hooks getting partial committed file list
- by Rex Xia
I know running git-diff and other tools can identify the changes in the repository, but when I do a partial commit, I need to pass only the committed files (rather than the entire set of files that are touched) to the pre-commit hook.
For example, I modified three files and commit only two, and I want the pre-commit hook to know the name of the two files.
git status --porcelain
M A.c
M B.c
M C.h
then I execute:
git commit -m "two files only" A.c B.c
How can the pre-commit hook get hold of the list of the two files only?