Pre-commit hooks getting partial committed file list

Posted by Rex Xia on Stack Overflow See other posts from Stack Overflow or by Rex Xia
Published on 2012-08-29T03:35:17Z Indexed on 2012/08/29 3:38 UTC
Read the original article Hit count: 397

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about git

Related posts about pre-commit-hook