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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 11, 2016 at 9:17 AM, Christian Couder
<christian.couder@xxxxxxxxx> wrote:
> 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@xxxxxxxxxxxxx>
> ---
> 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(...);

>         /*
>          * 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;
>  }
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]