]> git.ozlabs.org Git - next-scripts/blobdiff - find_branch
update to_build_host a bit
[next-scripts] / find_branch
index dbaf1fa19b1c4f9550501c366d0dc453e0b6e878..edc15c35f356de795c25b675bf3b97b9095a4738 100755 (executable)
@@ -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