diff options
Diffstat (limited to 'src/repository.h')
-rw-r--r-- | src/repository.h | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/repository.h b/src/repository.h index 91c69a655..cc2f8c2b8 100644 --- a/src/repository.h +++ b/src/repository.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. @@ -18,8 +18,10 @@ #include "refs.h" #include "buffer.h" #include "odb.h" -#include "attr.h" +#include "object.h" +#include "attrcache.h" #include "strmap.h" +#include "refdb.h" #define DOT_GIT ".git" #define GIT_DIR DOT_GIT "/" @@ -68,20 +70,21 @@ typedef enum { GIT_EOL_DEFAULT = GIT_EOL_NATIVE } git_cvar_value; -/** Base git object for inheritance */ -struct git_object { - git_cached_obj cached; - git_repository *repo; - git_otype type; +/* internal repository init flags */ +enum { + GIT_REPOSITORY_INIT__HAS_DOTGIT = (1u << 16), + GIT_REPOSITORY_INIT__NATURAL_WD = (1u << 17), + GIT_REPOSITORY_INIT__IS_REINIT = (1u << 18), }; +/** Internal structure for repository object */ struct git_repository { git_odb *_odb; + git_refdb *_refdb; git_config *_config; git_index *_index; git_cache objects; - git_refcache references; git_attr_cache attrcache; git_strmap *submodules; @@ -94,15 +97,6 @@ struct git_repository { git_cvar_value cvar_cache[GIT_CVAR_CACHE_MAX]; }; -/* fully free the object; internal method, do not - * export */ -void git_object__free(void *object); - -int git_object__resolve_to_type(git_object **obj, git_otype type); - -int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header); -void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid); - GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo) { return &repo->attrcache; @@ -119,10 +113,11 @@ int git_repository_head_tree(git_tree **tree, git_repository *repo); */ int git_repository_config__weakptr(git_config **out, git_repository *repo); int git_repository_odb__weakptr(git_odb **out, git_repository *repo); +int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo); int git_repository_index__weakptr(git_index **out, git_repository *repo); /* - * CVAR cache + * CVAR cache * * Efficient access to the most used config variables of a repository. * The cache is cleared everytime the config backend is replaced. @@ -135,4 +130,19 @@ void git_repository__cvar_cache_clear(git_repository *repo); */ extern void git_submodule_config_free(git_repository *repo); +GIT_INLINE(int) git_repository__ensure_not_bare( + git_repository *repo, + const char *operation_name) +{ + if (!git_repository_is_bare(repo)) + return 0; + + giterr_set( + GITERR_REPOSITORY, + "Cannot %s. This operation is not allowed against bare repositories.", + operation_name); + + return GIT_EBAREREPO; +} + #endif |