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