From cbadaccdf6b8a87f962a9230b977cd6b28d7bada Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:14:32 -0700 Subject: Build a literal pathspec in one place Git's pathspec item holds a const string now, so a path needs no writable copy to be matched. --- source/ui-blame.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'source/ui-blame.c') diff --git a/source/ui-blame.c b/source/ui-blame.c index 28fd16f..7254118 100644 --- a/source/ui-blame.c +++ b/source/ui-blame.c @@ -369,18 +369,8 @@ void cgit_print_blame(void) const char *rev = ctx.qry.oid; struct object_id oid; struct commit *commit; - int path_len = ctx.qry.path ? strlen(ctx.qry.path) : 0; - // nowildcard_len matches len so git treats the path as literal rather - // than as a glob, which is what a request naming one file means. - struct pathspec_item path_items = { - .match = ctx.qry.path, - .len = path_len, - .nowildcard_len = path_len - }; - struct pathspec paths = { - .nr = 1, - .items = &path_items - }; + struct pathspec_item path_item; + struct pathspec paths = { 0 }; struct walk_tree_context walk = { .found = TARGET_MISSING }; @@ -393,7 +383,8 @@ void cgit_print_blame(void) return; walk.rev = rev; - walk.match_baselen = path_items.match ? basedir_len(path_items.match) : -1; + walk.match_baselen = ctx.qry.path ? basedir_len(ctx.qry.path) : -1; + cgit_literal_pathspec(&paths, &path_item, ctx.qry.path); read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk); if (walk.found == TARGET_MISSING) -- cgit