1#ifndef REPOSITORY_H 2#define REPOSITORY_H 3 4struct config_set; 5struct index_state; 6struct submodule_cache; 7struct git_hash_algo; 8 9struct repository { 10/* Environment */ 11/* 12 * Path to the git directory. 13 * Cannot be NULL after initialization. 14 */ 15char*gitdir; 16 17/* 18 * Path to the common git directory. 19 * Cannot be NULL after initialization. 20 */ 21char*commondir; 22 23/* 24 * Path to the repository's object store. 25 * Cannot be NULL after initialization. 26 */ 27char*objectdir; 28 29/* Path to extra alternate object database if not NULL */ 30char*alternate_db; 31 32/* 33 * Path to the repository's graft file. 34 * Cannot be NULL after initialization. 35 */ 36char*graft_file; 37 38/* 39 * Path to the current worktree's index file. 40 * Cannot be NULL after initialization. 41 */ 42char*index_file; 43 44/* 45 * Path to the working directory. 46 * A NULL value indicates that there is no working directory. 47 */ 48char*worktree; 49 50/* 51 * Path from the root of the top-level superproject down to this 52 * repository. This is only non-NULL if the repository is initialized 53 * as a submodule of another repository. 54 */ 55char*submodule_prefix; 56 57/* Subsystems */ 58/* 59 * Repository's config which contains key-value pairs from the usual 60 * set of config files (i.e. repo specific .git/config, user wide 61 * ~/.gitconfig, XDG config file and the global /etc/gitconfig) 62 */ 63struct config_set *config; 64 65/* Repository's submodule config as defined by '.gitmodules' */ 66struct submodule_cache *submodule_cache; 67 68/* 69 * Repository's in-memory index. 70 * 'repo_read_index()' can be used to populate 'index'. 71 */ 72struct index_state *index; 73 74/* Repository's current hash algorithm, as serialized on disk. */ 75const struct git_hash_algo *hash_algo; 76 77/* Configurations */ 78 79/* Indicate if a repository has a different 'commondir' from 'gitdir' */ 80unsigned different_commondir:1; 81}; 82 83externstruct repository *the_repository; 84 85struct set_gitdir_args { 86const char*commondir; 87const char*object_dir; 88const char*graft_file; 89const char*index_file; 90const char*alternate_db; 91}; 92 93externvoidrepo_set_gitdir(struct repository *repo, 94const char*root, 95const struct set_gitdir_args *optional); 96externvoidrepo_set_worktree(struct repository *repo,const char*path); 97externvoidrepo_set_hash_algo(struct repository *repo,int algo); 98externvoidinitialize_the_repository(void); 99externintrepo_submodule_init(struct repository *submodule, 100struct repository *superproject, 101const char*path); 102externvoidrepo_clear(struct repository *repo); 103 104/* 105 * Populates the repository's index from its index_file, an index struct will 106 * be allocated if needed. 107 * 108 * Return the number of index entries in the populated index or a value less 109 * than zero if an error occured. If the repository's index has already been 110 * populated then the number of entries will simply be returned. 111 */ 112externintrepo_read_index(struct repository *repo); 113 114#endif/* REPOSITORY_H */