git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Junio C Hamano <gitster@pobox.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	Brandon Williams <bmwill@google.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	David Turner <David.Turner@twosigma.com>
Subject: Re: [PATCHv4 3/5] run-command: add {run,start,finish}_command_or_die
Date: Tue, 20 Dec 2016 12:49:13 -0800	[thread overview]
Message-ID: <CAGZ79kYG-veuWNFh6G1g5MiQHBGk2i1qbH_NBtnMS6jFcoWocg@mail.gmail.com> (raw)
In-Reply-To: <f14ee492-8297-c8ec-f80f-f8f24caf91e1@kdbg.org>

On Tue, Dec 20, 2016 at 12:12 PM, Johannes Sixt <j6t@kdbg.org> wrote:
> Am 20.12.2016 um 20:23 schrieb Stefan Beller:
>>
>> In a reroll I'll drop this patch and instead introduce
>> a function `char *get_child_command_line(struct child_process*);`, which
>> a caller can call before calling finish_command and then use the
>> resulting string
>> to assemble an error message without lego.
>
>
> That sounds a lot better, thank you. Note though, that the function would
> have to be called before start_command(), because when it fails, it would be
> too late.

Yes, the pattern to use it would be

    // first assemble the child process struct with conditions

    char *cmdline = get_child_command_line(&child)

    if (start_command(&child))
        // use cmdline here for error reporting.


>
> I have to ask, though: Is it so much necessary to report the exact command
> line in an error message?

Have a look at https://github.com/git/git/blob/master/submodule.c#L1122

    die("Could not run 'git status --porcelain -uall \
        --ignore-submodules=none' in submodule %s", path);

There are 2 things:
1) The error message is not very informative, as your question hints at.
    I consider changing it to add more meaning. I think the end user
    would also be interested in "Why did we run this command?".
2) We really want to report the correct command line here.
    Currently that is the case, but if you look at the prior patch that extends
    the arguments conditionally (and then also uses the same condition
    to format the error message... that hints at hard to maintain error
    messages.)

So the new proposed function really only addresses 2) here.

> If someone is interested in which command failed,
> it would be "sufficient" to run the command under GIT_TRACE=2.
>

Yes, while at it, I may just move up the error reporting to the builtin
command giving a higher level message.

Thanks,
Stefan

  reply	other threads:[~2016-12-20 20:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 23:28 [PATCHv4 0/5] git-rm absorbs submodule git directory before deletion Stefan Beller
2016-12-19 23:28 ` [PATCHv4 1/5] submodule.h: add extern keyword to functions Stefan Beller
2016-12-19 23:28 ` [PATCHv4 2/5] submodule: modernize ok_to_remove_submodule to use argv_array Stefan Beller
2016-12-19 23:28 ` [PATCHv4 3/5] run-command: add {run,start,finish}_command_or_die Stefan Beller
2016-12-19 23:32   ` Brandon Williams
2016-12-19 23:35     ` Stefan Beller
2016-12-20 18:33   ` Johannes Sixt
2016-12-20 18:54     ` Johannes Sixt
2016-12-20 19:23     ` Stefan Beller
2016-12-20 20:12       ` Johannes Sixt
2016-12-20 20:49         ` Stefan Beller [this message]
2016-12-20 21:47           ` Johannes Sixt
2016-12-20 22:07             ` Stefan Beller
2016-12-19 23:28 ` [PATCHv4 4/5] submodule: add flags to ok_to_remove_submodule Stefan Beller
2016-12-19 23:28 ` [PATCHv4 5/5] rm: absorb a submodules git dir before deletion Stefan Beller
2016-12-19 23:35 ` [PATCHv4 0/5] git-rm absorbs submodule git directory " David Turner

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=CAGZ79kYG-veuWNFh6G1g5MiQHBGk2i1qbH_NBtnMS6jFcoWocg@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=David.Turner@twosigma.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=sandals@crustytoothpaste.net \
    /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).