Reputation: 34667
Given two (or more) commits, I want to find the oldest merge which joins them. Something like the opposite of git merge-base
(which finds the youngest common ancestors). Notice that the commit I’m looking for will be a younger descendant of the starting commits.
In other words: I want to investigate the merge commit which merged two given commits (where changes to the same file happened).
Upvotes: 8
Views: 777
Reputation: 60255
oldest-merge() {
( for c; do git log --all --merges --ancestry-path ^$c --pretty='%aI %h %s'; done ) \
| sort | uniq -c | awk "\$1 == $# {print;exit}"
}
oldest-merge `git rev-list --all --grep=BUG-27182` # e.g.
the final awk takes the first commit that showed up in all the merge-ancestry lists.
Upvotes: 1
Reputation: 1588
If $a and $b are the two commit hashes and they are both contained in master, then say
git rev-list $a..master --ancestry-path >a
git rev-list $b..master --ancestry-path >b
Then use a diff tool to find the last common line of a an b.
Upvotes: 0