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