sequencer (rebase -i): show only failed `git commit`'s output

This is the behavior of the shell script version of the interactive rebase, by using the `output` function defined in `git-rebase.sh`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jan 2, 2017 at 16:35 UTC 9a757c4970837162dfe4a64b70a428209c135641
1 file changed +18
sequencer.c
+18
@@ -610,6 +610,11 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
610 cmd.git_cmd = 1;
611
612 if (is_rebase_i(opts)) {
613 + if (!edit) {
614 + cmd.stdout_to_stderr = 1;
615 + cmd.err = -1;
616 + }
617 +
618 if (read_env_script(&cmd.env_array)) {
619 const char *gpg_opt = gpg_sign_opt_quoted(opts);
620
@@ -644,6 +649,19 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
649 if (opts->allow_empty_message)
650 argv_array_push(&cmd.args, "--allow-empty-message");
651
652 + if (cmd.err == -1) {
653 + /* hide stderr on success */
654 + struct strbuf buf = STRBUF_INIT;
655 + int rc = pipe_command(&cmd,
656 + NULL, 0,
657 + /* stdout is already redirected */
658 + NULL, 0,
659 + &buf, 0);
660 + if (rc)
661 + fputs(buf.buf, stderr);
662 + strbuf_release(&buf);
663 + return rc;
664 + }
665
666 return run_command(&cmd);
667 }