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-tree.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'source/ui-tree.c') diff --git a/source/ui-tree.c b/source/ui-tree.c index 300207f..157aba3 100644 --- a/source/ui-tree.c +++ b/source/ui-tree.c @@ -466,18 +466,8 @@ void cgit_print_tree(const char *rev, char *path) { struct object_id oid; struct commit *commit; - int path_len = path ? strlen(path) : 0; - // nowildcard_len matches len so git treats the path as literal rather - // than as a glob. - struct pathspec_item path_items = { - .match = path, - .len = path_len, - .nowildcard_len = path_len - }; - struct pathspec paths = { - .nr = path ? 1 : 0, - .items = &path_items - }; + struct pathspec_item path_item; + struct pathspec paths = { 0 }; struct walk_tree_context walk = { .match_path = path, .state = WALK_LOOKING @@ -491,6 +481,7 @@ void cgit_print_tree(const char *rev, char *path) return; walk.rev = rev; + cgit_literal_pathspec(&paths, &path_item, path); if (!path) { // The walk is never handed an entry for the top of the tree -- cgit