{"thread":{"id":"11545","subject":"[PATCH] additional help when editing during interactive rebase","startedAt":"2008-01-09T02:32:17Z","lastAt":"2008-01-11T11:29:32Z","messageCount":6,"participants":["William Morgan","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"64804","messageId":"1199845915-sup-797@south","threadId":"11545","inReplyTo":null,"subject":"[PATCH] additional help when editing during interactive rebase","fromName":"William Morgan","fromEmail":"wmorgan-git@masanjin.net","sentAt":"2008-01-09T02:32:17Z","receivedAt":"2008-01-09T02:32:17Z","isPatch":true,"sender":{"key":"wmorgan-git@masanjin.net","avatar":null},"body":"I personally would have found this message useful the first time I used\ngit rebase --interactive. YMMV.\n\nSigned-off-by: William Morgan <wmorgan-git@masanjin.net>\n---\n git-rebase--interactive.sh |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex acdcc54..d53d283 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -263,6 +263,10 @@ do_next () {\n \t\twarn\n \t\twarn \"\tgit commit --amend\"\n \t\twarn\n+\t\twarn \"Once amended, continue with\"\n+\t\twarn\n+\t\twarn \"\tgit rebase --continue\"\n+\t\twarn\n \t\texit 0\n \t\t;;\n \tsquash|s)\n-- \n1.5.4.rc2.68.ge708a-dirty\n\n\n-- \nWilliam <wmorgan-git@masanjin.net>\n"},{"id":"64805","messageId":"7vsl17pv1c.fsf@gitster.siamese.dyndns.org","threadId":"11545","inReplyTo":"1199845915-sup-797@south","subject":"Re: [PATCH] additional help when editing during interactive rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-09T02:55:27Z","receivedAt":"2008-01-09T02:55:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"William Morgan <wmorgan-git@masanjin.net> writes:\n\n> I personally would have found this message useful the first time I used\n> git rebase --interactive. YMMV.\n\nAside from this message being inappropriate as a proposed commit\nlog message, I think what the patch tries to achieve is a worthy\nUI improvement.\n\nI would have removed those empty lines around the instruction if\nI were patching this, though.  Losing 5 lines out of 25-line\nterminal was marginally Ok.  Losing 9 lines 4 lines too many and\nis unacceptable.\n\nThoughts?\n\n> Signed-off-by: William Morgan <wmorgan-git@masanjin.net>\n> ---\n>  git-rebase--interactive.sh |    4 ++++\n>  1 files changed, 4 insertions(+), 0 deletions(-)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index acdcc54..d53d283 100755\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -263,6 +263,10 @@ do_next () {\n>  \t\twarn\n>  \t\twarn \"\tgit commit --amend\"\n>  \t\twarn\n> +\t\twarn \"Once amended, continue with\"\n> +\t\twarn\n> +\t\twarn \"\tgit rebase --continue\"\n> +\t\twarn\n>  \t\texit 0\n>  \t\t;;\n>  \tsquash|s)\n> -- \n> 1.5.4.rc2.68.ge708a-dirty\n>\n>\n> -- \n> William <wmorgan-git@masanjin.net>\n"},{"id":"64809","messageId":"1199849225-sup-6981@south","threadId":"11545","inReplyTo":"7vsl17pv1c.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] additional help when editing during interactive rebase","fromName":"William Morgan","fromEmail":"wmorgan-git@masanjin.net","sentAt":"2008-01-09T03:29:01Z","receivedAt":"2008-01-09T03:29:01Z","isPatch":true,"sender":{"key":"wmorgan-git@masanjin.net","avatar":null},"body":"Let the user know how to continue a rebase after amending a commit\nduring a git rebase --interactive session.\n\nSigned-off-by: William Morgan <wmorgan@masanjin.net>\n---\n git-rebase--interactive.sh |    5 ++---\n 1 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex acdcc54..ccef1ac 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -258,11 +258,10 @@ do_next () {\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n \t\tmake_patch $sha1\n \t\t: > \"$DOTEST\"/amend\n-\t\twarn\n \t\twarn \"You can amend the commit now, with\"\n-\t\twarn\n \t\twarn \"\tgit commit --amend\"\n-\t\twarn\n+\t\twarn \"Once amended, continue with\"\n+\t\twarn \"\tgit rebase --continue\"\n \t\texit 0\n \t\t;;\n \tsquash|s)\n-- \n1.5.4.rc2.69.g10f0\n\n-- \nWilliam <wmorgan-git@masanjin.net>\n"},{"id":"64843","messageId":"alpine.LSU.1.00.0801091120150.31053@racer.site","threadId":"11545","inReplyTo":"7vsl17pv1c.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] additional help when editing during interactive rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-01-09T11:23:32Z","receivedAt":"2008-01-09T11:23:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 8 Jan 2008, Junio C Hamano wrote:\n\n> I would have removed those empty lines around the instruction if I were \n> patching this, though.  Losing 5 lines out of 25-line terminal was \n> marginally Ok.  Losing 9 lines 4 lines too many and is unacceptable.\n> \n> Thoughts?\n\nI wonder if it would not make even more sense to record the current HEAD \nname, and call \"commit --amend\" if it is the same upon \"--continue\".\n\nNote that \"commit --amend\" is _already_ called automatically if the index \nis dirty (but agrees with the working directory).\n\nThen the user would be spared some additional typing, and the help could \nbe changed to hint at \"rebase --continue\".  It also would make things more \nconsistent.\n\nCiao,\nDscho\n"},{"id":"64996","messageId":"7vprw83g8z.fsf@gitster.siamese.dyndns.org","threadId":"11545","inReplyTo":"alpine.LSU.1.00.0801091120150.31053@racer.site","subject":"Re: [PATCH] additional help when editing during interactive rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-11T08:42:36Z","receivedAt":"2008-01-11T08:42:36Z","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> Hi,\n>\n> On Tue, 8 Jan 2008, Junio C Hamano wrote:\n>\n>> I would have removed those empty lines around the instruction if I were \n>> patching this, though.  Losing 5 lines out of 25-line terminal was \n>> marginally Ok.  Losing 9 lines 4 lines too many and is unacceptable.\n>> \n>> Thoughts?\n>\n> I wonder if it would not make even more sense to record the current HEAD \n> name, and call \"commit --amend\" if it is the same upon \"--continue\".\n\nMy understanding of the original issue is that \"git-rebase -i\"\nstops at 'edit' and gives the user a chance to muck with the\ncommit, saying \"do whatever you want now and then record the\nresult with git commit --amend\".  The user can follow that but\nthen needs to say \"git rebase --continue\" after that.  The insn\ndoes not talk about it, so after running \"git commit --amend\" as\ntold, a clueless user is left wondering \"huh, and then now\nwhat?\".\n\nDo you mean you would instead suggest \"git rebase --continue\" in\nthe insn, and make the workflow like this:\n\n\t$ git rebase -i ...\n        Now do whatever you want and say \"rebase --continue\"\n\t$ edit foo.c\n        $ git add foo.c\n        $ git rebase --continue\n\nand have \"rebase --continue\" to continue with the modified\ncontents recorded in the index, invoking \"git commit --amend\",\nbut doing so only if the user hasn't run \"git commit\" with or\nwithout --amend yet?\n\nIt feels like a better automation than what we currently have,\nbut I somewhat worry how that would change the user experience\nfor using 'edit' to split a commit into two or more.\n"},{"id":"65006","messageId":"Pine.LNX.4.64.0801111147440.14355@wbgn129.biozentrum.uni-wuerzburg.de","threadId":"11545","inReplyTo":"7vprw83g8z.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] additional help when editing during interactive rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-01-11T11:29:32Z","receivedAt":"2008-01-11T11:29:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 11 Jan 2008, Junio C Hamano wrote:\n\n> Do you mean you would instead suggest \"git rebase --continue\" in\n> the insn, and make the workflow like this:\n> \n> \t$ git rebase -i ...\n>         Now do whatever you want and say \"rebase --continue\"\n> \t$ edit foo.c\n>         $ git add foo.c\n>         $ git rebase --continue\n> \n> and have \"rebase --continue\" to continue with the modified\n> contents recorded in the index, invoking \"git commit --amend\",\n> but doing so only if the user hasn't run \"git commit\" with or\n> without --amend yet?\n\nYes, exactly.\n\n> It feels like a better automation than what we currently have,\n> but I somewhat worry how that would change the user experience\n> for using 'edit' to split a commit into two or more.\n\nIf you want to split a commit into two or more, you will already have \ncommitted twice when you say \"--continue\", and all is fine.\n\nHowever, if you do the first commit, and then only add the files for the \nsecond commit, the HEAD's commit name has changed!  And so, rebase can \npick up on that, and avoid the --amend.\n\nIOW something like below.  However, this patch does not yet make \"rebase \n-i\" call \"commit --amend\" automatically when both the index and HEAD are \nunchanged.\n\n-- snipsnap --\n[PATCH] rebase -i: only ever commit --amend when HEAD is untouched\n\nWhen a commit is marked to edit, and the index is dirty when \"rebase\n--continue\" is called, that state will be committed with the \"--amend\"\noption.\n\nHowever, this is wrong when the user wanted to split the commit.\n\nLuckily, we can pick up on that, by recording the HEAD's name in the\nfile \"amend\", and only --amend when no commit was made in the interim.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\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 acdcc54..4a8a980 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -257,7 +257,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@@ -378,7 +378,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"}]}