Re: [PATCH v2 4/6] backfill: work with prefix pathspecs
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Mar 24, 2026, 07:59 UTC
- Message-ID
- <acJEV18rQAh2i2a4@pks.im>
- In-Reply-To
- <f8f2c613260458e3c86109888ee1c51313095319.1774266019.git.gitgitgadget@gmail.com>
On Mon, Mar 23, 2026 at 11:40:17AM +0000, Derrick Stolee via GitGitGadget wrote:
Show 14 quoted lines
> diff --git a/path-walk.c b/path-walk.c
> index 364e4cfa19..0d640e2f24 100644
> --- a/path-walk.c
> +++ b/path-walk.c
> @@ -206,6 +207,34 @@ 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;
> +
> + /* remove '/' for these checks. */
> + path.buf[path.len - 1] = 0;Hm. Is this _always_ safe to do? We add the directory separator a few lines further up, but only in the case where `type == OBJ_TREE`. So in reverse this may mean that there are cases where we don't have a trailing '/'.
Maybe we should instead:
did_strip_suffix = strbuf_strip_suffix(path, "/");
...
if (did_strip_suffix)
strbuf_addch(path, "/");Patrick