Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: tboegi@web.de
Cc: git@vger.kernel.org,  curtis.allen.smith@gmail.com
Subject: Re: [PATCH/RESEND v6 1/2] read-cache: do not trust a size change when conversion is active
Date: Fri, 27 Nov 2026 19:28:57 -0800	[thread overview]
Message-ID: <xmqq8q2dzlae.fsf@gitster.g> (raw)
In-Reply-To: <20261127194241.10085-1-tboegi@web.de> (tboegi@web.de's message of "Fri, 27 Nov 2026 20:42:41 +0100")

tboegi@web.de writes:

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

I would have pretended that the patch was relayed directly from the list
message by omitting my sign-off from the list if I were you, but I
presume that the above accurately records the chain of custody by
stating that you did not pick up Curtis's message from the list but
picked up the copy I queued to my tree (and later got timed out).  What
we see above is not wrong, but I do not know if the distinction matters.

>  read-cache.c    |  4 +++-
>  t/t0020-crlf.sh | 39 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index c4cf08a3a3..70f4787de9 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"
> @@ -480,7 +481,8 @@ int ie_modified(struct index_state *istate,
>  	     */
>  	    (!S_ISLNK(st->st_mode) || ce->ce_stat_data.sd_size != MAX_PATH) &&
>  #endif
> -	    (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;
>  
>  	changed_fs = ce_modified_check_fs(istate, ce, st);

Keeping this check in ie_modified() rather than ie_match_stat() is the
right call, I think.  Because preload_index() calls ie_match_stat() from
worker threads with CE_MATCH_RACY_IS_DIRTY, attribute lookups must not
run there.

In contrast, none of the callers of ie_modified() (refresh_cache_ent(),
builtin/ls-files.c, builtin/mv.c, and is_staging_gitmodules_ok() in
submodule.c) pass CE_MATCH_RACY_IS_DIRTY.

When a regular file's size changes and would_convert_to_git() returns
true (covering clean filters, working-tree-encoding, CRLF conversion,
and ident), ie_modified() falls through to ce_modified_check_fs(), which
calls ce_compare_data() and index_fd() to convert and hash the file.  If
the resulting object name matches the index entry, ie_modified() returns
0 and refresh_cache_ent() calls fill_stat_cache_info() to update the
cached stat data, so subsequent runs match on lstat(2) alone.

Files without conversion still take the fast early return on size
mismatch.  OK.

It might be worth adding a bit to the comment above this conditional in
ie_modified() to explain why DATA_CHANGED is ignored when conversion is
active on a regular file, since the existing comment only mentions a
zero '.sd_size' after read-tree or update-index.

Thanks.

  reply	other threads:[~2026-11-28  3:29 UTC|newest]

Thread overview: 37+ 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   ` [PATCH/RFC 1/1] read-cache: optimize file size change when conversion is active tboegi
2026-11-27 19:42   ` [PATCH/RESEND v6 0/2] read-cache: do not trust a " tboegi
2026-11-28  4:09     ` Junio C Hamano
2026-11-27 19:42   ` [PATCH/RESEND v6 1/2] " tboegi
2026-11-28  3:28     ` Junio C Hamano [this message]
2026-11-28  7:38       ` Torsten Bögershausen
2026-11-29 17:44         ` Junio C Hamano
2026-11-27 19:42   ` [PATCH/RESEND v6 2/2] read-cache: optimize file " tboegi
2026-11-28  3:38     ` Junio C Hamano
2026-11-29 15:28   ` [PATCH v7 1/1] read-cache: do not trust a " tboegi
2026-11-29 20:13     ` Junio C Hamano
2026-11-29 21:53       ` Junio C Hamano
2026-11-29 20:18     ` Junio C Hamano
2026-11-29 22:05       ` Torsten Bögershausen
2026-11-29 22:10         ` Junio C Hamano

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=xmqq8q2dzlae.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=curtis.allen.smith@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /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