{"thread":{"id":"45993","subject":"[PATCH 0/2] Fix a couple of minor rebase -i regressions","startedAt":"2017-05-18T10:03:15Z","lastAt":"2017-05-18T21:19:48Z","messageCount":6,"participants":["Phillip Wood","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"320151","messageId":"20170518100233.30559-1-phillip.wood@talktalk.net","threadId":"45993","inReplyTo":null,"subject":"[PATCH 0/2] Fix a couple of minor rebase -i regressions","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-05-18T10:02:31Z","receivedAt":"2017-05-18T10:03:15Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nThese patches fix a regression in the reflog message written when\nrebase -i finishes and supresses the status output from applying any\nautostashed changes to match the shell version of rebase -i.\n\nPhillip Wood (2):\n  rebase -i: fix reflog message\n  rebase -i: silence stash apply\n\n sequencer.c | 3 +++\n 1 file changed, 3 insertions(+)\n\n-- \n2.13.0\n\n"},{"id":"320152","messageId":"20170518100233.30559-2-phillip.wood@talktalk.net","threadId":"45993","inReplyTo":"20170518100233.30559-1-phillip.wood@talktalk.net","subject":"[PATCH 1/2] rebase -i: fix reflog message","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-05-18T10:02:32Z","receivedAt":"2017-05-18T10:03:22Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nWhen rebase -i was converted to C a bug was introduced into the code\nthat creates the reflog message. Instead of saying\nrebase -i (finish): <head-name> onto <onto>\nit says\nrebase -i (finish): <head-name> onto <orig-head><onto>\nas the strbuf is not reset between reading the value of <orig-head>\nand <onto>.\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n sequencer.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 0fa3fb14f7c1df5f11ba0ef7e4e46a44a32817bd..f8bc18badf1a3fb1b39656501c5a316e229968d2 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -2089,6 +2089,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)\n \t\t\t\tres = error(_(\"could not read orig-head\"));\n \t\t\t\tgoto cleanup_head_ref;\n \t\t\t}\n+\t\t\tstrbuf_reset(&buf);\n \t\t\tif (!read_oneliner(&buf, rebase_path_onto(), 0)) {\n \t\t\t\tres = error(_(\"could not read 'onto'\"));\n \t\t\t\tgoto cleanup_head_ref;\n-- \n2.13.0\n\n"},{"id":"320153","messageId":"20170518100233.30559-3-phillip.wood@talktalk.net","threadId":"45993","inReplyTo":"20170518100233.30559-1-phillip.wood@talktalk.net","subject":"[PATCH 2/2] rebase -i: silence stash apply","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-05-18T10:02:33Z","receivedAt":"2017-05-18T10:03:25Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nThe shell version of rebase -i silences the status output from 'git\nstash apply' when restoring the autostashed changes. The C version\ndoes not.\n\nHaving the output from git stash apply on the screen is\ndistracting as it makes it difficult to find the message from git\nrebase saying that the rebase succeeded. Also the status information\nthat git stash prints talks about looking in .git/rebase-merge/done to\nsee which commits have been applied. As .git/rebase-merge is removed\nshortly after the message is printed before rebase -i exits this is\nconfusing.\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n sequencer.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex f8bc18badf1a3fb1b39656501c5a316e229968d2..311728a145dfc66e230334221a2610468239932d 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1914,6 +1914,8 @@ static int apply_autostash(struct replay_opts *opts)\n \tstrbuf_trim(&stash_sha1);\n \n \tchild.git_cmd = 1;\n+\tchild.no_stdout = 1;\n+\tchild.no_stderr = 1;\n \targv_array_push(&child.args, \"stash\");\n \targv_array_push(&child.args, \"apply\");\n \targv_array_push(&child.args, stash_sha1.buf);\n-- \n2.13.0\n\n"},{"id":"320157","messageId":"alpine.DEB.2.21.1.1705181246430.3610@virtualbox","threadId":"45993","inReplyTo":"20170518100233.30559-3-phillip.wood@talktalk.net","subject":"Re: [PATCH 2/2] rebase -i: silence stash apply","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-05-18T10:49:57Z","receivedAt":"2017-05-18T12:12:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Phillip,\n\nOn Thu, 18 May 2017, Phillip Wood wrote:\n\n> diff --git a/sequencer.c b/sequencer.c\n> index f8bc18badf1a3fb1b39656501c5a316e229968d2..311728a145dfc66e230334221a2610468239932d 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -1914,6 +1914,8 @@ static int apply_autostash(struct replay_opts *opts)\n>  \tstrbuf_trim(&stash_sha1);\n>  \n>  \tchild.git_cmd = 1;\n> +\tchild.no_stdout = 1;\n> +\tchild.no_stderr = 1;\n>  \targv_array_push(&child.args, \"stash\");\n>  \targv_array_push(&child.args, \"apply\");\n>  \targv_array_push(&child.args, stash_sha1.buf);\n\nIf I remember correctly, then the shell version prints the output in case\nof an error.\n\nWe already imitated that behavior in `git commit`\n(https://github.com/git-for-windows/git/blob/v2.13.0.windows.1/sequencer.c#L674-L684):\n\n\t\t/* hide stderr on success */\n\t\tstruct strbuf buf = STRBUF_INIT;\n\t\tint rc = pipe_command(&cmd,\n\t\t\t\t      NULL, 0,\n\t\t\t\t      /* stdout is already redirected */\n\t\t\t\t      NULL, 0,\n\t\t\t\t      &buf, 0);\n\t\tif (rc)\n\t\t\tfputs(buf.buf, stderr);\n\t\tstrbuf_release(&buf);\n\nI think that would be the appropriate approach here, too.\n\nCiao,\nJohannes\n\nP.S.: it may be a very good idea to accompany this patch (as well as the\nprevious one) by a patch to the test suite to verify that the fixed code\ndoes not regress.\n"},{"id":"320161","messageId":"decdfff1-dd21-4e10-44d5-9dbee38ba05f@talktalk.net","threadId":"45993","inReplyTo":"alpine.DEB.2.21.1.1705181246430.3610@virtualbox","subject":"Re: [PATCH 2/2] rebase -i: silence stash apply","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-05-18T14:51:31Z","receivedAt":"2017-05-18T14:51:39Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Johannes\n\nThanks for your reply\nOn 18/05/17 11:49, Johannes Schindelin wrote:\n> Hi Phillip,\n> \n> On Thu, 18 May 2017, Phillip Wood wrote:\n> \n>> diff --git a/sequencer.c b/sequencer.c\n>> index f8bc18badf1a3fb1b39656501c5a316e229968d2..311728a145dfc66e230334221a2610468239932d 100644\n>> --- a/sequencer.c\n>> +++ b/sequencer.c\n>> @@ -1914,6 +1914,8 @@ static int apply_autostash(struct replay_opts *opts)\n>>   \tstrbuf_trim(&stash_sha1);\n>>   \n>>   \tchild.git_cmd = 1;\n>> +\tchild.no_stdout = 1;\n>> +\tchild.no_stderr = 1;\n>>   \targv_array_push(&child.args, \"stash\");\n>>   \targv_array_push(&child.args, \"apply\");\n>>   \targv_array_push(&child.args, stash_sha1.buf);\n> \n> If I remember correctly, then the shell version prints the output in case\n> of an error.\n\nThe shell version prints it's own error message if there's an error, the \nC version does this as well\n\nShell version:\napply_autostash () {\n\tif test -f \"$state_dir/autostash\"\n\tthen\n\t\tstash_sha1=$(cat \"$state_dir/autostash\")\n\t\tif git stash apply $stash_sha1 2>&1 >/dev/null\n\t\tthen\n\t\t\techo \"$(gettext 'Applied autostash.')\"\n\t\telse\n\t\t\tgit stash store -m \"autostash\" -q $stash_sha1 ||\n\t\t\tdie \"$(eval_gettext \"Cannot store \\$stash_sha1\")\"\n\t\t\tgettext 'Applying autostash resulted in conflicts.\nYour changes are safe in the stash.\nYou can run \"git stash pop\" or \"git stash drop\" at any time.\n'\n\t\tfi\n\tfi\n}\n\nC version:\nstatic int apply_autostash(struct replay_opts *opts)\n{\n\tstruct strbuf stash_sha1 = STRBUF_INIT;\n\tstruct child_process child = CHILD_PROCESS_INIT;\n\tint ret = 0;\n\n\tif (!read_oneliner(&stash_sha1, rebase_path_autostash(), 1)) {\n\t\tstrbuf_release(&stash_sha1);\n\t\treturn 0;\n\t}\n\tstrbuf_trim(&stash_sha1);\n\n\tchild.git_cmd = 1;\n\tchild.no_stdout = 1;\n\tchild.no_stderr = 1;\n\targv_array_push(&child.args, \"stash\");\n\targv_array_push(&child.args, \"apply\");\n\targv_array_push(&child.args, stash_sha1.buf);\n\tif (!run_command(&child))\n\t\tprintf(_(\"Applied autostash.\\n\"));\n\telse {\n\t\tstruct child_process store = CHILD_PROCESS_INIT;\n\n\t\tstore.git_cmd = 1;\n\t\targv_array_push(&store.args, \"stash\");\n\t\targv_array_push(&store.args, \"store\");\n\t\targv_array_push(&store.args, \"-m\");\n\t\targv_array_push(&store.args, \"autostash\");\n\t\targv_array_push(&store.args, \"-q\");\n\t\targv_array_push(&store.args, stash_sha1.buf);\n\t\tif (run_command(&store))\n\t\t\tret = error(_(\"cannot store %s\"), stash_sha1.buf);\n\t\telse\n\t\t\tprintf(_(\"Applying autostash resulted in conflicts.\\n\"\n\t\t\t\t\"Your changes are safe in the stash.\\n\"\n\t\t\t\t\"You can run \\\"git stash pop\\\" or\"\n\t\t\t\t\" \\\"git stash drop\\\" at any time.\\n\"));\n\t}\n\n\tstrbuf_release(&stash_sha1);\n\treturn ret;\n}\n\n\n> We already imitated that behavior in `git commit`\n> (https://github.com/git-for-windows/git/blob/v2.13.0.windows.1/sequencer.c#L674-L684):\n> \n> \t\t/* hide stderr on success */\n> \t\tstruct strbuf buf = STRBUF_INIT;\n> \t\tint rc = pipe_command(&cmd,\n> \t\t\t\t      NULL, 0,\n> \t\t\t\t      /* stdout is already redirected */\n> \t\t\t\t      NULL, 0,\n> \t\t\t\t      &buf, 0);\n> \t\tif (rc)\n> \t\t\tfputs(buf.buf, stderr);\n> \t\tstrbuf_release(&buf);\n> \n> I think that would be the appropriate approach here, too.\n\nI can change it to do this if you think it is an improvement but the \nexisting error message seems fairly clear to me and I think (though I \nhaven't checked) that the call to stash store should print out the id of \nthe stash for the user\n\n> P.S.: it may be a very good idea to accompany this patch (as well as the\n> previous one) by a patch to the test suite to verify that the fixed code\n> does not regress.\n\nI agree that a test for this (and probably my other changes) would be \nuseful, I'll try and put something together but it won't be until after \nthe end of next week.\n\nThanks\n\nPhillip\n"},{"id":"320211","messageId":"alpine.DEB.2.21.1.1705182318170.3610@virtualbox","threadId":"45993","inReplyTo":"decdfff1-dd21-4e10-44d5-9dbee38ba05f@talktalk.net","subject":"Re: [PATCH 2/2] rebase -i: silence stash apply","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-05-18T21:19:30Z","receivedAt":"2017-05-18T21:19:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Phillip,\n\nOn Thu, 18 May 2017, Phillip Wood wrote:\n\n> The shell version prints it's own error message if there's an error, the\n> C version does this as well\n> \n> Shell version:\n> apply_autostash () {\n> \tif test -f \"$state_dir/autostash\"\n> \tthen\n> \t\tstash_sha1=$(cat \"$state_dir/autostash\")\n> \t\tif git stash apply $stash_sha1 2>&1 >/dev/null\n> \t\tthen\n> \t\t\techo \"$(gettext 'Applied autostash.')\"\n> \t\telse\n> \t\t\tgit stash store -m \"autostash\" -q $stash_sha1 ||\n> \t\t\tdie \"$(eval_gettext \"Cannot store \\$stash_sha1\")\"\n> \t\t\tgettext 'Applying autostash resulted in conflicts.\n> Your changes are safe in the stash.\n> You can run \"git stash pop\" or \"git stash drop\" at any time.\n> '\n> \t\tfi\n> \tfi\n> }\n> \n> C version:\n> static int apply_autostash(struct replay_opts *opts)\n> {\n> \tstruct strbuf stash_sha1 = STRBUF_INIT;\n> \tstruct child_process child = CHILD_PROCESS_INIT;\n> \tint ret = 0;\n> \n> \tif (!read_oneliner(&stash_sha1, rebase_path_autostash(), 1)) {\n> \t\tstrbuf_release(&stash_sha1);\n> \t\treturn 0;\n> \t}\n> \tstrbuf_trim(&stash_sha1);\n> \n> \tchild.git_cmd = 1;\n> \tchild.no_stdout = 1;\n> \tchild.no_stderr = 1;\n> \targv_array_push(&child.args, \"stash\");\n> \targv_array_push(&child.args, \"apply\");\n> \targv_array_push(&child.args, stash_sha1.buf);\n> \tif (!run_command(&child))\n> \t\tprintf(_(\"Applied autostash.\\n\"));\n> \telse {\n> \t\tstruct child_process store = CHILD_PROCESS_INIT;\n> \n> \t\tstore.git_cmd = 1;\n> \t\targv_array_push(&store.args, \"stash\");\n> \t\targv_array_push(&store.args, \"store\");\n> \t\targv_array_push(&store.args, \"-m\");\n> \t\targv_array_push(&store.args, \"autostash\");\n> \t\targv_array_push(&store.args, \"-q\");\n> \t\targv_array_push(&store.args, stash_sha1.buf);\n> \t\tif (run_command(&store))\n> \t\t\tret = error(_(\"cannot store %s\"), stash_sha1.buf);\n> \t\telse\n> \t\t\tprintf(_(\"Applying autostash resulted in conflicts.\\n\"\n> \t\t\t\t\"Your changes are safe in the stash.\\n\"\n> \t\t\t\t\"You can run \\\"git stash pop\\\" or\"\n> \t\t\t\t\" \\\"git stash drop\\\" at any time.\\n\"));\n> \t}\n> \n> \tstrbuf_release(&stash_sha1);\n> \treturn ret;\n> }\n\nOh, you're right, I misremembered.\n\nThank you for being so thorough. This patch is Acked-by: me, then.\n\nThanks,\nJohannes\n"}]}