Re: [PATCH v2 52/94] builtin/apply: read_patch_file() return -1 instead of die()ing
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 16, 2016, 01:56 UTC
- Message-ID
- <CAPig+cQrLZiwZm34+hFZXPmFGVtyPCvCEv4TwsTeL__cfzuORA@mail.gmail.com>
- In-Reply-To
- <20160511131745.2914-53-chriscool@tuxfamily.org>
On Wed, May 11, 2016 at 9:17 AM, Christian Couder <christian.couder@gmail.com> wrote:
Show 14 quoted lines
> To libify `git apply` functionality we have to signal errors to the
> caller instead of die()ing. Let's do that by using error() instead
> of die()ing in read_patch_file().
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> diff --git a/builtin/apply.c b/builtin/apply.c
> @@ -445,10 +445,10 @@ static void say_patch_name(FILE *output, const char *fmt, struct patch *patch)
> -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));When Duy's nd/error-errno series, which is in 'next', gets promoted to 'master', then this could become:
return error_errno(...);
Show 8 quoted lines
> /* > * Make sure that we have some slop in the buffer > @@ -457,6 +457,7 @@ static void read_patch_file(struct strbuf *sb, int fd) > */ > strbuf_grow(sb, SLOP); > memset(sb->buf + sb->len, 0, SLOP); > + return 0; > }