Re: [PATCH v7 02/40] builtin/apply: make apply_patch() return -1 instead of die()ing
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 13, 2016, 22:55 UTC
- Message-ID
- <xmqq37ogbswg.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160613160942.1806-3-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
Show 29 quoted lines
> +/*
> + * 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?