From: Stephen Rothwell Date: Thu, 16 Apr 2009 04:50:24 +0000 (+1000) Subject: Make find_branch work on Linus' tree better X-Git-Url: http://git.ozlabs.org/?a=commitdiff_plain;h=1e3e3fc6f975494da3ec00a56477e48e2f0fb387;p=next-scripts Make find_branch work on Linus' tree better --- diff --git a/find_branch b/find_branch index dbaf1fa..edc15c3 100755 --- a/find_branch +++ b/find_branch @@ -6,14 +6,26 @@ commit=$1 exit 1 } commit=$(git rev-parse --verify "$commit") -[ "$commit" ] || +[ "$commit" ] || { + echo "No such commit" 1>&2 exit 1 +} top=$2 [ "$top" ] || top=HEAD +tcommit=$(git rev-parse --verify "$top") +[ "$tcommit" ] || { + echo "Bad top tag" 1>&2 + exit 1 +} linus=$3 [ "$linus" ] || linus=origin/master +lcommit=$(git rev-parse --verify "$linus") +[ "$lcommit" ] || { + echo "Bad linus branch" 1>&2 + exit 1 +} base=$(git merge-base "$linus" "$top") @@ -21,22 +33,13 @@ git log --first-parent --reverse --pretty='format:%H %P' "$base".."$top" | while read m p1 p2 do [ "$p1" = "$commit" ] && { - echo "Directly committed" + git show -s --pretty="format:Commit: %H%nAuthor: %aN <%aE>%nAuthorDate: %ad%nCommitter: %cN <%cE>%nCommitterDate: %cd%nSubject: %s" $p1 break } [ "$p2" ] || continue git rev-list $base..$p2 | grep -q "$commit" || continue - branch=$(git show $m | sed -n "s/[ ]*Merge .*'\([^']*\)'\( of \([^ ]*\).*\)*$/\1|\3/p") - tree=${branch##*|} - branch=${branch%%|*} - [ "$tree" ] || { - tree=${branch%%/*} - [ "$tree" = "quilt" ] && tree=${branch##*/} - echo "$tree" - break - } - echo "$tree#$branch" + git show -s --pretty="format:Commit: %H%nAuthor: %aN <%aE>%nAuthorDate: %ad%nCommitter: %cN <%cE>%nCommitterDate: %cd%nSubject: %s" $m break done