2 * Copyright (C) 2009-2012 the libgit2 contributors
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_repository_h__
8 #define INCLUDE_repository_h__
10 #include "git2/common.h"
13 #include "git2/repository.h"
14 #include "git2/object.h"
16 #include "hashtable.h"
24 #define DOT_GIT ".git"
25 #define GIT_DIR DOT_GIT "/"
26 #define GIT_DIR_MODE 0755
27 #define GIT_BARE_DIR_MODE 0777
29 /** Cvar cache identifiers */
31 GIT_CVAR_AUTO_CRLF
= 0, /* core.autocrlf */
32 GIT_CVAR_EOL
, /* core.eol */
37 * CVAR value enumerations
39 * These are the values that are actually stored in the cvar cache, instead
40 * of their string equivalents. These values are internal and symbolic;
41 * make sure that none of them is set to `-1`, since that is the unique
42 * identifier for "not cached"
45 /* The value hasn't been loaded from the cache yet */
46 GIT_CVAR_NOT_CACHED
= -1,
48 /* core.safecrlf: false, 'fail', 'warn' */
49 GIT_SAFE_CRLF_FALSE
= 0,
50 GIT_SAFE_CRLF_FAIL
= 1,
51 GIT_SAFE_CRLF_WARN
= 2,
53 /* core.autocrlf: false, true, 'input; */
54 GIT_AUTO_CRLF_FALSE
= 0,
55 GIT_AUTO_CRLF_TRUE
= 1,
56 GIT_AUTO_CRLF_INPUT
= 2,
57 GIT_AUTO_CRLF_DEFAULT
= GIT_AUTO_CRLF_FALSE
,
59 /* core.eol: unset, 'crlf', 'lf', 'native' */
64 GIT_EOL_NATIVE
= GIT_EOL_CRLF
,
66 GIT_EOL_NATIVE
= GIT_EOL_LF
,
68 GIT_EOL_DEFAULT
= GIT_EOL_NATIVE
71 /** Base git object for inheritance */
73 git_cached_obj cached
;
78 struct git_repository
{
84 git_refcache references
;
85 git_attr_cache attrcache
;
87 char *path_repository
;
91 unsigned int lru_counter
;
93 git_cvar_value cvar_cache
[GIT_CVAR_CACHE_MAX
];
96 /* fully free the object; internal method, do not
98 void git_object__free(void *object
);
100 int git_oid__parse(git_oid
*oid
, const char **buffer_out
, const char *buffer_end
, const char *header
);
101 void git_oid__writebuf(git_buf
*buf
, const char *header
, const git_oid
*oid
);
104 * Weak pointers to repository internals.
106 * The returned pointers do not need to be freed. Do not keep
107 * permanent references to these (i.e. between API calls), since they may
108 * become invalidated if the user replaces a repository internal.
110 int git_repository_config__weakptr(git_config
**out
, git_repository
*repo
);
111 int git_repository_odb__weakptr(git_odb
**out
, git_repository
*repo
);
112 int git_repository_index__weakptr(git_index
**out
, git_repository
*repo
);
117 * Efficient access to the most used config variables of a repository.
118 * The cache is cleared everytime the config backend is replaced.
120 int git_repository__cvar(int *out
, git_repository
*repo
, git_cvar_cached cvar
);
121 void git_repository__cvar_cache_clear(git_repository
*repo
);