diff options
| author | Vicent Martà <tanoku@gmail.com> | 2011-06-01 09:58:21 -0700 |
|---|---|---|
| committer | Vicent Martà <tanoku@gmail.com> | 2011-06-01 09:58:21 -0700 |
| commit | 50b7334e513c9fe7347b3240a2c20d93ac6e0c59 (patch) | |
| tree | c221c03e7b42faacd834844017f09753217645a0 | |
| parent | 786ad84fa9b38c705b0d064a10644f6747e9ce26 (diff) | |
| parent | fa9bcd81f51ae33e315adbf8bbfc27eddd82cf57 (diff) | |
| download | libgit2-50b7334e513c9fe7347b3240a2c20d93ac6e0c59.tar.gz | |
Merge pull request #206 from nulltoken/topic/is-bare
Add git_repository_is_bare() accessor
| -rw-r--r-- | include/git2/repository.h | 8 | ||||
| -rw-r--r-- | src/repository.c | 6 | ||||
| -rw-r--r-- | tests/t12-repo.c | 9 |
3 files changed, 22 insertions, 1 deletions
diff --git a/include/git2/repository.h b/include/git2/repository.h index 0d67ff8cc..493e82ad5 100644 --- a/include/git2/repository.h +++ b/include/git2/repository.h @@ -220,6 +220,14 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo); */ GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); +/** + * Check if a repository is bare + * + * @param repo Repo to test + * @return 1 if the repository is empty, 0 otherwise. + */ +GIT_EXTERN(int) git_repository_is_bare(git_repository *repo); + /** @} */ GIT_END_DECL #endif diff --git a/src/repository.c b/src/repository.c index 0dd36688b..32ca8dd79 100644 --- a/src/repository.c +++ b/src/repository.c @@ -486,3 +486,9 @@ const char *git_repository_workdir(git_repository *repo) assert(repo); return repo->path_workdir; } + +int git_repository_is_bare(git_repository *repo) +{ + assert(repo); + return repo->is_bare; +} diff --git a/tests/t12-repo.c b/tests/t12-repo.c index 70dba4255..4e51f1b15 100644 --- a/tests/t12-repo.c +++ b/tests/t12-repo.c @@ -126,7 +126,14 @@ static int ensure_repository_init( if (repo->path_index != NULL || expected_path_index != NULL) { if (git__suffixcmp(repo->path_index, expected_path_index) != 0) goto cleanup; - } + + if (git_repository_is_bare(repo) == 1) + goto cleanup; + } else if (git_repository_is_bare(repo) == 0) + goto cleanup; + + if (git_repository_is_empty(repo) == 0) + goto cleanup; git_repository_free(repo); rmdir_recurs(working_directory); |
