Alban Gruin <alban.gruin@xxxxxxxxx> writes: > Subject: Re: [GSoC][PATCH v2 5/7] sequencer: add a new function to silence a command, except if it fails. Lose the full-stop at the end. > This adds a new function, run_command_silent_on_success(), to > redirect the stdout and stderr of a command to a strbuf, and then to run > that command. This strbuf is printed only if the command fails. It is > functionnaly similar to output() from git-rebase.sh. > > run_git_commit() is then refactored to use of > run_command_silent_on_success(). > > Signed-off-by: Alban Gruin <alban.gruin@xxxxxxxxx> > --- > sequencer.c | 49 ++++++++++++++++++++++++------------------------- > 1 file changed, 24 insertions(+), 25 deletions(-) > > diff --git a/sequencer.c b/sequencer.c > index 57fd58bc1..9e2b34a49 100644 > --- a/sequencer.c > +++ b/sequencer.c > @@ -768,6 +768,24 @@ N_("you have staged changes in your working tree\n" > #define VERIFY_MSG (1<<4) > #define CREATE_ROOT_COMMIT (1<<5) > > +static int run_command_silent_on_success(struct child_process *cmd) > +{ > + struct strbuf buf = STRBUF_INIT; > + int rc; > + > + cmd->stdout_to_stderr = 1; > + rc = pipe_command(cmd, > + NULL, 0, > + /* stdout is already redirected */ Are we reviewing the correct version? I thought we discarded this comment in the previous round. > + NULL, 0, > + &buf, 0);