Commit 20a2b02d by Julian Ganz

refdb_fs: enable root arbitration for fixed portion of globs

A glob used for iteration may start with an entire path containing no
special characters. If we start scanning for references within that path
rather than in `refs/`, we may end up scanning only a small fraction of
all references.
parent 27e98cf7
......@@ -513,6 +513,30 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
fsit_opts.flags = backend->iterator_flags;
if (iter->glob) {
const char *last_sep = NULL;
const char *pos;
for (pos = iter->glob; *pos; ++pos) {
switch (*pos) {
case '?':
case '*':
case '[':
case '\\':
break;
case '/':
last_sep = pos;
/* FALLTHROUGH */
default:
continue;
}
break;
}
if (last_sep) {
ref_prefix = iter->glob;
ref_prefix_len = (last_sep - ref_prefix) + 1;
}
}
if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0 ||
(error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment