Thread (133 messages) 133 messages, 6 authors, 2016-06-16
STALE3642d
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 52/83] builtin/apply: read_patch_file() return -1 instead of die()ing

From: Christian Couder <hidden>
Date: 2016-06-16 02:18:56
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Christian Couder <redacted>
---
 builtin/apply.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index bc209f5..c0bb24c 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -454,10 +454,10 @@ static void say_patch_name(FILE *output, const char *fmt, struct patch *patch)
 
 #define SLOP (16)
 
-static void read_patch_file(struct strbuf *sb, int fd)
+static int read_patch_file(struct strbuf *sb, int fd)
 {
 	if (strbuf_read(sb, fd, 0) < 0)
-		die_errno("git apply: failed to read");
+		return error("git apply: failed to read: %s", strerror(errno));
 
 	/*
 	 * Make sure that we have some slop in the buffer
@@ -466,6 +466,7 @@ static void read_patch_file(struct strbuf *sb, int fd)
 	 */
 	strbuf_grow(sb, SLOP);
 	memset(sb->buf + sb->len, 0, SLOP);
+	return 0;
 }
 
 static unsigned long linelen(const char *buffer, unsigned long size)
@@ -4541,7 +4542,8 @@ static int apply_patch(struct apply_state *state,
 	int skipped_patch = 0;
 
 	state->patch_input_file = filename;
-	read_patch_file(&buf, fd);
+	if (read_patch_file(&buf, fd))
+		return -1;
 	offset = 0;
 	while (offset < buf.len) {
 		struct patch *patch;
-- 
2.8.1.300.g5fed0c0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help