]>
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 | ||
102de880 SB |
41 | /* |
42 | * Contains path to often used file names. | |
43 | */ | |
44 | struct path_cache cached_paths; | |
45 | ||
359efeff BW |
46 | /* |
47 | * Path to the repository's graft file. | |
48 | * Cannot be NULL after initialization. | |
49 | */ | |
50 | char *graft_file; | |
51 | ||
52 | /* | |
53 | * Path to the current worktree's index file. | |
54 | * Cannot be NULL after initialization. | |
55 | */ | |
56 | char *index_file; | |
57 | ||
58 | /* | |
59 | * Path to the working directory. | |
60 | * A NULL value indicates that there is no working directory. | |
61 | */ | |
62 | char *worktree; | |
63 | ||
96dc883b BW |
64 | /* |
65 | * Path from the root of the top-level superproject down to this | |
66 | * repository. This is only non-NULL if the repository is initialized | |
67 | * as a submodule of another repository. | |
68 | */ | |
69 | char *submodule_prefix; | |
70 | ||
3b256228 BW |
71 | /* Subsystems */ |
72 | /* | |
73 | * Repository's config which contains key-value pairs from the usual | |
74 | * set of config files (i.e. repo specific .git/config, user wide | |
75 | * ~/.gitconfig, XDG config file and the global /etc/gitconfig) | |
76 | */ | |
77 | struct config_set *config; | |
78 | ||
bf12fcdf BW |
79 | /* Repository's submodule config as defined by '.gitmodules' */ |
80 | struct submodule_cache *submodule_cache; | |
81 | ||
639e30b5 BW |
82 | /* |
83 | * Repository's in-memory index. | |
84 | * 'repo_read_index()' can be used to populate 'index'. | |
85 | */ | |
86 | struct index_state *index; | |
87 | ||
78a67668 | 88 | /* Repository's current hash algorithm, as serialized on disk. */ |
89 | const struct git_hash_algo *hash_algo; | |
90 | ||
359efeff | 91 | /* Configurations */ |
359efeff BW |
92 | |
93 | /* Indicate if a repository has a different 'commondir' from 'gitdir' */ | |
94 | unsigned different_commondir:1; | |
95 | }; | |
96 | ||
97 | extern struct repository *the_repository; | |
98 | ||
00a3da2a NTND |
99 | /* |
100 | * Define a custom repository layout. Any field can be NULL, which | |
101 | * will default back to the path according to the default layout. | |
102 | */ | |
357a03eb NTND |
103 | struct set_gitdir_args { |
104 | const char *commondir; | |
105 | const char *object_dir; | |
106 | const char *graft_file; | |
107 | const char *index_file; | |
7bc0dcaa | 108 | const char *alternate_db; |
357a03eb NTND |
109 | }; |
110 | ||
c2ec4175 NTND |
111 | void repo_set_gitdir(struct repository *repo, const char *root, |
112 | const struct set_gitdir_args *extra_args); | |
113 | void repo_set_worktree(struct repository *repo, const char *path); | |
114 | void repo_set_hash_algo(struct repository *repo, int algo); | |
115 | void initialize_the_repository(void); | |
116 | int repo_init(struct repository *r, const char *gitdir, const char *worktree); | |
117 | int repo_submodule_init(struct repository *submodule, | |
118 | struct repository *superproject, | |
119 | const char *path); | |
120 | void repo_clear(struct repository *repo); | |
359efeff | 121 | |
3f138775 BW |
122 | /* |
123 | * Populates the repository's index from its index_file, an index struct will | |
124 | * be allocated if needed. | |
125 | * | |
126 | * Return the number of index entries in the populated index or a value less | |
127 | * than zero if an error occured. If the repository's index has already been | |
128 | * populated then the number of entries will simply be returned. | |
129 | */ | |
c2ec4175 | 130 | int repo_read_index(struct repository *repo); |
639e30b5 | 131 | |
359efeff | 132 | #endif /* REPOSITORY_H */ |