#!/usr/bin/env bash # Given a git hash ($1), # use vimdiff to compare given commit to commit it was cherry-picked from. # # Author: Tom Saeger # 6/21/2017 FIRST=${1:-$(tig-pick)} SECOND=${2:-$(git show --format=email "${FIRST}" | sed -ne '/cherry picked/{s/.*commit \([0-9a-z]\+\).*/\1/;p;q;}')} # if not "cherry picked" find first line with "commit" if test -z "${SECOND}" ; then SECOND=$(git show --format=email "${FIRST}" | sed -ne '/commit /{s/.*commit \([0-9a-z]\+\).*/\1/;p;q;}') fi if test -z "${SECOND}" ; then exit 0; fi vim -d <(git show --format=email "${FIRST}") <(git show --format=email "${SECOND}")