diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-06-28 21:30:15 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-06-28 21:30:38 +0200 |
commit | 0f489fb211a18b197af1fe26b94f774a84fe000c (patch) | |
tree | 6f32b8caddd2e1366c240b7f2443bc096a29ed96 | |
parent | ab7941b5d97e5b90bebe6278fcf5351b6a4d5262 (diff) | |
download | libgit2-0f489fb211a18b197af1fe26b94f774a84fe000c.tar.gz |
repo: Fix git_repository_is_empty
-rw-r--r-- | src/repository.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/repository.c b/src/repository.c index 969880355..47884c937 100644 --- a/src/repository.c +++ b/src/repository.c @@ -800,12 +800,16 @@ int git_repository_is_empty(git_repository *repo) error = git_reference_lookup(&head, repo, "HEAD"); if (error < GIT_SUCCESS) - return git__throw(error, "Failed to determine the emptiness of the repository. An error occured while retrieving the HEAD reference"); + return git__throw(error, "Corrupted repository. HEAD does not exist"); if (git_reference_type(head) != GIT_REF_SYMBOLIC) - return git__throw(GIT_EOBJCORRUPTED, "Failed to determine the emptiness of the repository. HEAD is probably in detached state"); + return 0; + + if (strcmp(git_reference_target(head), "refs/heads/master") != 0) + return 0; - return git_reference_resolve(&branch, head) == GIT_SUCCESS ? 0 : 1; + error = git_reference_resolve(&branch, head); + return error == GIT_ENOTFOUND ? 1 : error; } const char *git_repository_path(git_repository *repo, git_repository_pathid id) |