Skip to content

Instantly share code, notes, and snippets.

@bjackman
Created October 13, 2017 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjackman/d36ca2db983d344eb7e0912fc48ec61c to your computer and use it in GitHub Desktop.
Save bjackman/d36ca2db983d344eb7e0912fc48ec61c to your computer and use it in GitHub Desktop.
#/bin/bash
set -eu
# In a kernel repo, this finds all the tip:sched commits Linus has merged,
# with a header for each of the merge commits that merged them.
# Got it?
# This helper takes a merge commit, then finds the point at which the merged
# branches diverged, and gives you all the commits between that point and the
# second parent of the merge commit. What? OK..
#
# M
# |\
# X A
# | |
# Y B
# |/
# Z
#
# find_merged_commits M will print A and B.
find_merged_commits() {
merge=$1 # This is M
first_parent=$(git rev-parse $merge^1) # This is X
second_parent=$(git rev-parse $merge^2) # This is A
merge_base=$(git merge-base $first_parent $second_parent) # This is Z
git --no-pager log --format=format:" %h %s <%aN>" $merge_base..$second_parent # This prints A and B
}
# For each merge commit authored by Torvalds with "sched.*tip" in the message
git log --author "Linus Torvalds" --merges --grep "sched.*tip" --format=format:%H | while read merge; do
echo
echo ====================================================
git log -1 --date=short --format=format:"%h %cd %s" $merge
echo
echo
find_merged_commits $merge
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment