Re: [PATCH 4/5] backfill: work with prefix pathspecs
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 19, 2026, 10:15 UTC
- Message-ID
- <abvMwBr_03_Z0nMX@pks.im>
- In-Reply-To
- <977f62faa550ecc4ef7774b4ecf53a9a520fc62a.1773707361.git.gitgitgadget@gmail.com>
On Tue, Mar 17, 2026 at 12:29:20AM +0000, Derrick Stolee via GitGitGadget wrote:
Show 45 quoted lines
> 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