Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:37

0001 /*
0002  * Copyright (C) the libgit2 contributors. All rights reserved.
0003  *
0004  * This file is part of libgit2, distributed under the GNU GPL v2 with
0005  * a Linking Exception. For full terms see the included COPYING file.
0006  */
0007 #ifndef INCLUDE_git_config_h__
0008 #define INCLUDE_git_config_h__
0009 
0010 #include "common.h"
0011 #include "types.h"
0012 #include "buffer.h"
0013 
0014 /**
0015  * @file git2/config.h
0016  * @brief Git config management routines
0017  * @defgroup git_config Git config management routines
0018  * @ingroup Git
0019  * @{
0020  */
0021 GIT_BEGIN_DECL
0022 
0023 /**
0024  * Priority level of a config file.
0025  *
0026  * These priority levels correspond to the natural escalation logic
0027  * (from higher to lower) when reading or searching for config entries
0028  * in git.git. Meaning that for the same key, the configuration in
0029  * the local configuration is preferred over the configuration in
0030  * the system configuration file.
0031  *
0032  * Callers can add their own custom configuration, beginning at the
0033  * `GIT_CONFIG_LEVEL_APP` level.
0034  *
0035  * Writes, by default, occur in the highest priority level backend
0036  * that is writable. This ordering can be overridden with
0037  * `git_config_set_writeorder`.
0038  *
0039  * git_config_open_default() and git_repository_config() honor those
0040  * priority levels as well.
0041  */
0042 typedef enum {
0043     /** System-wide on Windows, for compatibility with portable git */
0044     GIT_CONFIG_LEVEL_PROGRAMDATA = 1,
0045 
0046     /** System-wide configuration file; /etc/gitconfig on Linux systems */
0047     GIT_CONFIG_LEVEL_SYSTEM = 2,
0048 
0049     /** XDG compatible configuration file; typically ~/.config/git/config */
0050     GIT_CONFIG_LEVEL_XDG = 3,
0051 
0052     /** User-specific configuration file (also called Global configuration
0053      * file); typically ~/.gitconfig
0054      */
0055     GIT_CONFIG_LEVEL_GLOBAL = 4,
0056 
0057     /** Repository specific configuration file; $WORK_DIR/.git/config on
0058      * non-bare repos
0059      */
0060     GIT_CONFIG_LEVEL_LOCAL = 5,
0061 
0062     /** Worktree specific configuration file; $GIT_DIR/config.worktree
0063      */
0064     GIT_CONFIG_LEVEL_WORKTREE = 6,
0065 
0066     /** Application specific configuration file; freely defined by applications
0067      */
0068     GIT_CONFIG_LEVEL_APP = 7,
0069 
0070     /** Represents the highest level available config file (i.e. the most
0071      * specific config file available that actually is loaded)
0072      */
0073     GIT_CONFIG_HIGHEST_LEVEL = -1
0074 } git_config_level_t;
0075 
0076 /**
0077  * An entry in a configuration file
0078  */
0079 typedef struct git_config_entry {
0080     /** Name of the configuration entry (normalized) */
0081     const char *name;
0082 
0083     /** Literal (string) value of the entry */
0084     const char *value;
0085 
0086     /** The type of backend that this entry exists in (eg, "file") */
0087     const char *backend_type;
0088 
0089     /**
0090      * The path to the origin of this entry. For config files, this is
0091      * the path to the file.
0092      */
0093     const char *origin_path;
0094 
0095     /** Depth of includes where this variable was found */
0096     unsigned int include_depth;
0097 
0098     /** Configuration level for the file this was found in */
0099     git_config_level_t level;
0100 
0101     /**
0102      * Free function for this entry; for internal purposes. Callers
0103      * should call `git_config_entry_free` to free data.
0104      */
0105     void GIT_CALLBACK(free)(struct git_config_entry *entry);
0106 } git_config_entry;
0107 
0108 /**
0109  * Free a config entry
0110  *
0111  * @param entry The entry to free.
0112  */
0113 GIT_EXTERN(void) git_config_entry_free(git_config_entry *entry);
0114 
0115 /**
0116  * A config enumeration callback
0117  *
0118  * @param entry the entry currently being enumerated
0119  * @param payload a user-specified pointer
0120  * @return non-zero to terminate the iteration.
0121  */
0122 typedef int GIT_CALLBACK(git_config_foreach_cb)(const git_config_entry *entry, void *payload);
0123 
0124 /**
0125  * An opaque structure for a configuration iterator
0126  */
0127 typedef struct git_config_iterator git_config_iterator;
0128 
0129 /**
0130  * Config var type
0131  */
0132 typedef enum {
0133     GIT_CONFIGMAP_FALSE = 0,
0134     GIT_CONFIGMAP_TRUE = 1,
0135     GIT_CONFIGMAP_INT32,
0136     GIT_CONFIGMAP_STRING
0137 } git_configmap_t;
0138 
0139 /**
0140  * Mapping from config variables to values.
0141  */
0142 typedef struct {
0143     git_configmap_t type;
0144     const char *str_match;
0145     int map_value;
0146 } git_configmap;
0147 
0148 /**
0149  * Locate the path to the global configuration file
0150  *
0151  * The user or global configuration file is usually
0152  * located in `$HOME/.gitconfig`.
0153  *
0154  * This method will try to guess the full path to that
0155  * file, if the file exists. The returned path
0156  * may be used on any `git_config` call to load the
0157  * global configuration file.
0158  *
0159  * This method will not guess the path to the xdg compatible
0160  * config file (`.config/git/config`).
0161  *
0162  * @param out Pointer to a user-allocated git_buf in which to store the path
0163  * @return 0 if a global configuration file has been found. Its path will be stored in `out`.
0164  */
0165 GIT_EXTERN(int) git_config_find_global(git_buf *out);
0166 
0167 /**
0168  * Locate the path to the global xdg compatible configuration file
0169  *
0170  * The xdg compatible configuration file is usually
0171  * located in `$HOME/.config/git/config`.
0172  *
0173  * This method will try to guess the full path to that
0174  * file, if the file exists. The returned path
0175  * may be used on any `git_config` call to load the
0176  * xdg compatible configuration file.
0177  *
0178  * @param out Pointer to a user-allocated git_buf in which to store the path
0179  * @return 0 if a xdg compatible configuration file has been
0180  *  found. Its path will be stored in `out`.
0181  */
0182 GIT_EXTERN(int) git_config_find_xdg(git_buf *out);
0183 
0184 /**
0185  * Locate the path to the system configuration file
0186  *
0187  * If `/etc/gitconfig` doesn't exist, it will look for
0188  * `%PROGRAMFILES%\Git\etc\gitconfig`.
0189  *
0190  * @param out Pointer to a user-allocated git_buf in which to store the path
0191  * @return 0 if a system configuration file has been
0192  *  found. Its path will be stored in `out`.
0193  */
0194 GIT_EXTERN(int) git_config_find_system(git_buf *out);
0195 
0196 /**
0197  * Locate the path to the configuration file in ProgramData
0198  *
0199  * Look for the file in `%PROGRAMDATA%\Git\config` used by portable git.
0200  *
0201  * @param out Pointer to a user-allocated git_buf in which to store the path
0202  * @return 0 if a ProgramData configuration file has been
0203  *  found. Its path will be stored in `out`.
0204  */
0205 GIT_EXTERN(int) git_config_find_programdata(git_buf *out);
0206 
0207 /**
0208  * Open the global, XDG and system configuration files
0209  *
0210  * Utility wrapper that finds the global, XDG and system configuration files
0211  * and opens them into a single prioritized config object that can be
0212  * used when accessing default config data outside a repository.
0213  *
0214  * @param out Pointer to store the config instance
0215  * @return 0 or an error code
0216  */
0217 GIT_EXTERN(int) git_config_open_default(git_config **out);
0218 
0219 /**
0220  * Allocate a new configuration object
0221  *
0222  * This object is empty, so you have to add a file to it before you
0223  * can do anything with it.
0224  *
0225  * @param out pointer to the new configuration
0226  * @return 0 or an error code
0227  */
0228 GIT_EXTERN(int) git_config_new(git_config **out);
0229 
0230 /**
0231  * Add an on-disk config file instance to an existing config
0232  *
0233  * The on-disk file pointed at by `path` will be opened and
0234  * parsed; it's expected to be a native Git config file following
0235  * the default Git config syntax (see man git-config).
0236  *
0237  * If the file does not exist, the file will still be added and it
0238  * will be created the first time we write to it.
0239  *
0240  * Note that the configuration object will free the file
0241  * automatically.
0242  *
0243  * Further queries on this config object will access each
0244  * of the config file instances in order (instances with
0245  * a higher priority level will be accessed first).
0246  *
0247  * @param cfg the configuration to add the file to
0248  * @param path path to the configuration file to add
0249  * @param level the priority level of the backend
0250  * @param force replace config file at the given priority level
0251  * @param repo optional repository to allow parsing of
0252  *  conditional includes
0253  * @return 0 on success, GIT_EEXISTS when adding more than one file
0254  *  for a given priority level (and force_replace set to 0),
0255  *  GIT_ENOTFOUND when the file doesn't exist or error code
0256  */
0257 GIT_EXTERN(int) git_config_add_file_ondisk(
0258     git_config *cfg,
0259     const char *path,
0260     git_config_level_t level,
0261     const git_repository *repo,
0262     int force);
0263 
0264 /**
0265  * Create a new config instance containing a single on-disk file
0266  *
0267  * This method is a simple utility wrapper for the following sequence
0268  * of calls:
0269  *  - git_config_new
0270  *  - git_config_add_file_ondisk
0271  *
0272  * @param out The configuration instance to create
0273  * @param path Path to the on-disk file to open
0274  * @return 0 on success, or an error code
0275  */
0276 GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
0277 
0278 /**
0279  * Build a single-level focused config object from a multi-level one.
0280  *
0281  * The returned config object can be used to perform get/set/delete operations
0282  * on a single specific level.
0283  *
0284  * Getting several times the same level from the same parent multi-level config
0285  * will return different config instances, but containing the same config_file
0286  * instance.
0287  *
0288  * @param out The configuration instance to create
0289  * @param parent Multi-level config to search for the given level
0290  * @param level Configuration level to search for
0291  * @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
0292  * multi-level parent config, or an error code
0293  */
0294 GIT_EXTERN(int) git_config_open_level(
0295     git_config **out,
0296     const git_config *parent,
0297     git_config_level_t level);
0298 
0299 /**
0300  * Open the global/XDG configuration file according to git's rules
0301  *
0302  * Git allows you to store your global configuration at
0303  * `$HOME/.gitconfig` or `$XDG_CONFIG_HOME/git/config`. For backwards
0304  * compatibility, the XDG file shouldn't be used unless the use has
0305  * created it explicitly. With this function you'll open the correct
0306  * one to write to.
0307  *
0308  * @param out pointer in which to store the config object
0309  * @param config the config object in which to look
0310  * @return 0 or an error code.
0311  */
0312 GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config);
0313 
0314 GIT_EXTERN(int) git_config_set_writeorder(
0315     git_config *cfg,
0316     git_config_level_t *levels,
0317     size_t len);
0318 
0319 /**
0320  * Create a snapshot of the configuration
0321  *
0322  * Create a snapshot of the current state of a configuration, which
0323  * allows you to look into a consistent view of the configuration for
0324  * looking up complex values (e.g. a remote, submodule).
0325  *
0326  * The string returned when querying such a config object is valid
0327  * until it is freed.
0328  *
0329  * @param out pointer in which to store the snapshot config object
0330  * @param config configuration to snapshot
0331  * @return 0 or an error code
0332  */
0333 GIT_EXTERN(int) git_config_snapshot(git_config **out, git_config *config);
0334 
0335 /**
0336  * Free the configuration and its associated memory and files
0337  *
0338  * @param cfg the configuration to free
0339  */
0340 GIT_EXTERN(void) git_config_free(git_config *cfg);
0341 
0342 /**
0343  * Get the git_config_entry of a config variable.
0344  *
0345  * Free the git_config_entry after use with `git_config_entry_free()`.
0346  *
0347  * @param out pointer to the variable git_config_entry
0348  * @param cfg where to look for the variable
0349  * @param name the variable's name
0350  * @return 0 or an error code
0351  */
0352 GIT_EXTERN(int) git_config_get_entry(
0353     git_config_entry **out,
0354     const git_config *cfg,
0355     const char *name);
0356 
0357 /**
0358  * Get the value of an integer config variable.
0359  *
0360  * All config files will be looked into, in the order of their
0361  * defined level. A higher level means a higher priority. The
0362  * first occurrence of the variable will be returned here.
0363  *
0364  * @param out pointer to the variable where the value should be stored
0365  * @param cfg where to look for the variable
0366  * @param name the variable's name
0367  * @return 0 or an error code
0368  */
0369 GIT_EXTERN(int) git_config_get_int32(int32_t *out, const git_config *cfg, const char *name);
0370 
0371 /**
0372  * Get the value of a long integer config variable.
0373  *
0374  * All config files will be looked into, in the order of their
0375  * defined level. A higher level means a higher priority. The
0376  * first occurrence of the variable will be returned here.
0377  *
0378  * @param out pointer to the variable where the value should be stored
0379  * @param cfg where to look for the variable
0380  * @param name the variable's name
0381  * @return 0 or an error code
0382  */
0383 GIT_EXTERN(int) git_config_get_int64(int64_t *out, const git_config *cfg, const char *name);
0384 
0385 /**
0386  * Get the value of a boolean config variable.
0387  *
0388  * This function uses the usual C convention of 0 being false and
0389  * anything else true.
0390  *
0391  * All config files will be looked into, in the order of their
0392  * defined level. A higher level means a higher priority. The
0393  * first occurrence of the variable will be returned here.
0394  *
0395  * @param out pointer to the variable where the value should be stored
0396  * @param cfg where to look for the variable
0397  * @param name the variable's name
0398  * @return 0 or an error code
0399  */
0400 GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char *name);
0401 
0402 /**
0403  * Get the value of a path config variable.
0404  *
0405  * A leading '~' will be expanded to the global search path (which
0406  * defaults to the user's home directory but can be overridden via
0407  * `git_libgit2_opts()`.
0408  *
0409  * All config files will be looked into, in the order of their
0410  * defined level. A higher level means a higher priority. The
0411  * first occurrence of the variable will be returned here.
0412  *
0413  * @param out the buffer in which to store the result
0414  * @param cfg where to look for the variable
0415  * @param name the variable's name
0416  * @return 0 or an error code
0417  */
0418 GIT_EXTERN(int) git_config_get_path(git_buf *out, const git_config *cfg, const char *name);
0419 
0420 /**
0421  * Get the value of a string config variable.
0422  *
0423  * This function can only be used on snapshot config objects. The
0424  * string is owned by the config and should not be freed by the
0425  * user. The pointer will be valid until the config is freed.
0426  *
0427  * All config files will be looked into, in the order of their
0428  * defined level. A higher level means a higher priority. The
0429  * first occurrence of the variable will be returned here.
0430  *
0431  * @param out pointer to the string
0432  * @param cfg where to look for the variable
0433  * @param name the variable's name
0434  * @return 0 or an error code
0435  */
0436 GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name);
0437 
0438 /**
0439  * Get the value of a string config variable.
0440  *
0441  * The value of the config will be copied into the buffer.
0442  *
0443  * All config files will be looked into, in the order of their
0444  * defined level. A higher level means a higher priority. The
0445  * first occurrence of the variable will be returned here.
0446  *
0447  * @param out buffer in which to store the string
0448  * @param cfg where to look for the variable
0449  * @param name the variable's name
0450  * @return 0 or an error code
0451  */
0452 GIT_EXTERN(int) git_config_get_string_buf(git_buf *out, const git_config *cfg, const char *name);
0453 
0454 /**
0455  * Get each value of a multivar in a foreach callback
0456  *
0457  * The callback will be called on each variable found
0458  *
0459  * The regular expression is applied case-sensitively on the normalized form of
0460  * the variable name: the section and variable parts are lower-cased. The
0461  * subsection is left unchanged.
0462  *
0463  * @param cfg where to look for the variable
0464  * @param name the variable's name
0465  * @param regexp regular expression to filter which variables we're
0466  * interested in. Use NULL to indicate all
0467  * @param callback the function to be called on each value of the variable
0468  * @param payload opaque pointer to pass to the callback
0469  * @return 0 or an error code.
0470  */
0471 GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
0472 
0473 /**
0474  * Get each value of a multivar
0475  *
0476  * The regular expression is applied case-sensitively on the normalized form of
0477  * the variable name: the section and variable parts are lower-cased. The
0478  * subsection is left unchanged.
0479  *
0480  * @param out pointer to store the iterator
0481  * @param cfg where to look for the variable
0482  * @param name the variable's name
0483  * @param regexp regular expression to filter which variables we're
0484  * interested in. Use NULL to indicate all
0485  * @return 0 or an error code.
0486  */
0487 GIT_EXTERN(int) git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp);
0488 
0489 /**
0490  * Return the current entry and advance the iterator
0491  *
0492  * The pointers returned by this function are valid until the next call
0493  * to `git_config_next` or until the iterator is freed.
0494  *
0495  * @param entry pointer to store the entry
0496  * @param iter the iterator
0497  * @return 0 or an error code. GIT_ITEROVER if the iteration has completed
0498  */
0499 GIT_EXTERN(int) git_config_next(git_config_entry **entry, git_config_iterator *iter);
0500 
0501 /**
0502  * Free a config iterator
0503  *
0504  * @param iter the iterator to free
0505  */
0506 GIT_EXTERN(void) git_config_iterator_free(git_config_iterator *iter);
0507 
0508 /**
0509  * Set the value of an integer config variable in the config file
0510  * with the highest level (usually the local one).
0511  *
0512  * @param cfg where to look for the variable
0513  * @param name the variable's name
0514  * @param value Integer value for the variable
0515  * @return 0 or an error code
0516  */
0517 GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value);
0518 
0519 /**
0520  * Set the value of a long integer config variable in the config file
0521  * with the highest level (usually the local one).
0522  *
0523  * @param cfg where to look for the variable
0524  * @param name the variable's name
0525  * @param value Long integer value for the variable
0526  * @return 0 or an error code
0527  */
0528 GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value);
0529 
0530 /**
0531  * Set the value of a boolean config variable in the config file
0532  * with the highest level (usually the local one).
0533  *
0534  * @param cfg where to look for the variable
0535  * @param name the variable's name
0536  * @param value the value to store
0537  * @return 0 or an error code
0538  */
0539 GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value);
0540 
0541 /**
0542  * Set the value of a string config variable in the config file
0543  * with the highest level (usually the local one).
0544  *
0545  * A copy of the string is made and the user is free to use it
0546  * afterwards.
0547  *
0548  * @param cfg where to look for the variable
0549  * @param name the variable's name
0550  * @param value the string to store.
0551  * @return 0 or an error code
0552  */
0553 GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value);
0554 
0555 /**
0556  * Set a multivar in the local config file.
0557  *
0558  * The regular expression is applied case-sensitively on the value.
0559  *
0560  * @param cfg where to look for the variable
0561  * @param name the variable's name
0562  * @param regexp a regular expression to indicate which values to replace
0563  * @param value the new value.
0564  * @return 0 or an error code.
0565  */
0566 GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
0567 
0568 /**
0569  * Delete a config variable from the config file
0570  * with the highest level (usually the local one).
0571  *
0572  * @param cfg the configuration
0573  * @param name the variable to delete
0574  * @return 0 or an error code.
0575  */
0576 GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name);
0577 
0578 /**
0579  * Deletes one or several entries from a multivar in the local config file.
0580  *
0581  * The regular expression is applied case-sensitively on the value.
0582  *
0583  * @param cfg where to look for the variables
0584  * @param name the variable's name
0585  * @param regexp a regular expression to indicate which values to delete
0586  *
0587  * @return 0 or an error code
0588  */
0589 GIT_EXTERN(int) git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp);
0590 
0591 /**
0592  * Perform an operation on each config variable.
0593  *
0594  * The callback receives the normalized name and value of each variable
0595  * in the config backend, and the data pointer passed to this function.
0596  * If the callback returns a non-zero value, the function stops iterating
0597  * and returns that value to the caller.
0598  *
0599  * The pointers passed to the callback are only valid as long as the
0600  * iteration is ongoing.
0601  *
0602  * @param cfg where to get the variables from
0603  * @param callback the function to call on each variable
0604  * @param payload the data to pass to the callback
0605  * @return 0 on success, non-zero callback return value, or error code
0606  */
0607 GIT_EXTERN(int) git_config_foreach(
0608     const git_config *cfg,
0609     git_config_foreach_cb callback,
0610     void *payload);
0611 
0612 /**
0613  * Iterate over all the config variables
0614  *
0615  * Use `git_config_next` to advance the iteration and
0616  * `git_config_iterator_free` when done.
0617  *
0618  * @param out pointer to store the iterator
0619  * @param cfg where to get the variables from
0620  * @return 0 or an error code.
0621  */
0622 GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_config *cfg);
0623 
0624 /**
0625  * Iterate over all the config variables whose name matches a pattern
0626  *
0627  * Use `git_config_next` to advance the iteration and
0628  * `git_config_iterator_free` when done.
0629  *
0630  * The regular expression is applied case-sensitively on the normalized form of
0631  * the variable name: the section and variable parts are lower-cased. The
0632  * subsection is left unchanged.
0633  *
0634  * @param out pointer to store the iterator
0635  * @param cfg where to ge the variables from
0636  * @param regexp regular expression to match the names
0637  * @return 0 or an error code.
0638  */
0639 GIT_EXTERN(int) git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp);
0640 
0641 /**
0642  * Perform an operation on each config variable matching a regular expression.
0643  *
0644  * This behaves like `git_config_foreach` with an additional filter of a
0645  * regular expression that filters which config keys are passed to the
0646  * callback.
0647  *
0648  * The regular expression is applied case-sensitively on the normalized form of
0649  * the variable name: the section and variable parts are lower-cased. The
0650  * subsection is left unchanged.
0651  *
0652  * The regular expression is applied case-sensitively on the normalized form of
0653  * the variable name: the case-insensitive parts are lower-case.
0654  *
0655  * @param cfg where to get the variables from
0656  * @param regexp regular expression to match against config names
0657  * @param callback the function to call on each variable
0658  * @param payload the data to pass to the callback
0659  * @return 0 or the return value of the callback which didn't return 0
0660  */
0661 GIT_EXTERN(int) git_config_foreach_match(
0662     const git_config *cfg,
0663     const char *regexp,
0664     git_config_foreach_cb callback,
0665     void *payload);
0666 
0667 /**
0668  * Query the value of a config variable and return it mapped to
0669  * an integer constant.
0670  *
0671  * This is a helper method to easily map different possible values
0672  * to a variable to integer constants that easily identify them.
0673  *
0674  * A mapping array looks as follows:
0675  *
0676  *  git_configmap autocrlf_mapping[] = {
0677  *      {GIT_CVAR_FALSE, NULL, GIT_AUTO_CRLF_FALSE},
0678  *      {GIT_CVAR_TRUE, NULL, GIT_AUTO_CRLF_TRUE},
0679  *      {GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT},
0680  *      {GIT_CVAR_STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
0681  *
0682  * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
0683  * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
0684  *
0685  * The same thing applies for any "true" value such as "true", "yes" or "1", storing
0686  * the `GIT_AUTO_CRLF_TRUE` variable.
0687  *
0688  * Otherwise, if the value matches the string "input" (with case insensitive comparison),
0689  * the given constant will be stored in `out`, and likewise for "default".
0690  *
0691  * If not a single match can be made to store in `out`, an error code will be
0692  * returned.
0693  *
0694  * @param out place to store the result of the mapping
0695  * @param cfg config file to get the variables from
0696  * @param name name of the config variable to lookup
0697  * @param maps array of `git_configmap` objects specifying the possible mappings
0698  * @param map_n number of mapping objects in `maps`
0699  * @return 0 on success, error code otherwise
0700  */
0701 GIT_EXTERN(int) git_config_get_mapped(
0702     int *out,
0703     const git_config *cfg,
0704     const char *name,
0705     const git_configmap *maps,
0706     size_t map_n);
0707 
0708 /**
0709  * Maps a string value to an integer constant
0710  *
0711  * @param out place to store the result of the parsing
0712  * @param maps array of `git_configmap` objects specifying the possible mappings
0713  * @param map_n number of mapping objects in `maps`
0714  * @param value value to parse
0715  * @return 0 or an error code.
0716  */
0717 GIT_EXTERN(int) git_config_lookup_map_value(
0718     int *out,
0719     const git_configmap *maps,
0720     size_t map_n,
0721     const char *value);
0722 
0723 /**
0724  * Parse a string value as a bool.
0725  *
0726  * Valid values for true are: 'true', 'yes', 'on', 1 or any
0727  *  number different from 0
0728  * Valid values for false are: 'false', 'no', 'off', 0
0729  *
0730  * @param out place to store the result of the parsing
0731  * @param value value to parse
0732  * @return 0 or an error code.
0733  */
0734 GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
0735 
0736 /**
0737  * Parse a string value as an int32.
0738  *
0739  * An optional value suffix of 'k', 'm', or 'g' will
0740  * cause the value to be multiplied by 1024, 1048576,
0741  * or 1073741824 prior to output.
0742  *
0743  * @param out place to store the result of the parsing
0744  * @param value value to parse
0745  * @return 0 or an error code.
0746  */
0747 GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
0748 
0749 /**
0750  * Parse a string value as an int64.
0751  *
0752  * An optional value suffix of 'k', 'm', or 'g' will
0753  * cause the value to be multiplied by 1024, 1048576,
0754  * or 1073741824 prior to output.
0755  *
0756  * @param out place to store the result of the parsing
0757  * @param value value to parse
0758  * @return 0 or an error code.
0759  */
0760 GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
0761 
0762 /**
0763  * Parse a string value as a path.
0764  *
0765  * A leading '~' will be expanded to the global search path (which
0766  * defaults to the user's home directory but can be overridden via
0767  * `git_libgit2_opts()`.
0768  *
0769  * If the value does not begin with a tilde, the input will be
0770  * returned.
0771  *
0772  * @param out placae to store the result of parsing
0773  * @param value the path to evaluate
0774  * @return 0 or an error code.
0775  */
0776 GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value);
0777 
0778 /**
0779  * Perform an operation on each config variable in a given config backend,
0780  * matching a regular expression.
0781  *
0782  * This behaves like `git_config_foreach_match` except that only config
0783  * entries from the given backend entry are enumerated.
0784  *
0785  * The regular expression is applied case-sensitively on the normalized form of
0786  * the variable name: the section and variable parts are lower-cased. The
0787  * subsection is left unchanged.
0788  *
0789  * @param backend where to get the variables from
0790  * @param regexp regular expression to match against config names (can be NULL)
0791  * @param callback the function to call on each variable
0792  * @param payload the data to pass to the callback
0793  * @return 0 or an error code.
0794  */
0795 GIT_EXTERN(int) git_config_backend_foreach_match(
0796     git_config_backend *backend,
0797     const char *regexp,
0798     git_config_foreach_cb callback,
0799     void *payload);
0800 
0801 
0802 /**
0803  * Lock the backend with the highest priority
0804  *
0805  * Locking disallows anybody else from writing to that backend. Any
0806  * updates made after locking will not be visible to a reader until
0807  * the file is unlocked.
0808  *
0809  * You can apply the changes by calling `git_transaction_commit()`
0810  * before freeing the transaction. Either of these actions will unlock
0811  * the config.
0812  *
0813  * @param tx the resulting transaction, use this to commit or undo the
0814  * changes
0815  * @param cfg the configuration in which to lock
0816  * @return 0 or an error code
0817  */
0818 GIT_EXTERN(int) git_config_lock(git_transaction **tx, git_config *cfg);
0819 
0820 /** @} */
0821 GIT_END_DECL
0822 #endif