Re: [PATCH v9 2/6] convert.c: stream and early out
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 9, 2016, 20:29 UTC
- Message-ID
- <xmqqtwi7t1of.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1462601460-23543-1-git-send-email-tboegi@web.de>
tboegi@web.de writes:
> + if (stats->stat_bits & earlyout) > + break; /* We found what we have been searching for */
Are we sure if our callers are only interested in just one bit at a time? Otherwise, if we want to ensure all of the given bits are set,
if ((stats->stat_bits & earlyout) == earlyout)
break;would be necessary. Otherwise, the "only one bit" assumption on the "earlyout" parameter somehow needs to be documented in the code.
> + ssize_t readlen = read(fd, buf, sizeof(buf));
xread() to automatically retry an interrupted read?
Show 12 quoted lines
> @@ -309,11 +354,13 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
> {
> char *to_free = NULL;
> struct text_stat stats;
> + unsigned earlyout = CONVERT_STAT_BITS_TXT_CRLF | CONVERT_STAT_BITS_BIN;
> +
>
> if (!len || output_eol(crlf_action) != EOL_CRLF)
> return 0;
>
> - gather_stats(src, len, &stats);
> + gather_stats(src, len, &stats, earlyout);Oops, this answers my earlier question, no?