]> git.ozlabs.org Git - next-scripts/blobdiff - find_branch
update to_build_host a bit
[next-scripts] / find_branch
index 95c3bfa077b12c1ce656ae71e50b34c51a206b6c..edc15c35f356de795c25b675bf3b97b9095a4738 100755 (executable)
@@ -5,24 +5,41 @@ commit=$1
        echo "$0: <commit id> [<top tag> [<linus branch>]]" 1>&2
        exit 1
 }
+commit=$(git rev-parse --verify "$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")
 
-git log --first-parent --pretty='format:%H %P' "$base".."$top" |
+git log --first-parent --reverse --pretty='format:%H %P' "$base".."$top" |
 while read m p1 p2
 do
-       [ "$p2" ] || continue
+       [ "$p1" = "$commit" ] && {
+               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 .* '\([^']*\)'/\1/p")
-       tree=${branch%%/*}
-       [ "$tree" = "quilt" ] && tree=${branch##*/}
-       echo "$tree"
+       git show -s --pretty="format:Commit:            %H%nAuthor:             %aN <%aE>%nAuthorDate:  %ad%nCommitter: %cN <%cE>%nCommitterDate:       %cd%nSubject:   %s" $m
        break
 done