{"thread":{"id":"66774","subject":"[PATCH] path-walk: allow revisiting paths from tagged trees","startedAt":"2026-11-04T19:07:48Z","lastAt":"2026-11-05T17:42:57Z","messageCount":3,"participants":["Derrick Stolee via GitGitGadget","Taylor Blau","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"557491","messageId":"pull.2296.git.1793819268371.gitgitgadget@gmail.com","threadId":"66774","inReplyTo":null,"subject":"[PATCH] path-walk: allow revisiting paths from tagged trees","fromName":"Derrick Stolee via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-04T19:07:48Z","receivedAt":"2026-11-04T19:07:48Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"From: Derrick Stolee <stolee@gmail.com>\n\nWhen adding support for tree-depth filters, 5111520e2a1 (path-walk:\nsupport `tree:0` filter, 2026-05-22) moved tagged root trees into a\nseparate batch. These trees are expanded after commit root trees and\ntheir root-level blob batches.  If a tagged tree introduces another blob\nat an already consumed path, push_to_stack() refuses to queue that path\nagain because path_stack_pushed remembers every previously queued path.\nThe final remaining-path drain makes the same check and also skips the\nblob, leading to a repository with missing objects.\n\nThis regression was first released in Git 2.55.0. The torvalds/linux\nrepository has such tagged trees that revealed the bug.\n\nTo resolve this issue, remove a path from path_stack_pushed when\nconsuming its queue entry.  The set then suppresses duplicate pending\nentries without preventing new objects from being visited at a\npreviously consumed path. This preserves the existing visit priorities\ninstead of reordering tagged trees relative to other batches.\n\nAdd a regression test with a commit and an annotated tree tag that\ncontain distinct blobs at the same path. After an initial repack to\nclear loose objects, repack everything with path-walk and run an fsck\nconnectivity check to reveal the error without this fix.\n\nAssisted-by: GPT-6.1 Sol\nSigned-off-by: Derrick Stolee <stolee@gmail.com>\n---\n    path-walk: allow revisiting paths from tagged trees\n    \n    While exploring potential future improvements to path-walk repacks, I\n    discovered this regression. It's slightly subtle in a way that the\n    existing tree-tag tests didn't catch, due to needing to revisit paths.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2296%2Fderrickstolee%2Fpath-walk-tree-tags-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2296/derrickstolee/path-walk-tree-tags-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2296\n\n path-walk.c       |  5 ++++-\n t/t7700-repack.sh | 23 +++++++++++++++++++++++\n 2 files changed, 27 insertions(+), 1 deletion(-)\n\ndiff --git a/path-walk.c b/path-walk.c\nindex 9ca3248ea8..e3a5ba201c 100644\n--- a/path-walk.c\n+++ b/path-walk.c\n@@ -62,7 +62,8 @@ struct path_walk_context {\n \t * like a stack and performs a DFS within the trees.\n \t *\n \t * Use path_stack_pushed to indicate whether a path\n-\t * was previously added to path_stack.\n+\t * is currently queued in path_stack. Tagged trees can\n+\t * discover new objects at an already visited path.\n \t */\n \tstruct prio_queue path_stack;\n \tstruct strset path_stack_pushed;\n@@ -309,6 +310,8 @@ static int walk_path(struct path_walk_context *ctx,\n \tif (!list)\n \t\tBUG(\"provided path '%s' that had no associated list\", path);\n \n+\tstrset_remove(&ctx->path_stack_pushed, path);\n+\n \tif (!list->oids.nr)\n \t\treturn 0;\n \ndiff --git a/t/t7700-repack.sh b/t/t7700-repack.sh\nindex f0a390e3c6..338f622614 100755\n--- a/t/t7700-repack.sh\n+++ b/t/t7700-repack.sh\n@@ -904,4 +904,27 @@ test_expect_success 'pending objects are repacked appropriately' '\n \t)\n '\n \n+test_expect_success '--path-walk keeps blobs from tagged trees at already visited paths' '\n+\tgit init --bare tagged-tree.git &&\n+\t(\n+\t\tcd tagged-tree.git &&\n+\t\tGIT_DIR=. &&\n+\t\texport GIT_DIR &&\n+\t\told=$(echo old | git hash-object -w --stdin) &&\n+\t\ttree=$(printf \"100644 blob %s\\tfile\\n\" \"$old\" | git mktree) &&\n+\t\tgit tag -a -m \"historical tree\" tree-tag \"$tree\" &&\n+\t\tnew=$(echo new | git hash-object -w --stdin) &&\n+\t\ttree=$(printf \"100644 blob %s\\tfile\\n\" \"$new\" | git mktree) &&\n+\t\tcommit=$(echo new | git commit-tree \"$tree\") &&\n+\t\tgit update-ref HEAD \"$commit\" &&\n+\n+\t\t# collect all loose objects into packs\n+\t\tgit repack -adf --no-path-walk &&\n+\n+\t\t# now confirm that --path-walk keeps all objects.\n+\t\tgit repack -adf --path-walk &&\n+\t\tgit fsck --connectivity-only\n+\t)\n+'\n+\n test_done\n\nbase-commit: a018953688f1b10bddf91bff8747068f5f4746a4\n-- \ngitgitgadget\n\n"},{"id":"557506","messageId":"auuvwlhhRpA0T2ml@com-79390","threadId":"66774","inReplyTo":"pull.2296.git.1793819268371.gitgitgadget@gmail.com","subject":"Re: [PATCH] path-walk: allow revisiting paths from tagged trees","fromName":"Taylor Blau","fromEmail":"ttaylorr@openai.com","sentAt":"2026-11-04T22:20:50Z","receivedAt":"2026-11-04T22:20:50Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Nov 04, 2026 at 07:07:48PM +0000, Derrick Stolee via GitGitGadget wrote:\n>  path-walk.c       |  5 ++++-\n>  t/t7700-repack.sh | 23 +++++++++++++++++++++++\n>  2 files changed, 27 insertions(+), 1 deletion(-)\n\nNice find and fix! Thanks for looking at it, this patch LGTM.\n\nThanks,\nTaylor\n\n"},{"id":"557586","messageId":"xmqqecczw4wu.fsf@gitster.g","threadId":"66774","inReplyTo":"auuvwlhhRpA0T2ml@com-79390","subject":"Re: [PATCH] path-walk: allow revisiting paths from tagged trees","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-05T17:42:57Z","receivedAt":"2026-11-05T17:42:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Taylor Blau <ttaylorr@openai.com> writes:\n\n> On Wed, Nov 04, 2026 at 07:07:48PM +0000, Derrick Stolee via GitGitGadget wrote:\n>>  path-walk.c       |  5 ++++-\n>>  t/t7700-repack.sh | 23 +++++++++++++++++++++++\n>>  2 files changed, 27 insertions(+), 1 deletion(-)\n>\n> Nice find and fix! Thanks for looking at it, this patch LGTM.\n\nThanks, both.\n\n"}]}