{"thread":{"id":"39645","subject":"rebase -i might leave CHERRY_PICK_HEAD behind","startedAt":"2015-06-16T12:06:12Z","lastAt":"2015-06-18T20:11:01Z","messageCount":20,"participants":["SZEDER Gábor","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"263926","messageId":"20150616140612.Horde.a1irZQmh2o42SqDfxAytHg1@webmail.informatik.kit.edu","threadId":"39645","inReplyTo":null,"subject":"rebase -i might leave CHERRY_PICK_HEAD behind","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-06-16T12:06:12Z","receivedAt":"2015-06-16T12:06:12Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nHi,\n\nWhen skipping an empty commit with 'git rebase --continue' a\nCHERRY_PICK_HEAD file might be left behind.\n\nWhat I did boils down to this:\n\n     echo one >file\n     git add file\n     git commit -m first\n     echo two >file\n     git commit -a -m second\n     echo three >file\n     git commit -a -m third\n     git rebase -i HEAD^^\n     # change todo list to edit the \"second\" commit\n\n     echo three >file\n     git commit -a --amend\n     # this effectively makes the third commit an empty commit\n     # and rebase will ask what to do:\n     git rebase --continue\n     The previous cherry-pick is now empty, possibly due to conflict  \nresolution.\n     If you wish to commit it anyway, use:\n\n         git commit --allow-empty\n\n     Otherwise, please use 'git reset'\n     rebase in progress; onto 7335bbe7a5\n     You are currently rebasing branch 'master' on '7335bbe7a5'.\n\n     nothing to commit, working directory clean\n     Could not apply d19f82ac6d467247117fd734ed039b03ef923c86... third\n\n     # I didn't want an empty commit, but didn't read that carefully, so I did:\n     git rebase --continue\n     Successfully rebased and updated refs/heads/master.\n     # and was rewarded for my lack of attention with the following  \nbash prompt:\n     test/rebase-empty-continue (master|CHERRY-PICKING)$\n     # indeed:\n     ls -l .git/CHERRY_PICK_HEAD\n     -rw-r--r-- 1 szeder szeder 41 Jun 16 13:22 .git/CHERRY_PICK_HEAD\n\nOn one hand, it's user error: it told me to run 'git reset' to achive\nwhat I want but I didn't.\nNote, however, how it told me about 'git reset': while 'git commit\n--allow-empty' is greatly emphasized by indentation and empty lines\nbefore and after, 'git reset' blends in quite well into the rebase\nprogress.  It was late, I was tired, and there was a questionable\npenalty on Copa América as well ;), so I simply didn't notice.\n\nOn the other hand,\n\n    1. 'git rebase' claimed that \"Successfully rebased...\", yet it left\n       cruft behind.  I think it shouldn't.\n    2. 'git rebase --continue' didn't complain by the lack of prior\n       'git reset' and finished doing exacly what I expected from it to\n       do (except leaving CHERRY_PICK_HEAD behind, of course).\n       Perhaps it should complain, like it does when the worktree is\n       dirty.\n       Alternatively, it could just continue to DWIM, as it does\n       already, but then it should remove CHERRY_PICK_HEAD as well.\n\nGábor\n"},{"id":"263943","messageId":"a1b485b913b374a1cf7f1bcd1e77532f@www.dscho.org","threadId":"39645","inReplyTo":"20150616140612.Horde.a1irZQmh2o42SqDfxAytHg1@webmail.informatik.kit.edu","subject":"Re: rebase -i might leave CHERRY_PICK_HEAD behind","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-16T14:56:43Z","receivedAt":"2015-06-16T14:56:43Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn 2015-06-16 14:06, SZEDER Gábor wrote:\n\n> When skipping an empty commit with 'git rebase --continue' a\n> CHERRY_PICK_HEAD file might be left behind.\n\nYeah, I noticed that, too... it even survives the cleanup of the finished rebase under certain circumstances.\n\nMaybe something like this?\n\n-- snipsnap --\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex dc3133f..16e0a82 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -849,7 +849,11 @@ continue)\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet HEAD --\n \tthen\n-\t\t: Nothing to commit -- skip this\n+\t\t: Nothing to commit -- skip this commit\n+\n+\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\tdie \"Could not remove CHERRY_PICK_HEAD\"\n \telse\n \t\tif ! test -f \"$author_script\"\n \t\tthen\n"},{"id":"263989","messageId":"cover.1434528725.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"20150616140612.Horde.a1irZQmh2o42SqDfxAytHg1@webmail.informatik.kit.edu","subject":"[PATCH 0/2] rebase -i: Fix left-behind CHERRY_PICK_HEAD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-17T08:15:27Z","receivedAt":"2015-06-17T08:15:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Gábor's mail reminded me that this bug bites me often enough when rebasing Git for Windows.\n\nThe symptom is that .git/CHERRY_PICK_HEAD is left behind after skipping an already-merged patch with `git rebase --continue` instead of `git rebase --skip`. I always prefer the former invocation because the latter would also skip legitimate patches if there were merge conflicts, while the former would not allow that.\n\nJohannes Schindelin (2):\n  t3404: demonstrate CHERRY_PICK_HEAD bug\n  rebase -i: do not leave a CHERRY_PICK_HEAD file behind\n\n git-rebase--interactive.sh    |  6 +++++-\n t/t3404-rebase-interactive.sh | 20 ++++++++++++++++++++\n 2 files changed, 25 insertions(+), 1 deletion(-)\n\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"263990","messageId":"f76ca5d0b6687a4d2ee4f587d8ba75a643a33c04.1434528725.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434528725.git.johannes.schindelin@gmx.de","subject":"[PATCH 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-17T08:16:08Z","receivedAt":"2015-06-17T08:16:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When rev-list's --cherry option does not detect that a patch has already\nbeen applied upstream, an interactive rebase would offer to reapply it and\nconsequently stop at that patch with a failure, mentioning that the diff\nis empty.\n\nTraditionally, a `git rebase --continue` simply skips the commit in such a\nsituation.\n\nHowever, as pointed out by Gábor Szeder, this leaves a CHERRY_PICK_HEAD\nbehind, making the Git prompt believe that a cherry pick is still going\non. This commit adds a test case demonstrating this bug.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t3404-rebase-interactive.sh | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex ac429a0..5d52775 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1102,4 +1102,24 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '\n \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n '\n \n+test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n+\tgit checkout -b commit-to-skip &&\n+\tfor double in X 3 1\n+\tdo\n+\t\tseq 5 | sed \"s/$double/&&/\" >seq &&\n+\t\tgit add seq &&\n+\t\ttest_tick &&\n+\t\tgit commit -m seq-$double\n+\tdone &&\n+\tgit tag seq-onto &&\n+\tgit reset --hard HEAD~2 &&\n+\tgit cherry-pick seq-onto &&\n+\ttest_must_fail git rebase -i seq-onto &&\n+\ttest -d .git/rebase-merge &&\n+\tgit rebase --continue &&\n+\tgit diff seq-onto &&\n+\ttest ! -d .git/rebase-merge &&\n+\ttest ! -f .git/CHERRY_PICK_HEAD\n+'\n+\n test_done\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"263991","messageId":"2751d249ba6315f0139ba8fd6aa6ff23c32c9e69.1434528725.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434528725.git.johannes.schindelin@gmx.de","subject":"[PATCH 2/2] rebase -i: do not leave a CHERRY_PICK_HEAD file behind","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-17T08:16:18Z","receivedAt":"2015-06-17T08:16:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When skipping commits whose changes were already applied via `git rebase\n--continue`, we need to clean up said file explicitly.\n\nThe same is not true for `git rebase --skip` because that will execute\n`git reset --hard` as part of the \"skip\" handling in git-rebase.sh, even\nbefore git-rebase--interactive.sh is called.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-rebase--interactive.sh    | 6 +++++-\n t/t3404-rebase-interactive.sh | 2 +-\n 2 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex dc3133f..16e0a82 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -849,7 +849,11 @@ continue)\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet HEAD --\n \tthen\n-\t\t: Nothing to commit -- skip this\n+\t\t: Nothing to commit -- skip this commit\n+\n+\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\tdie \"Could not remove CHERRY_PICK_HEAD\"\n \telse\n \t\tif ! test -f \"$author_script\"\n \t\tthen\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 5d52775..241d4d1 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1102,7 +1102,7 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '\n \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n '\n \n-test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n+test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '\n \tgit checkout -b commit-to-skip &&\n \tfor double in X 3 1\n \tdo\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264011","messageId":"20150617145814.Horde.VFmyWwlQfspzMMXX3ZuSlQ4@webmail.informatik.kit.edu","threadId":"39645","inReplyTo":"2751d249ba6315f0139ba8fd6aa6ff23c32c9e69.1434528725.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH 2/2] rebase -i: do not leave a CHERRY_PICK_HEAD file behind","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-06-17T12:58:14Z","receivedAt":"2015-06-17T12:58:14Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\nQuoting Johannes Schindelin <johannes.schindelin@gmx.de>:\n> When skipping commits whose changes were already applied via `git rebase\n> --continue`, we need to clean up said file explicitly.\n>\n> The same is not true for `git rebase --skip` because that will execute\n> `git reset --hard` as part of the \"skip\" handling in git-rebase.sh, even\n> before git-rebase--interactive.sh is called.\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nNice quick turnaround, thanks.\n\nSo, with this change the 'git reset' won't be necessary at all, right?\n\n> ---\n>  git-rebase--interactive.sh    | 6 +++++-\n>  t/t3404-rebase-interactive.sh | 2 +-\n>  2 files changed, 6 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index dc3133f..16e0a82 100644\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -849,7 +849,11 @@ continue)\n>  \t# do we have anything to commit?\n>  \tif git diff-index --cached --quiet HEAD --\n>  \tthen\n> -\t\t: Nothing to commit -- skip this\n> +\t\t: Nothing to commit -- skip this commit\n\n\"While at it\", perhaps you could turn this into a proper comment with '#\".\nNow that this if-branch starts to actually do something, there's no  \nreason to continue (ab)using the null command.\n\n> +\n> +\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n> +\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n> +\t\tdie \"Could not remove CHERRY_PICK_HEAD\"\n>  \telse\n>  \t\tif ! test -f \"$author_script\"\n>  \t\tthen\n> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\n> index 5d52775..241d4d1 100755\n> --- a/t/t3404-rebase-interactive.sh\n> +++ b/t/t3404-rebase-interactive.sh\n> @@ -1102,7 +1102,7 @@ test_expect_success 'rebase -i commits that  \n> overwrite untracked files (no ff)' '\n>  \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n>  '\n>\n> -test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n> +test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '\n>  \tgit checkout -b commit-to-skip &&\n>  \tfor double in X 3 1\n>  \tdo\n> --\n> 2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264030","messageId":"d8b9c3f3376817962207b9c3f16c7d01@www.dscho.org","threadId":"39645","inReplyTo":"20150617145814.Horde.VFmyWwlQfspzMMXX3ZuSlQ4@webmail.informatik.kit.edu","subject":"Re: [PATCH 2/2] rebase -i: do not leave a CHERRY_PICK_HEAD file behind","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-17T15:24:44Z","receivedAt":"2015-06-17T15:24:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn 2015-06-17 14:58, SZEDER Gábor wrote:\n\n> Quoting Johannes Schindelin <johannes.schindelin@gmx.de>:\n>> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n>> index dc3133f..16e0a82 100644\n>> --- a/git-rebase--interactive.sh\n>> +++ b/git-rebase--interactive.sh\n>> @@ -849,7 +849,11 @@ continue)\n>>  \t# do we have anything to commit?\n>>  \tif git diff-index --cached --quiet HEAD --\n>>  \tthen\n>> -\t\t: Nothing to commit -- skip this\n>> +\t\t: Nothing to commit -- skip this commit\n> \n> \"While at it\", perhaps you could turn this into a proper comment with '#\".\n> Now that this if-branch starts to actually do something, there's no \n> reason to continue (ab)using the null command.\n\nSure thing. I'll wait if there are more comments and then send out v2.\n\nCiao,\nJohannes\n"},{"id":"264043","messageId":"xmqqvbem2slg.fsf@gitster.dls.corp.google.com","threadId":"39645","inReplyTo":"cover.1434528725.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH 0/2] rebase -i: Fix left-behind CHERRY_PICK_HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-17T16:43:39Z","receivedAt":"2015-06-17T16:43:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n> The symptom is that .git/CHERRY_PICK_HEAD is left behind after\n> skipping an already-merged patch with `git rebase --continue`\n> instead of `git rebase --skip`. I always prefer the former\n> invocation because the latter would also skip legitimate patches\n> if there were merge conflicts, while the former would not allow\n> that.\n\nMakes sense; will queue.  Thanks.\n"},{"id":"264050","messageId":"xmqqtwu66xzg.fsf@gitster.dls.corp.google.com","threadId":"39645","inReplyTo":"f76ca5d0b6687a4d2ee4f587d8ba75a643a33c04.1434528725.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-17T17:33:39Z","receivedAt":"2015-06-17T17:33:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n> +test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n> +\tgit checkout -b commit-to-skip &&\n> +\tfor double in X 3 1\n> +\tdo\n> +\t\tseq 5 | sed \"s/$double/&&/\" >seq &&\n> +\t\tgit add seq &&\n> +\t\ttest_tick &&\n> +\t\tgit commit -m seq-$double\n> +\tdone &&\n> +\tgit tag seq-onto &&\n> +\tgit reset --hard HEAD~2 &&\n> +\tgit cherry-pick seq-onto &&\n> +\ttest_must_fail git rebase -i seq-onto &&\n\nShouldn't this explicitly specify what fake editor is to be used,\ninstead of relying on whatever the last test happened to have used?\n\nI thought this deserved to go to older maintenance track, but the\nfake editor that was used last are different between branches, so\n\"rebase -i\" fails for a wrong reason (i.e. cannot spawn the editor)\nwhen queued on say maint-2.2.\n\n> +\ttest -d .git/rebase-merge &&\n> +\tgit rebase --continue &&\n> +\tgit diff seq-onto &&\n\nI am puzzled with this \"diff\"; what is this about?  Is it a remnant\nfrom an earlier debugging session, or is it making sure seq-onto is\na valid tree-ish?\n\n> +\ttest ! -d .git/rebase-merge &&\n> +\ttest ! -f .git/CHERRY_PICK_HEAD\n> +'\n> +\n>  test_done\n\nThanks.\n"},{"id":"264137","messageId":"c2b427850cc6f298bee017123639c4df@www.dscho.org","threadId":"39645","inReplyTo":"xmqqtwu66xzg.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T11:22:04Z","receivedAt":"2015-06-18T11:22:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn 2015-06-17 19:33, Junio C Hamano wrote:\n> Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n> \n>> +test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n>> +\tgit checkout -b commit-to-skip &&\n>> +\tfor double in X 3 1\n>> +\tdo\n>> +\t\tseq 5 | sed \"s/$double/&&/\" >seq &&\n>> +\t\tgit add seq &&\n>> +\t\ttest_tick &&\n>> +\t\tgit commit -m seq-$double\n>> +\tdone &&\n>> +\tgit tag seq-onto &&\n>> +\tgit reset --hard HEAD~2 &&\n>> +\tgit cherry-pick seq-onto &&\n>> +\ttest_must_fail git rebase -i seq-onto &&\n> \n> Shouldn't this explicitly specify what fake editor is to be used,\n> instead of relying on whatever the last test happened to have used?\n> \n> I thought this deserved to go to older maintenance track, but the\n> fake editor that was used last are different between branches, so\n> \"rebase -i\" fails for a wrong reason (i.e. cannot spawn the editor)\n> when queued on say maint-2.2.\n\nTrue. Thanks for pointing that out. Will be fixed in v2.\n\n>> +\ttest -d .git/rebase-merge &&\n>> +\tgit rebase --continue &&\n>> +\tgit diff seq-onto &&\n> \n> I am puzzled with this \"diff\"; what is this about?  Is it a remnant\n> from an earlier debugging session, or is it making sure seq-onto is\n> a valid tree-ish?\n\nThe idea is to verify that we end up with the same tree even if we exchanged the latest two patches. I can remove it if you want as it is not strictly necessary, but I would like to keep it just to make sure that we did not end up with an incomplete rebase.\n\nCiao,\nDscho\n"},{"id":"264172","messageId":"cover.1434627492.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434528725.git.johannes.schindelin@gmx.de","subject":"[PATCH v2 0/2] rebase -i: Fix left-behind CHERRY_PICK_HEAD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T11:44:29Z","receivedAt":"2015-06-18T11:44:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"These patches fix a bug that bites me often enough when rebasing Git for\nWindows.\n\nThe symptom is that .git/CHERRY_PICK_HEAD is left behind after skipping\nan already-merged patch with `git rebase --continue` instead of `git\nrebase --skip`. I always prefer the former invocation because the latter\nwould also skip legitimate patches if there were merge conflicts, while\nthe former would not allow that.\n\nChanges since v1:\n\n- no longer uses ':' to make the comment a no-op statement\n\n- sets the fake editor correctly in the test (I verified that by\n  rebasing onto v2.2.2 and running the test with and without setting the\n  fake editor)\n\nInterdiff below the diffstat.\n\nJohannes Schindelin (2):\n  t3404: demonstrate CHERRY_PICK_HEAD bug\n  rebase -i: do not leave a CHERRY_PICK_HEAD file behind\n\n git-rebase--interactive.sh    |  6 +++++-\n t/t3404-rebase-interactive.sh | 21 +++++++++++++++++++++\n 2 files changed, 26 insertions(+), 1 deletion(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 16e0a82..5ff0f1c 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -849,7 +849,7 @@ continue)\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet HEAD --\n \tthen\n-\t\t: Nothing to commit -- skip this commit\n+\t\t# Nothing to commit -- skip this commit\n \n \t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n \t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 241d4d1..f3337ad 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1114,7 +1114,8 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '\n \tgit tag seq-onto &&\n \tgit reset --hard HEAD~2 &&\n \tgit cherry-pick seq-onto &&\n-\ttest_must_fail git rebase -i seq-onto &&\n+\tset_fake_editor &&\n+\tFAKE_LINES= test_must_fail git rebase -i seq-onto &&\n \ttest -d .git/rebase-merge &&\n \tgit rebase --continue &&\n \tgit diff seq-onto &&\n\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264174","messageId":"930906ab4bb4d629d8963850460c1d15f958af5a.1434627492.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434627492.git.johannes.schindelin@gmx.de","subject":"[PATCH v2 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T11:44:38Z","receivedAt":"2015-06-18T11:44:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When rev-list's --cherry option does not detect that a patch has already\nbeen applied upstream, an interactive rebase would offer to reapply it and\nconsequently stop at that patch with a failure, mentioning that the diff\nis empty.\n\nTraditionally, a `git rebase --continue` simply skips the commit in such a\nsituation.\n\nHowever, as pointed out by Gábor Szeder, this leaves a CHERRY_PICK_HEAD\nbehind, making the Git prompt believe that a cherry pick is still going\non. This commit adds a test case demonstrating this bug.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t3404-rebase-interactive.sh | 21 +++++++++++++++++++++\n 1 file changed, 21 insertions(+)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex ac429a0..e5e7744 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1102,4 +1102,25 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '\n \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n '\n \n+test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n+\tgit checkout -b commit-to-skip &&\n+\tfor double in X 3 1\n+\tdo\n+\t\tseq 5 | sed \"s/$double/&&/\" >seq &&\n+\t\tgit add seq &&\n+\t\ttest_tick &&\n+\t\tgit commit -m seq-$double\n+\tdone &&\n+\tgit tag seq-onto &&\n+\tgit reset --hard HEAD~2 &&\n+\tgit cherry-pick seq-onto &&\n+\tset_fake_editor &&\n+\tFAKE_LINES= test_must_fail git rebase -i seq-onto &&\n+\ttest -d .git/rebase-merge &&\n+\tgit rebase --continue &&\n+\tgit diff seq-onto &&\n+\ttest ! -d .git/rebase-merge &&\n+\ttest ! -f .git/CHERRY_PICK_HEAD\n+'\n+\n test_done\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264173","messageId":"23bb1e151564cdc0249735b3c5f28ea441a5a907.1434627492.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434627492.git.johannes.schindelin@gmx.de","subject":"[PATCH v2 2/2] rebase -i: do not leave a CHERRY_PICK_HEAD file behind","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T11:44:48Z","receivedAt":"2015-06-18T11:44:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When skipping commits whose changes were already applied via `git rebase\n--continue`, we need to clean up said file explicitly.\n\nThe same is not true for `git rebase --skip` because that will execute\n`git reset --hard` as part of the \"skip\" handling in git-rebase.sh, even\nbefore git-rebase--interactive.sh is called.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-rebase--interactive.sh    | 6 +++++-\n t/t3404-rebase-interactive.sh | 2 +-\n 2 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex dc3133f..5ff0f1c 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -849,7 +849,11 @@ continue)\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet HEAD --\n \tthen\n-\t\t: Nothing to commit -- skip this\n+\t\t# Nothing to commit -- skip this commit\n+\n+\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\tdie \"Could not remove CHERRY_PICK_HEAD\"\n \telse\n \t\tif ! test -f \"$author_script\"\n \t\tthen\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex e5e7744..f3337ad 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1102,7 +1102,7 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '\n \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n '\n \n-test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n+test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '\n \tgit checkout -b commit-to-skip &&\n \tfor double in X 3 1\n \tdo\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264193","messageId":"xmqqoakdf1lu.fsf@gitster.dls.corp.google.com","threadId":"39645","inReplyTo":"c2b427850cc6f298bee017123639c4df@www.dscho.org","subject":"Re: [PATCH 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-18T16:00:29Z","receivedAt":"2015-06-18T16:00:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n>>> +\tgit diff seq-onto &&\n>> \n>> I am puzzled with this \"diff\"; what is this about?  Is it a remnant\n>> from an earlier debugging session, or is it making sure seq-onto is\n>> a valid tree-ish?\n>\n> The idea is to verify that we end up with the same tree even if we\n> exchanged the latest two patches. I can remove it if you want as it is\n> not strictly necessary, but I would like to keep it just to make sure\n> that we did not end up with an incomplete rebase.\n\nI agree that such a verification is a very good thing to have here.\nBut you would need to ask \"git diff\" to signal that it found no\ndifferences with --exit-code or --quiet, I would think.\n\nThanks.\n"},{"id":"264195","messageId":"0f55232f453ab3a75bafe17db2744552@www.dscho.org","threadId":"39645","inReplyTo":"xmqqoakdf1lu.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T16:16:19Z","receivedAt":"2015-06-18T16:16:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn 2015-06-18 18:00, Junio C Hamano wrote:\n> Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n> \n>>>> +\tgit diff seq-onto &&\n>>>\n>>> I am puzzled with this \"diff\"; what is this about?  Is it a remnant\n>>> from an earlier debugging session, or is it making sure seq-onto is\n>>> a valid tree-ish?\n>>\n>> The idea is to verify that we end up with the same tree even if we\n>> exchanged the latest two patches. I can remove it if you want as it is\n>> not strictly necessary, but I would like to keep it just to make sure\n>> that we did not end up with an incomplete rebase.\n> \n> I agree that such a verification is a very good thing to have here.\n> But you would need to ask \"git diff\" to signal that it found no\n> differences with --exit-code or --quiet, I would think.\n> \n> Thanks.\n\nWhoops! Of course... You want me to re-roll?\n\nCiao,\nDscho\n"},{"id":"264197","messageId":"cover.1434645436.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434627492.git.johannes.schindelin@gmx.de","subject":"[PATCH v3 0/2] rebase -i: Fix left-behind CHERRY_PICK_HEAD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T16:38:27Z","receivedAt":"2015-06-18T16:38:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"These patches fix a bug that bites me often enough when rebasing Git for\nWindows.\n\nThe symptom is that .git/CHERRY_PICK_HEAD is left behind after skipping\nan already-merged patch with `git rebase --continue` instead of `git\nrebase --skip`. I always prefer the former invocation because the latter\nwould also skip legitimate patches if there were merge conflicts, while\nthe former would not allow that.\n\nChanges since v2:\n\n- the test uses `--exit-code` to verify that the result of the rebase is\n  correct\n\nInterdiff below the diffstat.\n\nJohannes Schindelin (2):\n  t3404: demonstrate CHERRY_PICK_HEAD bug\n  rebase -i: do not leave a CHERRY_PICK_HEAD file behind\n\n git-rebase--interactive.sh    |  6 +++++-\n t/t3404-rebase-interactive.sh | 21 +++++++++++++++++++++\n 2 files changed, 26 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex f3337ad..6bcf18b 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1118,7 +1118,7 @@ test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '\n \tFAKE_LINES= test_must_fail git rebase -i seq-onto &&\n \ttest -d .git/rebase-merge &&\n \tgit rebase --continue &&\n-\tgit diff seq-onto &&\n+\tgit diff --exit-code seq-onto &&\n \ttest ! -d .git/rebase-merge &&\n \ttest ! -f .git/CHERRY_PICK_HEAD\n '\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264198","messageId":"66bd04e531ae5db6a06d370a0f7e4370ef4e1539.1434645436.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434645436.git.johannes.schindelin@gmx.de","subject":"[PATCH v3 1/2] t3404: demonstrate CHERRY_PICK_HEAD bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T16:38:44Z","receivedAt":"2015-06-18T16:38:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When rev-list's --cherry option does not detect that a patch has already\nbeen applied upstream, an interactive rebase would offer to reapply it and\nconsequently stop at that patch with a failure, mentioning that the diff\nis empty.\n\nTraditionally, a `git rebase --continue` simply skips the commit in such a\nsituation.\n\nHowever, as pointed out by Gábor Szeder, this leaves a CHERRY_PICK_HEAD\nbehind, making the Git prompt believe that a cherry pick is still going\non. This commit adds a test case demonstrating this bug.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t3404-rebase-interactive.sh | 21 +++++++++++++++++++++\n 1 file changed, 21 insertions(+)\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex ac429a0..6fe6c47 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1102,4 +1102,25 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '\n \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n '\n \n+test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n+\tgit checkout -b commit-to-skip &&\n+\tfor double in X 3 1\n+\tdo\n+\t\tseq 5 | sed \"s/$double/&&/\" >seq &&\n+\t\tgit add seq &&\n+\t\ttest_tick &&\n+\t\tgit commit -m seq-$double\n+\tdone &&\n+\tgit tag seq-onto &&\n+\tgit reset --hard HEAD~2 &&\n+\tgit cherry-pick seq-onto &&\n+\tset_fake_editor &&\n+\tFAKE_LINES= test_must_fail git rebase -i seq-onto &&\n+\ttest -d .git/rebase-merge &&\n+\tgit rebase --continue &&\n+\tgit diff --exit-code seq-onto &&\n+\ttest ! -d .git/rebase-merge &&\n+\ttest ! -f .git/CHERRY_PICK_HEAD\n+'\n+\n test_done\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264199","messageId":"bf1954a4447bcf99c27a566a10cb0b311221135f.1434645436.git.johannes.schindelin@gmx.de","threadId":"39645","inReplyTo":"cover.1434645436.git.johannes.schindelin@gmx.de","subject":"[PATCH v3 2/2] rebase -i: do not leave a CHERRY_PICK_HEAD file behind","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T16:38:53Z","receivedAt":"2015-06-18T16:38:53Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"When skipping commits whose changes were already applied via `git rebase\n--continue`, we need to clean up said file explicitly.\n\nThe same is not true for `git rebase --skip` because that will execute\n`git reset --hard` as part of the \"skip\" handling in git-rebase.sh, even\nbefore git-rebase--interactive.sh is called.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-rebase--interactive.sh    | 6 +++++-\n t/t3404-rebase-interactive.sh | 2 +-\n 2 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex dc3133f..5ff0f1c 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -849,7 +849,11 @@ continue)\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet HEAD --\n \tthen\n-\t\t: Nothing to commit -- skip this\n+\t\t# Nothing to commit -- skip this commit\n+\n+\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\tdie \"Could not remove CHERRY_PICK_HEAD\"\n \telse\n \t\tif ! test -f \"$author_script\"\n \t\tthen\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 6fe6c47..6bcf18b 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1102,7 +1102,7 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '\n \ttest $(git cat-file commit HEAD | sed -ne \\$p) = I\n '\n \n-test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n+test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '\n \tgit checkout -b commit-to-skip &&\n \tfor double in X 3 1\n \tdo\n-- \n2.3.1.windows.1.9.g8c01ab4\n"},{"id":"264210","messageId":"xmqqwpz0er61.fsf@gitster.dls.corp.google.com","threadId":"39645","inReplyTo":"cover.1434645436.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH v3 0/2] rebase -i: Fix left-behind CHERRY_PICK_HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-06-18T19:45:58Z","receivedAt":"2015-06-18T19:45:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n\nThis round looks good, except one trivial nit (below), which I'll\nlocally squash-in a fix for.\n\ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex fb1b571..6938e5e 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -1052,7 +1052,7 @@ test_expect_failure 'rebase --continue removes CHERRY_PICK_HEAD' '\n \tgit reset --hard HEAD~2 &&\n \tgit cherry-pick seq-onto &&\n \tset_fake_editor &&\n-\tFAKE_LINES= test_must_fail git rebase -i seq-onto &&\n+\ttest_must_fail env FAKE_LINES= git rebase -i seq-onto &&\n \ttest -d .git/rebase-merge &&\n \tgit rebase --continue &&\n \tgit diff --exit-code seq-onto &&\n-- \n2.4.4-569-gdcc90bb\n"},{"id":"264235","messageId":"f2eff1416fdae8daf003a9c54b314a6b@www.dscho.org","threadId":"39645","inReplyTo":"xmqqwpz0er61.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v3 0/2] rebase -i: Fix left-behind CHERRY_PICK_HEAD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-06-18T20:11:01Z","receivedAt":"2015-06-18T20:11:01Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"On 2015-06-18 21:45, Junio C Hamano wrote:\n\n> This round looks good, except one trivial nit (below), which I'll\n> locally squash-in a fix for.\n\nThanks,\nDscho\n"}]}