summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-04-13 17:00:37 +0100
committerGitHub <noreply@github.com>2021-04-13 17:00:37 +0100
commitac77d306f539938aa599ba81faee52854c262328 (patch)
tree321f6b4b360630bcbf184051c861c1cf54050b3b /src/repository.c
parentd05eda872b7998f7152cdd922cd83a4c5e8db3a1 (diff)
parent6591deefbf2443ef2162ac2384620bf0ec8065cb (diff)
downloadlibgit2-ac77d306f539938aa599ba81faee52854c262328.tar.gz
Merge pull request #5834 from libgit2/cmn/repo-no-passthrough
repo: remove an inappropriate use of PASSTHROUGH
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/repository.c b/src/repository.c
index 124722bba..79c068648 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2354,21 +2354,19 @@ int git_repository_head_unborn(git_repository *repo)
return 0;
}
-static int at_least_one_cb(const char *refname, void *payload)
-{
- GIT_UNUSED(refname);
- GIT_UNUSED(payload);
- return GIT_PASSTHROUGH;
-}
-
static int repo_contains_no_reference(git_repository *repo)
{
- int error = git_reference_foreach_name(repo, &at_least_one_cb, NULL);
+ git_reference_iterator *iter;
+ const char *refname;
+ int error;
- if (error == GIT_PASSTHROUGH)
- return 0;
+ if ((error = git_reference_iterator_new(&iter, repo)) < 0)
+ return error;
- if (!error)
+ error = git_reference_next_name(&refname, iter);
+ git_reference_iterator_free(iter);
+
+ if (error == GIT_ITEROVER)
return 1;
return error;