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

[PATCH] path-walk: allow revisiting paths from tagged trees

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 4, 2026, 19:07 UTC
Message-ID
<pull.2296.git.1793819268371.gitgitgadget@gmail.com>
From: Derrick Stolee <stolee@gmail.com>

When adding support for tree-depth filters, 5111520e2a1 (path-walk: support `tree:0` filter, 2026-05-22) moved tagged root trees into a separate batch. These trees are expanded after commit root trees and their root-level blob batches. If a tagged tree introduces another blob at an already consumed path, push_to_stack() refuses to queue that path again because path_stack_pushed remembers every previously queued path. The final remaining-path drain makes the same check and also skips the blob, leading to a repository with missing objects.

This regression was first released in Git 2.55.0. The torvalds/linux repository has such tagged trees that revealed the bug.

To resolve this issue, remove a path from path_stack_pushed when consuming its queue entry. The set then suppresses duplicate pending entries without preventing new objects from being visited at a previously consumed path. This preserves the existing visit priorities instead of reordering tagged trees relative to other batches.

Add a regression test with a commit and an annotated tree tag that contain distinct blobs at the same path. After an initial repack to clear loose objects, repack everything with path-walk and run an fsck connectivity check to reveal the error without this fix.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
    path-walk: allow revisiting paths from tagged trees
    
    While exploring potential future improvements to path-walk repacks, I
    discovered this regression. It's slightly subtle in a way that the
    existing tree-tag tests didn't catch, due to needing to revisit paths.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2296%2Fderrickstolee%2Fpath-walk-tree-tags-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2296/derrickstolee/path-walk-tree-tags-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2296
 path-walk.c       |  5 ++++-
 t/t7700-repack.sh | 23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/path-walk.c b/path-walk.c
index 9ca3248ea8..e3a5ba201c 100644
--- a/path-walk.c
+++ b/path-walk.c
@@ -62,7 +62,8 @@ struct path_walk_context {
 	 * like a stack and performs a DFS within the trees.
 	 *
 	 * Use path_stack_pushed to indicate whether a path
-	 * was previously added to path_stack.
+	 * is currently queued in path_stack. Tagged trees can
+	 * discover new objects at an already visited path.
 	 */
 	struct prio_queue path_stack;
 	struct strset path_stack_pushed;
@@ -309,6 +310,8 @@ static int walk_path(struct path_walk_context *ctx,
 	if (!list)
 		BUG("provided path '%s' that had no associated list", path);
 
+	strset_remove(&ctx->path_stack_pushed, path);
+
 	if (!list->oids.nr)
 		return 0;
 
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index f0a390e3c6..338f622614 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -904,4 +904,27 @@ test_expect_success 'pending objects are repacked appropriately' '
 	)
 '
 
+test_expect_success '--path-walk keeps blobs from tagged trees at already visited paths' '
+	git init --bare tagged-tree.git &&
+	(
+		cd tagged-tree.git &&
+		GIT_DIR=. &&
+		export GIT_DIR &&
+		old=$(echo old | git hash-object -w --stdin) &&
+		tree=$(printf "100644 blob %s\tfile\n" "$old" | git mktree) &&
+		git tag -a -m "historical tree" tree-tag "$tree" &&
+		new=$(echo new | git hash-object -w --stdin) &&
+		tree=$(printf "100644 blob %s\tfile\n" "$new" | git mktree) &&
+		commit=$(echo new | git commit-tree "$tree") &&
+		git update-ref HEAD "$commit" &&
+
+		# collect all loose objects into packs
+		git repack -adf --no-path-walk &&
+
+		# now confirm that --path-walk keeps all objects.
+		git repack -adf --path-walk &&
+		git fsck --connectivity-only
+	)
+'
+
 test_done

base-commit: a018953688f1b10bddf91bff8747068f5f4746a4
-- 
gitgitgadget
Next: Taylor Blau
Message 1 of 3 in “path-walk: allow revisiting paths from tagged trees”
  1. path-walk: allow revisiting paths from tagged treesDerrick Stolee via GitGitGadget, Nov 4, 2026
  2. Taylor BlauNov 4, 2026
  3. Junio C HamanoNov 5, 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.