Skip to content

Commit 05e891f

Browse files
committed
refdb_fs: test whether the base directory exists when globbing
This commit fixes a regression introduced by 20a2b02 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.
1 parent 771dfd1 commit 05e891f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/refdb_fs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,12 +538,16 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
538538
}
539539

540540
if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
541-
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0 ||
542-
(error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
541+
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
543542
git_buf_free(&path);
544543
return error;
545544
}
546545

546+
if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
547+
git_buf_free(&path);
548+
return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
549+
}
550+
547551
error = git_buf_sets(&path, ref_prefix);
548552

549553
while (!error && !git_iterator_advance(&entry, fsit)) {

0 commit comments

Comments
 (0)