Re: [PATCH v7 02/40] builtin/apply: make apply_patch() return -1 instead of die()ing

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

 



On Tue, Jun 14, 2016 at 12:55 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Christian Couder <christian.couder@xxxxxxxxx> writes:
>
>> +/*
>> + * Try to apply a patch.
>> + *
>> + * Returns:
>> + *  -1 if an error happened
>> + *   0 if the patch applied
>> + *   1 if the patch did not apply
>> + */
>>  static int apply_patch(struct apply_state *state,
>>                      int fd,
>>                      const char *filename,
>> @@ -4413,6 +4421,7 @@ static int apply_patch(struct apply_state *state,
>>       struct strbuf buf = STRBUF_INIT; /* owns the patch text */
>>       struct patch *list = NULL, **listp = &list;
>>       int skipped_patch = 0;
>> +     int res = 0;
>>
>>       state->patch_input_file = filename;
>>       read_patch_file(&buf, fd);
>> @@ -4445,8 +4454,10 @@ static int apply_patch(struct apply_state *state,
>>               offset += nr;
>>       }
>>
>> -     if (!list && !skipped_patch)
>> -             die(_("unrecognized input"));
>> +     if (!list && !skipped_patch) {
>> +             res = error(_("unrecognized input"));
>> +             goto end;
>> +     }
>
> Before this patch, the program said "fatal: $message" and exited
> with status = 128.  All these changes in this step modifies the
> external behaviour and make it say "error: $message" and exit with
> status = 1 (at least the caller in apply_all_patches() does so).
>
> Will that be an issue for the calling scripts?

Hopefully the scripts don't check the specific error code and message.

I will add something about this in the commit message.

Do you think something else that should be done about this?
--
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]