Thread (1 message) 1 message, 1 author, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:29

Alberto Bertogli [off-list ref] 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 <redacted>
---

On Mon, Apr 14, 2008 at 03:33:54PM +0100, Johannes Schindelin wrote:
quoted
On Mon, 14 Apr 2008, Alberto Bertogli wrote:
quoted
+           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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help