On Mon, May 16, 2016 at 3:56 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 21 quoted lines
> On Wed, May 11, 2016 at 9:17 AM, Christian Couder
> <christian.couder@gmail.com> 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@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(...);