git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin-apply: Show a more descriptive error on failure when opening a patch

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 16, 2008, 05:20 UTC
Message-ID
<7vy77etlyb.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1208187027-29198-1-git-send-email-albertito@gmail.com>
Alberto Bertogli <albertito@gmail.com> writes:
Show 28 quoted lines
> When a patch can't be opened (it doesn't exist, there are permission
> problems, etc.) we get the usage text, which is not a proper indication of
> failure.
>
> This patch fixes that by calling error() instead.
>
> Signed-off-by: Alberto Bertogli <albertito@gmail.com>
> ---
>
> On Mon, Apr 14, 2008 at 03:33:54PM +0100, Johannes Schindelin wrote:
>> On Mon, 14 Apr 2008, Alberto Bertogli wrote:
>> 
>> > +           if (fd < 0) {
>> > +                   error("can't open patch '%s': %s", arg,
>> > +                                   strerror(errno));
>> > +                   return 1;
>> > +           }
>> 
>> Do you absolutely want to retain the curly braces, and have two 
>> statements?   I would prefer "return error(...)", and if you absolutely 
>> insist on a return 1: "return !!error(...)".
>
> No, I'm not insisting on any version, I just thought returning 1 would be
> better since it will become the script exit status; Now that I think a bit
> more about it, maybe I should just use die() instead.
>
> Anyway, here's the version returning directly from error(); if you prefer it
> some other way just let me know.

I would apply this while changing "return error()" to "die()", as the original usage() call would have exited here and we do not have a good reason to change it.

Thanks.
Previous: Alberto BertogliNext: Johannes Schindelin
Message 6 of 7 in “builtin-apply: Show a more descriptive error on failure when opening a patch”
  1. builtin-apply: Show a more descriptive error on failure when opening a patchAlberto Bertogli, Apr 13, 2008
  2. Junio C HamanoApr 13, 2008
  3. builtin-apply: Show a more descriptive error on failure when opening a patchAlberto Bertogli, Apr 14, 2008
  4. Johannes SchindelinApr 14, 2008
  5. builtin-apply: Show a more descriptive error on failure when opening a patchAlberto Bertogli, Apr 14, 2008
  6. Junio C HamanoApr 16, 2008
  7. Johannes SchindelinApr 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.