🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
2 messages
2 total messages Started by Johannes Sixt Tue, 13 Oct 2026 05:34
Re: [PATCH v3/RFC 1/1] read-cache: do not trust a size change when conversion is active
#382
Author: Johannes Sixt
Date: Tue, 13 Oct 2026 05:34
31 lines
6154 bytes
Am 12.10.26 um 19:56 schrieb tboegi@web.de:
> @@ -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
> + * being true as soon as the path is run through a clean filter:

I cannot agree with this reasoning. The index is a cache of the stat
information. The size recorded in the index is only used as a clue
whether the file was changed or not. It does *not* record the size of
the data that the object database holds for the blob.

If your analysis found that, after the content was `git add`-ed, the
size in the index is *not* identical to the size taken from the
filesystem, then the problem is that an incorrect size was put into the
index, and not that the size between the blob data in the database and
the filesystem's file are different (and unusable).

> + * 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.
> + */

-- Hannes
Re: [PATCH v3/RFC 1/1] read-cache: do not trust a size change when conversion is active
#384
Author: Curtis Smith
Date: Tue, 13 Oct 2026 06:48
59 lines
11544 bytes
Johannes Sixt <j6t@kdbg.org> writes:

> I cannot agree with this reasoning. The index is a cache of the stat
> information. The size recorded in the index is only used as a clue
> whether the file was changed or not. It does *not* record the size of
> the data that the object database holds for the blob.

Agreed, and that comment is worded badly.  The size in the index is
correct here: it is the size of the LF file as it was checked out or
added.  The tool then rewrites the file with CRLF endings, so the
size on disk really does change.

The problem is what ie_modified() concludes from that.  A size change
proves that the bytes in the working tree changed.  Without
conversion, that means the content Git would record changed too.
With conversion it does not: the CRLF file converts to the same
blob, which is why "git diff" shows nothing.

v4 has no such comment, and its log message says it this way.

On Mon, Oct 12, 2026 at 11:34 PM Johannes Sixt <j6t@kdbg.org> wrote:
>
> Am 12.10.26 um 19:56 schrieb tboegi@web.de:
> > @@ -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
> > + * being true as soon as the path is run through a clean filter:
>
> I cannot agree with this reasoning. The index is a cache of the stat
> information. The size recorded in the index is only used as a clue
> whether the file was changed or not. It does *not* record the size of
> the data that the object database holds for the blob.
>
> If your analysis found that, after the content was `git add`-ed, the
> size in the index is *not* identical to the size taken from the
> filesystem, then the problem is that an incorrect size was put into the
> index, and not that the size between the blob data in the database and
> the filesystem's file are different (and unusable).
>
> > + * 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.
> > + */
>
> -- Hannes
>
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