completion: use __gitcomp_builtin in _git_fetch
[git/debian.git] / repository.h
blob0329e40c7f5e72dad3ba46328a8e3d6c29ed8e58
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;
30 * Path to the repository's graft file.
31 * Cannot be NULL after initialization.
33 char *graft_file;
36 * Path to the current worktree's index file.
37 * Cannot be NULL after initialization.
39 char *index_file;
42 * Path to the working directory.
43 * A NULL value indicates that there is no working directory.
45 char *worktree;
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.
52 char *submodule_prefix;
54 /* Subsystems */
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)
60 struct config_set *config;
62 /* Repository's submodule config as defined by '.gitmodules' */
63 struct submodule_cache *submodule_cache;
66 * Repository's in-memory index.
67 * 'repo_read_index()' can be used to populate 'index'.
69 struct index_state *index;
71 /* Repository's current hash algorithm, as serialized on disk. */
72 const struct git_hash_algo *hash_algo;
74 /* Configurations */
76 * Bit used during initialization to indicate if repository state (like
77 * the location of the 'objectdir') should be read from the
78 * environment. By default this bit will be set at the begining of
79 * 'repo_init()' so that all repositories will ignore the environment.
80 * The exception to this is 'the_repository', which doesn't go through
81 * the normal 'repo_init()' process.
83 unsigned ignore_env:1;
85 /* Indicate if a repository has a different 'commondir' from 'gitdir' */
86 unsigned different_commondir:1;
89 extern struct repository *the_repository;
91 extern void repo_set_gitdir(struct repository *repo, const char *path);
92 extern void repo_set_worktree(struct repository *repo, const char *path);
93 extern void repo_set_hash_algo(struct repository *repo, int algo);
94 extern int repo_init(struct repository *repo, const char *gitdir, const char *worktree);
95 extern int repo_submodule_init(struct repository *submodule,
96 struct repository *superproject,
97 const char *path);
98 extern void repo_clear(struct repository *repo);
101 * Populates the repository's index from its index_file, an index struct will
102 * be allocated if needed.
104 * Return the number of index entries in the populated index or a value less
105 * than zero if an error occured. If the repository's index has already been
106 * populated then the number of entries will simply be returned.
108 extern int repo_read_index(struct repository *repo);
110 #endif /* REPOSITORY_H */