diff options
author | Russell Belfer <rb@github.com> | 2013-05-24 10:35:58 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-05-24 10:35:58 -0700 |
commit | 16adc9fade52b49e2bc13cb52407cc0025a93c8b (patch) | |
tree | 4e4e46a8d370237a766e9edd5a277520c4f43aef /include/git2/config.h | |
parent | 2e62e7c23ce69d89d495a2c42458c7e185a3120a (diff) | |
download | libgit2-16adc9fade52b49e2bc13cb52407cc0025a93c8b.tar.gz |
Typedef git_config_level_t and use it everywhere
The GIT_CONFIG_LEVEL constants actually work well as an enum
because they are mutually exclusive, so this adds a typedef to
the enum and uses that everywhere that one of these constants are
expected, instead of the old code that typically used an unsigned
int.
Diffstat (limited to 'include/git2/config.h')
-rw-r--r-- | include/git2/config.h | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/include/git2/config.h b/include/git2/config.h index 8d1a1a5a6..518dcaf16 100644 --- a/include/git2/config.h +++ b/include/git2/config.h @@ -27,18 +27,33 @@ GIT_BEGIN_DECL * git_config_open_default() and git_repository_config() honor those * priority levels as well. */ -enum { - GIT_CONFIG_LEVEL_SYSTEM = 1, /**< System-wide configuration file. */ - GIT_CONFIG_LEVEL_XDG = 2, /**< XDG compatible configuration file (.config/git/config). */ - GIT_CONFIG_LEVEL_GLOBAL = 3, /**< User-specific configuration file, also called Global configuration file. */ - GIT_CONFIG_LEVEL_LOCAL = 4, /**< Repository specific configuration file. */ - GIT_CONFIG_HIGHEST_LEVEL = -1, /**< Represents the highest level of a config file. */ -}; +typedef enum { + /** System-wide configuration file; /etc/gitconfig on Linux systems */ + GIT_CONFIG_LEVEL_SYSTEM = 1, + + /** XDG compatible configuration file; typically ~/.config/git/config */ + GIT_CONFIG_LEVEL_XDG = 2, + + /** User-specific configuration file (also called Global configuration + * file); typically ~/.gitconfig + */ + GIT_CONFIG_LEVEL_GLOBAL = 3, + + /** Repository specific configuration file; $WORK_DIR/.git/config on + * non-bare repos + */ + GIT_CONFIG_LEVEL_LOCAL = 4, + + /** Represents the highest level available config file (i.e. the most + * specific config file available that actually is loaded) + */ + GIT_CONFIG_HIGHEST_LEVEL = -1, +} git_config_level_t; typedef struct { const char *name; const char *value; - unsigned int level; + git_config_level_t level; } git_config_entry; typedef int (*git_config_foreach_cb)(const git_config_entry *, void *); @@ -155,7 +170,7 @@ GIT_EXTERN(int) git_config_new(git_config **out); GIT_EXTERN(int) git_config_add_file_ondisk( git_config *cfg, const char *path, - unsigned int level, + git_config_level_t level, int force); /** @@ -192,7 +207,7 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path); GIT_EXTERN(int) git_config_open_level( git_config **out, const git_config *parent, - unsigned int level); + git_config_level_t level); /** * Open the global/XDG configuration file according to git's rules @@ -241,7 +256,7 @@ GIT_EXTERN(void) git_config_free(git_config *cfg); * @return 0 or an error code */ GIT_EXTERN(int) git_config_get_entry( - const git_config_entry **out, + const git_config_entry **out, const git_config *cfg, const char *name); |