Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to '')
| -rw-r--r-- | source/ui-tree.c | 15 |
1 file changed, 3 insertions, 12 deletions
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 |
