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