3a41568aa06698cda7b4819d1a0110b9d95709f4
   1#ifndef REPOSITORY_H
   2#define REPOSITORY_H
   3
   4struct config_set;
   5struct index_state;
   6
   7struct repository {
   8        /* Environment */
   9        /*
  10         * Path to the git directory.
  11         * Cannot be NULL after initialization.
  12         */
  13        char *gitdir;
  14
  15        /*
  16         * Path to the common git directory.
  17         * Cannot be NULL after initialization.
  18         */
  19        char *commondir;
  20
  21        /*
  22         * Path to the repository's object store.
  23         * Cannot be NULL after initialization.
  24         */
  25        char *objectdir;
  26
  27        /*
  28         * Path to the repository's graft file.
  29         * Cannot be NULL after initialization.
  30         */
  31        char *graft_file;
  32
  33        /*
  34         * Path to the current worktree's index file.
  35         * Cannot be NULL after initialization.
  36         */
  37        char *index_file;
  38
  39        /*
  40         * Path to the working directory.
  41         * A NULL value indicates that there is no working directory.
  42         */
  43        char *worktree;
  44
  45        /* Subsystems */
  46        /*
  47         * Repository's config which contains key-value pairs from the usual
  48         * set of config files (i.e. repo specific .git/config, user wide
  49         * ~/.gitconfig, XDG config file and the global /etc/gitconfig)
  50         */
  51        struct config_set *config;
  52
  53        /*
  54         * Repository's in-memory index.
  55         * 'repo_read_index()' can be used to populate 'index'.
  56         */
  57        struct index_state *index;
  58
  59        /* Configurations */
  60        /*
  61         * Bit used during initialization to indicate if repository state (like
  62         * the location of the 'objectdir') should be read from the
  63         * environment.  By default this bit will be set at the begining of
  64         * 'repo_init()' so that all repositories will ignore the environment.
  65         * The exception to this is 'the_repository', which doesn't go through
  66         * the normal 'repo_init()' process.
  67         */
  68        unsigned ignore_env:1;
  69
  70        /* Indicate if a repository has a different 'commondir' from 'gitdir' */
  71        unsigned different_commondir:1;
  72};
  73
  74extern struct repository *the_repository;
  75
  76extern void repo_set_gitdir(struct repository *repo, const char *path);
  77extern void repo_set_worktree(struct repository *repo, const char *path);
  78extern int repo_init(struct repository *repo, const char *gitdir, const char *worktree);
  79extern void repo_clear(struct repository *repo);
  80
  81extern int repo_read_index(struct repository *repo);
  82
  83#endif /* REPOSITORY_H */