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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alberto Bertogli
Date: Sunday, April 13, 2008 - 11:56 am

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 simply doing a perror() instead.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>
---
 builtin-apply.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index abe73a0..d80b231 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -3120,8 +3120,11 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 			arg = prefix_filename(prefix, prefix_length, arg);
 
 		fd = open(arg, O_RDONLY);
-		if (fd < 0)
-			usage(apply_usage);
+		if (fd < 0) {
+			perror("Error opening patch");
+			return 1;
+		}
+
 		read_stdin = 0;
 		set_default_whitespace_mode(whitespace_option);
 		errs |= apply_patch(fd, arg, inaccurate_eof);
-- 
1.5.5.104.ge4331

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] builtin-apply: Show a more descriptive error on fa ..., Alberto Bertogli, (Sun Apr 13, 11:56 am)
Re: [PATCH] builtin-apply: Show a more descriptive error o ..., Johannes Schindelin, (Mon Apr 14, 7:03 am)
Re: [PATCH] builtin-apply: Show a more descriptive error o ..., Johannes Schindelin, (Mon Apr 14, 7:33 am)