{"thread":{"id":"14600","subject":"[PATCH] rebase -i: only automatically amend commit if HEAD did not change","startedAt":"2008-07-22T21:36:14Z","lastAt":"2008-07-25T10:35:42Z","messageCount":14,"participants":["Johannes Schindelin","Stephan Beyer","Avery Pennarun","Junio C Hamano","Dmitry Potapov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"84380","messageId":"alpine.DEB.1.00.0807222235520.8986@racer","threadId":"14600","inReplyTo":null,"subject":"[PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-22T21:36:14Z","receivedAt":"2008-07-22T21:36:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nIf the user called \"rebase -i\", marked a commit as \"edit\", \"rebase\n--continue\" would automatically amend the commit when there were\nstaged changes.\n\nHowever, this is actively wrong when the current commit is not the\none marked with \"edit\".  So guard against this.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-rebase--interactive.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex e63a864..444f393 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -276,7 +276,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 HEAD > \"$DOTEST\"/amend\n \t\twarn\n \t\twarn \"You can amend the commit now, with\"\n \t\twarn\n@@ -419,7 +419,9 @@ do\n \t\telse\n \t\t\t. \"$DOTEST\"/author-script ||\n \t\t\t\tdie \"Cannot find the author identity\"\n-\t\t\tif test -f \"$DOTEST\"/amend\n+\t\t\tif test -f \"$DOTEST\"/amend &&\n+\t\t\t\ttest $(git rev-parse HEAD) = \\\n+\t\t\t\t\t$(cat \"$DOTEST\"/amend)\n \t\t\tthen\n \t\t\t\tgit reset --soft HEAD^ ||\n \t\t\t\tdie \"Cannot rewind the HEAD\"\n-- \n1.6.0.rc0.22.gf2096d.dirty\n"},{"id":"84384","messageId":"20080722214858.GC5904@leksak.fem-net","threadId":"14600","inReplyTo":"alpine.DEB.1.00.0807222235520.8986@racer","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-22T21:48:58Z","receivedAt":"2008-07-22T21:48:58Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nJohannes Schindelin wrote:\n> If the user called \"rebase -i\", marked a commit as \"edit\", \"rebase\n> --continue\" would automatically amend the commit when there were\n> staged changes.\n> \n> However, this is actively wrong when the current commit is not the\n> one marked with \"edit\".  So guard against this.\n\nHmm, I like it. ;-)\n\n> @@ -419,7 +419,9 @@ do\n>  \t\telse\n>  \t\t\t. \"$DOTEST\"/author-script ||\n>  \t\t\t\tdie \"Cannot find the author identity\"\n> -\t\t\tif test -f \"$DOTEST\"/amend\n> +\t\t\tif test -f \"$DOTEST\"/amend &&\n> +\t\t\t\ttest $(git rev-parse HEAD) = \\\n> +\t\t\t\t\t$(cat \"$DOTEST\"/amend)\n>  \t\t\tthen\n>  \t\t\t\tgit reset --soft HEAD^ ||\n>  \t\t\t\tdie \"Cannot rewind the HEAD\"\n\nSo if this fails, a non-amending commit is done.  Agreed. :)\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"},{"id":"84388","messageId":"32541b130807221522r2a43c49cl6400f00dbe7451a0@mail.gmail.com","threadId":"14600","inReplyTo":"alpine.DEB.1.00.0807222235520.8986@racer","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-22T22:22:34Z","receivedAt":"2008-07-22T22:22:34Z","isPatch":true,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/22/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>  If the user called \"rebase -i\", marked a commit as \"edit\", \"rebase\n>  --continue\" would automatically amend the commit when there were\n>  staged changes.\n>\n>  However, this is actively wrong when the current commit is not the\n>  one marked with \"edit\".  So guard against this.\n\nThis patch is perhaps a symptom of something I've been meaning to ask\nabout for a while.\n\nWhy doesn't \"edit\" just stage the commit and not auto-commit it at\nall?  That way an amend would *never* be necessary, and rebase\n--continue would always do a commit -a (if there was anything left to\ncommit).  The special case fixed by this patch would thus not be\nneeded.\n\nIt would also make it more obvious how to remove files from a commit,\nfor example, without having to learn about \"git reset\".  For that\nmatter, you wouldn't have to learn about \"git commit --amend\" either,\nand it would save typing.\n\nIt would also be a little more consistent with \"squash\", which already\nlets you edit the commit message by default.\n\nJust a thought.  Presumably it was implemented the way it is for some\nreason, but I haven't seen any discussion about it.\n\nHave fun,\n\nAvery\n"},{"id":"84406","messageId":"7viquxjwyf.fsf@gitster.siamese.dyndns.org","threadId":"14600","inReplyTo":"32541b130807221522r2a43c49cl6400f00dbe7451a0@mail.gmail.com","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-22T23:55:20Z","receivedAt":"2008-07-22T23:55:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Avery Pennarun\" <apenwarr@gmail.com> writes:\n\n> On 7/22/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>>  If the user called \"rebase -i\", marked a commit as \"edit\", \"rebase\n>>  --continue\" would automatically amend the commit when there were\n>>  staged changes.\n>>\n>>  However, this is actively wrong when the current commit is not the\n>>  one marked with \"edit\".  So guard against this.\n>\n> This patch is perhaps a symptom of something I've been meaning to ask\n> about for a while.\n>\n> Why doesn't \"edit\" just stage the commit and not auto-commit it at\n> all?  That way an amend would *never* be necessary, and rebase\n> --continue would always do a commit -a (if there was anything left to\n> commit).  The special case fixed by this patch would thus not be\n> needed.\n\nThat would actually be in-line with the way how \"rebase --skip\" does the\nresetting without asking the user to do so, wouldn't it?\n"},{"id":"84475","messageId":"20080723120104.GQ2925@dpotapov.dyndns.org","threadId":"14600","inReplyTo":"32541b130807221522r2a43c49cl6400f00dbe7451a0@mail.gmail.com","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-07-23T12:01:04Z","receivedAt":"2008-07-23T12:01:04Z","isPatch":true,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Tue, Jul 22, 2008 at 06:22:34PM -0400, Avery Pennarun wrote:\n> \n> This patch is perhaps a symptom of something I've been meaning to ask\n> about for a while.\n> \n> Why doesn't \"edit\" just stage the commit and not auto-commit it at\n> all?  That way an amend would *never* be necessary, and rebase\n> --continue would always do a commit -a (if there was anything left to\n> commit).\n\nActually, it would be better to refuse to continue if there are unstaged\nchanges in the work tree, and if all changes are staged then just do git\ncommit.\n\n> The special case fixed by this patch would thus not be\n> needed.\n> \n> It would also make it more obvious how to remove files from a commit,\n> for example, without having to learn about \"git reset\".  For that\n> matter, you wouldn't have to learn about \"git commit --amend\" either,\n> and it would save typing.\n\nIt would not only save typing, but also help to avoid costly mistakes\nwhere users, being taught to use \"git commit --amend\" after editing\nduring git-rebase, fire this command automatically after a conflict\nresolution and get two commits accidently squashed.\n\nSo, I completely agree that the current auto-commit behavior is not very\nuser friendly...\n\nDmitry\n"},{"id":"84526","messageId":"32541b130807230853y136f41bdmf221637e35d601c3@mail.gmail.com","threadId":"14600","inReplyTo":"20080723120104.GQ2925@dpotapov.dyndns.org","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-23T15:53:53Z","receivedAt":"2008-07-23T15:53:53Z","isPatch":true,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/23/08, Dmitry Potapov <dpotapov@gmail.com> wrote:\n> On Tue, Jul 22, 2008 at 06:22:34PM -0400, Avery Pennarun wrote:\n>  > This patch is perhaps a symptom of something I've been meaning to ask\n>  > about for a while.\n>  >\n>  > Why doesn't \"edit\" just stage the commit and not auto-commit it at\n>  > all?  That way an amend would *never* be necessary, and rebase\n>  > --continue would always do a commit -a (if there was anything left to\n>  > commit).\n>\n> Actually, it would be better to refuse to continue if there are unstaged\n>  changes in the work tree, and if all changes are staged then just do git\n> commit.\n\nI'm not sure about that.  The auto-committing on --continue has never\nannoyed me, and in fact I greatly appreciate that I can just \"git\nrebase --continue\" after making changes and the expected thing will\nhappen.  After all, if I screw it up and commit too much at once, I\ncan always just rebase one more time.\n\nHowever, taking out the auto-commit wouldn't pain me too much if\nothers want it that way.  It would be somewhat more typing, but at\nleast makes easy to understand exactly what's going on.\n\n> It would not only save typing, but also help to avoid costly mistakes\n>  where users, being taught to use \"git commit --amend\" after editing\n>  during git-rebase, fire this command automatically after a conflict\n>  resolution and get two commits accidently squashed.\n\nYes!  Good point.  I forgot about this, but I've been bitten by it a\ncouple of times.\n\nHave fun,\n\nAvery\n"},{"id":"84527","messageId":"32541b130807230855y19bbedfah38dce9391ff4f481@mail.gmail.com","threadId":"14600","inReplyTo":"7viquxjwyf.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-23T15:55:41Z","receivedAt":"2008-07-23T15:55:41Z","isPatch":true,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/22/08, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Avery Pennarun\" <apenwarr@gmail.com> writes:\n>  > Why doesn't \"edit\" just stage the commit and not auto-commit it at\n>  > all?  That way an amend would *never* be necessary, and rebase\n>  > --continue would always do a commit -a (if there was anything left to\n>  > commit).  The special case fixed by this patch would thus not be\n>  > needed.\n>\n> That would actually be in-line with the way how \"rebase --skip\" does the\n>  resetting without asking the user to do so, wouldn't it?\n\nI'm not sure exactly what you mean, but I think with my proposed\nchange, \"rebase --skip\" would do \"git reset --hard HEAD\" while \"rebase\n--continue\" would do \"git commit -a\", so it would be nice and\nsymmetrical, where currently it isn't exactly.\n\nHave fun,\n\nAvery\n"},{"id":"84533","messageId":"alpine.DEB.1.00.0807231708520.8986@racer","threadId":"14600","inReplyTo":"32541b130807230853y136f41bdmf221637e35d601c3@mail.gmail.com","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-23T16:09:37Z","receivedAt":"2008-07-23T16:09:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Jul 2008, Avery Pennarun wrote:\n\n> However, taking out the auto-commit wouldn't pain me too much if\n> others want it that way.\n\nIMO the -rc0 cycle is a particularly ill-chosen time to discuss behavior \nchanges like this.\n\nHth,\nDscho\n"},{"id":"84536","messageId":"32541b130807230919j64634e94ybb61b55fcb27582@mail.gmail.com","threadId":"14600","inReplyTo":"alpine.DEB.1.00.0807231708520.8986@racer","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-07-23T16:19:18Z","receivedAt":"2008-07-23T16:19:18Z","isPatch":true,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 7/23/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>  On Wed, 23 Jul 2008, Avery Pennarun wrote:\n>  > However, taking out the auto-commit wouldn't pain me too much if\n>  > others want it that way.\n>\n> IMO the -rc0 cycle is a particularly ill-chosen time to discuss behavior\n>  changes like this.\n\nProbably, but it relates to the discussion of the current patch.\nWould it be better to change the rebase behaviour now and then\npossibly again in the next version, or just leave it as-is for now?\n\nAvery\n"},{"id":"84644","messageId":"7vmyk888z5.fsf@gitster.siamese.dyndns.org","threadId":"14600","inReplyTo":"alpine.DEB.1.00.0807222235520.8986@racer","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-23T23:41:02Z","receivedAt":"2008-07-23T23:41:02Z","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> If the user called \"rebase -i\", marked a commit as \"edit\", \"rebase\n> --continue\" would automatically amend the commit when there were\n> staged changes.\n>\n> However, this is actively wrong when the current commit is not the\n> one marked with \"edit\".  So guard against this.\n\nAt what point in what valid workflow sequence does HEAD become different\nfrom dotest/amend?\n\n> @@ -419,7 +419,9 @@ do\n>  \t\telse\n>  \t\t\t. \"$DOTEST\"/author-script ||\n>  \t\t\t\tdie \"Cannot find the author identity\"\n> -\t\t\tif test -f \"$DOTEST\"/amend\n> +\t\t\tif test -f \"$DOTEST\"/amend &&\n> +\t\t\t\ttest $(git rev-parse HEAD) = \\\n> +\t\t\t\t\t$(cat \"$DOTEST\"/amend)\n>  \t\t\tthen\n>  \t\t\t\tgit reset --soft HEAD^ ||\n>  \t\t\t\tdie \"Cannot rewind the HEAD\"\n\nIn what way is this \"guarding against it\"?  It goes on and makes an\nunrelated commit without erroring out nor giving indication to the user\nwhat is going on, doesn't it?\n\nI am sure you meant well and the code is good, but I find that the\nexplanation is a bit lacking...\n"},{"id":"84704","messageId":"alpine.DEB.1.00.0807241311450.8986@racer","threadId":"14600","inReplyTo":"7vmyk888z5.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-24T12:20:51Z","receivedAt":"2008-07-24T12:20:51Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 23 Jul 2008, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > If the user called \"rebase -i\", marked a commit as \"edit\", \"rebase \n> > --continue\" would automatically amend the commit when there were \n> > staged changes.\n> >\n> > However, this is actively wrong when the current commit is not the one \n> > marked with \"edit\".  So guard against this.\n> \n> At what point in what valid workflow sequence does HEAD become different \n> from dotest/amend?\n\n$ rebase -i HEAD~5\n\n\t<mark one commit as edit>\n\n\t<Whoa! While editing, I realize that this contains an unrelated \n\t bugfix>\n\n$ git reset HEAD^\n$ git add -p\n$ git commit\n\n\t<Edit a bit here, a bit there>\n\n$ git rebase --continue\n\n\nSure it is a pilot error.  It hit this pilot, too.\n\n> > @@ -419,7 +419,9 @@ do\n> >  \t\telse\n> >  \t\t\t. \"$DOTEST\"/author-script ||\n> >  \t\t\t\tdie \"Cannot find the author identity\"\n> > -\t\t\tif test -f \"$DOTEST\"/amend\n> > +\t\t\tif test -f \"$DOTEST\"/amend &&\n> > +\t\t\t\ttest $(git rev-parse HEAD) = \\\n> > +\t\t\t\t\t$(cat \"$DOTEST\"/amend)\n> >  \t\t\tthen\n> >  \t\t\t\tgit reset --soft HEAD^ ||\n> >  \t\t\t\tdie \"Cannot rewind the HEAD\"\n> \n> In what way is this \"guarding against it\"?\n\nIn the way that the user certainly did not mean to amend _this_ HEAD.  \nAnother HEAD was marked with \"edit\".\n\nBy not amending, the user has a chance to fix anything unintended in \nanother rebase -i more easily, since the two commits have not been \nsquashed together.\n\n'course, the user should have seen in the editor that popped up that she \nis squashing two different commits, should have deleted the whole commit \nmessage to abort, make the independent commit herself (finding the correct \ncommit to steal the commit message from), then run rebase --continue \n(which would no longer commit anything, there being nothing to).\n\nHowever, that course of action is a bit unintuitive.\n\nThe way it runs with my patch, at least a user has a chance to fix it up \nwithout a Git expert standing nearby.\n\nI will definitely keep this in my personal fork, even in my personal \nfork of \"master\" during the rc period.  But if you think it is not worth \nit, and others seem to be utterly disinterested (instead discussing \nbehavior changes), I will not push further.\n\nCiao,\nDscho\n"},{"id":"84706","messageId":"20080724123556.GA7125@leksak.fem-net","threadId":"14600","inReplyTo":"alpine.DEB.1.00.0807241311450.8986@racer","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-24T12:35:56Z","receivedAt":"2008-07-24T12:35:56Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nJohannes Schindelin wrote:\n> The way it runs with my patch, at least a user has a chance to fix it up \n> without a Git expert standing nearby.\n> \n> I will definitely keep this in my personal fork, even in my personal \n> fork of \"master\" during the rc period.  But if you think it is not worth \n> it, and others seem to be utterly disinterested (instead discussing \n> behavior changes), I will not push further.\n\nI don't know how much my opinion counts here, but I think it definitely\nis worth it because I've ran into this *several* times -- \"Ooops, where \nis my commit? ... ... ... Ah! F***!\", which meant that I had to had to\nsplit accidentally squashed commits.\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"},{"id":"84847","messageId":"7vod4muzck.fsf@gitster.siamese.dyndns.org","threadId":"14600","inReplyTo":"alpine.DEB.1.00.0807241311450.8986@racer","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-25T08:44:59Z","receivedAt":"2008-07-25T08:44:59Z","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>> At what point in what valid workflow sequence does HEAD become different \n>> from dotest/amend?\n>\n> $ rebase -i HEAD~5\n>\n> \t<mark one commit as edit>\n>\n> \t<Whoa! While editing, I realize that this contains an unrelated \n> \t bugfix>\n>\n> $ git reset HEAD^\n> $ git add -p\n> $ git commit\n>\n> \t<Edit a bit here, a bit there>\n>\n> $ git rebase --continue\n>\n> Sure it is a pilot error.  It hit this pilot, too.\n> ...\n> In the way that the user certainly did not mean to amend _this_ HEAD.  \n> Another HEAD was marked with \"edit\".\n\nOk; after this \"refraining from incorrectly squashing them\", how would the\nuser edit the one the user originally intended to edit (I am not\ncomplaining, but asking for information)?\n\nSo in your workflow example, when there is no pilot error, is this the\n\"ideal\" sequence?\n\n\t$ git rebase -i HEAD~5\n        .. mark one as edit\n        .. ah, the one I wanted to just \"edit\" actually need to be\n        .. split into two because it has some other thing I need to change\n\t$ git reset HEAD^\n\t$ git add -p\n        $ git stash --keep-index\n        .. test to verify the initial part\n        $ git commit ;# first part of split commit\n        $ git stash pop\n        .. test test\n        $ git add -p\n        $ git rebase --continue ;# gives you the editor to edit\n\nI wonder if we can make the transcript of the \"pilot error\" case look like\nthis:\n\n\t$ git rebase -i HEAD~5\n\t...\n\t$ git reset HEAD^\n        .. same as above up to...\n        .. test to verify the initial part\n\t$ git rebase --continue ;# oops\n\t.. gives you the editor to edit the message.\n        .. makes a commit, and says:\n        committed initial part of the change, stopping.\n\t.. ah, the command noticed it and did not escape, thanks!\n        $ git stash pop\n        .. test test\n        $ git add -p\n        $ git rebase --continue ;# gives you the editor to edit\n\t.. and goes on this time.\n"},{"id":"84858","messageId":"alpine.DEB.1.00.0807251231560.11976@eeepc-johanness","threadId":"14600","inReplyTo":"7vod4muzck.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] rebase -i: only automatically amend commit if HEAD did not change","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-25T10:35:42Z","receivedAt":"2008-07-25T10:35:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 25 Jul 2008, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> >> At what point in what valid workflow sequence does HEAD become \n> >> different from dotest/amend?\n> >\n> > $ rebase -i HEAD~5\n> >\n> > \t<mark one commit as edit>\n> >\n> > \t<Whoa! While editing, I realize that this contains an unrelated \n> > \t bugfix>\n> >\n> > $ git reset HEAD^\n> > $ git add -p\n> > $ git commit\n> >\n> > \t<Edit a bit here, a bit there>\n> >\n> > $ git rebase --continue\n> >\n> > Sure it is a pilot error.  It hit this pilot, too.\n> > ...\n> > In the way that the user certainly did not mean to amend _this_ HEAD.  \n> > Another HEAD was marked with \"edit\".\n> \n> Ok; after this \"refraining from incorrectly squashing them\", how would the\n> user edit the one the user originally intended to edit (I am not\n> complaining, but asking for information)?\n\nIn this case, the two commits are two commits, the editor popped up with \nrebase --continue contains the original commit message, and all is fine.\n\n> So in your workflow example, when there is no pilot error, is this the \n> \"ideal\" sequence?\n> \n> \t$ git rebase -i HEAD~5\n>         .. mark one as edit\n>         .. ah, the one I wanted to just \"edit\" actually need to be\n>         .. split into two because it has some other thing I need to change\n> \t$ git reset HEAD^\n> \t$ git add -p\n>         $ git stash --keep-index\n>         .. test to verify the initial part\n>         $ git commit ;# first part of split commit\n>         $ git stash pop\n>         .. test test\n>         $ git add -p\n\nWithout pilot error, here has to come a \"git commit -c HEAD@{1}\".\n\n>         $ git rebase --continue ;# gives you the editor to edit\n> \n> I wonder if we can make the transcript of the \"pilot error\" case look like\n> this:\n> \n> \t$ git rebase -i HEAD~5\n> \t...\n> \t$ git reset HEAD^\n>         .. same as above up to...\n>         .. test to verify the initial part\n> \t$ git rebase --continue ;# oops\n> \t.. gives you the editor to edit the message.\n>         .. makes a commit, and says:\n>         committed initial part of the change, stopping.\n> \t.. ah, the command noticed it and did not escape, thanks!\n>         $ git stash pop\n>         .. test test\n>         $ git add -p\n>         $ git rebase --continue ;# gives you the editor to edit\n> \t.. and goes on this time.\n\nPossible.\n\nThe first hunk (IIRC) of my patch would stay the same, but the second hunk \nwould not fall through to the interactive commit, instead testing if amend \nexists, _and_ is different from HEAD, and if both are the case, say \nsomething helpful and exit.\n\nCiao,\nDscho\n"}]}