From: Tamir Duberstein Date: Wed, 23 Sep 2026 17:10:08 GMT Subject: [PATCH 1/2] dir: hash ignore files before adding parser LF Message-ID: <20260923-ls-files-untracked-cache-v1-1-08db4cc1efdb@gmail.com> In-Reply-To: <20260923-ls-files-untracked-cache-v1-0-08db4cc1efdb@gmail.com> add_patterns() appends a newline for the pattern parser before computing an ignore file's object ID. Its fallback hash therefore includes a byte that is absent from the file. The fast path instead copies the original blob ID from an up-to-date index entry. Switching between those paths changes the recorded ignore identity even when the file has not changed, invalidating the untracked cache below it. Compute the hash before appending the parser newline so both paths agree. Update the expected identities of the untracked ignore files accordingly. Signed-off-by: Tamir Duberstein --- dir.c | 2 +- t/t7063-status-untracked-cache.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dir.c b/dir.c index d896e7be4b..037780e556 100644 --- a/dir.c +++ b/dir.c @@ -1195,7 +1195,6 @@ static int add_patterns(const char *fname, const char *base, int baselen, close(fd); return -1; } - buf[size++] = '\n'; close(fd); if (oid_stat) { int pos; @@ -1215,6 +1214,7 @@ static int add_patterns(const char *fname, const char *base, int baselen, fill_stat_data(&oid_stat->stat, &st); oid_stat->valid = 1; } + buf[size++] = '\n'; } if (size > PATTERN_MAX_FILE_SIZE) { diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index 8929ef481f..10d4850077 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -98,11 +98,11 @@ test_expect_success 'setup' ' : >.git/info/exclude && git update-index --untracked-cache && test_oid_cache <<-EOF - root sha1:e6fcc8f2ee31bae321d66afd183fcb7237afae6e - root sha256:b90c672088c015b9c83876e919da311bad4cd39639fb139f988af6a11493b974 + root sha1:8510665149157c2bc901848c3e0b746954e9cbd9 + root sha256:09ef24b38105f396a61ad78d73ba6a18ee3cbd89ce4524b4e13b6c1af191e2d8 - exclude sha1:13263c0978fb9fad16b2d580fb800b6d811c3ff0 - exclude sha256:fe4aaa1bbbbce4cb8f73426748a14c5ad6026b26f90505a0bf2494b165a5b76c + exclude sha1:2bdf67abb163a4ffb2d7f3f0880c9fe5068ce782 + exclude sha256:b83643f4390b339c1b3ff2f5132c99bd4a77687dd321d3f386c25953aa6f1ce4 done sha1:1946f0437f90c5005533cbe1736a6451ca301714 done sha256:7f079501d79f665b3acc50f5e0e9e94509084d5032ac20113a37dd5029b757cc -- 2.56.0.rc0.807.ga0c0929ce1.frankengit