]>
git.proxmox.com Git - libgit2.git/blob - src/config.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_config_h__
8 #define INCLUDE_config_h__
13 #include "git2/config.h"
15 #include "repository.h"
17 #define GIT_CONFIG_FILENAME_PROGRAMDATA "config"
18 #define GIT_CONFIG_FILENAME_SYSTEM "gitconfig"
19 #define GIT_CONFIG_FILENAME_GLOBAL ".gitconfig"
20 #define GIT_CONFIG_FILENAME_XDG "config"
22 #define GIT_CONFIG_FILENAME_INREPO "config"
23 #define GIT_CONFIG_FILE_MODE 0666
30 extern int git_config__global_location(git_buf
*buf
);
32 extern int git_config_rename_section(
34 const char *old_section_name
, /* eg "branch.dummy" */
35 const char *new_section_name
); /* NULL to drop the old section */
37 extern int git_config__normalize_name(const char *in
, char **out
);
39 /* internal only: does not normalize key and sets out to NULL if not found */
40 extern int git_config__lookup_entry(
41 git_config_entry
**out
,
42 const git_config
*cfg
,
46 /* internal only: update and/or delete entry string with constraints */
47 extern int git_config__update_entry(
51 bool overwrite_existing
,
52 bool only_if_existing
);
55 * Lookup functions that cannot fail. These functions look up a config
56 * value and return a fallback value if the value is missing or if any
57 * failures occur while trying to access the value.
60 extern char *git_config__get_string_force(
61 const git_config
*cfg
, const char *key
, const char *fallback_value
);
63 extern int git_config__get_bool_force(
64 const git_config
*cfg
, const char *key
, int fallback_value
);
66 extern int git_config__get_int_force(
67 const git_config
*cfg
, const char *key
, int fallback_value
);
69 /* API for repository configmap-style lookups from config - not cached, but
70 * uses configmap value maps and fallbacks
72 extern int git_config__configmap_lookup(
73 int *out
, git_config
*config
, git_configmap_item item
);
76 * The opposite of git_config_lookup_map_value, we take an enum value
77 * and map it to the string or bool value on the config.
79 int git_config_lookup_map_enum(git_configmap_t
*type_out
,
80 const char **str_out
, const git_configmap
*maps
,
81 size_t map_n
, int enum_val
);
84 * Unlock the backend with the highest priority
86 * Unlocking will allow other writers to updat the configuration
87 * file. Optionally, any changes performed since the lock will be
88 * applied to the configuration.
90 * @param cfg the configuration
91 * @param commit boolean which indicates whether to commit any changes
93 * @return 0 or an error code
95 GIT_EXTERN(int) git_config_unlock(git_config
*cfg
, int commit
);