sha1_file.c: move delayed getenv(altdb) back to setup_git_env()
[git.git] / repository.h
blob2bfbf762f398f81c6116b1aa18a459f9178aa727
1 #ifndef REPOSITORY_H
2 #define REPOSITORY_H
4 struct config_set;
5 struct index_state;
6 struct submodule_cache;
7 struct git_hash_algo;
9 struct repository {
10 /* Environment */
12 * Path to the git directory.
13 * Cannot be NULL after initialization.
15 char *gitdir;
18 * Path to the common git directory.
19 * Cannot be NULL after initialization.
21 char *commondir;
24 * Path to the repository's object store.
25 * Cannot be NULL after initialization.
27 char *objectdir;
29 /* Path to extra alternate object database if not NULL */
30 char *alternate_db;
33 * Path to the repository's graft file.
34 * Cannot be NULL after initialization.
36 char *graft_file;
39 * Path to the current worktree's index file.
40 * Cannot be NULL after initialization.
42 char *index_file;
45 * Path to the working directory.
46 * A NULL value indicates that there is no working directory.
48 char *worktree;
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.
55 char *submodule_prefix;
57 /* Subsystems */
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)
63 struct config_set *config;
65 /* Repository's submodule config as defined by '.gitmodules' */
66 struct submodule_cache *submodule_cache;
69 * Repository's in-memory index.
70 * 'repo_read_index()' can be used to populate 'index'.
72 struct index_state *index;
74 /* Repository's current hash algorithm, as serialized on disk. */
75 const struct git_hash_algo *hash_algo;
77 /* Configurations */
79 * Bit used during initialization to indicate if repository state (like
80 * the location of the 'objectdir') should be read from the
81 * environment. By default this bit will be set at the begining of
82 * 'repo_init()' so that all repositories will ignore the environment.
83 * The exception to this is 'the_repository', which doesn't go through
84 * the normal 'repo_init()' process.
86 unsigned ignore_env:1;
88 /* Indicate if a repository has a different 'commondir' from 'gitdir' */
89 unsigned different_commondir:1;
92 extern struct repository *the_repository;
94 struct set_gitdir_args {
95 const char *commondir;
96 const char *object_dir;
97 const char *graft_file;
98 const char *index_file;
99 const char *alternate_db;
102 extern void repo_set_gitdir(struct repository *repo,
103 const char *root,
104 const struct set_gitdir_args *optional);
105 extern void repo_set_worktree(struct repository *repo, const char *path);
106 extern void repo_set_hash_algo(struct repository *repo, int algo);
107 extern void initialize_the_repository(void);
108 extern int repo_submodule_init(struct repository *submodule,
109 struct repository *superproject,
110 const char *path);
111 extern void repo_clear(struct repository *repo);
114 * Populates the repository's index from its index_file, an index struct will
115 * be allocated if needed.
117 * Return the number of index entries in the populated index or a value less
118 * than zero if an error occured. If the repository's index has already been
119 * populated then the number of entries will simply be returned.
121 extern int repo_read_index(struct repository *repo);
123 #endif /* REPOSITORY_H */