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 */ 14char*gitdir; 15 16/* 17 * Path to the common git directory. 18 * Cannot be NULL after initialization. 19 */ 20char*commondir; 21 22/* 23 * Path to the repository's object store. 24 * Cannot be NULL after initialization. 25 */ 26char*objectdir; 27 28/* 29 * Path to the repository's graft file. 30 * Cannot be NULL after initialization. 31 */ 32char*graft_file; 33 34/* 35 * Path to the current worktree's index file. 36 * Cannot be NULL after initialization. 37 */ 38char*index_file; 39 40/* 41 * Path to the working directory. 42 * A NULL value indicates that there is no working directory. 43 */ 44char*worktree; 45 46/* 47 * Path from the root of the top-level superproject down to this 48 * repository. This is only non-NULL if the repository is initialized 49 * as a submodule of another repository. 50 */ 51char*submodule_prefix; 52 53/* Subsystems */ 54/* 55 * Repository's config which contains key-value pairs from the usual 56 * set of config files (i.e. repo specific .git/config, user wide 57 * ~/.gitconfig, XDG config file and the global /etc/gitconfig) 58 */ 59struct config_set *config; 60 61/* Repository's submodule config as defined by '.gitmodules' */ 62struct submodule_cache *submodule_cache; 63 64/* 65 * Repository's in-memory index. 66 * 'repo_read_index()' can be used to populate 'index'. 67 */ 68struct index_state *index; 69 70/* Configurations */ 71/* 72 * Bit used during initialization to indicate if repository state (like 73 * the location of the 'objectdir') should be read from the 74 * environment. By default this bit will be set at the begining of 75 * 'repo_init()' so that all repositories will ignore the environment. 76 * The exception to this is 'the_repository', which doesn't go through 77 * the normal 'repo_init()' process. 78 */ 79unsigned ignore_env:1; 80 81/* Indicate if a repository has a different 'commondir' from 'gitdir' */ 82unsigned different_commondir:1; 83}; 84 85externstruct repository *the_repository; 86 87externvoidrepo_set_gitdir(struct repository *repo,const char*path); 88externvoidrepo_set_worktree(struct repository *repo,const char*path); 89externintrepo_init(struct repository *repo,const char*gitdir,const char*worktree); 90externintrepo_submodule_init(struct repository *submodule, 91struct repository *superproject, 92const char*path); 93externvoidrepo_clear(struct repository *repo); 94 95externintrepo_read_index(struct repository *repo); 96 97#endif/* REPOSITORY_H */