From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795983536; b=kVZXcLwKZQHibcBnKSY70OiJasJiZhYb0Y4TEc88XlDsZtUKzdzbBIeOh67DjVw9fS8l sEEjYQ8XBZ+qz5apN2YA9x2NxmHVQIYKynjmwb8ME7bk+q/pI52ssTzQ0552b74Tjanv7 SgNw65YUKcZ2mAbCAueEsKCOyx6sHA4hzbbY+Pbxlg5IPpyyB2BVoKdUkhP10RP2IpjYy RpRyE9SXdL5Bd07X4ZZhR8UQvo5KtP2U0YREbU+dRmD5oPdD9JQybZjOA1uLJFvdAK0rB NdRT9raB1K9roTR01trQt/k8bknMGCIBv9FOP34Lml4vT74uqAzNZgIE5I7ZBkQqDkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795983536; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:In-Reply-To:References:User-Agent:Date: Message-ID:MIME-Version:Content-Type; bh=fdKCLyHV0+788+3LS6q3rs+x1iWM1iNwr/lkiSPFYlw=; b=QgUMe+dIkZ+Hc1k4l4qnnI8nj9xuzkI2CmNQYweA96R6+dRXmpRSJv43aTAPYxX1JL8W oSd/XcQ851tLhz5ER0tsQ8bei60qsgPlQBH0TuIUM+E8HcP+n6W8aptF4FvEz8xgwH1U0 m9KIJLl5pjDCfXwsIf+8iH/RF6k4ECqyZpDWrGhCdxpf9AlaLEmPo4Mfq9m4kYHQfgziv G6RZiVjqMm2Qm7JrSzmLe381oTsJ2O1+QGTU9V5Yzi3RflntGyUGeNj020QrSARzCkJMc B4Hvn5I/llptEVVzJaI0Rb4cmq0PpOgWzPA6kO4S6qS3HWv0Fl7/0Xz/x1+UpcSTbKA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=Dsepyilw; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b="m4WDW/P5"; arc=none smtp.remote-ip=103.168.172.151 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91DA4606A31C for ; Sun, 29 Nov 2026 20:18:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 91DA4606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=Dsepyilw; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=m4WDW/P5 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 7AEF4EC0970 for ; Sun, 29 Nov 2026 15:18:54 -0500 (EST) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-06.internal (MEProxy); Sun, 29 Nov 2026 15:18:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1795983534; x=1796069934; bh=fdKCLyHV0+ 788+3LS6q3rs+x1iWM1iNwr/lkiSPFYlw=; b=DsepyilwF/V0wBAtby1+qBIhXP SV4lAlKIDiUXUO5nZjPz+NNm+/41Q+IVCpV/yZ3l+T3yU75p0AZzBgynCh86aiR5 6wQT+F3pbV2pmdSsIP63kB7AVySNnQp3C325Jnc9yi2wo64OhPSbI3li5ZVQV/7D ZWTIQJFrr73U0EWs/2sm7tuwLp9bQI55EBPO/2G+OSs04qBzPHNwLmZCHFztuy71 VHszr62XUTwnTxFaO8UM0iVT1PDge9cxsGasXTFdZcrAY+rlSUXmXbqxYJfTeMo2 ZBq3yX/15W3dpy4NoXzvzy1COSHcKVU4zRq5hQUfkiwiiT/Fa71PZh++cXDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1795983534; x=1796069934; bh=fdKCLyHV0+788+3LS6q3rs+x1iWM1iNwr/l kiSPFYlw=; b=m4WDW/P5RzZQgrkARA6XZmPlmijE5gAuLWtxHAWdShwjylMVEz6 FFUpUQaITRI2+7+FshKidM1r5M4mBK4l4dMVJ2N48lO1xJs2rSG42AtS+uYCWbsq 3Afq358zLJgZdKdWdFjLoRcpjl1ZFKc0u6yLq6mIJabrmgUyQ8ktRHn41Cg2SguK te6516DecBOCtVR4fUHThMK1f7iWdjr+v1kDIBbHoxmdST8c4Q8oe7K3ToI1+s4l 0vS1b2Fa6kPQnagftsSkFFn1xMyzzFSaep0+1ZaiK5XVN6T61uKy1pi5Mv3KYUQa 2VvX3k6TGyVepWhOtTsCX6BfGlgM9RMN8yg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pobox.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795983534; d=pobox.com; mf=PGdpdHN0ZXJAcG9ib3guY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:IOX/VYFTOUaA9Yu9LhPLbpLkHSKSc5xcpZOdMHkjHEtRIR4 GzcQJ8nAgKlJNDc0FgU+ELXJA62OJBtQyl7Q4ZZEwS/VnnByOzvIUhEKde7BMLIk 9zvUwultoLDaXOoz+rTo5z8fMlLmdSnZVDlrhyMsojdHPAdtnfFd/JDGSWhDJgFi yDp8uujHKk2kxxwQC9rCw62fgSa2lUHbRqy8eqMf+j51feMsTGO67ZmGY2RDpv+k BayQyzhVhhPdcAKouenZliJVyj0t1JXKtZUwFBIRWITF2YobvSrBJgvWCWd+cOFh fk7VEeO+KoW0RrNVLgvQ3nhLz7rLQUNS6+hp/FA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,references,subject,to,user-agent; Message-Instance: m=1; h=sha256:4YSNidoovnITlxMgh7UTTELatg++p7IVe5lSAzi9FYU=:VvlKjIQYUlcYV1eFycdcNxf57ei9ihv0B4rpdxv/dk4=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE9jFy76gCBJCZx6MBJbnt97FRyDHnYr3d09th9Fz+CyHcq4uF7ElsdPO/cwKUu3t HHihmv/hq3LckZbwM/HWLmsWZnXxOstCp+UJQ9SRYQBvhSKrK1Pd+sVwxOstoVv6fSfTBi Ii4jQk5hP1OtHVvagu3FAckc+9pQ439jL7p+WnJ1fXI6ziorIbvhabW2qfNePTYcv1PHBh +2bJBI9RYVo/F6fKNSyXaBywbggrruQ00QhMC5dKDKa+gXf1OsBsQjKlxq4EiBwtMRx+PO fcVnw4hdHwQiWvDmlGt9wUvNSmH3VUNPOlEDazhAh98s9S1c38Vd77obJRVceUx8khqTCl C+yXk6dEDW5qFgLWkpDvGYSjfnOOi9hcIxn8p28Bn6RL23gy89fsYBFcDz4GMgvlaIOvgm VDvzRY9bfyLSLrIKh1+p8pixckko4Gdca/adHHbS5GrDSSpCg40jzLvJDQeBJHnFNOkopb OIghRs7fyQ5HDtggaJmXFUCvJMOyL2QBD84nia2HPr1SShHKOSfQpfeuNBnRE0z5d0TZ6J qFxr6JOocwEKR2anaVdnZ5WTHLIKnxsIdl5TLedMDJaXWrzy6jdieowBEV2IzZEPyFyph9 J75NqJdLIV7n7MkbmRD/cTxBWQQjdCYkQoOlfnpxLYpMZDqoNBrLZZophRNA X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Nov 2026 15:18:53 -0500 (EST) From: Junio C Hamano To: tboegi@web.de Cc: git@vger.kernel.org, curtis.allen.smith@gmail.com Subject: Re: [PATCH v7 1/1] read-cache: do not trust a size change when conversion is active In-Reply-To: <20261129152805.758456-1-tboegi@web.de> (tboegi@web.de's message of "Sun, 29 Nov 2026 16:28:05 +0100") References: <20261129152805.758456-1-tboegi@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Sun, 29 Nov 2026 12:18:52 -0800 Message-ID: X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain tboegi@web.de writes: > git status --short # -> M file.txt > git ls-files --debug file.txt | grep size # size: 14 (*) > > git diff # -> empty > git add file.txt # -> nothing to commit As pointed out earlier, 'git add' does not say "nothing to commit". Running 'git commit file.txt' after 'git add file.txt' (or 'git status' after 'git add file.txt') is what reports "nothing to commit". > Today different different file contents and/or file length may result > in the same content in the index using `git add`, when all input > conversions are run. > (*) With this change: size: 17 There is a doubled word ("different different"), and this log message uses Markdown backticks around commands, which we tend to avoid in plain-text commit logs. Also, placing the "(*)" note between prose paragraphs breaks the flow; folding that note right below the transcript (or showing the refreshed size directly in a short post-patch snippet) would read more smoothly. > This change removes the 'shortcut' in read-cache/ie_modified(): > when a regular file has a different size compared to what is > recorded in the index then the file is modified. > When the path is subject to conversion > (the "text" and "eol" attributes, core.autocrlf, a clean filter), > different bytes can convert to the same blob, as the CRLF rewrite > above does. This paragraph describes checking only paths subject to conversion, but the patch seems to remove the shortcut unconditionally for all regular files and symlinks, which may be a serious regression I already pointed out in the review of [2/2] in an earlier round. The proposed log message also uses reporting prose ("This change removes...", "Now ...") instead of ending with an imperative command telling the codebase what to change. > read-cache.c | 26 ++++++++++++-------------- > t/t0020-crlf.sh | 39 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 51 insertions(+), 14 deletions(-) > > diff --git a/read-cache.c b/read-cache.c > index 595497d14c..2757bbb6ff 100644 > --- a/read-cache.c > +++ b/read-cache.c > @@ -593,20 +593,18 @@ 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". > + * gitlinks do not go through any conversion, see below. > + * When the size if different, the content is different. "if" -> "is". I do not think gitlinks compare file sizes at all. In ce_match_stat_basic(), gitlinks enter a dedicated S_IFGITLINK branch that ignores '.st_size' and sets DATA_CHANGED only when ce_compare_gitlink() detects that the subproject's HEAD differs from the recorded object ID. Keeping the original explanation for gitlinks and symlinks alongside the new note for converted regular files would be much clearer. > + * > + * When the length field of a regular file is zero or changed, > + * this does not always 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(). > * This becomes a stray empty comment line. > - * The logic does not apply to gitlinks, as ce_match_stat_basic() > - * already has checked the actual HEAD from the filesystem in the > - * subproject. If ie_match_stat() already said it is different, > - * then we know it is. > */ > - if ((changed & DATA_CHANGED) && > + if ((S_ISGITLINK(ce->ce_mode) && > #ifdef GIT_WINDOWS_NATIVE > /* > * Work around Git for Windows v2.27.0 fixing a bug where symlinks' > @@ -616,9 +614,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)) > + (changed & DATA_CHANGED))) > return changed; Squashing v6 1/2 and 2/2 into one commit carried forward the two bugs that was already flagged against v6 [PATCH 2/2], didn't it? Keeping the check in ie_modified() rather than ie_match_stat() is the right design so that preload_index() worker threads never run attribute lookups, I think. By dropping would_convert_to_git() and the non-zero check on '.sd_size', you remove the size-change fast path even when no conversion is active. Imagine a repository has 'core.autocrlf' set to false (or marks a large binary file with '-text' in .gitattributes). The user modifies that file so its size changes. When 'git status' runs refresh_index(), ie_modified() now sees that S_ISGITLINK() is false and unconditionally falls through to ce_modified_check_fs(), which calls ce_compare_data() and index_fd(). Although index_fd() calls would_convert_to_git() and notices that there is no need for conversion, it is too late. It does not know that it is only called to see if there is a change, or the fact that the caller knows that the last-known size is different from what is on the disk, and it does not know its work to read (or mmap), stream, and hash the entire file will be wasted because without conversion, what is on disk and what is in the index are definitely different once we know their sizes are different. Also, I think it breaks both symlinks and the GIT_WINDOWS_NATIVE workaround to remove "!S_ISLNK(st->st_mode) ||" and to use the remaining '.sd_size != MAX_PATH' check on S_ISGITLINK(). Because S_ISGITLINK() is always false for symlinks, the Windows MAX_PATH workaround is dead for symlinks and instead applies a symlink length check to gitlinks. Meanwhile, every size-changed symlink on all platforms now falls through to ce_compare_link(), reading the symlink target and the object database blob even though symlinks never undergo input conversion. > diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh > index fd1cae09ed..9c8d07cfc4 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 > +' Both new tests in t/t0020-crlf.sh are nicely scoped to their own paths and clean up cleanly against autocrlf-checkpoint, covering both the plain CRLF rewrite and the lone-CR case where converted size equals the original blob size.