[PATCH/RFC 03/10] Teach rebase interactive the merge command

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jörg Sommer
Date: Wednesday, April 9, 2008 - 4:58 pm

This command redoes merges. It's useful if you rebase a branch that
contains merges and you want to preserve these merges. You can also use
it to add new merges.
---
 git-rebase--interactive.sh    |   25 +++++++++++++++++++++++++
 t/t3404-rebase-interactive.sh |    3 +++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 7dac51b..18cdf3d 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -362,6 +362,29 @@ do_next () {
 		git rev-parse --verify HEAD > "$MARKS"/$mark || \
 			die "HEAD is invalid"
 		;;
+	merge|m)
+		comment_for_reflog merge
+
+		if ! git rev-parse --verify $sha1
+		then
+			die "Invalid reference merge '$sha1' in $command $sha1 $rest"
+		fi
+
+		new_parents=
+		for p in $rest
+		do
+			tmp=$(mark_to_sha1 $p) || \
+				tmp=$(git rev-parse --verify $p) ||
+				die "Invalid parent '$sha1' in $command $sha1 $rest"
+			new_parents="$new_parents $tmp"
+		done
+		new_parents="${new_parents# }"
+		test -n "$new_parents" || \
+			die "You forgot to give the parents for the merge"
+
+		mark_action_done
+		redo_merge $sha1 $new_parents
+		;;
 	reset|r)
 		comment_for_reflog reset
 
@@ -589,6 +612,8 @@ do
 #  squash = use commit, but meld into previous commit
 #  mark #NUM = mark the current HEAD for later reference
 #  reset #NUM|commit = reset HEAD to a previous set mark or a commit
+#  merge commit-M #NUM|commit-P ... = redo merge commit-M with the
+#         current HEAD and the parents marked with #NUM or the commit-P
 #
 # If you remove a line here THAT COMMIT WILL BE LOST.
 # However, if you remove everything, the rebase will be aborted.
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 521206f..892fd5d 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -88,6 +88,9 @@ for line in $FAKE_LINES; do
 	reset*)
 		echo "reset ${line#reset}"
 		echo "reset ${line#reset}" >> "$1";;
+	merge*)
+		echo "merge ${line#merge}" | tr / ' '
+		echo "merge ${line#merge}" | tr / ' ' >> "$1";;
 	*)
 		echo sed -n "${line}s/^pick/$action/p"
 		sed -n "${line}p" < "$1".tmp
-- 
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/4] Move redo merge code in a function, Jörg Sommer, (Sun Mar 23, 2:42 pm)
[PATCH 2/4] Rework redo_merge, Jörg Sommer, (Sun Mar 23, 2:42 pm)
Re: [PATCH 1/4] Move redo merge code in a function, Johannes Schindelin, (Sun Mar 23, 3:26 pm)
Re: [PATCH 2/4] Rework redo_merge, Johannes Schindelin, (Sun Mar 23, 3:29 pm)
Re: [PATCH 3/4] Add a function for get the parents of a commit, Johannes Schindelin, (Sun Mar 23, 3:33 pm)
Re: [PATCH 4/4] git-rebase -i: New option to support rebas ..., Johannes Schindelin, (Sun Mar 23, 3:41 pm)
Re: [PATCH 4/4] git-rebase -i: New option to support rebas ..., Johannes Schindelin, (Mon Mar 24, 6:08 am)
[PATCH/RFC 03/10] Teach rebase interactive the merge command, Jörg Sommer, (Wed Apr 9, 4:58 pm)
[PATCH/RFC 04/10] Move redo merge code in a function, Jörg Sommer, (Wed Apr 9, 4:58 pm)
[PATCH/RFC 05/10] Rework redo_merge, Jörg Sommer, (Wed Apr 9, 4:58 pm)
[PATCH/RFC 09/10] Select all lines with fake-editor, Jörg Sommer, (Wed Apr 9, 4:58 pm)
[PATCH v2 06/13] Move redo merge code in a function, Jörg Sommer, (Sun Apr 13, 5:21 pm)
[PATCH v2 09/13] Select all lines with fake-editor, Jörg Sommer, (Sun Apr 13, 5:21 pm)
[PATCH v2 11/13] Add option --first-parent, Jörg Sommer, (Sun Apr 13, 5:21 pm)
[PATCH v2 13/13] Add option --preserve-tags, Jörg Sommer, (Sun Apr 13, 5:21 pm)
[PATCH v2.1] Teach rebase interactive the mark command, Jörg Sommer, (Mon Apr 14, 3:39 am)
Re: [PATCH v2.1] Teach rebase interactive the mark command, Shawn O. Pearce, (Mon Apr 14, 4:29 pm)
mark parsing in fast-import, Jörg, (Sun Apr 20, 4:44 pm)
Re: mark parsing in fast-import, Shawn O. Pearce, (Sun Apr 20, 5:26 pm)
Re: mark parsing in fast-import, Jörg, (Mon Apr 21, 1:41 am)
Re: mark parsing in fast-import, Shawn O. Pearce, (Mon Apr 21, 4:59 pm)
Re: [PATCH v2 04/13] Teach rebase interactive the mark command, Johannes Schindelin, (Tue Apr 22, 1:52 am)
Re: mark parsing in fast-import, Jörg, (Tue Apr 22, 2:39 am)
Re: [PATCH v2 04/13] Teach rebase interactive the mark command, Johannes Schindelin, (Tue Apr 22, 3:31 am)
Re: mark parsing in fast-import, Shawn O. Pearce, (Tue Apr 22, 4:15 pm)
[PATCH v2] Make mark parsing much more restrictive, Jörg Sommer, (Fri Apr 25, 2:04 am)
[PATCH v2.2] Teach rebase interactive the mark command, Jörg Sommer, (Fri Apr 25, 2:44 am)
Re: [PATCH v2.2] Teach rebase interactive the mark command, Junio C Hamano, (Sat Apr 26, 11:13 pm)