git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Make attributes "-diff" and "diff" work as advertized

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 8, 2007, 00:08 UTC
Message-ID
<7vy7hr69ky.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0707071749220.4093@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 22 quoted lines
> diff --git a/diff.c b/diff.c
> index 21e61af..e92db5c 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1170,13 +1170,19 @@ static void diff_filespec_check_attr(struct diff_filespec *one)
>  	one->is_binary = 0;
>  	one->funcname_pattern_ident = NULL;
>  
> +	if (!one->data && DIFF_FILE_VALID(one))
> +		diff_populate_filespec(one, 0);
> +
> +	if (one->data)
> +		one->is_binary = buffer_is_binary(one->data, one->size);
> +
>  	if (!git_checkattr(one->path, 1, &attr_diff_check)) {
>  		const char *value;
>  
>  		/* binaryness */
>  		value = attr_diff_check.value;
>  		if (ATTR_TRUE(value))
> -			;
> +			one->is_binary = 0;

I wanted to make sure we do not have to read data and run buffer_is_binary() when attribute says we do not have to. I wonder why moving the code around makes the difference.

Show 15 quoted lines
>  		else if (ATTR_FALSE(value))
>  			one->is_binary = 1;
>  
> @@ -1186,13 +1192,6 @@ static void diff_filespec_check_attr(struct diff_filespec *one)
>  		else
>  			one->funcname_pattern_ident = value;
>  	}
> -
> -	if (!one->data && DIFF_FILE_VALID(one))
> -		diff_populate_filespec(one, 0);
> -
> -	if (one->data)
> -		one->is_binary = buffer_is_binary(one->data, one->size);
> -
>  }

Ah, I see, because these are done unconditionally. That was silly of me.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 3 in “Make attributes "-diff" and "diff" work as advertized”
  1. Make attributes "-diff" and "diff" work as advertizedJohannes Schindelin, Jul 7, 2007
  2. Junio C HamanoJul 8, 2007
  3. Johannes SchindelinJul 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.