Commit 05e891f1 by Julian Ganz

refdb_fs: test whether the base directory exists when globbing

This commit fixes a regression introduced by

        20a2b02d

The commit introduced an optimization for finding references using a
glob: rather than iterating over all references and matching each one
against the glob, we would iterate only over references within the
directory common to all possible references which may match against the
glob.

However, contrary to the `ref/` directory, which was the previous entry
point for the iteration, this directory may not exist. In this case, the
optimization causes an error (`ENOENT`) rather than the iterator simply
yielding no references.

This patch fixes the regression by checkign for this specific case.
parent 771dfd1d
...@@ -538,12 +538,16 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter) ...@@ -538,12 +538,16 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
} }
if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 || if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0 || (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
(error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
git_buf_free(&path); git_buf_free(&path);
return error; return error;
} }
if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
git_buf_free(&path);
return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
}
error = git_buf_sets(&path, ref_prefix); error = git_buf_sets(&path, ref_prefix);
while (!error && !git_iterator_advance(&entry, fsit)) { while (!error && !git_iterator_advance(&entry, fsit)) {
......
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