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