Skip to content

Commit 20306d3

Browse files
authored
Merge pull request libgit2#4665 from neithernut/fix-refdb-glob
refdb_fs: fix regression: failure when globbing for non-existant references
2 parents 991bf69 + d7eca4c commit 20306d3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-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)) {

tests/refs/foreachglob.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ void test_refs_foreachglob__retrieve_local_branches(void)
6262
assert_retrieval("refs/heads/*", 12);
6363
}
6464

65+
void test_refs_foreachglob__retrieve_nonexistant(void)
66+
{
67+
assert_retrieval("refs/nonexistent/*", 0);
68+
}
69+
6570
void test_refs_foreachglob__retrieve_partially_named_references(void)
6671
{
6772
/*

0 commit comments

Comments
 (0)