1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
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.
6  */
7 module libgit2_d.config;
8 
9 
10 private static import libgit2_d.buffer;
11 private static import libgit2_d.sys.config;
12 private static import libgit2_d.types;
13 
14 /**
15  * @file git2/config.h
16  * @brief Git config management routines
17  * @defgroup git_config Git config management routines
18  * @ingroup Git
19  * @{
20  */
21 extern (C):
22 nothrow @nogc:
23 public:
24 
25 /**
26  * Priority level of a config file.
27  * These priority levels correspond to the natural escalation logic
28  * (from higher to lower) when searching for config entries in git.git.
29  *
30  * git_config_open_default() and git_repository_config() honor those
31  * priority levels as well.
32  */
33 enum git_config_level_t
34 {
35 	/**
36 	 * System-wide on Windows, for compatibility with portable git
37 	 */
38 	GIT_CONFIG_LEVEL_PROGRAMDATA = 1,
39 
40 	/**
41 	 * System-wide configuration file; /etc/gitconfig on Linux systems
42 	 */
43 	GIT_CONFIG_LEVEL_SYSTEM = 2,
44 
45 	/**
46 	 * XDG compatible configuration file; typically ~/.config/git/config
47 	 */
48 	GIT_CONFIG_LEVEL_XDG = 3,
49 
50 	/**
51 	 * User-specific configuration file (also called Global configuration
52 	 * file); typically ~/.gitconfig
53 	 */
54 	GIT_CONFIG_LEVEL_GLOBAL = 4,
55 
56 	/**
57 	 * Repository specific configuration file; $WORK_DIR/.git/config on
58 	 * non-bare repos
59 	 */
60 	GIT_CONFIG_LEVEL_LOCAL = 5,
61 
62 	/**
63 	 * Application specific configuration file; freely defined by applications
64 	 */
65 	GIT_CONFIG_LEVEL_APP = 6,
66 
67 	/**
68 	 * Represents the highest level available config file (i.e. the most
69 	 * specific config file available that actually is loaded)
70 	 */
71 	GIT_CONFIG_HIGHEST_LEVEL = -1,
72 }
73 
74 /**
75  * An entry in a configuration file
76  */
77 struct git_config_entry
78 {
79 	/**
80 	 * Name of the entry (normalised)
81 	 */
82 	const (char)* name;
83 
84 	/**
85 	 * String value of the entry
86 	 */
87 	const (char)* value;
88 
89 	/**
90 	 * Depth of includes where this variable was found
91 	 */
92 	uint include_depth;
93 
94 	/**
95 	 * Which config file this was found in
96 	 */
97 	.git_config_level_t level;
98 
99 	/**
100 	 * Free function for this entry
101 	 */
102 	void function(.git_config_entry* entry) free;
103 
104 	/**
105 	 * Opaque value for the free function. Do not read or write
106 	 */
107 	void* payload;
108 }
109 
110 /**
111  * Free a config entry
112  */
113 //GIT_EXTERN
114 void git_config_entry_free(.git_config_entry*);
115 
116 /**
117  * A config enumeration callback
118  *
119  * Params:
120  *      entry = the entry currently being enumerated
121  *      payload = a user-specified pointer
122  */
123 alias git_config_foreach_cb = int function(const (.git_config_entry)*, void* payload);
124 
125 /**
126  * An opaque structure for a configuration iterator
127  */
128 alias git_config_iterator = libgit2_d.sys.config.git_config_iterator;
129 
130 /**
131  * Config var type
132  */
133 enum git_configmap_t
134 {
135 	GIT_CONFIGMAP_FALSE = 0,
136 	GIT_CONFIGMAP_TRUE = 1,
137 	GIT_CONFIGMAP_INT32,
138 	GIT_CONFIGMAP_STRING,
139 }
140 
141 /**
142  * Mapping from config variables to values.
143  */
144 struct git_configmap
145 {
146 	.git_configmap_t cvar_type;
147 	const (char)* str_match;
148 	int map_value;
149 }
150 
151 /**
152  * Locate the path to the global configuration file
153  *
154  * The user or global configuration file is usually
155  * located in `$HOME/.gitconfig`.
156  *
157  * This method will try to guess the full path to that
158  * file, if the file exists. The returned path
159  * may be used on any `git_config` call to load the
160  * global configuration file.
161  *
162  * This method will not guess the path to the xdg compatible
163  * config file (.config/git/config).
164  *
165  * Params:
166  *      out_ = Pointer to a user-allocated git_buf in which to store the path
167  *
168  * Returns: 0 if a global configuration file has been found. Its path will be stored in `out`.
169  */
170 //GIT_EXTERN
171 int git_config_find_global(libgit2_d.buffer.git_buf* out_);
172 
173 /**
174  * Locate the path to the global xdg compatible configuration file
175  *
176  * The xdg compatible configuration file is usually
177  * located in `$HOME/.config/git/config`.
178  *
179  * This method will try to guess the full path to that
180  * file, if the file exists. The returned path
181  * may be used on any `git_config` call to load the
182  * xdg compatible configuration file.
183  *
184  * Params:
185  *      out_ = Pointer to a user-allocated git_buf in which to store the path
186  *
187  * Returns: 0 if a xdg compatible configuration file has been found. Its path will be stored in `out`.
188  */
189 //GIT_EXTERN
190 int git_config_find_xdg(libgit2_d.buffer.git_buf* out_);
191 
192 /**
193  * Locate the path to the system configuration file
194  *
195  * If /etc/gitconfig doesn't exist, it will look for
196  * %PROGRAMFILES%\Git\etc\gitconfig.
197  *
198  * Params:
199  *      out_ = Pointer to a user-allocated git_buf in which to store the path
200  *
201  * Returns: 0 if a system configuration file has been found. Its path will be stored in `out`.
202  */
203 //GIT_EXTERN
204 int git_config_find_system(libgit2_d.buffer.git_buf* out_);
205 
206 /**
207  * Locate the path to the configuration file in ProgramData
208  *
209  * Look for the file in %PROGRAMDATA%\Git\config used by portable git.
210  *
211  * Params:
212  *      out_ = Pointer to a user-allocated git_buf in which to store the path
213  *
214  * Returns: 0 if a ProgramData configuration file has been found. Its path will be stored in `out`.
215  */
216 //GIT_EXTERN
217 int git_config_find_programdata(libgit2_d.buffer.git_buf* out_);
218 
219 /**
220  * Open the global, XDG and system configuration files
221  *
222  * Utility wrapper that finds the global, XDG and system configuration files
223  * and opens them into a single prioritized config object that can be
224  * used when accessing default config data outside a repository.
225  *
226  * Params:
227  *      out_ = Pointer to store the config instance
228  *
229  * Returns: 0 or an error code
230  */
231 //GIT_EXTERN
232 int git_config_open_default(libgit2_d.types.git_config** out_);
233 
234 /**
235  * Allocate a new configuration object
236  *
237  * This object is empty, so you have to add a file to it before you
238  * can do anything with it.
239  *
240  * Params:
241  *      out_ = pointer to the new configuration
242  *
243  * Returns: 0 or an error code
244  */
245 //GIT_EXTERN
246 int git_config_new(libgit2_d.types.git_config** out_);
247 
248 /**
249  * Add an on-disk config file instance to an existing config
250  *
251  * The on-disk file pointed at by `path` will be opened and
252  * parsed; it's expected to be a native Git config file following
253  * the default Git config syntax (see man git-config).
254  *
255  * If the file does not exist, the file will still be added and it
256  * will be created the first time we write to it.
257  *
258  * Note that the configuration object will free the file
259  * automatically.
260  *
261  * Further queries on this config object will access each
262  * of the config file instances in order (instances with
263  * a higher priority level will be accessed first).
264  *
265  * Params:
266  *      cfg = the configuration to add the file to
267  *      path = path to the configuration file to add
268  *      level = the priority level of the backend
269  *      force = replace config file at the given priority level
270  *      repo = optional repository to allow parsing of conditional includes
271  *
272  * Returns: 0 on success, git_error_code.GIT_EEXISTS when adding more than one file for a given priority level (and force_replace set to 0), git_error_code.GIT_ENOTFOUND when the file doesn't exist or error code
273  */
274 //GIT_EXTERN
275 int git_config_add_file_ondisk(libgit2_d.types.git_config* cfg, const (char)* path, .git_config_level_t level, const (libgit2_d.types.git_repository)* repo, int force);
276 
277 /**
278  * Create a new config instance containing a single on-disk file
279  *
280  * This method is a simple utility wrapper for the following sequence
281  * of calls:
282  *	- git_config_new
283  *	- git_config_add_file_ondisk
284  *
285  * Params:
286  *      out_ = The configuration instance to create
287  *      path = Path to the on-disk file to open
288  *
289  * Returns: 0 on success, or an error code
290  */
291 //GIT_EXTERN
292 int git_config_open_ondisk(libgit2_d.types.git_config** out_, const (char)* path);
293 
294 /**
295  * Build a single-level focused config object from a multi-level one.
296  *
297  * The returned config object can be used to perform get/set/delete operations
298  * on a single specific level.
299  *
300  * Getting several times the same level from the same parent multi-level config
301  * will return different config instances, but containing the same config_file
302  * instance.
303  *
304  * Params:
305  *      out_ = The configuration instance to create
306  *      parent = Multi-level config to search for the given level
307  *      level = Configuration level to search for
308  *
309  * Returns: 0, git_error_code.GIT_ENOTFOUND if the passed level cannot be found in the multi-level parent config, or an error code
310  */
311 //GIT_EXTERN
312 int git_config_open_level(libgit2_d.types.git_config** out_, const (libgit2_d.types.git_config)* parent, .git_config_level_t level);
313 
314 /**
315  * Open the global/XDG configuration file according to git's rules
316  *
317  * Git allows you to store your global configuration at
318  * `$HOME/.gitconfig` or `$XDG_CONFIG_HOME/git/config`. For backwards
319  * compatability, the XDG file shouldn't be used unless the use has
320  * created it explicitly. With this function you'll open the correct
321  * one to write to.
322  *
323  * Params:
324  *      out_ = pointer in which to store the config object
325  *      config = the config object in which to look
326  */
327 //GIT_EXTERN
328 int git_config_open_global(libgit2_d.types.git_config** out_, libgit2_d.types.git_config* config);
329 
330 /**
331  * Create a snapshot of the configuration
332  *
333  * Create a snapshot of the current state of a configuration, which
334  * allows you to look into a consistent view of the configuration for
335  * looking up complex values (e.g. a remote, submodule).
336  *
337  * The string returned when querying such a config object is valid
338  * until it is freed.
339  *
340  * Params:
341  *      out_ = pointer in which to store the snapshot config object
342  *      config = configuration to snapshot
343  *
344  * Returns: 0 or an error code
345  */
346 //GIT_EXTERN
347 int git_config_snapshot(libgit2_d.types.git_config** out_, libgit2_d.types.git_config* config);
348 
349 /**
350  * Free the configuration and its associated memory and files
351  *
352  * Params:
353  *      cfg = the configuration to free
354  */
355 //GIT_EXTERN
356 void git_config_free(libgit2_d.types.git_config* cfg);
357 
358 /**
359  * Get the git_config_entry of a config variable.
360  *
361  * Free the git_config_entry after use with `git_config_entry_free()`.
362  *
363  * Params:
364  *      out_ = pointer to the variable git_config_entry
365  *      cfg = where to look for the variable
366  *      name = the variable's name
367  *
368  * Returns: 0 or an error code
369  */
370 //GIT_EXTERN
371 int git_config_get_entry(.git_config_entry** out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
372 
373 /**
374  * Get the value of an integer config variable.
375  *
376  * All config files will be looked into, in the order of their
377  * defined level. A higher level means a higher priority. The
378  * first occurrence of the variable will be returned here.
379  *
380  * Params:
381  *      out_ = pointer to the variable where the value should be stored
382  *      cfg = where to look for the variable
383  *      name = the variable's name
384  *
385  * Returns: 0 or an error code
386  */
387 //GIT_EXTERN
388 int git_config_get_int32(int* out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
389 
390 /**
391  * Get the value of a long integer config variable.
392  *
393  * All config files will be looked into, in the order of their
394  * defined level. A higher level means a higher priority. The
395  * first occurrence of the variable will be returned here.
396  *
397  * Params:
398  *      out_ = pointer to the variable where the value should be stored
399  *      cfg = where to look for the variable
400  *      name = the variable's name
401  *
402  * Returns: 0 or an error code
403  */
404 //GIT_EXTERN
405 int git_config_get_int64(long* out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
406 
407 /**
408  * Get the value of a boolean config variable.
409  *
410  * This function uses the usual C convention of 0 being false and
411  * anything else true.
412  *
413  * All config files will be looked into, in the order of their
414  * defined level. A higher level means a higher priority. The
415  * first occurrence of the variable will be returned here.
416  *
417  * Params:
418  *      out_ = pointer to the variable where the value should be stored
419  *      cfg = where to look for the variable
420  *      name = the variable's name
421  *
422  * Returns: 0 or an error code
423  */
424 //GIT_EXTERN
425 int git_config_get_bool(int* out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
426 
427 /**
428  * Get the value of a path config variable.
429  *
430  * A leading '~' will be expanded to the global search path (which
431  * defaults to the user's home directory but can be overridden via
432  * `git_libgit2_opts()`.
433  *
434  * All config files will be looked into, in the order of their
435  * defined level. A higher level means a higher priority. The
436  * first occurrence of the variable will be returned here.
437  *
438  * Params:
439  *      out_ = the buffer in which to store the result
440  *      cfg = where to look for the variable
441  *      name = the variable's name
442  *
443  * Returns: 0 or an error code
444  */
445 //GIT_EXTERN
446 int git_config_get_path(libgit2_d.buffer.git_buf* out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
447 
448 /**
449  * Get the value of a string config variable.
450  *
451  * This function can only be used on snapshot config objects. The
452  * string is owned by the config and should not be freed by the
453  * user. The pointer will be valid until the config is freed.
454  *
455  * All config files will be looked into, in the order of their
456  * defined level. A higher level means a higher priority. The
457  * first occurrence of the variable will be returned here.
458  *
459  * Params:
460  *      out_ = pointer to the string
461  *      cfg = where to look for the variable
462  *      name = the variable's name
463  *
464  * Returns: 0 or an error code
465  */
466 //GIT_EXTERN
467 int git_config_get_string(const (char)** out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
468 
469 /**
470  * Get the value of a string config variable.
471  *
472  * The value of the config will be copied into the buffer.
473  *
474  * All config files will be looked into, in the order of their
475  * defined level. A higher level means a higher priority. The
476  * first occurrence of the variable will be returned here.
477  *
478  * Params:
479  *      out_ = buffer in which to store the string
480  *      cfg = where to look for the variable
481  *      name = the variable's name
482  *
483  * Returns: 0 or an error code
484  */
485 //GIT_EXTERN
486 int git_config_get_string_buf(libgit2_d.buffer.git_buf* out_, const (libgit2_d.types.git_config)* cfg, const (char)* name);
487 
488 /**
489  * Get each value of a multivar in a foreach callback
490  *
491  * The callback will be called on each variable found
492  *
493  * The regular expression is applied case-sensitively on the normalized form of
494  * the variable name: the section and variable parts are lower-cased. The
495  * subsection is left unchanged.
496  *
497  * Params:
498  *      cfg = where to look for the variable
499  *      name = the variable's name
500  *      regexp = regular expression to filter which variables we're interested in. Use null to indicate all
501  *      callback = the function to be called on each value of the variable
502  *      payload = opaque pointer to pass to the callback
503  */
504 //GIT_EXTERN
505 int git_config_get_multivar_foreach(const (libgit2_d.types.git_config)* cfg, const (char)* name, const (char)* regexp, .git_config_foreach_cb callback, void* payload);
506 
507 /**
508  * Get each value of a multivar
509  *
510  * The regular expression is applied case-sensitively on the normalized form of
511  * the variable name: the section and variable parts are lower-cased. The
512  * subsection is left unchanged.
513  *
514  * Params:
515  *      out_ = pointer to store the iterator
516  *      cfg = where to look for the variable
517  *      name = the variable's name
518  *      regexp = regular expression to filter which variables we're interested in. Use null to indicate all
519  */
520 //GIT_EXTERN
521 int git_config_multivar_iterator_new(.git_config_iterator** out_, const (libgit2_d.types.git_config)* cfg, const (char)* name, const (char)* regexp);
522 
523 /**
524  * Return the current entry and advance the iterator
525  *
526  * The pointers returned by this function are valid until the iterator
527  * is freed.
528  *
529  * Params:
530  *      entry = pointer to store the entry
531  *      iter = the iterator
532  *
533  * Returns: 0 or an error code. git_error_code.GIT_ITEROVER if the iteration has completed
534  */
535 //GIT_EXTERN
536 int git_config_next(.git_config_entry** entry, .git_config_iterator* iter);
537 
538 /**
539  * Free a config iterator
540  *
541  * Params:
542  *      iter = the iterator to free
543  */
544 //GIT_EXTERN
545 void git_config_iterator_free(.git_config_iterator* iter);
546 
547 /**
548  * Set the value of an integer config variable in the config file
549  * with the highest level (usually the local one).
550  *
551  * Params:
552  *      cfg = where to look for the variable
553  *      name = the variable's name
554  *      value = Integer value for the variable
555  *
556  * Returns: 0 or an error code
557  */
558 //GIT_EXTERN
559 int git_config_set_int32(libgit2_d.types.git_config* cfg, const (char)* name, int value);
560 
561 /**
562  * Set the value of a long integer config variable in the config file
563  * with the highest level (usually the local one).
564  *
565  * Params:
566  *      cfg = where to look for the variable
567  *      name = the variable's name
568  *      value = Long integer value for the variable
569  *
570  * Returns: 0 or an error code
571  */
572 //GIT_EXTERN
573 int git_config_set_int64(libgit2_d.types.git_config* cfg, const (char)* name, long value);
574 
575 /**
576  * Set the value of a boolean config variable in the config file
577  * with the highest level (usually the local one).
578  *
579  * Params:
580  *      cfg = where to look for the variable
581  *      name = the variable's name
582  *      value = the value to store
583  *
584  * Returns: 0 or an error code
585  */
586 //GIT_EXTERN
587 int git_config_set_bool(libgit2_d.types.git_config* cfg, const (char)* name, int value);
588 
589 /**
590  * Set the value of a string config variable in the config file
591  * with the highest level (usually the local one).
592  *
593  * A copy of the string is made and the user is free to use it
594  * afterwards.
595  *
596  * Params:
597  *      cfg = where to look for the variable
598  *      name = the variable's name
599  *      value = the string to store.
600  *
601  * Returns: 0 or an error code
602  */
603 //GIT_EXTERN
604 int git_config_set_string(libgit2_d.types.git_config* cfg, const (char)* name, const (char)* value);
605 
606 /**
607  * Set a multivar in the local config file.
608  *
609  * The regular expression is applied case-sensitively on the value.
610  *
611  * Params:
612  *      cfg = where to look for the variable
613  *      name = the variable's name
614  *      regexp = a regular expression to indicate which values to replace
615  *      value = the new value.
616  */
617 //GIT_EXTERN
618 int git_config_set_multivar(libgit2_d.types.git_config* cfg, const (char)* name, const (char)* regexp, const (char)* value);
619 
620 /**
621  * Delete a config variable from the config file
622  * with the highest level (usually the local one).
623  *
624  * Params:
625  *      cfg = the configuration
626  *      name = the variable to delete
627  */
628 //GIT_EXTERN
629 int git_config_delete_entry(libgit2_d.types.git_config* cfg, const (char)* name);
630 
631 /**
632  * Deletes one or several entries from a multivar in the local config file.
633  *
634  * The regular expression is applied case-sensitively on the value.
635  *
636  * Params:
637  *      cfg = where to look for the variables
638  *      name = the variable's name
639  *      regexp = a regular expression to indicate which values to delete
640  *
641  * Returns: 0 or an error code
642  */
643 //GIT_EXTERN
644 int git_config_delete_multivar(libgit2_d.types.git_config* cfg, const (char)* name, const (char)* regexp);
645 
646 /**
647  * Perform an operation on each config variable.
648  *
649  * The callback receives the normalized name and value of each variable
650  * in the config backend, and the data pointer passed to this function.
651  * If the callback returns a non-zero value, the function stops iterating
652  * and returns that value to the caller.
653  *
654  * The pointers passed to the callback are only valid as long as the
655  * iteration is ongoing.
656  *
657  * Params:
658  *      cfg = where to get the variables from
659  *      callback = the function to call on each variable
660  *      payload = the data to pass to the callback
661  *
662  * Returns: 0 on success, non-zero callback return value, or error code
663  */
664 //GIT_EXTERN
665 int git_config_foreach(const (libgit2_d.types.git_config)* cfg, .git_config_foreach_cb callback, void* payload);
666 
667 /**
668  * Iterate over all the config variables
669  *
670  * Use `git_config_next` to advance the iteration and
671  * `git_config_iterator_free` when done.
672  *
673  * Params:
674  *      out_ = pointer to store the iterator
675  *      cfg = where to ge the variables from
676  */
677 //GIT_EXTERN
678 int git_config_iterator_new(.git_config_iterator** out_, const (libgit2_d.types.git_config)* cfg);
679 
680 /**
681  * Iterate over all the config variables whose name matches a pattern
682  *
683  * Use `git_config_next` to advance the iteration and
684  * `git_config_iterator_free` when done.
685  *
686  * The regular expression is applied case-sensitively on the normalized form of
687  * the variable name: the section and variable parts are lower-cased. The
688  * subsection is left unchanged.
689  *
690  * Params:
691  *      out_ = pointer to store the iterator
692  *      cfg = where to ge the variables from
693  *      regexp = regular expression to match the names
694  */
695 //GIT_EXTERN
696 int git_config_iterator_glob_new(.git_config_iterator** out_, const (libgit2_d.types.git_config)* cfg, const (char)* regexp);
697 
698 /**
699  * Perform an operation on each config variable matching a regular expression.
700  *
701  * This behaves like `git_config_foreach` with an additional filter of a
702  * regular expression that filters which config keys are passed to the
703  * callback.
704  *
705  * The regular expression is applied case-sensitively on the normalized form of
706  * the variable name: the section and variable parts are lower-cased. The
707  * subsection is left unchanged.
708  *
709  * The regular expression is applied case-sensitively on the normalized form of
710  * the variable name: the case-insensitive parts are lower-case.
711  *
712  * Params:
713  *      cfg = where to get the variables from
714  *      regexp = regular expression to match against config names
715  *      callback = the function to call on each variable
716  *      payload = the data to pass to the callback
717  *
718  * Returns: 0 or the return value of the callback which didn't return 0
719  */
720 //GIT_EXTERN
721 int git_config_foreach_match(const (libgit2_d.types.git_config)* cfg, const (char)* regexp, .git_config_foreach_cb callback, void* payload);
722 
723 /**
724  * Query the value of a config variable and return it mapped to
725  * an integer constant.
726  *
727  * This is a helper method to easily map different possible values
728  * to a variable to integer constants that easily identify them.
729  *
730  * A mapping array looks as follows:
731  *
732  *	git_configmap[] autocrlf_mapping = {
733  *		{GIT_CVAR_FALSE, null, GIT_AUTO_CRLF_FALSE},
734  *		{GIT_CVAR_TRUE, null, GIT_AUTO_CRLF_TRUE},
735  *		{GIT_CVAR_STRING, "input", GIT_AUTO_CRLF_INPUT},
736  *		{GIT_CVAR_STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
737  *
738  * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
739  * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
740  *
741  * The same thing applies for any "true" value such as "true", "yes" or "1",
742  *storing the `GIT_AUTO_CRLF_TRUE` variable.
743  *
744  * Otherwise, if the value matches the string "input" (with case insensitive
745  *comparison), the given constant will be stored in `out`, and likewise for
746  *"default".
747  *
748  * If not a single match can be made to store in `out`, an error code will be
749  * returned.
750  *
751  * Params:
752  *      out_ = place to store the result of the mapping
753  *      cfg = config file to get the variables from
754  *      name = name of the config variable to lookup
755  *      maps = array of `git_configmap` objects specifying the possible mappings
756  *      map_n = number of mapping objects in `maps`
757  *
758  * Returns: 0 on success, error code otherwise
759  */
760 //GIT_EXTERN
761 int git_config_get_mapped(int* out_, const (libgit2_d.types.git_config)* cfg, const (char)* name, const (.git_configmap)* maps, size_t map_n);
762 
763 /**
764  * Maps a string value to an integer constant
765  *
766  * Params:
767  *      out_ = place to store the result of the parsing
768  *      maps = array of `git_configmap` objects specifying the possible mappings
769  *      map_n = number of mapping objects in `maps`
770  *      value = value to parse
771  */
772 //GIT_EXTERN
773 int git_config_lookup_map_value(int* out_, const (.git_configmap)* maps, size_t map_n, const (char)* value);
774 
775 /**
776  * Parse a string value as a bool.
777  *
778  * Valid values for true are: 'true', 'yes', 'on', 1 or any
779  *  number different from 0
780  * Valid values for false are: 'false', 'no', 'off', 0
781  *
782  * Params:
783  *      out_ = place to store the result of the parsing
784  *      value = value to parse
785  */
786 //GIT_EXTERN
787 int git_config_parse_bool(int* out_, const (char)* value);
788 
789 /**
790  * Parse a string value as an int32.
791  *
792  * An optional value suffix of 'k', 'm', or 'g' will
793  * cause the value to be multiplied by 1024, 1048576,
794  * or 1073741824 prior to output.
795  *
796  * Params:
797  *      out_ = place to store the result of the parsing
798  *      value = value to parse
799  */
800 //GIT_EXTERN
801 int git_config_parse_int32(int* out_, const (char)* value);
802 
803 /**
804  * Parse a string value as an int64.
805  *
806  * An optional value suffix of 'k', 'm', or 'g' will
807  * cause the value to be multiplied by 1024, 1048576,
808  * or 1073741824 prior to output.
809  *
810  * Params:
811  *      out_ = place to store the result of the parsing
812  *      value = value to parse
813  */
814 //GIT_EXTERN
815 int git_config_parse_int64(long* out_, const (char)* value);
816 
817 /**
818  * Parse a string value as a path.
819  *
820  * A leading '~' will be expanded to the global search path (which
821  * defaults to the user's home directory but can be overridden via
822  * `git_libgit2_opts()`.
823  *
824  * If the value does not begin with a tilde, the input will be
825  * returned.
826  *
827  * Params:
828  *      out_ = placae to store the result of parsing
829  *      value = the path to evaluate
830  */
831 //GIT_EXTERN
832 int git_config_parse_path(libgit2_d.buffer.git_buf* out_, const (char)* value);
833 
834 /**
835  * Perform an operation on each config variable in a given config backend,
836  * matching a regular expression.
837  *
838  * This behaves like `git_config_foreach_match` except that only config
839  * entries from the given backend entry are enumerated.
840  *
841  * The regular expression is applied case-sensitively on the normalized form of
842  * the variable name: the section and variable parts are lower-cased. The
843  * subsection is left unchanged.
844  *
845  * Params:
846  *      backend = where to get the variables from
847  *      regexp = regular expression to match against config names (can be null)
848  *      callback = the function to call on each variable
849  *      payload = the data to pass to the callback
850  */
851 //GIT_EXTERN
852 int git_config_backend_foreach_match(libgit2_d.types.git_config_backend* backend, const (char)* regexp, .git_config_foreach_cb callback, void* payload);
853 
854 /**
855  * Lock the backend with the highest priority
856  *
857  * Locking disallows anybody else from writing to that backend. Any
858  * updates made after locking will not be visible to a reader until
859  * the file is unlocked.
860  *
861  * You can apply the changes by calling `git_transaction_commit()`
862  * before freeing the transaction. Either of these actions will unlock
863  * the config.
864  *
865  * Params:
866  *      tx = the resulting transaction, use this to commit or undo the changes
867  *      cfg = the configuration in which to lock
868  *
869  * Returns: 0 or an error code
870  */
871 //GIT_EXTERN
872 int git_config_lock(libgit2_d.types.git_transaction** tx, libgit2_d.types.git_config* cfg);
873 
874 /** @} */