include/git2/config.h


Log

Author Commit Date CI Message
Edward Thomson d4232e7c 2022-01-17T21:21:54 Apply suggestions from code review
punkymaniac c6ede676 2022-01-09T10:35:42 Fix misspelling word "ge" -> "get"
punkymaniac 68bc511a 2021-11-26T15:14:56 Add documentation about parameter and return value
punkymaniac 03aed8bc 2021-11-26T14:57:41 Add missing parameter name
Peter Pettersson 38c34498 2021-10-03T00:12:52 Make enum in includes C90 compliant by removing trailing comma.
Tobias Nießen 25efbc4b 2021-02-22T22:57:16 include: fix typos in comments
Patrick Steinhardt 658022c4 2019-07-18T13:53:41 configuration: cvar -> configmap `cvar` is an unhelpful name. Refactor its usage to `configmap` for more clarity.
Edward Thomson 22d2062d 2019-01-09T18:25:10 Introduce GIT_CALLBACK macro to enforce cdecl Since we now always build the library with cdecl calling conventions, our callbacks should be decorated as such so that users will not be able to provide callbacks defined with other calling conventions. The `GIT_CALLBACK` macro will inject the `__cdecl` attribute as appropriate.
Etienne Samson 25da1acb 2018-09-25T14:43:19 config: fix incorrect filename in documentation comment The underlying code uses GIT_CONFIG_FILENAME_GLOBAL, which is .gitconfig.
Etienne Samson 7283daa8 2018-10-01T21:00:15 doc: small fixups & additions
Patrick Steinhardt 26cf48fc 2018-02-09T11:35:16 config_file: move include depth into config entry In order to reject writes to included configuration entries, we need to keep track of whether an entry was included via another configuration file or not. This information is being stored in the `cvar` structure, which is a rather weird location, as it is only used to create a list structure of config entries. Move the include depth into the structure `git_config_entry` instead. While this fixes the layering issue, it enables users of libgit2 to access the depth, too.
Edward Thomson 358cc2e2 2018-03-12T09:50:00 Merge pull request #4396 from libgit2/cmn/config-regex-is-normalised config: specify how we match the regular expressions
Carlos Martín Nieto 2f89bd90 2018-03-11T12:36:13 config: explicitly state that subsections are case-sensitive
Carlos Martín Nieto 158a42a5 2017-11-04T15:28:35 config: specify how we match the regular expressions We do it the same as git does: case-sensitively on the normalized form of the variable name. While here also specify that we're case-sensitive on the values when handling the values when setting or deleting multivars.
Patrick Steinhardt 529e873c 2017-05-23T11:51:00 config: pass repository when opening config files Our current configuration logic is completely oblivious of any repository, but only cares for actual file paths. Unfortunately, we are forced to break this assumption by the introduction of conditional includes, which are evaluated in the context of a repository. Right now, only one conditional exists with "gitdir:" -- it will only include the configuration if the current repository's git directory matches the value passed to "gitdir:". To support these conditionals, we have to break our API and make the repository available when opening a configuration file. This commit extends the `open` call of configuration backends to include another repository and adjusts existing code to have it available. This includes the user-visible functions `git_config_add_file_ondisk` and `git_config_add_backend`.
Carlos Martín Nieto 8c7c5fa5 2015-10-20T17:42:42 config: add a ProgramData level This is where portable git stores the global configuration which we can use to adhere to it even though git isn't quite installed on the system.
Carlos Martín Nieto 1cef6b9f 2015-09-03T11:38:21 config: correct documentation for non-existent config file
Carlos Martín Nieto 5340d63d 2015-07-12T12:50:23 config: perform unlocking via git_transaction This makes the API for commiting or discarding changes the same as for references.
Carlos Martín Nieto 36f784b5 2015-06-01T20:02:23 config: expose locking via the main API This lock/unlock pair allows for the cller to lock a configuration file to avoid concurrent operations. It also allows for a transactional approach to updating a configuration file. If multiple updates must be made atomically, they can be done while the config is locked.
Carlos Martín Nieto 9a97f49e 2014-12-21T15:31:03 config: borrow refcounted references This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
Ben Chatelain c03e8c22 2015-02-10T12:44:05 Use correct Doxygen trailing comment syntax
Ben Chatelain ec7e1c93 2015-02-10T08:31:48 Fix doc comment formatting
Carlos Martín Nieto eac773d9 2015-01-14T15:05:43 config: add parsing and getter for paths
Carlos Martín Nieto a295bd2d 2014-12-06T03:36:18 doc: add documentation to all the public structs and enums This makes them show up in the reference, even if the text itself isn't the most descriptive. These have been found with grep -Przon '\n\ntypedef struct.*?\{' -- include grep -Przon '\n\ntypedef enum.*?\{' -- include
Will Stamper b874629b 2014-12-04T21:06:59 Spelling fixes
Carlos Martín Nieto 55cb4999 2014-10-23T19:05:02 config: remove the refresh function and backend field We have been refreshing on read and write for a while now, so git_config_refresh() is at best a no-op, and might just end up wasting cycles.
Carlos Martín Nieto c20d71ea 2014-03-31T10:13:40 config: document the how long the pointers are valid for
Carlos Martín Nieto 55ebd7d3 2014-03-13T17:11:34 config: implement config snapshotting In order to have consistent views of the config files for remotes, submodules et al. and a configuration that represents what is currently stored on-disk, we need a way to provide a view of the configuration that does not change. The goal here is to provide the snapshotting part by creating a read-only copy of the state of the configuration at a particular point in time, which does not change when a repository's main config changes.
Carlos Martín Nieto ee550477 2014-01-26T16:11:18 config: use git_buf for returning paths Again, we already did this internally, so simply remove the conversions.
Russell Belfer 373cf6a9 2013-12-09T10:17:47 Update docs for new callback return value behavior
Russell Belfer 25e0b157 2013-12-06T15:07:57 Remove converting user error to GIT_EUSER This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
Daniel Rodríguez Troitiño 3793fa9b 2013-10-31T01:08:50 Fix saving remotes with several fetch/push ref specs. At some moment git_config_delete_entry lost the ability to delete one entry of a multivar configuration. The moment you had more than one fetch or push ref spec for a remote you will not be able to save that remote anymore. The changes in network::remote::remotes::save show that problem. I needed to create a new git_config_delete_multivar because I was not able to remove one or several entries of a multivar config with the current API. Several tries modifying how git_config_set_multivar(..., NULL) behaved were not successful. git_config_delete_multivar is very similar to git_config_set_multivar, and delegates into config_delete_multivar of config_file. This function search for the cvar_t that will be deleted, storing them in a temporal array, and rebuilding the linked list. After calling config_write to delete the entries, the cvar_t stored in the temporal array are freed. There is a little fix in config_write, it avoids an infinite loop when using a regular expression (case for the multivars). This error was found by the test network::remote::remotes::tagopt.
Carlos Martín Nieto f4be8209 2013-08-14T00:45:05 config: don't special-case the multivar iterator Build it on top of the normal iterator instead, which lets use re-use a lot of code.
Carlos Martín Nieto 54f3a572 2013-08-09T10:29:11 config: introduce a regex-filtering iterator
Carlos Martín Nieto 5880962d 2013-08-09T09:05:19 config: introduce _iterator_new() As the name suggests, it iterates over all the entries
Carlos Martín Nieto 1e96c9d5 2013-08-08T20:47:06 config: add _next() and _iterator_free() Make it look like the refs iterator API.
Carlos Martín Nieto 99dfb538 2013-08-08T17:57:59 config: working multivar iterator Implement the foreach version as a wrapper around the iterator.
Carlos Martín Nieto eba73992 2013-08-08T14:39:32 config: move next() and free() into the iterator Like we have in the references iterator, next and free belong in the iterator itself.
Carlos Martín Nieto 4efa3290 2013-08-08T13:41:18 config: get_multivar -> get_multivar_foreach The plain function will return an iterator, so move this one out of the way.
Carlos Martín Nieto 4d588d97 2013-08-08T11:24:47 Don't typedef a pointer Make the iterator structure opaque and make sure it compiles.
Nico von Geyso a603c191 2013-03-18T21:02:36 replaced foreach() with non callback based iterations in git_config_backend new functions in struct git_config_backend: * iterator_new(...) * iterator_free(...) * next(...) The old callback based foreach style can still be used with `git_config_backend_foreach_match`
Andreas Linde e1967164 2013-06-24T15:33:41 Fixed most documentation header bugs Fixed a few header @param and @return typos with the help of -Wdocumentation in Xcode. The following warnings have not been fixed: common.h:213 - Not sure how the documentation format is for '...' notes.h:102 - Correct @param name but empty text notes.h:111 - Correct @param name but empty text pack.h:140 - @return missing text pack.h:148 - @return missing text
Sven Strickroth 76b893b6 2013-06-11T21:33:18 Add high(est) config level for application specific config files Some tools use an extra level to maintain an application specific config files on top of the normal ones. Revision 16adc9fade52b49e2bc13cb52407cc0025a93c8b broke this. Signed-off-by: Sven Strickroth <email@cs-ware.de>
Russell Belfer 16adc9fa 2013-05-24T10:35:58 Typedef git_config_level_t and use it everywhere The GIT_CONFIG_LEVEL constants actually work well as an enum because they are mutually exclusive, so this adds a typedef to the enum and uses that everywhere that one of these constants are expected, instead of the old code that typically used an unsigned int.
Linquize 0cb16fe9 2013-05-15T20:26:55 Unify whitespaces to tabs
Carlos Martín Nieto 5d831887 2013-05-07T00:10:02 config: convenience function to open global/xdg The rules for which one to open is a bit silly, so let's make it easier for our users.
Russell Belfer 83041c71 2013-04-19T11:52:04 Move git_config_backend to include/git2/sys Moving backend implementor objects into include/git2/sys so the APIs can be isolated from the ones that normal libgit2 users would be likely to use.
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Kevin Sawicki 7eb222fc 2013-01-06T10:39:35 Correct typos in documentation
Ben Straub fac43c54 2012-12-06T19:41:52 Allow compilation as C++
Ben Straub bde336ea 2012-11-29T12:26:09 Add version fields and init macros for public input structs.
Ben Straub 54b2a37a 2012-11-20T16:02:25 Clean up config.h
nulltoken 270160b9 2012-11-17T13:39:24 config: Opening a nonexistent file returns ENOTFOUND
nulltoken d36451c9 2012-11-17T12:34:15 config: Make git_config_file__ondisk() internal
Carlos Martín Nieto 3ee078c0 2012-11-13T13:46:17 config: rename get_config_entry -> config_entry We're already in the git_config namespace, there is no need to repeat it.
Russell Belfer 744cc03e 2012-10-30T12:10:36 Add git_config_refresh() API to reload config This adds a new API that allows users to reload the config if the file has changed on disk. A new config callback function to refresh the config was added. The modified time and file size are used to test if the file needs to be reloaded (and are now stored in the disk backend object). In writing tests, just using mtime was a problem / race, so I wanted to check file size as well. To support that, I extended `git_futils_readbuffer_updated` to optionally check file size in addition to mtime, and I added a new function `git_filebuf_stats` to fetch the mtime and size for an open filebuf (so that the config could be easily refreshed after a write). Lastly, I moved some similar file checking code for attributes into filebuf. It is still only being used for attrs, but it seems potentially reusable, so I thought I'd move it over.
yorah a1abe66a 2012-09-10T12:11:02 Add config level support in the config API Added `struct git_config_entry`: a git_config_entry contains the key, the value, and the config file level from which a config element was found. Added `git_config_open_level`: build a single-level focused config object from a multi-level one. We are now storing `git_config_entry`s in the khash of the config_file
Sven Strickroth 4258d483 2012-10-02T17:21:07 Rename xdr to xdg Signed-off-by: Sven Strickroth <email@cs-ware.de>
Sven Strickroth 8b4f9b17 2012-09-24T18:59:00 Correctly read xdr compatible %HOME%/.config/git/config config file This file is not just read if the global config file (%HOME%/.gitconfig) is not found, however, it is used everytime but with lower priority. Signed-off-by: Sven Strickroth <email@cs-ware.de>
Russell Belfer 85bd1746 2012-08-22T16:03:35 Some cleanup suggested during review This cleans up a number of items suggested during code review with @vmg, including: * renaming "outside repo" config API to `git_config_open_default` * killing the `git_config_open_global` API * removing the `git_` prefix from the static functions in fileops * removing some unnecessary functionality from the "cp" command
Russell Belfer ca1b6e54 2012-07-31T17:02:54 Add template dir and set gid to repo init This extends git_repository_init_ext further with support for initializing the repository from an external template directory and with support for the "create shared" type flags that make a set GID repository directory. This also adds tests for much of the new functionality to the existing `repo/init.c` test suite. Also, this adds a bunch of new utility functions including a very general purpose `git_futils_mkdir` (with the ability to make paths and to chmod the paths post-creation) and a file tree copying function `git_futils_cp_r`. Also, this includes some new path functions that were useful to keep the code simple.
Josh Triplett b90202bb 2012-08-12T03:56:15 Fix incorrect array size in example for git_config_get_mapped In the documentation for git_config_get_mapped, the sample mapping array uses [3] but has 4 entries. Fix by dropping the size entirely and letting the compiler figure it out.
Russell Belfer 5dca2010 2012-08-03T17:08:01 Update iterators for consistency across library This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
Russell Belfer b3ff1dab 2012-07-10T15:22:39 Adding git_config_foreach_match() iteration fn Adding a new config iteration function that let's you iterate over just the config entries that match a particular regular expression. The old foreach becomes a simple use of this with an empty pattern. This also fixes an apparent bug in the existing `git_config_foreach` where returning a non-zero value from the iteration callback was not correctly aborting the iteration and the returned value was not being propogated back to the caller of foreach. Added to tests to cover all these changes.
Vicent Martí e172cf08 2012-05-18T01:21:06 errors: Rename the generic return codes
Vicent Martí 29e948de 2012-05-10T10:38:10 global: Change parameter ordering in API Consistency is good.
Vicent Martí c5e94482 2012-03-01T00:52:21 config: Refactor & add `git_config_get_mapped` Sane API for real-world usage.
Carlos Martín Nieto 3005855f 2012-02-05T00:29:26 Implement setting multivars
Carlos Martín Nieto d9da4cca 2012-02-05T18:08:23 Document {get,set}_multivar
Carlos Martín Nieto 5e0dc4af 2012-02-04T23:18:30 Support getting multivars
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
Vicent Martí 9dd4c3e8 2011-12-31T05:56:39 config: Rename the `delete` callback name `delete` is a reserved keyword in C++.
Carlos Martín Nieto 80a665aa 2011-12-16T02:28:39 config: really delete variables Instead of just setting the value to NULL, which gives unwanted results when asking for that variable after deleting it, delete the variable from the list and re-write the file.
Vicent Marti dd3fd682 2011-10-05T13:44:27 msvc: Remove superfluous includes
Carlos Martín Nieto dc8e3096 2011-10-01T02:09:35 Include stdint.h in git2/config.h Otherwise MSVC doesn't know what we're talking about when we say int32_t or int64_t. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Vicent Marti fafd4710 2011-09-30T16:08:06 config: Proper type declarations for 64 bit ints
Carlos Martín Nieto 4c562347 2011-09-22T21:34:46 Add git_config_find_system This allows the library to guess where the system configuration file should be located. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
nulltoken ad196c6a 2011-09-21T23:17:39 config: make git_config_[get|set]_long() able to properly deal with 8 bytes wide values Should fix issue #419. Signed-off-by: nulltoken <emeric.fermas@gmail.com>
Vicent Marti bb742ede 2011-09-19T01:54:32 Cleanup legal data 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
David Boyce d9111722 2011-09-13T12:30:25 Standardized doxygen @return lines for int functions to say "GIT_SUCCESS or an error code".
Vicent Marti b08683ff 2011-07-12T02:38:20 config: Rename `del` to `delete
Carlos Martín Nieto 2601fcfc 2011-06-28T15:21:44 Add tests for deleting a config var Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Marti e0fc39da 2011-06-29T15:11:34 config: Fix unmatched parameters in docs
Vicent Marti cfef5fb7 2011-06-29T15:09:21 config: `foreach` now returns variable values too
Vicent Marti bfd5e3e2 2011-06-18T15:07:41 config: Fix API docs
Vicent Marti 19cb6857 2011-06-18T01:50:48 config: Bring back `git_config_open_global` Scott commands, I obey.
Vicent Marti 07ff8817 2011-06-18T00:39:39 config: Cleanup external API Do not mess with environment variables anymore. The new external API has more helper methods, and everything is explicit.
Vicent Marti d144c569 2011-06-16T03:02:46 Update documentation Fix all the missmatched arguments in the docs
Carlos Martín Nieto a2a305fc 2011-06-07T15:39:40 config: explain the cfg and file relationship better It's not clear how git_config and git_config_file relate to one another. Be more explicit about their relationship in the function documentation. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto ce78f39e 2011-06-07T14:18:22 config: update the git_config_add_file documentation Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Marti b0b527e0 2011-05-20T03:20:12 config: Cleanup & renaming of the external API "git_config_backend" have been renamed to "git_config_file", which implements a generic interface to access a configuration file -- be it either on disk, from a DB or whatever mumbojumbo. I think this makes more sense.
Carlos Martín Nieto f44cbec4 2011-05-17T14:59:23 Add documentation for git_config_add_backend
Carlos Martín Nieto 32234541 2011-05-17T14:18:42 Implement git_config_open_global Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto c0335005 2011-05-06T12:42:47 Move config to a backend structure Configuration options can come from different sources. Currently, there is only support for reading them from a flat file, but it might make sense to read it from a database at some point. Move the parsing code into src/config_file.c and create an include file include/git2/config_backend.h to allow for other backends to be developed. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto e69ac243 2011-04-19T16:38:52 config: export git_config_[sg]et_long Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 2974aa94 2011-03-30T11:30:40 Determine variable type at runtime Config variables should be interpreted at run-time, as we don't know if a zero means false or zero, or if yes means true or "yes". As a variable has no intrinsic type, git_cvtype is gone and the public API takes care of enforcing a few rules. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 9a3c5e55 2011-03-29T17:44:10 Expose config API for setters, getters and foreach These functions can be used to query or modify the variables in a given configuration. No sanity checking is done on the variable names. This is mostly meant as an API preview. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 5d4cd003 2011-03-28T17:02:45 Move the struct declaration outside config.c Signed-off-by: Carlos Martín Nieto <cmn@elego.de>