Git development
 help / color / mirror / Atom feed
From: tboegi@web.de
To: tboegi@web.de, git@vger.kernel.org, curtis.allen.smith@gmail.com
Subject: [PATCH/RFC 1/1] read-cache: optimize  file size change when conversion is active
Date: Mon, 26 Oct 2026 20:25:19 +0100	[thread overview]
Message-ID: <20261026192519.15860-1-tboegi@web.de> (raw)
In-Reply-To: <xmqqwm1no29m.fsf@gitster.g>

From: Torsten Bögershausen <tboegi@web.de>

Commit
"read-cache: do not trust a size change when conversion is active"

corrected the case when the file size in the worktree has changed.
Input filters may convert worktree files with different sizes into the
same blob.

Optimize the new code:
The call to would_convert_to_git() can be skipped since the same check
is done in ce_compare_data()  for regular files, which is called from
ce_modified_check_fs().

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
 read-cache.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 70f4787de9..3497997bda 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -9,7 +9,6 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "convert.h"
 #include "date.h"
 #include "diff.h"
 #include "diffcore.h"
@@ -456,13 +455,12 @@ int ie_modified(struct index_state *istate,
 		return changed;
 
 	/*
-	 * Immediately after read-tree or update-index --cacheinfo,
-	 * the length field is zero, as we have never even read the
-	 * lstat(2) information once, and we cannot trust DATA_CHANGED
-	 * returned by ie_match_stat() which in turn was returned by
-	 * ce_match_stat_basic() to signal that the filesize of the
-	 * blob changed.  We have to actually go to the filesystem to
-	 * see if the contents match, and if so, should answer "unchanged".
+	 * When the length field of a regular file is zero or changed,
+	 * this does not necessarily mean a changed blob in the index.
+	 * All input filters (CRLF line endings, clean filter..)
+	 * need to be applied followed by a hash and oideq().
+	 * This is done in ce_modified_check_fs() below,
+	 * which calls ce_compare_data().
 	 *
 	 * The logic does not apply to gitlinks, as ce_match_stat_basic()
 	 * already has checked the actual HEAD from the filesystem in the
@@ -479,10 +477,9 @@ int ie_modified(struct index_state *istate,
 	     * So let's just special-case symlinks with a target path length
 	     * (i.e. `sd_size`) of 4096 and force them to be re-checked.
 	     */
-	    (!S_ISLNK(st->st_mode) || ce->ce_stat_data.sd_size != MAX_PATH) &&
+	    (ce->ce_stat_data.sd_size != MAX_PATH) &&
 #endif
-	    (S_ISGITLINK(ce->ce_mode) || ce->ce_stat_data.sd_size != 0) &&
-	    !(S_ISREG(st->st_mode) && would_convert_to_git(istate, ce->name)))
+	    (S_ISGITLINK(ce->ce_mode)))
 		return changed;
 
 	changed_fs = ce_modified_check_fs(istate, ce, st);
-- 
2.53.0.154.g7c02d39fc2


      parent reply	other threads:[~2026-10-26 19:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-11 19:51 [PATCH v2 1/2] utf8.c: Prepare workaround for iconv under macOS 14/15 tboegi
2026-01-12  4:58 ` Junio C Hamano
2026-01-12 16:25   ` [PATCH v3 0/2] Workaround " tboegi
2026-01-12 16:25   ` [PATCH v3 1/2] utf8.c: Prepare workaround " tboegi
2026-01-12 16:25   ` [PATCH v3 2/2] utf8.c: Enable " tboegi
2026-10-12 17:56   ` [PATCH v3/RFC 0/1] read-cache: do not trust a size change when conversion tboegi
2026-10-12 17:56   ` [PATCH v3/RFC 1/1] read-cache: do not trust a size change when conversion is active tboegi
2026-10-12 19:11     ` Junio C Hamano
2026-10-13  1:29       ` Junio C Hamano
2026-10-13  6:45         ` Curtis Smith
2026-10-13  5:34     ` Johannes Sixt
2026-10-13  6:48       ` Curtis Smith
2026-10-13  6:58     ` [PATCH v4] " Curtis Allen Smith
2026-10-13  9:44       ` Phillip Wood
2026-10-13 17:57         ` Curtis Smith
2026-10-13 18:01       ` Torsten Bögershausen
2026-10-13 18:02       ` [PATCH v5] " Curtis Allen Smith
2026-10-13 20:29         ` Junio C Hamano
2026-10-18 11:18           ` Torsten Bögershausen
2026-10-19  5:57             ` Junio C Hamano
2026-10-20 20:56         ` Torsten Bögershausen
2026-10-26 19:25   ` [PATCH/RFC 0/1] More cs/read-cache-conversion-size tboegi
2026-10-26 19:25   ` tboegi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261026192519.15860-1-tboegi@web.de \
    --to=tboegi@web.de \
    --cc=curtis.allen.smith@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox