From 9f29493dcd93c17f0f635c7388c713a2bc4a6211 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 20 Jan 2009 11:21:05 +1100 Subject: [PATCH] New utiltiy (mainly for akpm) --- find_branch | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 find_branch diff --git a/find_branch b/find_branch new file mode 100755 index 0000000..95c3bfa --- /dev/null +++ b/find_branch @@ -0,0 +1,29 @@ +#!/bin/bash + +commit=$1 +[ "$commit" ] || { + echo "$0: [ []]" 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 -- 2.39.2