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

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

From
ABAlberto Bertogli <albertito@gmail.com>
Date
Apr 14, 2008, 14:23 UTC
Message-ID
<1208183018-27887-1-git-send-email-albertito@gmail.com>
In-Reply-To
<7vtzi5bkdz.fsf@gitster.siamese.dyndns.org>

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>
---
This one (hopefuly) addresses both Junio and Johannes' comments.
Thanks,
		Alberto
 builtin-apply.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index abe73a0..ebbe609 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -3120,8 +3120,12 @@ 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) {
+			error("can't open patch '%s': %s", arg,
+					strerror(errno));
+			return 1;
+		}
+
 		read_stdin = 0;
 		set_default_whitespace_mode(whitespace_option);
 		errs |= apply_patch(fd, arg, inaccurate_eof);
-- 
1.5.5.105.g9d11e.dirty
Previous: Junio C HamanoNext: Johannes Schindelin
Message 3 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.