From: Junio C Hamano <gitster@pobox.com>
To: Curtis Allen Smith <curtis.allen.smith@gmail.com>
Cc: git@vger.kernel.org, "Torsten Bögershausen" <tboegi@web.de>,
"Phillip Wood" <phillip.wood123@gmail.com>
Subject: Re: [PATCH v5] read-cache: do not trust a size change when conversion is active
Date: Tue, 13 Oct 2026 13:29:46 -0700 [thread overview]
Message-ID: <xmqq1p9twdhh.fsf@gitster.g> (raw)
In-Reply-To: <20261013180206.610-1-curtis.allen.smith@gmail.com> (Curtis Allen Smith's message of "Tue, 13 Oct 2026 12:02:04 -0600")
Curtis Allen Smith <curtis.allen.smith@gmail.com> writes:
> git status --short # -> M file.txt
> git diff # -> empty
> git add file.txt # -> nothing to commit
I do not think "git add" would ever say nothing to commit.
git commit file.txt
may say "nothing added to commit" when there is no modification made
to file.txt to indicate that there is no change worth comitting.
There are code paths that make performance trade-offs (see the
introductory part of Documentation/technical/racy-git.adoc for
examples) and are designed to tolerate false positives from
ie_modified(), filtering them out themselves. I am somewhat
hesitant to butcher code paths at this low level to make
unconditional changes that reduce false positives without thinking
things through. For example, we may want to disable this new code
when the 'CE_MATCH_RACY_IS_DIRTY' bit is set. But the goal
nevertheless should be to avoid surfacing these false positives,
which are deliberately allowed as performance trade-offs, to code
paths like 'git status' that do not further filter them out (as you
demonstrated above).
There may be other cases where this patch unknowingly breaks
carefully made performance trade-offs.
> diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
> index fd1cae09e..9c8d07cfc 100755
> --- a/t/t0020-crlf.sh
> +++ b/t/t0020-crlf.sh
> @@ -397,4 +397,43 @@ test_expect_success 'New CRLF file gets LF in repo' '
> test_cmp alllf alllf2
> '
>
> +test_expect_success 'status does not report a CRLF-only rewrite as modified' '
> + test_when_finished "git reset --hard autocrlf-checkpoint" &&
> + echo "eol.txt text eol=lf" >.gitattributes &&
> + printf "one\ntwo\nthree\n" >eol.txt &&
> + git add .gitattributes eol.txt &&
> + git commit -m "eol.txt" &&
> +
> + # a generator rewrites the file with CRLF, same content
> + printf "one\r\ntwo\r\nthree\r\n" >eol.txt &&
> + git status --porcelain -uno >actual &&
> + test_must_be_empty actual &&
> + git diff --exit-code &&
> +
> + # a real change is still reported
> + printf "one\r\ntwo\r\nfour\r\n" >eol.txt &&
> + git status --porcelain -uno >actual &&
> + echo " M eol.txt" >expect &&
> + test_cmp expect actual
> +'
>
> +test_expect_success 'status sees through a CRLF rewrite of a file with a lone CR' '
> + test_when_finished "git reset --hard autocrlf-checkpoint" &&
> + echo "cr.txt text eol=lf" >.gitattributes &&
> + printf "one\rtwo\nthree\n" >cr.txt &&
> + git add .gitattributes cr.txt &&
> + git commit -m "cr.txt" &&
> +
> + # "git add" keeps the lone CR and drops the others
> + printf "one\rtwo\r\nthree\r\n" >cr.txt &&
> + git status --porcelain -uno >actual &&
> + test_must_be_empty actual &&
> +
> + # the converted length matches the blob, the content does not
> + printf "one\rtwo\nthrEE\r\n" >cr.txt &&
> + git status --porcelain -uno >actual &&
> + echo " M cr.txt" >expect &&
> + test_cmp expect actual
> +'
Tests like these may run fast enough to trigger "oops, we may be in
the racy-git situation so make the comparison differently from the
normal code paths (usually spends extra cycles to compare the
contents)", which may hide existing problems, so these tests need to
be extra careful.
> +
> test_done
Thanks.
prev parent reply other threads:[~2026-10-13 20:29 UTC|newest]
Thread overview: 18+ 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 [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=xmqq1p9twdhh.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=curtis.allen.smith@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood123@gmail.com \
--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