From: Junio C Hamano <gitster@pobox.com>
To: Alberto Bertogli <albertito@gmail.com>
Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] builtin-apply: Show a more descriptive error on failure when opening a patch
Date: Tue, 15 Apr 2008 22:20:28 -0700 [thread overview]
Message-ID: <7vy77etlyb.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1208187027-29198-1-git-send-email-albertito@gmail.com> (Alberto Bertogli's message of "Mon, 14 Apr 2008 12:30:27 -0300")
Alberto Bertogli <albertito@gmail.com> writes:
> 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.
next prev parent reply other threads:[~2008-04-16 5:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-13 18:56 [PATCH] builtin-apply: Show a more descriptive error on failure when opening a patch Alberto Bertogli
2008-04-13 19:54 ` Junio C Hamano
2008-04-14 14:23 ` Alberto Bertogli
2008-04-14 14:33 ` Johannes Schindelin
2008-04-14 15:30 ` Alberto Bertogli
2008-04-16 5:20 ` Junio C Hamano [this message]
2008-04-14 14:03 ` Johannes Schindelin
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=7vy77etlyb.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=albertito@gmail.com \
--cc=git@vger.kernel.org \
/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).