{"thread":{"id":"30904","subject":"[PATCH 0/5] rebase: calculate patches in upstream correctly","startedAt":"2012-06-26T14:51:53Z","lastAt":"2012-06-27T16:17:53Z","messageCount":8,"participants":["Martin von Zweigbergk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"194275","messageId":"1340722318-24392-1-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"30904","inReplyTo":null,"subject":"[PATCH 0/5] rebase: calculate patches in upstream correctly","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-26T14:51:53Z","receivedAt":"2012-06-26T14:51:53Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"I worked on these patches last year but never sent them because I\nwasn't sure how they impact performance. I was hoping that getting the\npatch body from the commit and avoiding the call to mailinfo would\nmake am-based rebase a little faster, but if I remember correctly, it\ngot a little slower instead (not by much, though). I was also working\non a way to implement the 'git cherry' functionality in 'git\nrev-list', but I wasn't sure how that would work and I ran out of\ntime. I hope at least some of these patches can still be useful.\n\nMartin von Zweigbergk (5):\n  rebase: don't source git-sh-setup twice\n  rebase --root: print usage on too many args\n  am --rebasing: get patch body from commit, not from mailbox\n  am: don't call mailinfo if $rebasing\n  rebase [-m]: calculate patches in upstream correctly\n\n git-am.sh                   |   48 ++++++++++++++++++++++---------------------\n git-rebase--am.sh           |    8 ++------\n git-rebase--interactive.sh  |    4 +---\n git-rebase--merge.sh        |    4 +---\n git-rebase.sh               |   13 ++++++------\n t/t3401-rebase-partial.sh   |   17 +++++++++++++++\n t/t3405-rebase-malformed.sh |   32 +++++++++++++++++++++++++----\n t/t3406-rebase-message.sh   |   14 ++++++-------\n t/t3412-rebase-root.sh      |    8 +++++++-\n 9 files changed, 94 insertions(+), 54 deletions(-)\n\n-- \n1.7.9.3.327.g2980b\n"},{"id":"194276","messageId":"1340722318-24392-2-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"30904","inReplyTo":"1340722318-24392-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 1/5] rebase: don't source git-sh-setup twice","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-26T14:51:54Z","receivedAt":"2012-06-26T14:51:54Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The git-sh-setup script is already sourced in git-rebase.sh before\ncalling into git-rebase--(am|interactive|merge).sh. There are no other\ncallers of these scripts. It is therefore unnecessary to source\ngit-sh-setup again in them.\n---\n git-rebase--am.sh          |    2 --\n git-rebase--interactive.sh |    4 +---\n git-rebase--merge.sh       |    2 --\n 3 files changed, 1 insertion(+), 7 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 04d8941..392ebc9 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -3,8 +3,6 @@\n # Copyright (c) 2010 Junio C Hamano.\n #\n \n-. git-sh-setup\n-\n case \"$action\" in\n continue)\n \tgit am --resolved --resolvemsg=\"$resolvemsg\" &&\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0c19b7c..a5b018d 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -9,9 +9,7 @@\n #\n # The original idea comes from Eric W. Biederman, in\n # http://article.gmane.org/gmane.comp.version-control.git/22407\n-\n-. git-sh-setup\n-\n+#\n # The file containing rebase commands, comments, and empty lines.\n # This file is created by \"git rebase -i\" then edited by the user.  As\n # the lines are processed, they are removed from the front of this\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex dc59907..b10f2cf 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -3,8 +3,6 @@\n # Copyright (c) 2010 Junio C Hamano.\n #\n \n-. git-sh-setup\n-\n prec=4\n \n read_state () {\n-- \n1.7.9.3.327.g2980b\n"},{"id":"194278","messageId":"1340722318-24392-3-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"30904","inReplyTo":"1340722318-24392-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 2/5] rebase --root: print usage on too many args","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-26T14:51:55Z","receivedAt":"2012-06-26T14:51:55Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Just like\n\n  git rebase --onto newbase upstream branch error\n\ndisplays the usage message, so should clearly\n\n  git rebase --onto newbase --root branch error\n\n, but it doesn't. Instead, it ignores both \"branch\" and \"error\" and\nrebases the current HEAD. This is because we try to match the number\nof remainging arguments \"$#\", which fails to match \"1\" argument and\nmatches the \"*\" that really should have been a \"0\".\n\nMake sure we display usage information when too many arguments are\ngiven. Also fail-fast in case of similar bugs in the future by\nmatching on exactly 0 arguments and failing on unknown numbers.\n---\n git-rebase.sh          |    6 +++++-\n t/t3412-rebase-root.sh |    8 +++++++-\n 2 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e616737..6df06c4 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -400,6 +400,7 @@ else\n \ttest -z \"$onto\" && die \"You must specify --onto when using --root\"\n \tunset upstream_name\n \tunset upstream\n+\ttest $# -gt 1 && usage\n \tupstream_arg=--root\n fi\n \n@@ -450,7 +451,7 @@ case \"$#\" in\n \t\tdie \"fatal: no such branch: $1\"\n \tfi\n \t;;\n-*)\n+0)\n \t# Do not need to switch branches, we are already on it.\n \tif branch_name=`git symbolic-ref -q HEAD`\n \tthen\n@@ -462,6 +463,9 @@ case \"$#\" in\n \tfi\n \torig_head=$(git rev-parse --verify \"${branch_name}^0\") || exit\n \t;;\n+*)\n+\tdie \"BUG: unexpected number of arguments left to parse\"\n+\t;;\n esac\n \n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\ndiff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\nindex 086c91c..1e9d1a7 100755\n--- a/t/t3412-rebase-root.sh\n+++ b/t/t3412-rebase-root.sh\n@@ -23,9 +23,15 @@ test_expect_success 'prepare repository' '\n '\n \n test_expect_success 'rebase --root expects --onto' '\n+\tgit checkout -B fail other &&\n \ttest_must_fail git rebase --root\n '\n \n+test_expect_success 'rebase --root fails with too many args' '\n+\tgit checkout -B fail other &&\n+\ttest_must_fail git rebase --onto master --root fail fail\n+'\n+\n test_expect_success 'setup pre-rebase hook' '\n \tmkdir -p .git/hooks &&\n \tcat >.git/hooks/pre-rebase <<EOF &&\n@@ -42,7 +48,7 @@ cat > expect <<EOF\n EOF\n \n test_expect_success 'rebase --root --onto <newbase>' '\n-\tgit checkout -b work &&\n+\tgit checkout -b work other &&\n \tgit rebase --root --onto master &&\n \tgit log --pretty=tformat:\"%s\" > rebased &&\n \ttest_cmp expect rebased\n-- \n1.7.9.3.327.g2980b\n"},{"id":"194280","messageId":"1340722318-24392-4-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"30904","inReplyTo":"1340722318-24392-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 3/5] am --rebasing: get patch body from commit, not from mailbox","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-26T14:51:56Z","receivedAt":"2012-06-26T14:51:56Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Rebasing a commit that contains a diff in the commit message results\nin a failure with output such as\n\n  First, rewinding head to replay your work on top of it...\n  Applying: My cool patch.\n  fatal: sha1 information is lacking or useless\n  (app/controllers/settings_controller.rb).\n  Repository lacks necessary blobs to fall back on 3-way merge.\n  Cannot fall back to three-way merge.\n  Patch failed at 0001 My cool patch.\n\nThe reason is that 'git rebase' without -p/-i/-m internally calls 'git\nformat-patch' and pipes the output to 'git am --rebasing', which has\nno way of knowing what is a real patch and what is a commit message\nthat contains a patch.\n\nMake 'git am' while in --rebasing mode get the patch body from the\ncommit object instead of extracting it from the mailbox.\n\nPatch by Junio, test case and commit log message by Martin.\n\nReported-by: anikey <arty.anikey@gmail.com>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-am.sh                   |    1 +\n t/t3405-rebase-malformed.sh |   32 ++++++++++++++++++++++++++++----\n 2 files changed, 29 insertions(+), 4 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex f8b7a0c..ec8fde1 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -683,6 +683,7 @@ To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n \t\t\tsed -e '1,/^$/d' >\"$dotest/msg-clean\"\n \t\t\techo \"$commit\" > \"$dotest/original-commit\"\n \t\t\tget_author_ident_from_commit \"$commit\" > \"$dotest/author-script\"\n+\t\t\tgit diff-tree --root --binary \"$commit\" >\"$dotest/patch\"\n \t\telse\n \t\t\t{\n \t\t\t\tsed -n '/^Subject/ s/Subject: //p' \"$dotest/info\"\ndiff --git a/t/t3405-rebase-malformed.sh b/t/t3405-rebase-malformed.sh\nindex e5ad67c..19eddad 100755\n--- a/t/t3405-rebase-malformed.sh\n+++ b/t/t3405-rebase-malformed.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-test_description='rebase should not insist on git message convention'\n+test_description='rebase should handle arbitrary git message'\n \n . ./test-lib.sh\n \n@@ -12,6 +12,11 @@ It has two paragraphs, but its first paragraph is not friendly\n to oneline summary format.\n EOF\n \n+cat >G <<\\EOF\n+commit log message containing a diff\n+EOF\n+\n+\n test_expect_success setup '\n \n \t>file1 &&\n@@ -19,8 +24,9 @@ test_expect_success setup '\n \tgit add file1 file2 &&\n \ttest_tick &&\n \tgit commit -m \"Initial commit\" &&\n+\tgit branch diff-in-message\n \n-\tgit checkout -b side &&\n+\tgit checkout -b multi-line-subject &&\n \tcat F >file2 &&\n \tgit add file2 &&\n \ttest_tick &&\n@@ -28,6 +34,17 @@ test_expect_success setup '\n \n \tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" >F0 &&\n \n+\tgit checkout diff-in-message &&\n+\techo \"commit log message containing a diff\" >G &&\n+\techo \"\" >>G\n+\tcat G >file2 &&\n+\tgit add file2 &&\n+\tgit diff --cached >>G &&\n+\ttest_tick &&\n+\tgit commit -F G &&\n+\n+\tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" >G0 &&\n+\n \tgit checkout master &&\n \n \techo One >file1 &&\n@@ -36,13 +53,20 @@ test_expect_success setup '\n \tgit commit -m \"Second commit\"\n '\n \n-test_expect_success rebase '\n+test_expect_success 'rebase commit with multi-line subject' '\n \n-\tgit rebase master side &&\n+\tgit rebase master multi-line-subject &&\n \tgit cat-file commit HEAD | sed -e \"1,/^\\$/d\" >F1 &&\n \n \ttest_cmp F0 F1 &&\n \ttest_cmp F F0\n '\n \n+test_expect_success 'rebase commit with diff in message' '\n+\tgit rebase master diff-in-message &&\n+\tgit cat-file commit HEAD | sed -e \"1,/^$/d\" >G1 &&\n+\ttest_cmp G0 G1 &&\n+\ttest_cmp G G0\n+'\n+\n test_done\n-- \n1.7.9.3.327.g2980b\n"},{"id":"194277","messageId":"1340722318-24392-5-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"30904","inReplyTo":"1340722318-24392-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 4/5] am: don't call mailinfo if $rebasing","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-26T14:51:57Z","receivedAt":"2012-06-26T14:51:57Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Since 5e835ca (rebase: do not munge commit log message, 2008-04-16),\n'git am --rebasing' no longer gets the commit log message from the\npatch, but reads it from the commit identified by the \"From \" header\nline. From 43c2325 (am: use get_author_ident_from_commit instead of\nmailinfo when rebasing, 2010-06-16), it also gets the author name,\nemail and date from the commit. Now that the final part of the patch\n-- the patch body itself -- is also read from the commit, there is no\nlonger a need to call 'git mailinfo' to extract any of these parts\nwhile --rebasing.\n\nSugested-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-am.sh |   47 ++++++++++++++++++++++++-----------------------\n 1 file changed, 24 insertions(+), 23 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex ec8fde1..b6a5300 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -260,7 +260,7 @@ check_patch_format () {\n split_patches () {\n \tcase \"$patch_format\" in\n \tmbox)\n-\t\tif test -n \"$rebasing\" || test t = \"$keepcr\"\n+\t\tif test t = \"$keepcr\"\n \t\tthen\n \t\t    keep_cr=--keep-cr\n \t\telse\n@@ -413,7 +413,7 @@ do\n \t--abort)\n \t\tabort=t ;;\n \t--rebasing)\n-\t\trebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;\n+\t\trebasing=t threeway=t ;;\n \t-d|--dotest)\n \t\tdie \"$(gettext \"-d option is no longer supported.  Do not use.\")\"\n \t\t;;\n@@ -658,33 +658,34 @@ do\n \t# by the user, or the user can tell us to do so by --resolved flag.\n \tcase \"$resume\" in\n \t'')\n-\t\tgit mailinfo $keep $no_inbody_headers $scissors $utf8 \"$dotest/msg\" \"$dotest/patch\" \\\n-\t\t\t<\"$dotest/$msgnum\" >\"$dotest/info\" ||\n-\t\t\tstop_here $this\n-\n-\t\t# skip pine's internal folder data\n-\t\tsane_grep '^Author: Mail System Internal Data$' \\\n-\t\t\t<\"$dotest\"/info >/dev/null &&\n-\t\t\tgo_next && continue\n-\n-\t\ttest -s \"$dotest/patch\" || {\n-\t\t\teval_gettextln \"Patch is empty.  Was it split wrong?\n-If you would prefer to skip this patch, instead run \\\"\\$cmdline --skip\\\".\n-To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n-\t\t\tstop_here $this\n-\t\t}\n-\t\trm -f \"$dotest/original-commit\" \"$dotest/author-script\"\n-\t\tif test -f \"$dotest/rebasing\" &&\n+\t\tif test -f \"$dotest/rebasing\"\n+\t\tthen\n \t\t\tcommit=$(sed -e 's/^From \\([0-9a-f]*\\) .*/\\1/' \\\n \t\t\t\t-e q \"$dotest/$msgnum\") &&\n-\t\t\ttest \"$(git cat-file -t \"$commit\")\" = commit\n-\t\tthen\n+\t\t\ttest \"$(git cat-file -t \"$commit\")\" = commit ||\n+\t\t\t\tstop_here $this\n \t\t\tgit cat-file commit \"$commit\" |\n \t\t\tsed -e '1,/^$/d' >\"$dotest/msg-clean\"\n-\t\t\techo \"$commit\" > \"$dotest/original-commit\"\n-\t\t\tget_author_ident_from_commit \"$commit\" > \"$dotest/author-script\"\n+\t\t\techo \"$commit\" >\"$dotest/original-commit\"\n+\t\t\tget_author_ident_from_commit \"$commit\" >\"$dotest/author-script\"\n \t\t\tgit diff-tree --root --binary \"$commit\" >\"$dotest/patch\"\n \t\telse\n+\t\t\tgit mailinfo $keep $no_inbody_headers $scissors $utf8 \"$dotest/msg\" \"$dotest/patch\" \\\n+\t\t\t\t<\"$dotest/$msgnum\" >\"$dotest/info\" ||\n+\t\t\t\tstop_here $this\n+\n+\t\t\t# skip pine's internal folder data\n+\t\t\tsane_grep '^Author: Mail System Internal Data$' \\\n+\t\t\t\t<\"$dotest\"/info >/dev/null &&\n+\t\t\t\tgo_next && continue\n+\n+\t\t\ttest -s \"$dotest/patch\" || {\n+\t\t\t\teval_gettextln \"Patch is empty.  Was it split wrong?\n+If you would prefer to skip this patch, instead run \\\"\\$cmdline --skip\\\".\n+To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n+\t\t\t\tstop_here $this\n+\t\t\t}\n+\t\t\trm -f \"$dotest/original-commit\" \"$dotest/author-script\"\n \t\t\t{\n \t\t\t\tsed -n '/^Subject/ s/Subject: //p' \"$dotest/info\"\n \t\t\t\techo\n-- \n1.7.9.3.327.g2980b\n"},{"id":"194279","messageId":"1340722318-24392-6-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"30904","inReplyTo":"1340722318-24392-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 5/5] rebase [-m]: calculate patches in upstream correctly","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-26T14:51:58Z","receivedAt":"2012-06-26T14:51:58Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Plain 'git rebase' (without -m/-i/-p) applies the patches from\n\n  git format-patch --ignore-if-in-upstream $upstream..$orig_head\n\n, while 'git rebase -m' finds the commits using\n\n  git rev-list $upstream..$orig_head\n\nAs Knut Franke reported in [1], the fact that there is no\n--ignore-if-in-upstream or equivalent when using merge-based rebase\nmeans that unnecessary conflicts can arise due to commits\ncherry-picked between $orig_head and $upstream.\n\nThere is a second problem with the above method of calculating the\nupstream commits. Copying the example history from [1]:\n\n      .-c\n     /\na---b---d---e---f\n         \\\n          .-g---E\n\nCommit E is here a cherry-pick of e. If we now run 'git rebase --onto\nc f E', the revisions that will be applied onto 'c' are given by 'git\nformat-patch --ignore-if-in-upstream f..E'. In this case that would be\nonly 'g' and NOT 'E'.\n\nTo solve both of the above problems, we want to find the commits in\n$upstream..$orig_head that are not cherry-picked in\n$upstream..$onto. There is unfortunately no direct way of finding\nthese commits using 'git rev-list', so we will have to resort to using\n'git cherry' and filter for lines starting with '+'.\n\nTo reduce the risk of 'git rebase' and 'git rebase -m' behaving\ndifferently (with respect to the commits chosen) in the future,\nperform the calculation already in git-rebase.sh.\n\nAs a side-effect, we also avoid the cost of formatting patches.\n\nTest case updates for 'rebase -m' by Knut, the rest by Martin.\n\n [1] http://thread.gmane.org/gmane.comp.version-control.git/161917\n\nHelped-by: Knut Franke <Knut.Franke@gmx.de>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--am.sh         |    6 ++----\n git-rebase--merge.sh      |    2 +-\n git-rebase.sh             |    7 +------\n t/t3401-rebase-partial.sh |   17 +++++++++++++++++\n t/t3406-rebase-message.sh |   14 +++++++-------\n 5 files changed, 28 insertions(+), 18 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 392ebc9..89e0ab4 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -16,7 +16,6 @@ skip)\n \t;;\n esac\n \n-test -n \"$rebase_root\" && root_flag=--root\n \n if test -n \"$keep_empty\"\n then\n@@ -26,9 +25,8 @@ then\n \t# makes this easy\n \tgit cherry-pick --allow-empty \"$revisions\"\n else\n-\tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n-\t\t--src-prefix=a/ --dst-prefix=b/ \\\n-\t\t--no-renames $root_flag \"$revisions\" |\n+\techo \"$revisions\" |\n+\tsed -e 's/\\([0-9a-f]\\{40\\}\\)/From \\1 Mon Sep 17 00:00:00 2001/' |\n \tgit am $git_am_opt --rebasing --resolvemsg=\"$resolvemsg\"\n fi && move_to_original_branch\n \ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex b10f2cf..7ea33e3 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -131,7 +131,7 @@ echo \"$onto_name\" > \"$state_dir/onto_name\"\n write_basic_state\n \n msgnum=0\n-for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n+for cmt in $revisions\n do\n \tmsgnum=$(($msgnum + 1))\n \techo \"$cmt\" > \"$state_dir/cmt.$msgnum\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 6df06c4..47e75cb 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -522,11 +522,6 @@ then\n \texit 0\n fi\n \n-if test -n \"$rebase_root\"\n-then\n-\trevisions=\"$onto..$orig_head\"\n-else\n-\trevisions=\"$upstream..$orig_head\"\n-fi\n+revisions=\"$(git cherry $onto $orig_head $upstream | sed -ne 's/^+ //p')\"\n \n run_specific_rebase\ndiff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh\nindex 7ba1797..ce555fa 100755\n--- a/t/t3401-rebase-partial.sh\n+++ b/t/t3401-rebase-partial.sh\n@@ -42,4 +42,21 @@ test_expect_success 'rebase --merge topic branch that was partially merged upstr\n \ttest_path_is_missing .git/rebase-merge\n '\n \n+test_expect_success 'rebase --onto does not re-apply patches in $onto' '\n+\tgit checkout C &&\n+\ttest_commit C2 C.t &&\n+\tgit checkout -B my-topic-branch master &&\n+\ttest_commit D &&\n+\tgit rebase --onto C2 A2 &&\n+\ttest \"$(git log --format=%s C2..)\" = D\n+'\n+\n+test_expect_success 'rebase --onto does not lose patches in $upstream' '\n+\tgit rebase --onto A2 D &&\n+\ttest \"$(git log --format=%s A2..)\" = \"D\n+C2\n+C\n+B\"\n+'\n+\n test_done\ndiff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh\nindex 6898377..3eecc66 100755\n--- a/t/t3406-rebase-message.sh\n+++ b/t/t3406-rebase-message.sh\n@@ -5,8 +5,10 @@ test_description='messages from rebase operation'\n . ./test-lib.sh\n \n quick_one () {\n-\techo \"$1\" >\"file$1\" &&\n-\tgit add \"file$1\" &&\n+\tfileno=$2\n+\ttest -z \"$fileno\" && fileno=$1\n+\techo \"$1\" >\"file$fileno\" &&\n+\tgit add \"file$fileno\" &&\n \ttest_tick &&\n \tgit commit -m \"$1\"\n }\n@@ -16,21 +18,19 @@ test_expect_success setup '\n \tgit branch topic &&\n \tquick_one X &&\n \tquick_one A &&\n-\tquick_one B &&\n+\tquick_one B A &&\n \tquick_one Y &&\n \n \tgit checkout topic &&\n \tquick_one A &&\n-\tquick_one B &&\n+\tquick_one B A &&\n \tquick_one Z &&\n \tgit tag start\n \n '\n \n cat >expect <<\\EOF\n-Already applied: 0001 A\n-Already applied: 0002 B\n-Committed: 0003 Z\n+Committed: 0001 Z\n EOF\n \n test_expect_success 'rebase -m' '\n-- \n1.7.9.3.327.g2980b\n"},{"id":"194313","messageId":"7v8vf9bwv0.fsf@alter.siamese.dyndns.org","threadId":"30904","inReplyTo":"1340722318-24392-6-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 5/5] rebase [-m]: calculate patches in upstream correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-26T21:13:07Z","receivedAt":"2012-06-26T21:13:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Hrm, why does this break 9140.6?  Has the test been expecting a\nwrong result?\n\n-- >8 --\n\nexpecting success: \n        ( cd g &&\n          git svn fetch &&\n          git svn rebase &&\n          fgrep \"mod hidden\" hid/hid.txt\n        )\n\nIndex mismatch: a4b5c203f79112e92d530cb82366ca4d706fa4a8 != 6b5a1244749c8cdb5442eefd0abc3689d666322d\nrereading 6f980d1f3188db5082d5bfd2f28b317b6e7b8893\n        A       hid/hid.txt\nr2 = 9c02870abb807d33b84cc36ab2f2384bf01448f8 (refs/remotes/git-svn)\n        M       vis/vis.txt\nr3 = 26a2abacc1ca26dde5a0b18a73f0b2d306dc95d1 (refs/remotes/git-svn)\n        M       hid/hid.txt\nr4 = 9299b4c6227b8efcc64ec5e867f0eeae4d1c96ec (refs/remotes/git-svn)\nFirst, rewinding head to replay your work on top of it...\nApplying: create initially hidden files\nfatal: unrecognized input\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\nPatch failed at 0001 create initially hidden files\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase\n--skip\".\nTo check out the original branch and stop rebasing run \"git rebase\n--abort\".\n\nrebase refs/remotes/git-svn: command returned error: 1\n\nnot ok - 6 refetch succeeds not ignoring any files\n"},{"id":"194356","messageId":"CAOeW2eGVdZrccbLaOusirBY6PzpMVhy=gzHrpvTQq0dCLJL71g@mail.gmail.com","threadId":"30904","inReplyTo":"7v8vf9bwv0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 5/5] rebase [-m]: calculate patches in upstream correctly","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2012-06-27T16:17:53Z","receivedAt":"2012-06-27T16:17:53Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, Jun 26, 2012 at 2:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Hrm, why does this break 9140.6?  Has the test been expecting a\n> wrong result?\n\nI wish I could say that it was. I guess I never had the subversion\nlibraries installed while running the test cases :-(. It turns out\nthat that test case happens to create an empty commit. So when I\nchanged from git-format-patch to git-cherry for calculating the\nrevisions to rebase, it started including empty commits. It also turns\nout we don't have any test cases specifically for rebasing empty\ncommits, so I'm glad 9140.6 caught it. I'll send out a patch that adds\na test case for rebasing of empty commit, which should be good\nregardless of whether the current patch, in some form, is eventually\naccepted.\n\nI got all the tests to pass by special-casing empty patches in\ngit-am.sh when $rebasing, but I'm now unsure about this patch for a\nfew reasons:\n\n 1) I suppose the $revisions passed to git-am and may result in too\nlong a command line. This should be fixable by replacing it by a\nfunction, I guess.\n\n 2) The new --keep-empty stuff is clearly closely related to these\nchanges and at least the 'if test -n \"$keep_empty\"' block in\ngit-rebase--am.sh could possibly be replaced by similar logic in\ngit-am.sh by passing the --keep-empty to it. Using git-am should make\nit faster, which it the whole point of using git-am instead of\ngit-cherry-pick, IIUC.\n\nI'm not sure when I'll get time to work on these issues. If someone\nelse feels the urge, please go ahead.\n\nMartin\n"}]}