summaryrefslogtreecommitdiff
path: root/src/config.h
Commit message (Collapse)AuthorAgeFilesLines
* config: rename "config_file.h" to "config_backend.h"Patrick Steinhardt2018-09-281-13/+0
| | | | | | | | | | The header "config_file.h" has a list of inline-functions to access the contents of a config backend without directly messing with the struct's function pointers. While all these functions are called "git_config_file_*", they are in fact completely backend-agnostic and don't care whether it is a file or not. Rename all the function to instead be backend-agnostic versions called "git_config_backend_*" and rename the header to match.
* config: rename `files` vector to `backends`Patrick Steinhardt2018-09-211-1/+1
| | | | | | | | | | | | | | Originally, the `git_config` struct is a collection of all the parsed configuration files from different scopes (system-wide config, user-specific config as well as the repo-specific config files). Historically, we didn't and don't yet have any other configuration backends than the one for files, which is why the field holding the config backends is called `files`. But in fact, nothing dictates that the vector of backends actually holds file backends only, as they are generic and custom backends can be implemented by users. Rename the member to be called `backends` to clarify that there is nothing specific to files here.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* config: add a ProgramData levelcmn/programdata-configCarlos Martín Nieto2015-10-211-0/+1
| | | | | 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.
* config: perform unlocking via git_transactioncmn/config-txCarlos Martín Nieto2015-08-121-0/+15
| | | | | This makes the API for commiting or discarding changes the same as for references.
* config: provide a function to reverse-lookup mapped cvarsCarlos Martín Nieto2015-06-221-0/+6
|
* config: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-031-2/+2
| | | | | | | | | | | | | | | 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.
* Increase use of config snapshotsrb/coverity-fixesRussell Belfer2014-05-131-0/+6
| | | | And decrease extra reload checks of config data.
* Fix git_submodule_sync and add new config helperRussell Belfer2014-04-011-0/+8
| | | | | | | | | | | | This fixes `git_submodule_sync` to correctly update the remote URL of the default branch of the submodule along with the URL in the parent repository config (i.e. match core Git's behavior). Also move some useful helper logic from the submodule code into a shared config API `git_config__update_entry` that can either set or delete an entry with constraints like not overwriting or not creating a new entry. I used that helper to update a couple other places in the code.
* config: use git_buf for returning pathsCarlos Martín Nieto2014-01-271-5/+0
| | | | Again, we already did this internally, so simply remove the conversions.
* Add config read fns with controlled error behaviorRussell Belfer2013-12-111-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | This adds `git_config__lookup_entry` which will look up a key in a config and return either the entry or NULL if the key was not present. Optionally, it can either suppress all errors or can return them (although not finding the key is not an error for this function). Unlike other accessors, this does not normalize the config key string, so it must only be used when the key is known to be in normalized form (i.e. all lower-case before the first dot and after the last dot, with no invalid characters). This also adds three high-level helper functions to look up config values with no errors and a fallback value. The three functions are for string, bool, and int values, and will resort to the fallback value for any error that arises. They are: * `git_config__get_string_force` * `git_config__get_bool_force` * `git_config__get_int_force` None of them normalize the config `key` either, so they can only be used for internal cases where the key is known to be in normal format.
* Add git_repository_reset_filesystem and fix testsRussell Belfer2013-10-041-1/+1
| | | | | | | | | | | | | | | | | When a repository is transferred from one file system to another, many of the config settings that represent the properties of the file system may be wrong. This adds a new public API that will refresh the config settings of the repository to account for the change of file system. This doesn't do a full "reinitialize" and operates on a existing git_repository object refreshing the config when done. This commit then makes use of the new API in clar as each test repository is set up. This commit also has a number of other clar test fixes where we were making assumptions about the type of filesystem, either based on outdated config data or based on the OS instead of the FS.
* config: don't special-case the multivar iteratorCarlos Martín Nieto2013-08-141-0/+3
| | | | | Build it on top of the normal iterator instead, which lets use re-use a lot of code.
* config: move next() and free() into the iteratorCarlos Martín Nieto2013-08-081-5/+0
| | | | | Like we have in the references iterator, next and free belong in the iterator itself.
* config: compilation fixesCarlos Martín Nieto2013-08-081-2/+2
|
* Don't typedef a pointerCarlos Martín Nieto2013-08-081-0/+5
| | | | Make the iterator structure opaque and make sure it compiles.
* repo: unconditionally create a global config backendCarlos Martín Nieto2013-05-071-0/+3
| | | | | | | | | | | | | When a repository is initialised, we need to probe to see if there is a global config to load. If this is not the case, the user isn't able to write to the global config without creating the backend and adding it themselves, which is inconvenient and overly complex. Unconditionally create and add a backend for the global config file regardless of whether it exists as a convenience for users. To enable this, we allow creating backends to files that do not exist yet, changing the semantics somewhat, and making some tests invalid.
* Implement global/system file search pathsRussell Belfer2013-03-151-3/+4
| | | | | | | | | | | | | | | | | | | | | | | The goal of this work is to expose the search logic for "global", "system", and "xdg" files through the git_libgit2_opts() interface. Behind the scenes, I changed the logic for finding files to have a notion of a git_strarray that represents a search path and to store a separate search path for each of the three tiers of config file. For each tier, I implemented a function to initialize it to default values (generally based on environment variables), and then general interfaces to get it, set it, reset it, and prepend new directories to it. Next, I exposed these interfaces through the git_libgit2_opts interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants for the user to control which search path they were modifying. There are alternative designs for the opts interface / argument ordering, so I'm putting this phase out for discussion. Additionally, I ended up doing a little bit of clean up regarding attr.h and attr_file.h, adding a new attrcache.h so the other two files wouldn't have to be included in so many places.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Clean up config.hBen Straub2012-11-271-1/+1
|
* config: Make git_config_file__ondisk() internalnulltoken2012-11-171-0/+13
|
* config: introduce git_config_rename_section()nulltoken2012-10-251-0/+5
|
* Add config level support in the config APIyorah2012-10-231-5/+0
| | | | | | | 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
* Rename xdr to xdgSven Strickroth2012-10-021-1/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Silence MinGW warningsSven Strickroth2012-09-291-0/+1
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Support new config locationsRussell Belfer2012-08-241-0/+1
| | | | | As of git v1.7.12, $HOME/.config/git/ is supported as a new location for "config", "attributes", and "ignore" files.
* Improve config handling for diff,submodules,attrsRussell Belfer2012-03-301-0/+3
| | | | | | | | This adds support for a bunch of core.* settings that affect diff and status, plus fixes up some incorrect implementations of those settings from before. Also, this cleans up the handling of config settings in the new submodules code and in the old attrs/ignore code.
* Added submodule API and use in statusRussell Belfer2012-03-281-0/+2
| | | | | | | | | | When processing status for a newly checked out repo, it is possible that there will be submodules that have not yet been initialized. The only way to distinguish these from untracked directories is to have some knowledge of submodules. This commit adds a new submodule API which, given a name or path, can determine if it appears to be a submodule and can give information about the submodule.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Add support for macros and cache flush API.Russell Belfer2011-12-291-0/+1
| | | | | | | | | | | | | | Add support for git attribute macro definitions. Also, add support for cache flush API to clear the attribute file content cache when needed. Additionally, improved the handling of global and system files, making common utility functions in fileops and converting config and attr to both use the common functions. Adds a bunch more tests and fixed some memory leaks. Note that adding macros required me to use refcounted attribute assignment definitions, which complicated, but probably improved memory usage.
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-0/+3
| | | | | | | | | | | | | | | | | | | | This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
* repository: Change ownership semanticsVicent Marti2011-11-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
* *: correct and codify various file permissionsBrodie Rao2011-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
* Cleanup legal dataVicent Marti2011-09-191-0/+6
| | | | | | | | | | 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.
* Bind the configuration and remotes to a repositoryCarlos Martín Nieto2011-08-181-0/+2
| | | | | | | | Configurations when taken from a repository and remotes should be identifiable as coming from a particular repository. This allows us to reduce the amount of variables that the user has to keep track of. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Add git_repository_config APICarlos Martín Nieto2011-06-171-0/+1
| | | | | | | This function puts the global and repository configurations in one git_config object and gives it to the user. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* config: Cleanup & renaming of the external APIVicent Marti2011-05-201-1/+1
| | | | | | | | "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.
* Rewrite `git_config_open_global`Vicent Marti2011-05-201-0/+2
| | | | | We have a lot of utility methods that make path building trivial. Use them!
* utils: Move git__str[n]tolowerVicent Marti2011-05-171-3/+0
|
* Move config to a backend structureCarlos Martín Nieto2011-05-101-61/+3
| | | | | | | | | | | | 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>
* config: store the section name separatelyCarlos Martín Nieto2011-05-051-0/+1
| | | | | | | | | | | The section and variable names use different rules, so store them as two different variables internally. This will simplify the configuration-writing code as well later on, but even with parsing, the code is simpler. Take this opportunity to add a variable to the list directly when parsing instead of passing through config_set.
* config: use and implement list macrosCarlos Martín Nieto2011-04-071-6/+42
| | | | | Use list macros instead of manually changing the head and/or tail of the variable list.
* config: move str(n)tolower to the git__ namespaceCarlos Martín Nieto2011-04-061-2/+2
| | | | | | | Non-static functions in a library should always have a prefix namespace. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Add strtolower and strntolower functionsCarlos Martín Nieto2011-03-311-0/+3
| | | | | | As parts of variable names are case-sensitive, we need these functions. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* git_config: reorder fields according to useCarlos Martín Nieto2011-03-301-3/+3
| | | | Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* config: use a singly-linked list instead of a hash tableCarlos Martín Nieto2011-03-301-1/+10
| | | | | | | | | | | | Such a list preserves the order the variables were first read in which will be useful later for merging different data-sets. Furthermore, reading and writing out the same configuration should not reorganize the variables, which could happen when iterating through all the items in a hash table. A hash table is overkill for this small a data-set anyway. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Determine variable type at runtimeCarlos Martín Nieto2011-03-301-6/+1
| | | | | | | | | | 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>
* Move git_cvar_type to include/git2/config.hCarlos Martín Nieto2011-03-291-8/+4
| | | | | | Include it in src/config.h and fix the header name #define. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Rename git_config_{type,var} to git_cvar{_type,}Carlos Martín Nieto2011-03-291-3/+3
| | | | Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Move the struct declaration outside config.cCarlos Martín Nieto2011-03-281-0/+33
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>