Re: [PATCH v9 03/41] builtin/apply: make apply_patch() return -1 or -128 instead of die()ing
- From
Stefan Beller <sbeller@google.com>
- Date
- Aug 1, 2016, 16:16 UTC
- Message-ID
- <CAGZ79kY+VHLspQBm+cTarY8NR2_iOewUiVZVv79DHLVsv7v-Qg@mail.gmail.com>
- In-Reply-To
- <20160730172509.22939-4-chriscool@tuxfamily.org>
On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder <christian.couder@gmail.com> wrote:
Show 7 quoted lines
> + * Try to apply a patch. > + * > + * Returns: > + * -128 if a bad error happened (like patch unreadable) > + * -1 if patch did not apply and user cannot deal with it > + * 0 if the patch applied > + * 1 if the patch did not apply but user might fix it
I stopped and wondered when reading this comment, what the difference between -1 and 1 is, as the user is not part of this function.
When reading the code, this makes sense, though. So -1 is returned when the user set `apply_with_reject`, 1 otherwise? So the user told us upfront how to deal with certain errors.
What is a "bad" error, that generates a -128? (Only when the patch is not syntactically correct? Or are there other -128 errors as well?)
Maybe: Returns zero on success, non zero for failing to apply a patch negative values for hard errors, e.g. unreadable patc.
Though this is less precise, as it doesn't differentiate between -1 and -128. I dunno.
(These are just musings that should not stop going forward with this patch, just some thoughts on the precision of a comment)
Thanks, Stefan