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