Subject: Re: [PATCH v2 4/6] backfill: work with prefix pathspecs

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 24 Mar 2026 08:59:19 +0100

On Mon, Mar 23, 2026 at 11:40:17AM +0000, Derrick Stolee via GitGitGadget wrote:
> 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