git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 RFC] rebase-i-p: only list commits that require rewriting in todo

From
Stephen Haberman <stephen@exigencecorp.com>
Date
Oct 8, 2008, 06:41 UTC
Message-ID
<90b5228cee1617efcb970f4e27b26c769f78a9bd.1223445353.git.stephen@exigencecorp.com>
In-Reply-To
<0d4d2cf9388866fe033f3545790fba6062fb1e1e.1223445353.git.stephen@exigencecorp.com>
This is heavily based on Stephan Beyer's git sequencer rewrite of rebase-i-p.

Each commit is still found by rev-list UPSTREAM..HEAD, but a commit is only included in todo if at least one its parents has been marked for rewriting.

Signed-off-by: Stephen Haberman <stephen@exigencecorp.com>
---
 git-rebase--interactive.sh |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 0464bfb..7003ac0 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -561,9 +561,31 @@ first and then run 'git rebase --continue' again."
 		SHORTHEAD=$(git rev-parse --short $HEAD)
 		SHORTONTO=$(git rev-parse --short $ONTO)
 		git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
-			--abbrev=7 --reverse --left-right --cherry-pick \
+			--abbrev=7 --reverse --left-right --cherry-pick --topo-order \
 			$UPSTREAM...$HEAD | \
-			sed -n "s/^>/pick /p" > "$TODO"
+			sed -n "s/^>//p" | while read shortsha1 rest
+		do
+			if test t != "$PRESERVE_MERGES"
+			then
+				echo "pick $shortsha1 $rest" >> "$TODO"
+			else
+				sha1=$(git rev-parse $shortsha1)
+				preserve=t
+				for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
+				do
+					if test -f "$REWRITTEN"/$p
+					then
+						preserve=f
+					fi
+				done
+				if test f = "$preserve"
+				then
+					touch "$REWRITTEN/$sha1"
+					echo "pick $shortsha1 $rest" >> "$TODO"
+				fi
+			fi
+		done
+
 		cat >> "$TODO" << EOF
 
 # Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO
-- 
1.6.0.2
Previous: Stephen HabermanNext: Stephen Haberman
Message 6 of 11 in “rebase-i-p: squashing and limiting todo”
  1. rebase-i-p: squashing and limiting todoStephen Haberman, Oct 8, 2008
  2. rebase-i-p: test to exclude commits from todo based on its parentsStephen Haberman, Oct 8, 2008
  3. rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEADStephen Haberman, Oct 8, 2008
  4. rebase-i-p: delay saving current-commit to REWRITTEN if squashingStephen Haberman, Oct 8, 2008
  5. rebase-i-p: fix 'no squashing merges' tripping up non-mergesStephen Haberman, Oct 8, 2008
  6. rebase-i-p: only list commits that require rewriting in todoStephen Haberman, Oct 8, 2008
  7. rebase-i-p: do not include non-first-parent commits touching UPSTREAMStephen Haberman, Oct 8, 2008
  8. rebase-i-p: if todo was reordered use HEAD as the rewritten parentStephen Haberman, Oct 8, 2008
  9. Junio C HamanoOct 8, 2008
  10. Stephen HabermanOct 9, 2008
  11. Stephen HabermanOct 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.