1#ifndef REPOSITORY_H 2#define REPOSITORY_H 3 4struct config_set; 5struct index_state; 6struct submodule_cache; 7 8struct repository { 9 /* Environment */ 10 /* 11 * Path to the git directory. 12 * Cannot be NULL after initialization. 13 */ 14 char *gitdir; 15 16 /* 17 * Path to the common git directory. 18 * Cannot be NULL after initialization. 19 */ 20 char *commondir; 21 22 /* 23 * Path to the repository's object store. 24 * Cannot be NULL after initialization. 25 */ 26 char *objectdir; 27 28 /* 29 * Path to the repository's graft file. 30 * Cannot be NULL after initialization. 31 */ 32 char *graft_file; 33 34 /* 35 * Path to the current worktree's index file. 36 * Cannot be NULL after initialization. 37 */ 38 char *index_file; 39 40 /* 41 * Path to the working directory. 42 * A NULL value indicates that there is no working directory. 43 */ 44 char *worktree; 45 46 /* Subsystems */ 47 /* 48 * Repository's config which contains key-value pairs from the usual 49 * set of config files (i.e. repo specific .git/config, user wide 50 * ~/.gitconfig, XDG config file and the global /etc/gitconfig) 51 */ 52 struct config_set *config; 53 54 /* Repository's submodule config as defined by '.gitmodules' */ 55 struct submodule_cache *submodule_cache; 56 57 /* 58 * Repository's in-memory index. 59 * 'repo_read_index()' can be used to populate 'index'. 60 */ 61 struct index_state *index; 62 63 /* Configurations */ 64 /* 65 * Bit used during initialization to indicate if repository state (like 66 * the location of the 'objectdir') should be read from the 67 * environment. By default this bit will be set at the begining of 68 * 'repo_init()' so that all repositories will ignore the environment. 69 * The exception to this is 'the_repository', which doesn't go through 70 * the normal 'repo_init()' process. 71 */ 72 unsigned ignore_env:1; 73 74 /* Indicate if a repository has a different 'commondir' from 'gitdir' */ 75 unsigned different_commondir:1; 76}; 77 78extern struct repository *the_repository; 79 80extern void repo_set_gitdir(struct repository *repo, const char *path); 81extern void repo_set_worktree(struct repository *repo, const char *path); 82extern int repo_init(struct repository *repo, const char *gitdir, const char *worktree); 83extern void repo_clear(struct repository *repo); 84 85extern int repo_read_index(struct repository *repo); 86 87#endif /* REPOSITORY_H */