#ifndef INCLUDE_repository_h__
#define INCLUDE_repository_h__
#include "common.h"
#include "git2/common.h"
#include "git2/oid.h"
#include "git2/odb.h"
#include "git2/repository.h"
#include "git2/object.h"
#include "git2/config.h"
#include "array.h"
#include "cache.h"
#include "refs.h"
#include "buffer.h"
#include "object.h"
#include "attrcache.h"
#include "submodule.h"
#include "diff_driver.h"
#define DOT_GIT ".git"
#define GIT_DIR DOT_GIT "/"
#define GIT_DIR_MODE 0755
#define GIT_BARE_DIR_MODE 0777
#define GIT_DIR_SHORTNAME "GIT~1"
extern bool git_repository__fsync_gitdir;
typedef enum {
GIT_CONFIGMAP_AUTO_CRLF = 0,
GIT_CONFIGMAP_EOL,
GIT_CONFIGMAP_SYMLINKS,
GIT_CONFIGMAP_IGNORECASE,
GIT_CONFIGMAP_FILEMODE,
GIT_CONFIGMAP_IGNORESTAT,
GIT_CONFIGMAP_TRUSTCTIME,
GIT_CONFIGMAP_ABBREV,
GIT_CONFIGMAP_PRECOMPOSE,
GIT_CONFIGMAP_SAFE_CRLF,
GIT_CONFIGMAP_LOGALLREFUPDATES,
GIT_CONFIGMAP_PROTECTHFS,
GIT_CONFIGMAP_PROTECTNTFS,
GIT_CONFIGMAP_FSYNCOBJECTFILES,
GIT_CONFIGMAP_CACHE_MAX
} git_configmap_item;
typedef enum {
GIT_CONFIGMAP_NOT_CACHED = -1,
GIT_SAFE_CRLF_FALSE = 0,
GIT_SAFE_CRLF_FAIL = 1,
GIT_SAFE_CRLF_WARN = 2,
GIT_AUTO_CRLF_FALSE = 0,
GIT_AUTO_CRLF_TRUE = 1,
GIT_AUTO_CRLF_INPUT = 2,
GIT_AUTO_CRLF_DEFAULT = GIT_AUTO_CRLF_FALSE,
GIT_EOL_UNSET = 0,
GIT_EOL_CRLF = 1,
GIT_EOL_LF = 2,
#ifdef GIT_WIN32
GIT_EOL_NATIVE = GIT_EOL_CRLF,
#else
GIT_EOL_NATIVE = GIT_EOL_LF,
#endif
GIT_EOL_DEFAULT = GIT_EOL_NATIVE,
GIT_SYMLINKS_DEFAULT = GIT_CONFIGMAP_TRUE,
GIT_IGNORECASE_DEFAULT = GIT_CONFIGMAP_FALSE,
GIT_FILEMODE_DEFAULT = GIT_CONFIGMAP_TRUE,
GIT_IGNORESTAT_DEFAULT = GIT_CONFIGMAP_FALSE,
GIT_TRUSTCTIME_DEFAULT = GIT_CONFIGMAP_TRUE,
GIT_ABBREV_DEFAULT = 7,
GIT_PRECOMPOSE_DEFAULT = GIT_CONFIGMAP_FALSE,
GIT_SAFE_CRLF_DEFAULT = GIT_CONFIGMAP_FALSE,
GIT_LOGALLREFUPDATES_FALSE = GIT_CONFIGMAP_FALSE,
GIT_LOGALLREFUPDATES_TRUE = GIT_CONFIGMAP_TRUE,
GIT_LOGALLREFUPDATES_UNSET = 2,
GIT_LOGALLREFUPDATES_ALWAYS = 3,
GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET,
GIT_PROTECTHFS_DEFAULT = GIT_CONFIGMAP_FALSE,
GIT_PROTECTNTFS_DEFAULT = GIT_CONFIGMAP_FALSE,
GIT_FSYNCOBJECTFILES_DEFAULT = GIT_CONFIGMAP_FALSE,
} git_configmap_value;
enum {
GIT_REPOSITORY_INIT__HAS_DOTGIT = (1u << 16),
GIT_REPOSITORY_INIT__NATURAL_WD = (1u << 17),
GIT_REPOSITORY_INIT__IS_REINIT = (1u << 18),
};
struct git_repository {
git_odb *_odb;
git_refdb *_refdb;
git_config *_config;
git_index *_index;
git_cache objects;
git_attr_cache *attrcache;
git_diff_driver_registry *diff_drivers;
char *gitlink;
char *gitdir;
char *commondir;
char *workdir;
char *namespace;
char *ident_name;
char *ident_email;
git_array_t(git_buf) reserved_names;
unsigned is_bare:1;
unsigned is_worktree:1;
unsigned int lru_counter;
git_atomic attr_session_key;
git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
git_strmap *submodule_cache;
};
GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo)
{
return repo->attrcache;
}
int git_repository_head_tree(git_tree **tree, git_repository *repo);
int git_repository_create_head(const char *git_dir, const char *ref_name);
typedef int (*git_repository_foreach_head_cb)(git_repository *repo, const char *path, void *payload);
enum {
GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO = (1u << 0),
GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES = (1u << 1),
};
int git_repository_foreach_head(git_repository *repo,
git_repository_foreach_head_cb cb,
int flags, void *payload);
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);
int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item);
void git_repository__configmap_lookup_cache_clear(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;
git_error_set(
GIT_ERROR_REPOSITORY,
"cannot %s. This operation is not allowed against bare repositories.",
operation_name);
return GIT_EBAREREPO;
}
int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head);
int git_repository__cleanup_files(git_repository *repo, const char *files[], size_t files_len);
extern git_buf git_repository__reserved_names_win32[];
extern size_t git_repository__reserved_names_win32_len;
extern git_buf git_repository__reserved_names_posix[];
extern size_t git_repository__reserved_names_posix_len;
bool git_repository__reserved_names(
git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs);
#endif