The git show --raw
command will show if a commit hash was generated from a merge:
$ git show --raw -m 3d1718
commit 3d1718fb99d52d35700b596bac45caffd1af00dc (from 8923654049aa49c4813fa612e4108271e0361240)
Merge: 8923654 3f1a071
...
In the case where the merge came from a fork into origin/master, parsing the output will reveal which commit hash was the HEAD of origin/master and which commit hash came from the fork. So far, so good.
Once I have the commit hash from the fork, how would I generate a list of hashes for all the commits that are part of that merge? The history might look like this:
H---->J---->W origin/master
\ /
Q-->R-->T fork
In this case, the git show --raw -m
command would be executed on the hash for W, and I can get the hash for T. But how do I get the hashes for Q and R?