From: Jonathan Nieder <jrnieder@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: Junio C Hamano <gitster@pobox.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Jens Lehmann <Jens.Lehmann@web.de>, Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCHv15 2/5] run_processes_parallel: add LF when caller is sloppy
Date: Wed, 24 Feb 2016 16:55:13 -0800 [thread overview]
Message-ID: <20160225005513.GP28749@google.com> (raw)
In-Reply-To: <CAGZ79kZvD4zFA61XvSLa8fe1PzH91+4ii5vSeH-P+ER2wbQy2g@mail.gmail.com>
Stefan Beller wrote:
> On Wed, Feb 24, 2016 at 1:19 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> > Stefan Beller wrote:
>>> When the callers of parallel processing machine are sloppy with their
>>> messages, make sure the output is terminated with LF after one child
>>> process is handled.
>>
>> Why not always add \n here?
>
> So you propose to always add a \n if the output length was > 0 ?
Ah, now I see where I was confused.
I was seeing an analogy to functions like ref_transaction_begin(),
which use a 'struct strbuf *err' argument to store the argument to
die() that describes why they failed. They get used like this:
struct strbuf err = STRBUF_INIT;
if (ref_transaction_begin(..., &err))
die(err.buf);
and die() appends a \n at the end. They typically are implemented
like this:
if (open(...)) {
strbuf_addf(&err,
"cannot open '%s': %s", ..., strerror(errno));
return -1;
}
When the function doesn't fail, err doesn't need to be inspected at all.
get_next_task_fn et al looked similar to that pattern, but they are
doing something different. The strbuf passed in is the same buffer
that is used to collect the child process's output. Writing to that
strbuf is not a way to provide an error message for die() --- instead,
it is a way to provide additional output that should be combined with
the child process's output.
Renaming the parameter to something like 'struct strbuf *out' would
have avoided this clash of conventions and got me un-confused. That
would make it clearer that the callback function should do
strbuf_addf(out, "warning: foo\n");
including both its own 'warning: ' prefix and its own newline. It is
providing output meant to be passed as-is to the terminal.
That is a convenient API since if you want to write multiple messages,
you can do
if (foo)
strbuf_addf(out, "warning: foo\n");
... do some other things ...
if (bar)
strbuf_addf(out, "warning: bar\n");
The newlines avoid the messages running together.
The functions default_start_failure and default_task_finished are
buggy under that API, since they do not include newlines in their
output.
Once they're fixed, there wouldn't be any need to add \n, unless we
are worried about a child process that writes output that doesn't end
with a newline. It can be convenient for child processes to do things
like
printf '%s\t' "some information"
so I am not convinced this patch is helping.
Does that make sense?
Sorry for the confusion,
Jonathan
next prev parent reply other threads:[~2016-02-25 0:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 3:20 [PATCHv15 0/5] Expose submodule parallelism to the user Stefan Beller
2016-02-24 3:20 ` [PATCHv15 1/5] run-command: expose default_{start_failure, task_finished} Stefan Beller
2016-02-24 3:20 ` [PATCHv15 2/5] run_processes_parallel: add LF when caller is sloppy Stefan Beller
2016-02-24 20:07 ` Junio C Hamano
2016-02-24 21:19 ` Stefan Beller
2016-02-24 21:23 ` Junio C Hamano
2016-02-24 21:19 ` Jonathan Nieder
2016-02-24 21:59 ` Stefan Beller
2016-02-25 0:55 ` Jonathan Nieder [this message]
2016-02-25 2:56 ` Junio C Hamano
2016-02-24 3:20 ` [PATCHv15 3/5] git submodule update: have a dedicated helper for cloning Stefan Beller
2016-02-24 3:20 ` [PATCHv15 4/5] submodule update: expose parallelism to the user Stefan Beller
2016-02-24 3:20 ` [PATCHv15 5/5] clone: allow an explicit argument for parallel submodule clones Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160225005513.GP28749@google.com \
--to=jrnieder@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sbeller@google.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).