From: Derrick Stolee Date: Thu, 26 Mar 2026 12:58:31 GMT Subject: Re: [PATCH v2 4/6] backfill: work with prefix pathspecs Message-ID: <47cc997a-9a9e-4733-b5a3-ecf9f860a8c7@gmail.com> In-Reply-To: On 3/24/2026 3:59 AM, Patrick Steinhardt wrote: > 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, "/"); This is much cleaner, too! Thanks. -Stolee