Re: [PATCH 1/2] xdiff-interface: allow consume function to quit early by returning non-zero
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Aug 17, 2011, 02:26 UTC
- Message-ID
- <CACsJy8AYskdAvLViEjOCmxas2O=NVGWz-Pj6GQS42LZbKr1U_A@mail.gmail.com>
- In-Reply-To
- <7v39h2laxb.fsf@alter.siamese.dyndns.org>
2011/8/16 Junio C Hamano <gitster@pobox.com>:
Show 6 quoted lines
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes: > >> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> >> --- > > What is this for? No explanation?
Um.. for stopping emitting diff when the consumer feels enough and wants no more. Will update.
Show 15 quoted lines
>> @@ -64,10 +64,12 @@ static void consume_one(void *priv_, char *s, unsigned long size) >> unsigned long this_size; >> ep = memchr(s, '\n', size); >> this_size = (ep == NULL) ? size : (ep - s + 1); >> - priv->consume(priv->consume_callback_data, s, this_size); >> + if (priv->consume(priv->consume_callback_data, s, this_size)) >> + return -1; >> size -= this_size; >> s += this_size; >> } >> + return 0; >> } > > Returning a negative value implies that this is an error condition. Should > all "non-zero" returns from ->consume necessarily be considered error?
Perhaps negative values only, like how xdiff treats it.
-- Duy