git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] dir: hash ignore files before adding parser LF

From
Tamir Duberstein <tamird@gmail.com>
Date
Sep 23, 2026, 17:10 UTC
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 <tamird@gmail.com>
---
 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
Previous: Tamir DubersteinNext: Tamir Duberstein
Message 2 of 8 in “ls-files: reuse the untracked cache”
  1. 0/2 ls-files: reuse the untracked cacheTamir Duberstein, Sep 23, 2026
  2. 1/2 dir: hash ignore files before adding parser LFTamir Duberstein, Sep 23, 2026
  3. 2/2 ls-files: reuse cached untracked listingsTamir Duberstein, Sep 23, 2026
  4. Tamir DubersteinSep 23, 2026
  5. 0/3 ls-files: reuse and update the untracked cacheTamir Duberstein, Sep 23, 2026
  6. 1/3 dir: hash ignore files before appending newlineTamir Duberstein, Sep 23, 2026
  7. 2/3 dir: share untracked caches across output modesTamir Duberstein, Sep 23, 2026
  8. 3/3 ls-files: use and update the untracked cacheTamir Duberstein, Sep 23, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.