I built a general-purpose approach to doing various operations on a merge's commits.
Step One: Add an alias to git by editing ~/.gitconfig
:
[alias]
range = "!. ~/.githelpers && run_on_merge_range"
Step Two: In ~/.githelpers
, define a bash function:
run_on_merge_range() {
cmd=$1; shift
commit=$1; shift
range=$(git show $commit | grep Merge: | awk '{print $2 "..." $3}')
echo "git $cmd $range $@"
if [ -z $range ]; then
echo "No merge detected"
exit 1
fi
git $cmd $range $@
}
Step Three: Profit!
git range log <merge SHA> --oneline
git range diff <merge SHA> --reverse -p
git range diff <merge SHA> --name-only
There is probably a LOT of room for improvement here, I just whipped this together to get past an annoying situation. Feel free to mock my bash syntax and/or logic.