Subject: Re: [PATCH v9 2/6] convert.c: stream and early out

From: Junio C Hamano <[email-masked]>
Date: Mon, 09 May 2016 13:29:52 -0700

[email-masked] 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?

> @@ -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?