Last active
September 26, 2016 17:37
-
-
Save zadr/c6a534027956e176f1fa945dda33da84 to your computer and use it in GitHub Desktop.
find the parent of merge commits to have manual branch-aware bisecting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log master..HEAD --merges --format="%h" | tr '\n' '\0' | xargs -0 -n1 git rev-list --parents -n 1 | awk '{print $(NF)}' | tr '\n' '\0' | xargs -0 -n1 git log --pretty=oneline -n 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find all merges, and only print out the hash of the commit | |
git log master..HEAD --merges --format="%h" | |
# translate all \n's into \0's for `xargs` | |
# with gnu xargs, you can get rid of this command and pass in `-d '\n'` instead of having to convert and pass in `-0` to xargs | |
tr '\n' '\0' | |
# for every merge commit, find the most recent parents that were responsible for the merge | |
xargs -0 -n1 git rev-list --parents -n 1 | |
# get the last column, which is the hash of the parent on the branch being merged in | |
awk '{print $(NF)}' | |
# technially we could stop here, since we have a list of the last commit of each branch before it was merged in | |
# but lets keep going to get better output | |
# translate all \n's into \0's for `xargs` (again, since we have one more commit) | |
tr '\n' '\0' | |
# get a git log of each commit, in the format of '#{hash} #{commit message}' | |
xargs -0 -n1 git log --pretty=oneline -n 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
given: | |
------feature-x--bugfix-y--bugfix-z | |
/ / / | |
---C1 / / | |
--------C2 / | |
-----C3----------------C4 | |
this command finds and prints: | |
#{C1-hash} #{C1-commit message} | |
#{C2-hash} #{C2-commit message} | |
#{C4-hash} #{C4-commit message} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment