From: Patrick Steinhardt Date: Thu, 19 Mar 2026 10:15:28 GMT Subject: Re: [PATCH 4/5] backfill: work with prefix pathspecs Message-ID: In-Reply-To: <977f62faa550ecc4ef7774b4ecf53a9a520fc62a.1773707361.git.gitgitgadget@gmail.com> On Tue, Mar 17, 2026 at 12:29:20AM +0000, Derrick Stolee via GitGitGadget wrote: > diff --git a/path-walk.c b/path-walk.c > index 364e4cfa19..e1ad4b0208 100644 > --- a/path-walk.c > +++ b/path-walk.c > @@ -206,6 +206,49 @@ static int add_tree_entries(struct path_walk_context *ctx, > match != MATCHED) > continue; > } > + if (ctx->revs->prune_data.nr) { > + struct pathspec *pd = &ctx->revs->prune_data; > + bool found = false; > + > + for (int i = 0; i < pd->nr; i++) { > + struct pathspec_item *item = &pd->items[i]; > + > + /* > + * Is this path a parent directory of > + * the pathspec item? > + */ > + if (path.len < (size_t)item->len && > + !strncmp(path.buf, item->match, path.len) && > + item->match[path.len - 1] == '/') { > + found = true; > + break; > + } > + > + /* > + * Or, is the pathspec an exact match? > + */ > + if (path.len == (size_t)item->len && > + !strcmp(path.buf, item->match)) { > + found = true; > + break; > + } > + > + /* > + * Or, is the pathspec a directory prefix > + * match? > + */ > + if (path.len > (size_t)item->len && > + !strncmp(path.buf, item->match, item->len) && > + path.buf[item->len] == '/') { > + found = true; > + break; > + } Ah, one more thing: we could expose `dir_prefix()` from "path.c" and reuse it here. Patrick