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.