* [PATCH 0/2] Fix a couple of minor rebase -i regressions @ 2017-05-18 10:02 Phillip Wood 2017-05-18 10:02 ` [PATCH 1/2] rebase -i: fix reflog message Phillip Wood 2017-05-18 10:02 ` [PATCH 2/2] rebase -i: silence stash apply Phillip Wood 0 siblings, 2 replies; 6+ messages in thread From: Phillip Wood @ 2017-05-18 10:02 UTC (permalink / raw) To: git; +Cc: Phillip Wood From: Phillip Wood <phillip.wood@dunelm.org.uk> These patches fix a regression in the reflog message written when rebase -i finishes and supresses the status output from applying any autostashed changes to match the shell version of rebase -i. Phillip Wood (2): rebase -i: fix reflog message rebase -i: silence stash apply sequencer.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.13.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] rebase -i: fix reflog message 2017-05-18 10:02 [PATCH 0/2] Fix a couple of minor rebase -i regressions Phillip Wood @ 2017-05-18 10:02 ` Phillip Wood 2017-05-18 10:02 ` [PATCH 2/2] rebase -i: silence stash apply Phillip Wood 1 sibling, 0 replies; 6+ messages in thread From: Phillip Wood @ 2017-05-18 10:02 UTC (permalink / raw) To: git; +Cc: Phillip Wood From: Phillip Wood <phillip.wood@dunelm.org.uk> When rebase -i was converted to C a bug was introduced into the code that creates the reflog message. Instead of saying rebase -i (finish): <head-name> onto <onto> it says rebase -i (finish): <head-name> onto <orig-head><onto> as the strbuf is not reset between reading the value of <orig-head> and <onto>. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> --- sequencer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sequencer.c b/sequencer.c index 0fa3fb14f7c1df5f11ba0ef7e4e46a44a32817bd..f8bc18badf1a3fb1b39656501c5a316e229968d2 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2089,6 +2089,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) res = error(_("could not read orig-head")); goto cleanup_head_ref; } + strbuf_reset(&buf); if (!read_oneliner(&buf, rebase_path_onto(), 0)) { res = error(_("could not read 'onto'")); goto cleanup_head_ref; -- 2.13.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] rebase -i: silence stash apply 2017-05-18 10:02 [PATCH 0/2] Fix a couple of minor rebase -i regressions Phillip Wood 2017-05-18 10:02 ` [PATCH 1/2] rebase -i: fix reflog message Phillip Wood @ 2017-05-18 10:02 ` Phillip Wood 2017-05-18 10:49 ` Johannes Schindelin 1 sibling, 1 reply; 6+ messages in thread From: Phillip Wood @ 2017-05-18 10:02 UTC (permalink / raw) To: git; +Cc: Phillip Wood From: Phillip Wood <phillip.wood@dunelm.org.uk> The shell version of rebase -i silences the status output from 'git stash apply' when restoring the autostashed changes. The C version does not. Having the output from git stash apply on the screen is distracting as it makes it difficult to find the message from git rebase saying that the rebase succeeded. Also the status information that git stash prints talks about looking in .git/rebase-merge/done to see which commits have been applied. As .git/rebase-merge is removed shortly after the message is printed before rebase -i exits this is confusing. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> --- sequencer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sequencer.c b/sequencer.c index f8bc18badf1a3fb1b39656501c5a316e229968d2..311728a145dfc66e230334221a2610468239932d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1914,6 +1914,8 @@ static int apply_autostash(struct replay_opts *opts) strbuf_trim(&stash_sha1); child.git_cmd = 1; + child.no_stdout = 1; + child.no_stderr = 1; argv_array_push(&child.args, "stash"); argv_array_push(&child.args, "apply"); argv_array_push(&child.args, stash_sha1.buf); -- 2.13.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] rebase -i: silence stash apply 2017-05-18 10:02 ` [PATCH 2/2] rebase -i: silence stash apply Phillip Wood @ 2017-05-18 10:49 ` Johannes Schindelin 2017-05-18 14:51 ` Phillip Wood 0 siblings, 1 reply; 6+ messages in thread From: Johannes Schindelin @ 2017-05-18 10:49 UTC (permalink / raw) To: Phillip Wood; +Cc: git Hi Phillip, On Thu, 18 May 2017, Phillip Wood wrote: > diff --git a/sequencer.c b/sequencer.c > index f8bc18badf1a3fb1b39656501c5a316e229968d2..311728a145dfc66e230334221a2610468239932d 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -1914,6 +1914,8 @@ static int apply_autostash(struct replay_opts *opts) > strbuf_trim(&stash_sha1); > > child.git_cmd = 1; > + child.no_stdout = 1; > + child.no_stderr = 1; > argv_array_push(&child.args, "stash"); > argv_array_push(&child.args, "apply"); > argv_array_push(&child.args, stash_sha1.buf); If I remember correctly, then the shell version prints the output in case of an error. We already imitated that behavior in `git commit` (https://github.com/git-for-windows/git/blob/v2.13.0.windows.1/sequencer.c#L674-L684): /* hide stderr on success */ struct strbuf buf = STRBUF_INIT; int rc = pipe_command(&cmd, NULL, 0, /* stdout is already redirected */ NULL, 0, &buf, 0); if (rc) fputs(buf.buf, stderr); strbuf_release(&buf); I think that would be the appropriate approach here, too. Ciao, Johannes P.S.: it may be a very good idea to accompany this patch (as well as the previous one) by a patch to the test suite to verify that the fixed code does not regress. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] rebase -i: silence stash apply 2017-05-18 10:49 ` Johannes Schindelin @ 2017-05-18 14:51 ` Phillip Wood 2017-05-18 21:19 ` Johannes Schindelin 0 siblings, 1 reply; 6+ messages in thread From: Phillip Wood @ 2017-05-18 14:51 UTC (permalink / raw) To: Johannes Schindelin; +Cc: git Hi Johannes Thanks for your reply On 18/05/17 11:49, Johannes Schindelin wrote: > Hi Phillip, > > On Thu, 18 May 2017, Phillip Wood wrote: > >> diff --git a/sequencer.c b/sequencer.c >> index f8bc18badf1a3fb1b39656501c5a316e229968d2..311728a145dfc66e230334221a2610468239932d 100644 >> --- a/sequencer.c >> +++ b/sequencer.c >> @@ -1914,6 +1914,8 @@ static int apply_autostash(struct replay_opts *opts) >> strbuf_trim(&stash_sha1); >> >> child.git_cmd = 1; >> + child.no_stdout = 1; >> + child.no_stderr = 1; >> argv_array_push(&child.args, "stash"); >> argv_array_push(&child.args, "apply"); >> argv_array_push(&child.args, stash_sha1.buf); > > If I remember correctly, then the shell version prints the output in case > of an error. The shell version prints it's own error message if there's an error, the C version does this as well Shell version: apply_autostash () { if test -f "$state_dir/autostash" then stash_sha1=$(cat "$state_dir/autostash") if git stash apply $stash_sha1 2>&1 >/dev/null then echo "$(gettext 'Applied autostash.')" else git stash store -m "autostash" -q $stash_sha1 || die "$(eval_gettext "Cannot store \$stash_sha1")" gettext 'Applying autostash resulted in conflicts. Your changes are safe in the stash. You can run "git stash pop" or "git stash drop" at any time. ' fi fi } C version: static int apply_autostash(struct replay_opts *opts) { struct strbuf stash_sha1 = STRBUF_INIT; struct child_process child = CHILD_PROCESS_INIT; int ret = 0; if (!read_oneliner(&stash_sha1, rebase_path_autostash(), 1)) { strbuf_release(&stash_sha1); return 0; } strbuf_trim(&stash_sha1); child.git_cmd = 1; child.no_stdout = 1; child.no_stderr = 1; argv_array_push(&child.args, "stash"); argv_array_push(&child.args, "apply"); argv_array_push(&child.args, stash_sha1.buf); if (!run_command(&child)) printf(_("Applied autostash.\n")); else { struct child_process store = CHILD_PROCESS_INIT; store.git_cmd = 1; argv_array_push(&store.args, "stash"); argv_array_push(&store.args, "store"); argv_array_push(&store.args, "-m"); argv_array_push(&store.args, "autostash"); argv_array_push(&store.args, "-q"); argv_array_push(&store.args, stash_sha1.buf); if (run_command(&store)) ret = error(_("cannot store %s"), stash_sha1.buf); else printf(_("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")); } strbuf_release(&stash_sha1); return ret; } > We already imitated that behavior in `git commit` > (https://github.com/git-for-windows/git/blob/v2.13.0.windows.1/sequencer.c#L674-L684): > > /* hide stderr on success */ > struct strbuf buf = STRBUF_INIT; > int rc = pipe_command(&cmd, > NULL, 0, > /* stdout is already redirected */ > NULL, 0, > &buf, 0); > if (rc) > fputs(buf.buf, stderr); > strbuf_release(&buf); > > I think that would be the appropriate approach here, too. I can change it to do this if you think it is an improvement but the existing error message seems fairly clear to me and I think (though I haven't checked) that the call to stash store should print out the id of the stash for the user > P.S.: it may be a very good idea to accompany this patch (as well as the > previous one) by a patch to the test suite to verify that the fixed code > does not regress. I agree that a test for this (and probably my other changes) would be useful, I'll try and put something together but it won't be until after the end of next week. Thanks Phillip ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] rebase -i: silence stash apply 2017-05-18 14:51 ` Phillip Wood @ 2017-05-18 21:19 ` Johannes Schindelin 0 siblings, 0 replies; 6+ messages in thread From: Johannes Schindelin @ 2017-05-18 21:19 UTC (permalink / raw) To: phillip.wood; +Cc: git Hi Phillip, On Thu, 18 May 2017, Phillip Wood wrote: > The shell version prints it's own error message if there's an error, the > C version does this as well > > Shell version: > apply_autostash () { > if test -f "$state_dir/autostash" > then > stash_sha1=$(cat "$state_dir/autostash") > if git stash apply $stash_sha1 2>&1 >/dev/null > then > echo "$(gettext 'Applied autostash.')" > else > git stash store -m "autostash" -q $stash_sha1 || > die "$(eval_gettext "Cannot store \$stash_sha1")" > gettext 'Applying autostash resulted in conflicts. > Your changes are safe in the stash. > You can run "git stash pop" or "git stash drop" at any time. > ' > fi > fi > } > > C version: > static int apply_autostash(struct replay_opts *opts) > { > struct strbuf stash_sha1 = STRBUF_INIT; > struct child_process child = CHILD_PROCESS_INIT; > int ret = 0; > > if (!read_oneliner(&stash_sha1, rebase_path_autostash(), 1)) { > strbuf_release(&stash_sha1); > return 0; > } > strbuf_trim(&stash_sha1); > > child.git_cmd = 1; > child.no_stdout = 1; > child.no_stderr = 1; > argv_array_push(&child.args, "stash"); > argv_array_push(&child.args, "apply"); > argv_array_push(&child.args, stash_sha1.buf); > if (!run_command(&child)) > printf(_("Applied autostash.\n")); > else { > struct child_process store = CHILD_PROCESS_INIT; > > store.git_cmd = 1; > argv_array_push(&store.args, "stash"); > argv_array_push(&store.args, "store"); > argv_array_push(&store.args, "-m"); > argv_array_push(&store.args, "autostash"); > argv_array_push(&store.args, "-q"); > argv_array_push(&store.args, stash_sha1.buf); > if (run_command(&store)) > ret = error(_("cannot store %s"), stash_sha1.buf); > else > printf(_("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")); > } > > strbuf_release(&stash_sha1); > return ret; > } Oh, you're right, I misremembered. Thank you for being so thorough. This patch is Acked-by: me, then. Thanks, Johannes ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-18 21:19 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-18 10:02 [PATCH 0/2] Fix a couple of minor rebase -i regressions Phillip Wood 2017-05-18 10:02 ` [PATCH 1/2] rebase -i: fix reflog message Phillip Wood 2017-05-18 10:02 ` [PATCH 2/2] rebase -i: silence stash apply Phillip Wood 2017-05-18 10:49 ` Johannes Schindelin 2017-05-18 14:51 ` Phillip Wood 2017-05-18 21:19 ` Johannes Schindelin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).