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