[PATCH v2 11/13] Add option --first-parent

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jörg Sommer
Date: Sunday, April 13, 2008 - 5:21 pm

With this new option it's possible to narrow the list of commits in the
TODO list to only those commits you get following the first parent of
each merge, i.e. not those from the merged branches.

Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
 Documentation/git-rebase.txt  |    7 ++++++-
 git-rebase--interactive.sh    |   15 +++++++++++----
 t/t3404-rebase-interactive.sh |   12 ++++++++++++
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index e0412e0..9ebbb90 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -11,7 +11,7 @@ SYNOPSIS
 'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
 	[-s <strategy> | --strategy=<strategy>]
 	[-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
-	[--onto <newbase>] <upstream> [<branch>]
+	[-f | --first-parent] [--onto <newbase>] <upstream> [<branch>]
 'git-rebase' --continue | --skip | --abort
 
 DESCRIPTION
@@ -247,6 +247,11 @@ OPTIONS
 	Instead of ignoring merges, try to recreate them.  This option
 	only works in interactive mode.
 
+-f, \--first-parent::
+	This option implies the option --preserve-merges, but instead of
+	showing all commits from the merged branches show only the
+	commits and merges following the first parent of each commit.
+
 include::merge-strategies.txt[]
 
 NOTES
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d3327a8..ea67942 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -10,8 +10,8 @@
 # The original idea comes from Eric W. Biederman, in
 # http://article.gmane.org/gmane.comp.version-control.git/22407
 
-USAGE='(--continue | --abort | --skip | [--preserve-merges] [--verbose]
-	[--onto <branch>] <upstream> [<branch>])'
+USAGE='(--continue | --abort | --skip | [--preserve-merges] [--first-parent]
+	[--verbose] [--onto <branch>] <upstream> [<branch>])'
 
 OPTIONS_SPEC=
 . git-sh-setup
@@ -565,6 +565,10 @@ do
 	-p|--preserve-merges)
 		PRESERVE_MERGES=t
 		;;
+	-f|--first-parent)
+		FIRST_PARENT=t
+		PRESERVE_MERGES=t
+		;;
 	-i|--interactive)
 		# yeah, we know
 		;;
@@ -621,10 +625,13 @@ do
 		SHORTONTO=$(git rev-parse --short=7 $ONTO)
 		common_rev_list_opts="--abbrev-commit --abbrev=7
 			--left-right --cherry-pick $UPSTREAM...$HEAD"
-		if test t = "$PRESERVE_MERGES"
+		if test t = "$PRESERVE_MERGES" -o t = "${FIRST_PARENT:-f}"
 		then
+			opts=
+			test t = "${FIRST_PARENT:-f}" && \
+				opts="$opts --first-parent"
 			git rev-list --pretty='format:%h_%p_%s' --topo-order \
-				$common_rev_list_opts | \
+				$opts $common_rev_list_opts | \
 				grep -v ^commit | \
 				create_extended_todo_list
 		else
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index f919aaf..8da7829 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -294,6 +294,18 @@ test_expect_success 'rebase with preserve merge forth and back is a noop' '
 	test "$head" = "$(git rev-parse HEAD)"
 '
 
+test_expect_success 'interactive --first-parent gives a linear list' '
+	head=$(git rev-parse HEAD) &&
+	EXPECT_COUNT=6 FAKE_LINES="2 1 4 3 6 5" \
+		git rebase -i -f --onto dead-end master &&
+	test "$head" != "$(git rev-parse HEAD)" &&
+	git rev-parse HEAD^^2 &&
+	test "$(git rev-parse HEAD~6)" = "$(git rev-parse dead-end)" &&
+	EXPECT_COUNT=6 FAKE_LINES="2 1 4 3 6 5" \
+		git rebase -i -f --onto master dead-end &&
+	test "$head" = "$(git rev-parse HEAD)"
+'
+
 test_expect_success '--continue tries to commit' '
 	git checkout to-be-rebased &&
 	test_tick &&
-- 
1.5.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 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)