Commit fa9bcd81 by nulltoken

Add git_repository_is_bare() accessor

parent 4191d529
...@@ -212,6 +212,14 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo); ...@@ -212,6 +212,14 @@ GIT_EXTERN(const char *) git_repository_path(git_repository *repo);
*/ */
GIT_EXTERN(const char *) git_repository_workdir(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 GIT_END_DECL
#endif #endif
...@@ -509,3 +509,9 @@ const char *git_repository_workdir(git_repository *repo) ...@@ -509,3 +509,9 @@ const char *git_repository_workdir(git_repository *repo)
assert(repo); assert(repo);
return repo->path_workdir; return repo->path_workdir;
} }
int git_repository_is_bare(git_repository *repo)
{
assert(repo);
return repo->is_bare;
}
...@@ -126,7 +126,14 @@ static int ensure_repository_init( ...@@ -126,7 +126,14 @@ static int ensure_repository_init(
if (repo->path_index != NULL || expected_path_index != NULL) { if (repo->path_index != NULL || expected_path_index != NULL) {
if (git__suffixcmp(repo->path_index, expected_path_index) != 0) if (git__suffixcmp(repo->path_index, expected_path_index) != 0)
goto cleanup; 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); git_repository_free(repo);
rmdir_recurs(working_directory); rmdir_recurs(working_directory);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment