{"thread":{"id":"15435","subject":"[PATCH 1/2] git-rebase-interactive: do not squash commits on abort","startedAt":"2008-09-08T20:42:48Z","lastAt":"2008-09-10T22:36:34Z","messageCount":12,"participants":["Dmitry Potapov","Junio C Hamano","Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"90130","messageId":"1220906569-26878-1-git-send-email-dpotapov@gmail.com","threadId":"15435","inReplyTo":null,"subject":"[PATCH 1/2] git-rebase-interactive: do not squash commits on abort","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-08T20:42:48Z","receivedAt":"2008-09-08T20:42:48Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"If git rebase interactive is stopped by \"edit\" command and then the user\nsaid \"git rebase --continue\" while having some stage changes, git rebase\ninteractive is trying to amend the last commit by doing:\n  git --soft reset && git commit\n\nHowever, the user can abort commit for some reason by providing an empty\nlog message, and that would leave the last commit undone, while the user\nbeing completely unaware about what happened. Now if the user tries to\ncontinue, by issuing \"git rebase --continue\" that squashes two previous\ncommits.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n git-rebase--interactive.sh |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 929d681..5b2b1e5 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -429,12 +429,15 @@ do\n \t\t\t\tdie \"Cannot find the author identity\"\n \t\t\tif test -f \"$DOTEST\"/amend\n \t\t\tthen\n+\t\t\t\tamend=$(git rev-parse --verify HEAD)\n \t\t\t\tgit reset --soft HEAD^ ||\n \t\t\t\tdie \"Cannot rewind the HEAD\"\n \t\t\tfi\n \t\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&\n-\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e ||\n-\t\t\tdie \"Could not commit staged changes.\"\n+\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e || {\n+\t\t\t\ttest -n \"$amend\" && git reset --soft $amend\n+\t\t\t\tdie \"Could not commit staged changes.\"\n+\t\t\t}\n \t\tfi\n \n \t\trequire_clean_work_tree\n-- \n1.6.0\n"},{"id":"90131","messageId":"1220906569-26878-2-git-send-email-dpotapov@gmail.com","threadId":"15435","inReplyTo":"1220906569-26878-1-git-send-email-dpotapov@gmail.com","subject":"[PATCH 2/2] git-rebase--interactive: auto amend only edited commit","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-08T20:42:49Z","receivedAt":"2008-09-08T20:42:49Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"\"git rebase --continue\" issued after git rebase being stop by \"edit\"\ncommand is trying to amend the last commit using stage changes. However,\nif the last commit is not the commit that was marked as \"edit\" then it\ncan produce unexpected results.\n\nFor instance, after being stop by \"edit\", I have made some changes to\ncommit message using \"git commit --amend\". After that I realized that\nI forgot to add some changes to some file. So, I said \"git add file\"\nand the \"git rebase --continue\". Unfortunately, it caused that the new\ncommit message was lost.\n\nAnother problem is that after being stopped at \"edit\", the user adds new\ncommits. In this case, automatic amend behavior of git rebase triggered\nby some stage changes causes that not only that the log message of the\nlast commit is lost but that it will contain also wrong Author and Date\ninformation.\n\nTherefore, this patch restrict automatic amend only to the situation\nwhere HEAD is the commit at which git rebase stop by \"edit\" command.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n git-rebase--interactive.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5b2b1e5..84721c9 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -284,7 +284,7 @@ do_next () {\n \t\tpick_one $sha1 ||\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n \t\tmake_patch $sha1\n-\t\t: > \"$DOTEST\"/amend\n+\t\techo $sha1 > \"$DOTEST\"/amend\n \t\twarn \"Stopped at $sha1... $rest\"\n \t\twarn \"You can amend the commit now, with\"\n \t\twarn\n@@ -430,6 +430,8 @@ do\n \t\t\tif test -f \"$DOTEST\"/amend\n \t\t\tthen\n \t\t\t\tamend=$(git rev-parse --verify HEAD)\n+\t\t\t\ttest \"$amend\" = $(cat \"$DOTEST\"/amend) ||\n+\t\t\t\tdie \"You have uncommitted changes\"\n \t\t\t\tgit reset --soft HEAD^ ||\n \t\t\t\tdie \"Cannot rewind the HEAD\"\n \t\t\tfi\n-- \n1.6.0\n"},{"id":"90151","messageId":"7v7i9mdvyr.fsf@gitster.siamese.dyndns.org","threadId":"15435","inReplyTo":"1220906569-26878-1-git-send-email-dpotapov@gmail.com","subject":"Re: [PATCH 1/2] git-rebase-interactive: do not squash commits on abort","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-09T00:06:04Z","receivedAt":"2008-09-09T00:06:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dmitry Potapov <dpotapov@gmail.com> writes:\n\n> If git rebase interactive is stopped by \"edit\" command and then the user\n> said \"git rebase --continue\" while having some stage changes, git rebase\n> interactive is trying to amend the last commit by doing:\n>   git --soft reset && git commit\n>\n> However, the user can abort commit for some reason by providing an empty\n> log message, and that would leave the last commit undone, while the user\n> being completely unaware about what happened. Now if the user tries to\n> continue, by issuing \"git rebase --continue\" that squashes two previous\n> commits.\n>\n> Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>\n> ---\n>  git-rebase--interactive.sh |    7 +++++--\n>  1 files changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index 929d681..5b2b1e5 100755\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -429,12 +429,15 @@ do\n>  \t\t\t\tdie \"Cannot find the author identity\"\n>  \t\t\tif test -f \"$DOTEST\"/amend\n>  \t\t\tthen\n> +\t\t\t\tamend=$(git rev-parse --verify HEAD)\n>  \t\t\t\tgit reset --soft HEAD^ ||\n>  \t\t\t\tdie \"Cannot rewind the HEAD\"\n>  \t\t\tfi\n>  \t\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&\n> -\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e ||\n> -\t\t\tdie \"Could not commit staged changes.\"\n> +\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e || {\n> +\t\t\t\ttest -n \"$amend\" && git reset --soft $amend\n> +\t\t\t\tdie \"Could not commit staged changes.\"\n> +\t\t\t}\n>  \t\tfi\n\nFeels obviously correct from a cursory look, although I admit I haven't\nthought about other possible corner cases that this additional reset may\nfire when it shouldn't.  Dscho?\n\n>  \n>  \t\trequire_clean_work_tree\n> -- \n> 1.6.0\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"90153","messageId":"7viqt6cg4t.fsf@gitster.siamese.dyndns.org","threadId":"15435","inReplyTo":"1220906569-26878-2-git-send-email-dpotapov@gmail.com","subject":"Re: [PATCH 2/2] git-rebase--interactive: auto amend only edited commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-09T00:33:22Z","receivedAt":"2008-09-09T00:33:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I may not be reading your patch correctly; I am confused by what you are\ntrying to do.\n\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index 5b2b1e5..84721c9 100755\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -284,7 +284,7 @@ do_next () {\n>  \t\tpick_one $sha1 ||\n>  \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n>  \t\tmake_patch $sha1\n> -\t\t: > \"$DOTEST\"/amend\n> +\t\techo $sha1 > \"$DOTEST\"/amend\n\nYou record the $sha1 from the TODO file.  If you are editing the first one\nin the insn sequence, that is also the same as HEAD (i.e. the commit you\nare telling the user to modify with \"commit --amend\").  If you already\nhave edited earlier ones, it is not the value of HEAD at this point.\n\n>  \t\twarn \"Stopped at $sha1... $rest\"\n>  \t\twarn \"You can amend the commit now, with\"\n>  \t\twarn\n> @@ -430,6 +430,8 @@ do\n>  \t\t\tif test -f \"$DOTEST\"/amend\n>  \t\t\tthen\n>  \t\t\t\tamend=$(git rev-parse --verify HEAD)\n> +\t\t\t\ttest \"$amend\" = $(cat \"$DOTEST\"/amend) ||\n> +\t\t\t\tdie \"You have uncommitted changes\"\n\nAnd then you complain if HEAD, after running \"commit --amend\", is\nnot the value you recorded above.\n\n>  \t\t\t\tgit reset --soft HEAD^ ||\n>  \t\t\t\tdie \"Cannot rewind the HEAD\"\n>  \t\t\tfi\n\nIf the first commit was marked as \"edit\", then the value you recorded in\n\"$DOTEST/amend\" was the HEAD, the commit the user was told to modify with\n\"commit --amend\".  $DOTEST/amend being the same as HEAD here would be a\nsign that the user staged changes but hasn't done \"commit --amend\".\n\nBut if we think about the second and subsequent commits that are marked as\n\"edit\" in TODO file, the value recorded in \"$DOTEST/amend\" would not be\nthe value of HEAD at this point, and whether \"commit --amend\" has been run\nor not, the value of HEAD is very likely to be different from that value\n(unless the user said \"reset --hard $that_one\").  Wouldn't this test\nalmost always complain for them?\n\nPerhaps you wanted to record the value of the HEAD in the first hunk?\n\nHow would this change interact with the workflow of splitting existing\ncommits, described at the end of git-rebase documentation?\n"},{"id":"90171","messageId":"48C61AF1.1060703@viscovery.net","threadId":"15435","inReplyTo":"1220906569-26878-2-git-send-email-dpotapov@gmail.com","subject":"Re: [PATCH 2/2] git-rebase--interactive: auto amend only edited commit","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-09T06:42:57Z","receivedAt":"2008-09-09T06:42:57Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Dmitry Potapov schrieb:\n> Another problem is that after being stopped at \"edit\", the user adds new\n> commits. In this case, automatic amend behavior of git rebase triggered\n> by some stage changes causes that not only that the log message of the\n> last commit is lost but that it will contain also wrong Author and Date\n> information.\n> \n> Therefore, this patch restrict automatic amend only to the situation\n> where HEAD is the commit at which git rebase stop by \"edit\" command.\n...\n> @@ -430,6 +430,8 @@ do\n>  \t\t\tif test -f \"$DOTEST\"/amend\n>  \t\t\tthen\n>  \t\t\t\tamend=$(git rev-parse --verify HEAD)\n> +\t\t\t\ttest \"$amend\" = $(cat \"$DOTEST\"/amend) ||\n> +\t\t\t\tdie \"You have uncommitted changes\"\n\nDoesn't this terse message carry a bit of a \"WTF?\" factor? In other\nsituations rebase --continue goes into git-commit just fine, but it does\nnot under these special conditions. How about this:\n\n\"Will not auto-commit uncommitted changes after you have already committed\nsomething. Please run 'git commit --amend' yourself.\"\n\n>  \t\t\t\tgit reset --soft HEAD^ ||\n>  \t\t\t\tdie \"Cannot rewind the HEAD\"\n>  \t\t\tfi\n\n-- Hannes\n"},{"id":"90174","messageId":"20080909070055.GB28210@dpotapov.dyndns.org","threadId":"15435","inReplyTo":"7viqt6cg4t.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-rebase--interactive: auto amend only edited commit","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-09T07:00:55Z","receivedAt":"2008-09-09T07:00:55Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Mon, Sep 08, 2008 at 05:33:22PM -0700, Junio C Hamano wrote:\n> I may not be reading your patch correctly; I am confused by what you are\n> trying to do.\n> \n> > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> > index 5b2b1e5..84721c9 100755\n> > --- a/git-rebase--interactive.sh\n> > +++ b/git-rebase--interactive.sh\n> > @@ -284,7 +284,7 @@ do_next () {\n> >  \t\tpick_one $sha1 ||\n> >  \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n> >  \t\tmake_patch $sha1\n> > -\t\t: > \"$DOTEST\"/amend\n> > +\t\techo $sha1 > \"$DOTEST\"/amend\n> \n> You record the $sha1 from the TODO file.\n\nOops... I should have gone to bed instead of sending this patch...\n\n> \n> Perhaps you wanted to record the value of the HEAD in the first hunk?\n\nYou are asbolutely right. It should be:\n\n\tgit rev-parse --verify HEAD > \"$DOTEST\"/amend\n\n> \n> How would this change interact with the workflow of splitting existing\n> commits, described at the end of git-rebase documentation?\n\nIt is not affected, because accordingly to the documentation, you\ncommit all your changes \"until your working tree is clean.\"\n\nHowever, if you forgot to commit your changes, without my patch\nyou may lose some of your splitting work. Here is the script that\ndemonstrates the problem\n\n-- >8 --\n#!/bin/sh\n\nset -e\n\nrm -rf git-test\nmkdir -p git-test\ncd git-test\n\ngit init\nfor ((i=0;$i<10;i++)) do echo $i; done > foo\ngit add foo\ngit commit -m 'add foo'\n\nsed -e 's/^0$/first line/;s/^9/last line/' < foo > tmp\nmv tmp foo\ngit add foo\ngit commit -m 'change foo'\n\necho bar > bar\ngit add bar\ngit commit -m 'more changes'\n\ngit log\necho '==='\n\nGIT_EDITOR='sed -e '\\''s/pick \\(.* change foo\\)/edit \\1/'\\'' < \"$1\" > tmp && mv tmp' git rebase -i HEAD~2\n\ngit reset HEAD^\n\n{ echo y; echo n; } | git add -p\n\ngit commit -m 'commit chunk 1'\n\ngit add foo\n# If I commit chunk 2 then everything will be fine with and without\n# my patch\n#\n#   git commit -m 'commit chunk 2'\n#\n# However, if I forgot to commit chunk 2 then without my patch rebase\n# will lose my work on splitting these chunks!\n#\n# With my patch, it will error out: You have uncommitted changes\n\nGIT_EDITOR=cat git rebase --continue\n\ngit log\n-- >8 --\n\n\nDmitry\n"},{"id":"90176","messageId":"20080909073029.GC28210@dpotapov.dyndns.org","threadId":"15435","inReplyTo":"48C61AF1.1060703@viscovery.net","subject":"Re: [PATCH 2/2] git-rebase--interactive: auto amend only edited commit","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-09T07:30:29Z","receivedAt":"2008-09-09T07:30:29Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Tue, Sep 09, 2008 at 08:42:57AM +0200, Johannes Sixt wrote:\n> Dmitry Potapov schrieb:\n> > Another problem is that after being stopped at \"edit\", the user adds new\n> > commits. In this case, automatic amend behavior of git rebase triggered\n> > by some stage changes causes that not only that the log message of the\n> > last commit is lost but that it will contain also wrong Author and Date\n> > information.\n> > \n> > Therefore, this patch restrict automatic amend only to the situation\n> > where HEAD is the commit at which git rebase stop by \"edit\" command.\n> ...\n> > @@ -430,6 +430,8 @@ do\n> >  \t\t\tif test -f \"$DOTEST\"/amend\n> >  \t\t\tthen\n> >  \t\t\t\tamend=$(git rev-parse --verify HEAD)\n> > +\t\t\t\ttest \"$amend\" = $(cat \"$DOTEST\"/amend) ||\n> > +\t\t\t\tdie \"You have uncommitted changes\"\n> \n> Doesn't this terse message carry a bit of a \"WTF?\" factor?\n\nAgreed. However, the current message in the case when you have some\nunstaged changes in your working tree is not much better:\n  \"Working tree is dirty\"\n\n> In other\n> situations rebase --continue goes into git-commit just fine, but it does\n> not under these special conditions. How about this:\n> \n> \"Will not auto-commit uncommitted changes after you have already committed\n> something. Please run 'git commit --amend' yourself.\"\n\nI don't think this is the right suggestion. In cases that I mentioned above\n(and in some others), you may want to run 'git commit' *without* --amend.\nOnly user may know how those changes should be committed. Giving him/her\na direct instruction to run some specific command will produce the wrong\nresult in half cases. So, how about this:\n\n\"You have uncommitted changes in your working tree. Please, commit them\nfirst and then run 'git rebase --continue' again.\"\n\nor if you want to describe the cause why auto-commit does not work:\n\n\"Will not auto-commit uncommitted changes after you have already committed\nsomething. Please commit them first and then run 'git rebase --continue'\nagain.\"\n\nPersonally, I believe those words about auto-commit is not very helpful.\nAuto-commit-on-edit feature is undocumented. So, those words may be more\nconfusing than helpful, because the user starts thinking what this auto-\ncommit means, while the real question here is whether changes should be\ncommitted with --amend or without it.\n\nDmitry\n"},{"id":"90207","messageId":"1220961926-13235-1-git-send-email-dpotapov@gmail.com","threadId":"15435","inReplyTo":"20080909070055.GB28210@dpotapov.dyndns.org","subject":"[PATCH v2] git-rebase--interactive: auto amend only edited commit","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-09T12:05:26Z","receivedAt":"2008-09-09T12:05:26Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"\"git rebase --continue\" issued after git rebase being stop by \"edit\"\ncommand is trying to amend the last commit using stage changes. However,\nif the last commit is not the commit that was marked as \"edit\" then it\ncan produce unexpected results.\n\nFor instance, after being stop by \"edit\", I have made some changes to\ncommit message using \"git commit --amend\". After that I realized that\nI forgot to add some changes to some file. So, I said \"git add file\"\nand the \"git rebase --continue\". Unfortunately, it caused that the new\ncommit message was lost.\n\nAnother problem is that after being stopped at \"edit\", the user adds new\ncommits. In this case, automatic amend behavior of git rebase triggered\nby some stage changes causes that not only that the log message of the\nlast commit is lost but that it will contain also wrong Author and Date\ninformation.\n\nTherefore, this patch restrict automatic amend only to the situation\nwhere HEAD is the commit at which git rebase stop by \"edit\" command.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n\nChanges:\n 1. I have correct the obvious bug pointed by Junio.\n 2. The error message is more verbose now.\n\n git-rebase--interactive.sh |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5b2b1e5..d2aa954 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -284,7 +284,7 @@ do_next () {\n \t\tpick_one $sha1 ||\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n \t\tmake_patch $sha1\n-\t\t: > \"$DOTEST\"/amend\n+\t\tgit rev-parse --verify HEAD > \"$DOTEST\"/amend\n \t\twarn \"Stopped at $sha1... $rest\"\n \t\twarn \"You can amend the commit now, with\"\n \t\twarn\n@@ -430,6 +430,10 @@ do\n \t\t\tif test -f \"$DOTEST\"/amend\n \t\t\tthen\n \t\t\t\tamend=$(git rev-parse --verify HEAD)\n+\t\t\t\ttest \"$amend\" = $(cat \"$DOTEST\"/amend) ||\n+\t\t\t\tdie \"\\\n+You have uncommitted changes in your working tree. Please, commit them\n+first and then run 'git rebase --continue' again.\"\n \t\t\t\tgit reset --soft HEAD^ ||\n \t\t\t\tdie \"Cannot rewind the HEAD\"\n \t\t\tfi\n-- \n1.6.0\n"},{"id":"90218","messageId":"alpine.DEB.1.00.0809091616200.13830@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15435","inReplyTo":"7v7i9mdvyr.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/2] git-rebase-interactive: do not squash commits on abort","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-09-09T14:17:36Z","receivedAt":"2008-09-09T14:17:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 8 Sep 2008, Junio C Hamano wrote:\n\n> Dmitry Potapov <dpotapov@gmail.com> writes:\n> \n> > If git rebase interactive is stopped by \"edit\" command and then the user\n> > said \"git rebase --continue\" while having some stage changes, git rebase\n> > interactive is trying to amend the last commit by doing:\n> >   git --soft reset && git commit\n> >\n> > However, the user can abort commit for some reason by providing an empty\n> > log message, and that would leave the last commit undone, while the user\n> > being completely unaware about what happened. Now if the user tries to\n> > continue, by issuing \"git rebase --continue\" that squashes two previous\n> > commits.\n> >\n> > Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>\n> > ---\n> >  git-rebase--interactive.sh |    7 +++++--\n> >  1 files changed, 5 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> > index 929d681..5b2b1e5 100755\n> > --- a/git-rebase--interactive.sh\n> > +++ b/git-rebase--interactive.sh\n> > @@ -429,12 +429,15 @@ do\n> >  \t\t\t\tdie \"Cannot find the author identity\"\n> >  \t\t\tif test -f \"$DOTEST\"/amend\n> >  \t\t\tthen\n> > +\t\t\t\tamend=$(git rev-parse --verify HEAD)\n> >  \t\t\t\tgit reset --soft HEAD^ ||\n> >  \t\t\t\tdie \"Cannot rewind the HEAD\"\n> >  \t\t\tfi\n> >  \t\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&\n> > -\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e ||\n> > -\t\t\tdie \"Could not commit staged changes.\"\n> > +\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e || {\n> > +\t\t\t\ttest -n \"$amend\" && git reset --soft $amend\n> > +\t\t\t\tdie \"Could not commit staged changes.\"\n> > +\t\t\t}\n> >  \t\tfi\n> \n> Feels obviously correct from a cursory look, although I admit I haven't\n> thought about other possible corner cases that this additional reset may\n> fire when it shouldn't.  Dscho?\n\nIt might be safer to set the variable \"amend\" to empty before the \"if\".  \nOther than that, I think that patch makes tons of sense.\n\nThanks,\nDscho\n"},{"id":"90260","messageId":"20080909205036.GD28210@dpotapov.dyndns.org","threadId":"15435","inReplyTo":"alpine.DEB.1.00.0809091616200.13830@pacific.mpi-cbg.de.mpi-cbg.de","subject":"[PATCH v2] git-rebase-interactive: do not squash commits on abort","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-09-09T20:50:36Z","receivedAt":"2008-09-09T20:50:36Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"If git rebase interactive is stopped by \"edit\" command and then the user\nsaid \"git rebase --continue\" while having some stage changes, git rebase\ninteractive is trying to amend the last commit by doing:\n  git --soft reset && git commit\n\nHowever, the user can abort commit for some reason by providing an empty\nlog message, and that would leave the last commit undone, while the user\nbeing completely unaware about what happened. Now if the user tries to\ncontinue, by issuing \"git rebase --continue\" that squashes two previous\ncommits.\n\nSigned-off-by: Dmitry Potapov <dpotapov@gmail.com>\n---\n\nOn Tue, Sep 09, 2008 at 04:17:36PM +0200, Johannes Schindelin wrote:\n>_\n> It might be safer to set the variable \"amend\" to empty before the \"if\".\n\nOK. I have added it.\n\n git-rebase--interactive.sh |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 929d681..aaca915 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -427,14 +427,18 @@ do\n \t\telse\n \t\t\t. \"$DOTEST\"/author-script ||\n \t\t\t\tdie \"Cannot find the author identity\"\n+\t\t\tamend=\"\"\n \t\t\tif test -f \"$DOTEST\"/amend\n \t\t\tthen\n+\t\t\t\tamend=$(git rev-parse --verify HEAD)\n \t\t\t\tgit reset --soft HEAD^ ||\n \t\t\t\tdie \"Cannot rewind the HEAD\"\n \t\t\tfi\n \t\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&\n-\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e ||\n-\t\t\tdie \"Could not commit staged changes.\"\n+\t\t\tgit commit --no-verify -F \"$DOTEST\"/message -e || {\n+\t\t\t\ttest -n \"$amend\" && git reset --soft $amend\n+\t\t\t\tdie \"Could not commit staged changes.\"\n+\t\t\t}\n \t\tfi\n \n \t\trequire_clean_work_tree\n-- \n1.6.0\n"},{"id":"90337","messageId":"alpine.DEB.1.00.0809101150570.13830@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15435","inReplyTo":"20080909205036.GD28210@dpotapov.dyndns.org","subject":"Re: [PATCH v2] git-rebase-interactive: do not squash commits on abort","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-09-10T09:53:05Z","receivedAt":"2008-09-10T09:53:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 10 Sep 2008, Dmitry Potapov wrote:\n\n> On Tue, Sep 09, 2008 at 04:17:36PM +0200, Johannes Schindelin wrote:\n> >_\n> > It might be safer to set the variable \"amend\" to empty before the \"if\".\n> \n> OK. I have added it.\n> \n>  git-rebase--interactive.sh |    8 ++++++--\n>  1 files changed, 6 insertions(+), 2 deletions(-)\n> \n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index 929d681..aaca915 100755\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -427,14 +427,18 @@ do\n>  \t\telse\n>  \t\t\t. \"$DOTEST\"/author-script ||\n>  \t\t\t\tdie \"Cannot find the author identity\"\n> +\t\t\tamend=\"\"\n\nSorry, my mistake... I should have been more explicit.  In most (if not \nall) shell scripts, we prefer to set to the empty string with the \nexpression\n\n\t\t\tamend=\n\nSorry to be nitting here, but I think it might be desirable in the long \nrun to have consistent code style, as it makes it a bigger pleasure to \nwork with the code.\n\nCiao,\nDscho\n"},{"id":"90394","messageId":"7vfxo7vdal.fsf@gitster.siamese.dyndns.org","threadId":"15435","inReplyTo":"alpine.DEB.1.00.0809101150570.13830@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH v2] git-rebase-interactive: do not squash commits on abort","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-10T22:36:34Z","receivedAt":"2008-09-10T22:36:34Z","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>> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n>> index 929d681..aaca915 100755\n>> --- a/git-rebase--interactive.sh\n>> +++ b/git-rebase--interactive.sh\n>> @@ -427,14 +427,18 @@ do\n>>  \t\telse\n>>  \t\t\t. \"$DOTEST\"/author-script ||\n>>  \t\t\t\tdie \"Cannot find the author identity\"\n>> +\t\t\tamend=\"\"\n>\n> Sorry, my mistake... I should have been more explicit.  In most (if not \n> all) shell scripts, we prefer to set to the empty string with the \n> expression\n>\n> \t\t\tamend=\n\nDon't worry.  I would notice and remove \"\" in my MUA for things like\nthese; especially the patch is this small it is hard to miss.\n"}]}