Is there a way for a post-merge hook get a list of all the files that were changed by a merge, even if it was a fast-forward?
The right Git command to list the changed files is diff-tree
Also the ORIG_HEAD
and HEAD
shortcuts may be used:
git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD
(see also: List all the files for a commit in Git)
[upd]
Perhaps it is better to use HEAD@{1}
in place of ORIG_HEAD
. I.e.:
git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD
In case of git pull --ff-only
command, when many commits can be added, HEAD@{1}
(inside post-merge hook) gives the last commit before this command, while ORIG_HEAD
gives just HEAD^
commit (at least in Git 2.1.4).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With