]> git.ozlabs.org Git - next-scripts/commitdiff
New utiltiy (mainly for akpm)
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 20 Jan 2009 00:21:05 +0000 (11:21 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 20 Jan 2009 00:21:05 +0000 (11:21 +1100)
find_branch [new file with mode: 0755]

diff --git a/find_branch b/find_branch
new file mode 100755 (executable)
index 0000000..95c3bfa
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+commit=$1
+[ "$commit" ] || {
+       echo "$0: <commit id> [<top tag> [<linus branch>]]" 1>&2
+       exit 1
+}
+
+top=$2
+[ "$top" ] || top=HEAD
+
+linus=$3
+[ "$linus" ] || linus=origin/master
+
+base=$(git merge-base "$linus" "$top")
+
+git log --first-parent --pretty='format:%H %P' "$base".."$top" |
+while read m p1 p2
+do
+       [ "$p2" ] || continue
+       git rev-list $base..$p2 | grep -q "$commit" || continue
+       branch=$(git show $m | sed -n "s/[      ]*Merge .* '\([^']*\)'/\1/p")
+       tree=${branch%%/*}
+       [ "$tree" = "quilt" ] && tree=${branch##*/}
+       echo "$tree"
+       break
+done
+
+exit 0