]> git.ozlabs.org Git - next-scripts/commitdiff
merge_old_version: work out the last merged tree
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 25 Aug 2015 01:27:38 +0000 (11:27 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 25 Aug 2015 01:27:38 +0000 (11:27 +1000)
if we don't pass one in.  Otherwise verify it (just in case).

merge_old_version

index b20a8eff6685cb04108cdcade1f998b575bcc27a..5465ab51028a352fdb31e190026743e56ae41512 100755 (executable)
@@ -6,8 +6,12 @@ no_build=false
        no_build=true
 }
 
-tree=$1
-shift
+if [ "$1" ]; then
+       tree=$1
+       shift
+else
+       tree=
+fi
 if [ "$1" ]; then
        ver="next-${1#next-}"
        shift
@@ -15,12 +19,6 @@ else
        ver=$(git tag -l next-\* | sort | tail -n 1)
 fi
 
-rev=$(git show ${ver}:Next/SHA1s | sed -n "s/^$tree\t\t*//p")
-[ "$rev" ] || {
-       echo "No such tree/date" 1>&2
-       exit 1
-}
-
 . "$(dirname $0)/common.sh"
 
 log()
@@ -35,13 +33,33 @@ execute()
        return ${PIPESTATUS[0]}
 }
 
+line="$(tail -n 1 $SHA1_FILE)"
+
+# strip everything after the first tab character
+stree=${line%% *}
+if [ "$tree" ]; then
+       [ "$tree" = "$stree" ] || {
+               echo "That is not the last tree merged ($tree v $stree)" 1>&2
+               exit 1
+       }
+else
+       tree="$stree"
+fi
+
+rev=$(git show ${ver}:Next/SHA1s | sed -n "s/^$tree\t\t*//p")
+[ "$rev" ] || {
+       echo "No previous tree/date ($tree/$ver)" 1>&2
+       exit 1
+}
+
 bad_rev=$(git rev-parse --verify 'HEAD^2')
 
-line="$(tail -n 1 $SHA1_FILE)"
 tab="\t"
 [ $(echo "$tree" | wc -c) -le 8 ] && tab="\t\t"
-expected=$(printf "%s$tab%s" $tree $bad_rev)
-[ "$line" = "$expected" ] || {
+
+# strip evrything up to the last tab character
+srev=${line##* }
+[ "$bad_rev" = "$srev" ] || {
        echo "bad last line in $SHA1_FILE" 1>&2
        exit 1
 }