From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Tue, 20 Jan 2009 00:12:57 +0000 (+1100)
Subject: allow for restarting the merge from not the first tree
X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=99555b79cb29065473fbe1ca195c61325c318829;p=next-scripts

allow for restarting the merge from not the first tree
---

diff --git a/do_merge b/do_merge
index ff19ef6..d164812 100755
--- a/do_merge
+++ b/do_merge
@@ -6,14 +6,23 @@ build_dir="/scratch/sfr/next"
 build_cmd="bin/build_next"
 
 no_build=false
+start_from=""
+
 [ "$1" = "-n" ] && {
 	shift
 	no_build=true
 }
+[ "$1" = "-s" ] && {
+	shift
+	start_from="$1"
+	[ -z "$start_from" ] && {
+		echo "-s requires a start tree" 1>&2
+		exit 1
+	}
+	shift
+}
 [ -n "$1" ] && build_host="$1"
 
-cp /dev/null $LOG_FILE
-
 log()
 {
 	echo "$@" | tee -a $LOG_FILE
@@ -26,8 +35,11 @@ execute()
 	return ${PIPESTATUS[0]}
 }
 
-execute git checkout master
-execute git reset --hard stable
+[ -n "$start_from" ] || {
+	cp /dev/null $LOG_FILE
+	execute git checkout master
+	execute git reset --hard stable
+}
 
 heads=$(grep -v '^#' ../real_control | awk -F '	' '$2=="quilt" { printf("quilt/%s ", $3); } $2=="git" { printf("%s/%s ", $3, $5); }')
 
@@ -36,6 +48,15 @@ need_build=false
 for h in $heads; do
 	tree=${h%/*}
 	[ "$tree" == "quilt" ] && tree=${h#quilt/}
+
+	[ -n "$start_from" ] && {
+		if [ "$tree" = "$start_from" ]; then
+			start_from=""
+		else
+			continue
+		fi
+	}
+
 	log Merging $h
 	old_head=$(git rev-parse HEAD)
 	execute git merge $h || {