🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
3 messages
3 total messages Started by Junio C Hamano Mon, 12 Oct 2026 19:11
Re: [PATCH v3/RFC 1/1] read-cache: do not trust a size change when conversion is active
#353
Author: Junio C Hamano
Date: Mon, 12 Oct 2026 19:11
108 lines
13281 bytes
tboegi@web.de writes:

> From: Torsten Bögershausen <tboegi@web.de>
>
> "git status" can report a file as modified while "git diff" and
> "git add", which both run the clean filter, agree its contents are
> unchanged:
>
> 	git init t && cd t
> 	printf '* text eol=lf\n' >.gitattributes
> 	printf 'one\ntwo\nthree\n' >file.txt
> 	git add . && git commit -m init
>
> 	printf 'one\r\ntwo\r\nthree\r\n' >file.txt
>
> 	git status --short      # ->  M file.txt
> 	git diff                # -> empty
> 	git add file.txt        # -> updates the index
>
> Note that "clean filter" here means the "clean filter" and CRLF conversion,
> and all converting of a file in the worktree into the index.
>
> Problems that have been found in real live:

"in real life"?

>   Tools that rewrites unchanged files in native line endings e.g.
>     javadoc, code generators, formatters and some editors change
>     the size of every file it touches.

That is not just size but contents are changed, no?

>   Editors that insist to replace 4 space with a TAB,
>     even if the file is changed manually forth and back -

"back and forth"?

>     Using a clean filter that changes the TAB back into space when
>     committing will cause the same confusion.

This also changes size as a result of changing contents.

> `git status` and `git diff` disagree because ie_modified()
> in read-cache.c concludes that a file is modified
> as soon as the size has changed.

"when size differs, without looking at the contents"?

> Signed-off-by: Curtis Allen Smith <curtis.allen.smith@gmail.com>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>

How is the collaboration going here, Have you taken over the series,
or are you two working together on the topic (or I take that your
intention to CC Curtis is to work together starting with this
version)?

I am wondering if we want co-authored-by or similar when we lose the
RFC status.

> ---
>  read-cache.c    | 25 ++++++++++++++++++++++++-
>  t/t0020-crlf.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 69 insertions(+), 1 deletion(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index c4cf08a3a3..9aebe4c394 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -9,6 +9,7 @@
>  
>  #include "git-compat-util.h"
>  #include "config.h"
> +#include "convert.h"
>  #include "date.h"
>  #include "diff.h"
>  #include "diffcore.h"
> @@ -438,6 +439,27 @@ int ie_match_stat(struct index_state *istate,
>  	return changed;
>  }
>  
> +/*
> + * A difference between the size of the file in the working tree and the
> + * size recorded for it in the index proves that the contents changed
> + * only as long as the two are byte-for-byte comparable.  That stops

"compatable" -> "identical"?

> + * being true as soon as the path is run through a clean filter:
> + * rewriting a file with CRLF endings under "text eol=lf", for example,
> + * changes its size in the working tree without changing the blob Git
> + * would record for it.  For such a path the only way to tell is to read
> + * the contents and convert them, which is what we already do when only
> + * the mtime changed.
> + */
> +static int size_change_is_conclusive(struct index_state *istate,
> +				     const struct cache_entry *ce,
> +				     struct stat *st)
> +{
> +	if (!S_ISREG(st->st_mode))
> +		return 1;
> +
> +	return !would_convert_to_git(istate, ce->name);
> +}

Wooo, that is surprisingly simple.  Even attribute look-up is not
free.  How much overhead are we adding to the case where no clean
filter is involved, I wonder?
Re: [PATCH v3/RFC 1/1] read-cache: do not trust a size change when conversion is active
#377
Author: Junio C Hamano
Date: Tue, 13 Oct 2026 01:29
32 lines
10959 bytes
Junio C Hamano <gitster@pobox.com> writes:

> tboegi@web.de writes:
>
>> From: Torsten Bögershausen <tboegi@web.de>
>> ...
>> Signed-off-by: Curtis Allen Smith <curtis.allen.smith@gmail.com>
>> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
>
> How is the collaboration going here, Have you taken over the series,
> or are you two working together on the topic (or I take that your
> intention to CC Curtis is to work together starting with this
> version)?
>
> I am wondering if we want co-authored-by or similar when we lose the
> RFC status.

If you two are collaborating outside the mailing list, that would be
fine and I would have no reason to complain.  But such collaboration
is invisible to others, of course, so I would like to double-check
that you are not unilaterally taking over the topic.  Can you
confirm that you are working well together, or say something
similar, before we proceed to other technical points?

This is a tangent, but it is the reason why my mailer settings
drop into the trash all incoming Git-related messages that are
addressed only to me without CC'ing the list.  This forces me to
resist the temptation to collude with selected others behind
closed doors.

Thanks.
Re: [PATCH v3/RFC 1/1] read-cache: do not trust a size change when conversion is active
#381
Author: Curtis Smith
Date: Tue, 13 Oct 2026 06:45
64 lines
11799 bytes
Junio C Hamano <gitster@pobox.com> writes:

> If you two are collaborating outside the mailing list, that would be
> fine and I would have no reason to complain.  But such collaboration
> is invisible to others, of course, so I would like to double-check
> that you are not unilaterally taking over the topic.

We are not collaborating off the list, and Torsten did not ask me
before sending v3.  v3 is my v1 patch 1 with the optimization taken
out, but it keeps the size_change_is_conclusive() helper.  In my
reply to you on Saturday I proposed the fix inlined into the
condition in ie_modified() instead, with no new function.

I would like to keep the topic.  v4 follows in this thread: that
inlined fix, my tests, a short log message, and Torsten credited with
Helped-by.  Thanks, Torsten, for the review.

From your earlier message:

> Wooo, that is surprisingly simple.  Even attribute look-up is not
> free.  How much overhead are we adding to the case where no clean
> filter is involved, I wonder?

The lookup is the last test in the "changed & DATA_CHANGED"
condition, so it runs only for a path whose size changed.  A clean
tree never reaches it.  With no conversion configured, "git status"
on 10000 files with a size change takes 26ms on stock git and 24ms
with the fix.  The full numbers are below the "---" in v4.

On Mon, Oct 12, 2026 at 7:29 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Junio C Hamano <gitster@pobox.com> writes:
>
> > tboegi@web.de writes:
> >
> >> From: Torsten Bögershausen <tboegi@web.de>
> >> ...
> >> Signed-off-by: Curtis Allen Smith <curtis.allen.smith@gmail.com>
> >> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> >
> > How is the collaboration going here, Have you taken over the series,
> > or are you two working together on the topic (or I take that your
> > intention to CC Curtis is to work together starting with this
> > version)?
> >
> > I am wondering if we want co-authored-by or similar when we lose the
> > RFC status.
>
> If you two are collaborating outside the mailing list, that would be
> fine and I would have no reason to complain.  But such collaboration
> is invisible to others, of course, so I would like to double-check
> that you are not unilaterally taking over the topic.  Can you
> confirm that you are working well together, or say something
> similar, before we proceed to other technical points?
>
> This is a tangent, but it is the reason why my mailer settings
> drop into the trash all incoming Git-related messages that are
> addressed only to me without CC'ing the list.  This forces me to
> resist the temptation to collude with selected others behind
> closed doors.
>
> Thanks.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads