Thread (48 messages) 48 messages, 2 authors, 2016-08-08

Re: [PATCH v9 03/41] builtin/apply: make apply_patch() return -1 or -128 instead of die()ing

From: Stefan Beller <hidden>
Date: 2016-08-01 16:43:24

On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
+ * 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help