1#ifndef REPOSITORY_H 2#define REPOSITORY_H 3 4#include"path.h" 5 6struct config_set; 7struct git_hash_algo; 8struct index_state; 9struct raw_object_store; 10struct submodule_cache; 11 12struct repository { 13/* Environment */ 14/* 15 * Path to the git directory. 16 * Cannot be NULL after initialization. 17 */ 18char*gitdir; 19 20/* 21 * Path to the common git directory. 22 * Cannot be NULL after initialization. 23 */ 24char*commondir; 25 26/* 27 * Holds any information related to accessing the raw object content. 28 */ 29struct raw_object_store *objects; 30 31/* 32 * All objects in this repository that have been parsed. This structure 33 * owns all objects it references, so users of "struct object *" 34 * generally do not need to free them; instead, when a repository is no 35 * longer used, call parsed_object_pool_clear() on this structure, which 36 * is called by the repositories repo_clear on its desconstruction. 37 */ 38struct parsed_object_pool *parsed_objects; 39 40/* The store in which the refs are held. */ 41struct ref_store *refs; 42 43/* 44 * Contains path to often used file names. 45 */ 46struct path_cache cached_paths; 47 48/* 49 * Path to the repository's graft file. 50 * Cannot be NULL after initialization. 51 */ 52char*graft_file; 53 54/* 55 * Path to the current worktree's index file. 56 * Cannot be NULL after initialization. 57 */ 58char*index_file; 59 60/* 61 * Path to the working directory. 62 * A NULL value indicates that there is no working directory. 63 */ 64char*worktree; 65 66/* 67 * Path from the root of the top-level superproject down to this 68 * repository. This is only non-NULL if the repository is initialized 69 * as a submodule of another repository. 70 */ 71char*submodule_prefix; 72 73/* Subsystems */ 74/* 75 * Repository's config which contains key-value pairs from the usual 76 * set of config files (i.e. repo specific .git/config, user wide 77 * ~/.gitconfig, XDG config file and the global /etc/gitconfig) 78 */ 79struct config_set *config; 80 81/* Repository's submodule config as defined by '.gitmodules' */ 82struct submodule_cache *submodule_cache; 83 84/* 85 * Repository's in-memory index. 86 * 'repo_read_index()' can be used to populate 'index'. 87 */ 88struct index_state *index; 89 90/* Repository's current hash algorithm, as serialized on disk. */ 91const struct git_hash_algo *hash_algo; 92 93/* Configurations */ 94 95/* Indicate if a repository has a different 'commondir' from 'gitdir' */ 96unsigned different_commondir:1; 97}; 98 99externstruct repository *the_repository; 100 101/* 102 * Define a custom repository layout. Any field can be NULL, which 103 * will default back to the path according to the default layout. 104 */ 105struct set_gitdir_args { 106const char*commondir; 107const char*object_dir; 108const char*graft_file; 109const char*index_file; 110const char*alternate_db; 111}; 112 113externvoidrepo_set_gitdir(struct repository *repo, 114const char*root, 115const struct set_gitdir_args *extra_args); 116externvoidrepo_set_worktree(struct repository *repo,const char*path); 117externvoidrepo_set_hash_algo(struct repository *repo,int algo); 118externvoidinitialize_the_repository(void); 119externintrepo_init(struct repository *r, 120const char*gitdir, 121const char*worktree); 122externintrepo_submodule_init(struct repository *submodule, 123struct repository *superproject, 124const char*path); 125externvoidrepo_clear(struct repository *repo); 126 127/* 128 * Populates the repository's index from its index_file, an index struct will 129 * be allocated if needed. 130 * 131 * Return the number of index entries in the populated index or a value less 132 * than zero if an error occured. If the repository's index has already been 133 * populated then the number of entries will simply be returned. 134 */ 135externintrepo_read_index(struct repository *repo); 136 137#endif/* REPOSITORY_H */