{"thread":{"id":"15821","subject":"[PATCH v2 RFC] rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEAD","startedAt":"2008-10-08T06:41:50Z","lastAt":"2008-10-09T01:58:43Z","messageCount":11,"participants":["Stephen Haberman","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"92586","messageId":"cover.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":null,"subject":"[PATCH v2 RFC] rebase-i-p: squashing and limiting todo","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:50Z","receivedAt":"2008-10-08T06:41:50Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"This is v2 of my attempt at keeping commits with no-parents-being-rewritten off\nthe rebase-i-p todo list. This was prompted by Avi Kivity's request to squash\ncommits on either side of a merge, but is something I had wanted as well without\nfully realizing it.\n\nStephan Beyer pointed out his git sequencer branch already does this, contrary\nto my incorrect reading of it. His rewrite of rebase-i-p changed how todo was\ngenerated to follow these semantics, and nicely, too, so I replaced my initial\nhacky algorithm for \"only include commits with rewritten parents\" with his.\n\nThe better implementation aside, I found Stephan's matching semantics\nencouraging as if Avi, myself, and Stephan (plus others/the list involved in\npast git sequencer discussions) all expect rebase-i-p to drop non-rewritten\ncommits, then the semantics should be intuitive and what most users expect.\n\nAlso, even though git sequencer has these semantics (and more), I'd like to see\nthis patch reviewed and applied anyway as I think it is a nice solution to the\ncurrent rebase-i-p shortcomings. And, assuming its approved, it can be applied\nnow instead of waiting for git sequencer to be finished, reviewed, and applied.\n\nThis is also my first patch series. I started a new thread--I'm not sure if I\nwas supposed to use Avi's original message id or not. Also, I cheated and put\nthe tests in the first commit instead of starting them as test_expect_failure\nand gradually changing them to test_expect_success.\n\nStephen Haberman (7):\n  rebase-i-p: test to exclude commits from todo based on its parents\n  rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEAD\n  rebase-i-p: delay saving current-commit to REWRITTEN if squashing\n  rebase-i-p: fix 'no squashing merges' tripping up non-merges\n  rebase-i-p: only list commits that require rewriting in todo\n  rebase-i-p: do not include non-first-parent commits touching UPSTREAM\n  rebase-i-p: if todo was reordered use HEAD as the rewritten parent\n\n git-rebase--interactive.sh               |   80 ++++++++++++------\n t/t3411-rebase-preserve-around-merges.sh |  136 ++++++++++++++++++++++++++++++\n 2 files changed, 190 insertions(+), 26 deletions(-)\n create mode 100644 t/t3411-rebase-preserve-around-merges.sh\n"},{"id":"92587","messageId":"e5ababa1de420b6460fd856679990c9dd2caf1d1.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"cover.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: test to exclude commits from todo based on its parents","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:51Z","receivedAt":"2008-10-08T06:41:51Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"The first case was based off a script from Avi Kivity <avi@redhat.com>.\n\nThe second case includes a merge-of-a-merge to ensure both are included in todo.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n t/t3411-rebase-preserve-around-merges.sh |  136 ++++++++++++++++++++++++++++++\n 1 files changed, 136 insertions(+), 0 deletions(-)\n create mode 100644 t/t3411-rebase-preserve-around-merges.sh\n\ndiff --git a/t/t3411-rebase-preserve-around-merges.sh b/t/t3411-rebase-preserve-around-merges.sh\nnew file mode 100644\nindex 0000000..18202fb\n--- /dev/null\n+++ b/t/t3411-rebase-preserve-around-merges.sh\n@@ -0,0 +1,136 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Stephen Haberman\n+#\n+\n+test_description='git rebase preserve merges\n+\n+This test runs git rebase with and tries to squash a commit from after a merge\n+to before the merge.\n+'\n+. ./test-lib.sh\n+\n+# Copy/paste from t3404-rebase-interactive.sh\n+echo \"#!$SHELL_PATH\" >fake-editor.sh\n+cat >> fake-editor.sh <<\\EOF\n+case \"$1\" in\n+*/COMMIT_EDITMSG)\n+\ttest -z \"$FAKE_COMMIT_MESSAGE\" || echo \"$FAKE_COMMIT_MESSAGE\" > \"$1\"\n+\ttest -z \"$FAKE_COMMIT_AMEND\" || echo \"$FAKE_COMMIT_AMEND\" >> \"$1\"\n+\texit\n+\t;;\n+esac\n+test -z \"$EXPECT_COUNT\" ||\n+\ttest \"$EXPECT_COUNT\" = $(sed -e '/^#/d' -e '/^$/d' < \"$1\" | wc -l) ||\n+\texit\n+test -z \"$FAKE_LINES\" && exit\n+grep -v '^#' < \"$1\" > \"$1\".tmp\n+rm -f \"$1\"\n+cat \"$1\".tmp\n+action=pick\n+for line in $FAKE_LINES; do\n+\tcase $line in\n+\tsquash|edit)\n+\t\taction=\"$line\";;\n+\t*)\n+\t\techo sed -n \"${line}s/^pick/$action/p\"\n+\t\tsed -n \"${line}p\" < \"$1\".tmp\n+\t\tsed -n \"${line}s/^pick/$action/p\" < \"$1\".tmp >> \"$1\"\n+\t\taction=pick;;\n+\tesac\n+done\n+EOF\n+\n+test_set_editor \"$(pwd)/fake-editor.sh\"\n+chmod a+x fake-editor.sh\n+\n+# set up two branches like this:\n+#\n+# A1 - B1 - D1 - E1 - F1\n+#       \\        /\n+#        -- C1 --\n+\n+test_expect_success 'setup' '\n+\ttouch a &&\n+\ttouch b &&\n+\tgit add a &&\n+\tgit commit -m A1 &&\n+\tgit tag A1\n+\tgit add b &&\n+\tgit commit -m B1 &&\n+\tgit tag B1 &&\n+\tgit checkout -b branch &&\n+\ttouch c &&\n+\tgit add c &&\n+\tgit commit -m C1 &&\n+\tgit checkout master &&\n+\ttouch d &&\n+\tgit add d &&\n+\tgit commit -m D1 &&\n+\tgit merge branch &&\n+\ttouch f &&\n+\tgit add f &&\n+\tgit commit -m F1 &&\n+\tgit tag F1\n+'\n+\n+# Should result in:\n+#\n+# A1 - B1 - D2 - E2\n+#       \\        /\n+#        -- C1 --\n+#\n+test_expect_success 'squash F1 into D1' '\n+\tFAKE_LINES=\"1 squash 3 2\" git rebase -i -p B1 &&\n+\ttest \"$(git rev-parse HEAD^2)\" = \"$(git rev-parse branch)\" &&\n+\ttest \"$(git rev-parse HEAD~2)\" = \"$(git rev-parse B1)\" &&\n+\tgit tag E2\n+'\n+\n+# Start with:\n+#\n+# A1 - B1 - D2 - E2\n+#  \\\n+#   G1 ---- L1 ---- M1\n+#    \\             /\n+#     H1 -- J1 -- K1\n+#      \\         /\n+#        -- I1 --\n+#\n+# And rebase G1..M1 onto E3\n+\n+test_expect_success 'rebase two levels of merge' '\n+\tgit checkout -b branch2 A1 &&\n+\ttouch g &&\n+\tgit add g &&\n+\tgit commit -m G1 &&\n+\tgit checkout -b branch3 &&\n+\ttouch h\n+\tgit add h &&\n+\tgit commit -m H1 &&\n+\tgit checkout -b branch4 &&\n+\ttouch i &&\n+\tgit add i &&\n+\tgit commit -m I1 &&\n+\tgit tag I1 &&\n+\tgit checkout branch3 &&\n+\ttouch j &&\n+\tgit add j &&\n+\tgit commit -m J1 &&\n+\tgit merge I1 --no-commit &&\n+\tgit commit -m K1 &&\n+\tgit tag K1 &&\n+\tgit checkout branch2 &&\n+\ttouch l &&\n+\tgit add l &&\n+\tgit commit -m L1 &&\n+\tgit merge K1 --no-commit &&\n+\tgit commit -m M1 &&\n+\tGIT_EDITOR=: git rebase -i -p E2 &&\n+\ttest \"$(git rev-parse HEAD~3)\" = \"$(git rev-parse E2)\" &&\n+\ttest \"$(git rev-parse HEAD~2)\" = \"$(git rev-parse HEAD^2^2~2)\" &&\n+\ttest \"$(git rev-parse HEAD^2^1^1)\" = \"$(git rev-parse HEAD^2^2^1)\"\n+'\n+\n+test_done\n+\n-- \n1.6.0.2\n"},{"id":"92585","messageId":"e1cac64070f53f4f217a3b8e8c0f855f23691725.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"e5ababa1de420b6460fd856679990c9dd2caf1d1.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: use HEAD for updating the ref instead of mapping OLDHEAD","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:52Z","receivedAt":"2008-10-08T06:41:52Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"If OLDHEAD was reordered in the todo, and its mapped NEWHEAD was used to set the\nref, commits reordered after OLDHEAD in the todo would should up as un-committed\nchanges.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n git-rebase--interactive.sh |   15 +--------------\n 1 files changed, 1 insertions(+), 14 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex edb6ec6..b7eda66 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -350,20 +350,7 @@ do_next () {\n \tHEADNAME=$(cat \"$DOTEST\"/head-name) &&\n \tOLDHEAD=$(cat \"$DOTEST\"/head) &&\n \tSHORTONTO=$(git rev-parse --short $(cat \"$DOTEST\"/onto)) &&\n-\tif test -d \"$REWRITTEN\"\n-\tthen\n-\t\ttest -f \"$DOTEST\"/current-commit &&\n-\t\t\tcurrent_commit=$(cat \"$DOTEST\"/current-commit) &&\n-\t\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit\n-\t\tif test -f \"$REWRITTEN\"/$OLDHEAD\n-\t\tthen\n-\t\t\tNEWHEAD=$(cat \"$REWRITTEN\"/$OLDHEAD)\n-\t\telse\n-\t\t\tNEWHEAD=$OLDHEAD\n-\t\tfi\n-\telse\n-\t\tNEWHEAD=$(git rev-parse HEAD)\n-\tfi &&\n+\tNEWHEAD=$(git rev-parse HEAD) &&\n \tcase $HEADNAME in\n \trefs/*)\n \t\tmessage=\"$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)\" &&\n-- \n1.6.0.2\n"},{"id":"92588","messageId":"90b5c351699999b5b4e4aa33475993661c26ee4c.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"e1cac64070f53f4f217a3b8e8c0f855f23691725.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: delay saving current-commit to REWRITTEN if squashing","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:53Z","receivedAt":"2008-10-08T06:41:53Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"If the current-commit was dumped to REWRITTEN, but then we squash the next\ncommit in to it, we have invalidated the HEAD was just written to REWRITTEN.\nInstead, append the squash hash to current-commit and save both of them the next\ntime around.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n git-rebase--interactive.sh |   15 ++++++++++-----\n 1 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex b7eda66..8af425d 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -159,13 +159,18 @@ pick_one_preserving_merges () {\n \n \tif test -f \"$DOTEST\"/current-commit\n \tthen\n-\t\tcurrent_commit=$(cat \"$DOTEST\"/current-commit) &&\n-\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit &&\n-\t\trm \"$DOTEST\"/current-commit ||\n-\t\tdie \"Cannot write current commit's replacement sha1\"\n+\t\tif [ \"$fast_forward\" == \"t\" ]\n+\t\tthen\n+\t\t\tcat \"$DOTEST\"/current-commit | while read current_commit\n+\t\t\tdo\n+\t\t\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit\n+\t\t\tdone\n+\t\t\trm \"$DOTEST\"/current-commit ||\n+\t\t\tdie \"Cannot write current commit's replacement sha1\"\n+\t\tfi\n \tfi\n \n-\techo $sha1 > \"$DOTEST\"/current-commit\n+\techo $sha1 >> \"$DOTEST\"/current-commit\n \n \t# rewrite parents; if none were rewritten, we can fast-forward.\n \tnew_parents=\n-- \n1.6.0.2\n"},{"id":"92592","messageId":"0d4d2cf9388866fe033f3545790fba6062fb1e1e.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"90b5c351699999b5b4e4aa33475993661c26ee4c.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: fix 'no squashing merges' tripping up non-merges","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:54Z","receivedAt":"2008-10-08T06:41:54Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"Also only check out the first parent if this commit if not a squash--if it is a\nsquash, we want to explicitly ignore the parent and leave the wc as is, as\ncherry-pick will apply the squash on top of it.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n git-rebase--interactive.sh |   14 +++++++++-----\n 1 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 8af425d..0464bfb 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -198,15 +198,19 @@ pick_one_preserving_merges () {\n \t\t\tdie \"Cannot fast forward to $sha1\"\n \t\t;;\n \tf)\n-\t\ttest \"a$1\" = a-n && die \"Refusing to squash a merge: $sha1\"\n-\n \t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\t\t# detach HEAD to current parent\n-\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\tdie \"Cannot move HEAD to $first_parent\"\n+\n+\t\tif [ \"$1\" != \"-n\" ]\n+\t\tthen\n+\t\t\t# detach HEAD to current parent\n+\t\t\toutput git checkout $first_parent 2> /dev/null ||\n+\t\t\t\tdie \"Cannot move HEAD to $first_parent\"\n+\t\tfi\n \n \t\tcase \"$new_parents\" in\n \t\t' '*' '*)\n+\t\t\ttest \"a$1\" = a-n && die \"Refusing to squash a merge: $sha1\"\n+\n \t\t\t# redo merge\n \t\t\tauthor_script=$(get_author_ident_from_commit $sha1)\n \t\t\teval \"$author_script\"\n-- \n1.6.0.2\n"},{"id":"92590","messageId":"90b5228cee1617efcb970f4e27b26c769f78a9bd.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"0d4d2cf9388866fe033f3545790fba6062fb1e1e.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: only list commits that require rewriting in todo","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:55Z","receivedAt":"2008-10-08T06:41:55Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"This is heavily based on Stephan Beyer's git sequencer rewrite of rebase-i-p.\n\nEach commit is still found by rev-list UPSTREAM..HEAD, but a commit is only\nincluded in todo if at least one its parents has been marked for rewriting.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n git-rebase--interactive.sh |   26 ++++++++++++++++++++++++--\n 1 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0464bfb..7003ac0 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -561,9 +561,31 @@ first and then run 'git rebase --continue' again.\"\n \t\tSHORTHEAD=$(git rev-parse --short $HEAD)\n \t\tSHORTONTO=$(git rev-parse --short $ONTO)\n \t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n-\t\t\t--abbrev=7 --reverse --left-right --cherry-pick \\\n+\t\t\t--abbrev=7 --reverse --left-right --cherry-pick --topo-order \\\n \t\t\t$UPSTREAM...$HEAD | \\\n-\t\t\tsed -n \"s/^>/pick /p\" > \"$TODO\"\n+\t\t\tsed -n \"s/^>//p\" | while read shortsha1 rest\n+\t\tdo\n+\t\t\tif test t != \"$PRESERVE_MERGES\"\n+\t\t\tthen\n+\t\t\t\techo \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\t\t\telse\n+\t\t\t\tsha1=$(git rev-parse $shortsha1)\n+\t\t\t\tpreserve=t\n+\t\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)\n+\t\t\t\tdo\n+\t\t\t\t\tif test -f \"$REWRITTEN\"/$p\n+\t\t\t\t\tthen\n+\t\t\t\t\t\tpreserve=f\n+\t\t\t\t\tfi\n+\t\t\t\tdone\n+\t\t\t\tif test f = \"$preserve\"\n+\t\t\t\tthen\n+\t\t\t\t\ttouch \"$REWRITTEN/$sha1\"\n+\t\t\t\t\techo \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\t\t\t\tfi\n+\t\t\tfi\n+\t\tdone\n+\n \t\tcat >> \"$TODO\" << EOF\n \n # Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO\n-- \n1.6.0.2\n"},{"id":"92591","messageId":"c3ab1457d971985e349a0747178132c0c6f68b8a.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"90b5228cee1617efcb970f4e27b26c769f78a9bd.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: do not include non-first-parent commits touching UPSTREAM","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:56Z","receivedAt":"2008-10-08T06:41:56Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"This covers an odd boundary case found by Avi Kivity's script where a branch\ncoming off of UPSTREAM is merged into HEAD. Initially it show up in\nUPSTREAM..HEAD, but technically UPSTREAM is not moving, the rest of head is, so\nwe should not need to rewrite the merge.\n\nThis adds a check saying we can keep `preserve=t` if `p=UPSTREAM`...unless this\nis the first first-parent commit in our UPSTREAM..HEAD rev-list, which could\nvery well point to UPSTREAM, but we still need to consider it as rewritten so we\nstart pulling in the rest of the UPSTREAM..HEAD commits that point to it.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n git-rebase--interactive.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 7003ac0..2e9270a 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -553,6 +553,7 @@ first and then run 'git rebase --continue' again.\"\n \t\t\t\t\tdie \"Could not init rewritten commits\"\n \t\t\tdone\n \t\t\tMERGES_OPTION=\n+\t\t\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n \t\telse\n \t\t\tMERGES_OPTION=--no-merges\n \t\tfi\n@@ -573,7 +574,7 @@ first and then run 'git rebase --continue' again.\"\n \t\t\t\tpreserve=t\n \t\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)\n \t\t\t\tdo\n-\t\t\t\t\tif test -f \"$REWRITTEN\"/$p\n+\t\t\t\t\tif test -f \"$REWRITTEN\"/$p -a \\( $p != $UPSTREAM -o $sha1 = $first_after_upstream \\)\n \t\t\t\t\tthen\n \t\t\t\t\t\tpreserve=f\n \t\t\t\t\tfi\n-- \n1.6.0.2\n"},{"id":"92589","messageId":"211dfcea6f13f8ddb3153add3bfa3395c4a7e8c8.1223445353.git.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"c3ab1457d971985e349a0747178132c0c6f68b8a.1223445353.git.stephen@exigencecorp.com","subject":"[PATCH v2 RFC] rebase-i-p: if todo was reordered use HEAD as the rewritten parent","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T06:41:57Z","receivedAt":"2008-10-08T06:41:57Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"This seems like the best guess we can make until git sequencer marks are\navailable. That being said, within the context of re-ordering a commit before\nits parent in todo, I think applying it on top of the current commit seems like\na reasonable assumption of what the user intended.\n\nSigned-off-by: Stephen Haberman <stephen@exigencecorp.com>\n---\n git-rebase--interactive.sh |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2e9270a..8a22d78 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -179,6 +179,15 @@ pick_one_preserving_merges () {\n \t\tif test -f \"$REWRITTEN\"/$p\n \t\tthen\n \t\t\tnew_p=$(cat \"$REWRITTEN\"/$p)\n+\n+\t\t\t# If the todo reordered commits, and our parent is marked for\n+\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n+\t\t\t# drop it on top of the current HEAD\n+\t\t\tif test -z \"$new_p\"\n+\t\t\tthen\n+\t\t\t\tnew_p=$(git rev-parse HEAD)\n+\t\t\tfi\n+\n \t\t\ttest $p != $new_p && fast_forward=f\n \t\t\tcase \"$new_parents\" in\n \t\t\t*$new_p*)\n-- \n1.6.0.2\n"},{"id":"92601","messageId":"20081008021546.c553289f.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"cover.1223445353.git.stephen@exigencecorp.com","subject":"Re: [PATCH v2 RFC] rebase-i-p: squashing and limiting todo","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-08T07:15:46Z","receivedAt":"2008-10-08T07:15:46Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"\n> This is v2 of my attempt at keeping commits with\n> no-parents-being-rewritten off the rebase-i-p todo list. \n\nI forgot to mention, this series almost certainly conflicts with pu's\nsh/maint-rebase3. Given that pu is not next, I think I did the right\nthing by keeping this series separate, but I can merge them into one\nseries if that is preferable.\n\nThanks,\nStephen\n"},{"id":"92602","messageId":"7vmyhfr1lb.fsf@gitster.siamese.dyndns.org","threadId":"15821","inReplyTo":"e5ababa1de420b6460fd856679990c9dd2caf1d1.1223445353.git.stephen@exigencecorp.com","subject":"Re: [PATCH v2 RFC] rebase-i-p: test to exclude commits from todo based on its parents","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-08T07:24:32Z","receivedAt":"2008-10-08T07:24:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Haberman <stephen@exigencecorp.com> writes:\n\n> +# set up two branches like this:\n> +#\n> +# A1 - B1 - D1 - E1 - F1\n> +#       \\        /\n> +#        -- C1 --\n> ...\n> +test_expect_success 'setup' '\n> ...\n> +'\n> +\n> +# Should result in:\n> +#\n> +# A1 - B1 - D2 - E2\n> +#       \\        /\n> +#        -- C1 --\n> +#\n> +test_expect_success 'squash F1 into D1' '\n> +\tFAKE_LINES=\"1 squash 3 2\" git rebase -i -p B1 &&\n> +\ttest \"$(git rev-parse HEAD^2)\" = \"$(git rev-parse branch)\" &&\n> +\ttest \"$(git rev-parse HEAD~2)\" = \"$(git rev-parse B1)\" &&\n> +\tgit tag E2\n> +'\n\nVery nicely written test sequence with pictures.  I wish all the tests\nwere written like this.\n\n> +# Start with:\n> +#\n> +# A1 - B1 - D2 - E2\n> +#  \\\n> +#   G1 ---- L1 ---- M1\n> +#    \\             /\n> +#     H1 -- J1 -- K1\n> +#      \\         /\n> +#        -- I1 --\n> +#\n> +# And rebase G1..M1 onto E3\n\nI think s/E3/E2/ is what you meant.\n\nIf this is the first one in the series, you may want to mark these tests\nwith test_expect_failure and make a later patch that changes the behaviour\nof rebase-i-p include updates to the test script to turn expect-failure\ninto expect-success.\n"},{"id":"92639","messageId":"20081008205843.bd6c297b.stephen@exigencecorp.com","threadId":"15821","inReplyTo":"7vmyhfr1lb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 RFC] rebase-i-p: test to exclude commits from todo based on its parents","fromName":"Stephen Haberman","fromEmail":"stephen@exigencecorp.com","sentAt":"2008-10-09T01:58:43Z","receivedAt":"2008-10-09T01:58:43Z","isPatch":true,"sender":{"key":"stephen@exigencecorp.com","avatar":"https://gravatar.com/avatar/23b93ad70a06ce53505f17ddba65176edbcfb6588e7a4c1a2dca04aaf0a6aff1?d=mp&s=160"},"body":"\n> > +# And rebase G1..M1 onto E3\n> \n> I think s/E3/E2/ is what you meant.\n\nAh, yes.\n\n> If this is the first one in the series, you may want to mark these tests\n> with test_expect_failure and make a later patch that changes the behaviour\n> of rebase-i-p include updates to the test script to turn expect-failure\n> into expect-success.\n\nSounds good, I will do that.\n\nI haven't seen any other feedback yet--should I repost the series with\nthese two minor changes right now or wait and see if other feedback\ncomes up?\n\nThanks,\nStephen\n"}]}