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

Re: [PATCH 1/2] read-cache: do not trust a size change when conversion is active

From
CSCurtis Smith <curtis.allen.smith@gmail.com>
Date
Oct 10, 2026, 17:57 UTC
Message-ID
<CACnh8rJznfBDS9tfG49mFqB4J05KbxRWUh_q-OaCc5zfr3pgDw@mail.gmail.com>
In-Reply-To
<xmqqfqyfwi20.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> That's overly verbose.
Will fix.
> ... Why do we need to add a new function that compares converted
> data?
We don't.  The fix is only this:
--- 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"
@@ -480,7 +481,8 @@ int ie_modified(struct index_state *istate,
-        (S_ISGITLINK(ce->ce_mode) || ce->ce_stat_data.sd_size != 0))
+        (S_ISGITLINK(ce->ce_mode) || ce->ce_stat_data.sd_size != 0) &&
+        !(S_ISREG(st->st_mode) && would_convert_to_git(istate, ce->name)))
         return changed;

The existing index_fd() path then does the comparison, as it does when
only the mtime changed.  I have built and tested the fix by itself on
top of 6de20f6: the new t0020 tests pass with it and fail without it.

The rest is an optimization that skips converting and hashing when the
length already rules out a match.  I added it, and patch 2, expecting
cost to be the objection.  It belongs in a separate patch.

Without it, status on 200 modified 1 MB files under "* text=auto"
takes 507ms instead of 3ms, and on 10000 modified 2.6 KB files 129ms
instead of 20ms -- the same work the mtime branch already does.

After the first run, status on 10000 CRLF-rewritten 2.6 KB files
drops from 21ms to 5ms, because the index records their new sizes.

Shall I send v2 as only the fix, with a short log message, and offer
the rest separately if wanted?
Previous: Junio C HamanoNext: Curtis Allen Smith
Message 4 of 5 in “status: agree with diff and add when conversion is active”
  1. 0/2 status: agree with diff and add when conversion is activeCurtis Allen Smith, Oct 8, 2026
  2. 1/2 read-cache: do not trust a size change when conversion is activeCurtis Allen Smith, Oct 8, 2026
  3. Junio C HamanoOct 9, 2026
  4. Curtis SmithOct 10, 2026
  5. 2/2 core: add core.convertAwareStatus to opt out of the content checkCurtis Allen Smith, Oct 8, 2026

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.