summaryrefslogtreecommitdiff
path: root/src/config_file.c
Commit message (Collapse)AuthorAgeFilesLines
* Plug some leaksJacques Germishuys2014-12-291-7/+5
|
* Spelling fixesWill Stamper2014-12-041-1/+1
|
* Clean up issues include.path issues found during code review.John Fultz2014-11-021-2/+9
| | | | | | | | * Error-handling is cleaned up to only let a file-not-found error through, not other sorts of errors. And when a file-not-found error happens, we clean up the error. * Test now checks that file-not-found introduces no error. And other minor cleanups.
* Make config reading continue after hitting a missing include file.John Fultz2014-11-011-7/+6
| | | | | | | | | | | For example, if you have [include] path = foo and foo didn't exist, git_config_open_ondisk() would just give up on the rest of the file. Now it ignores the unresolved include without error and continues reading the rest of the file.
* config: remove the refresh function and backend fieldcmn/config-refresh-removeCarlos Martín Nieto2014-10-231-9/+0
| | | | | | 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.
* Patch from @carlosmn to refresh the parent config before snapshotting.refresh-config-snapshotAlan Rogers2014-10-231-1/+6
|
* config: Fix multiple trailing spaces before comments not completely trimmedLinquize2014-10-041-1/+1
|
* config: a multiline var can start immediatelyCarlos Martín Nieto2014-08-091-1/+1
| | | | | | | | | | | | | | | | | In the check for multiline, we traverse the backslashes from the end backwards and int the end assert that we haven't gone past the beginning of the line. We make sure of this in the loop condition, but we also check in the return value. However, for certain configurations, a line in a multiline variable might be empty to aid formatting. In that case, 'end' == 'start', since we ended up looking at the first char which made it a multiline. There is no need for the (end > start) check in the return, since the loop guarantees we won't go further back than the first char in the line, and we do accept the first char to be the final backslash. This fixes #2483.
* Make sure \n is at the end of config file before a new section is writtenLinquize2014-07-161-3/+3
|
* Fix mutex init/free in config_file.cPhilip Kelley2014-05-151-1/+4
|
* Some coverity inspired cleanupsRussell Belfer2014-05-131-3/+5
|
* Minor fixes for warnings and error propagationRussell Belfer2014-05-121-8/+5
|
* config: share the strmap on snapshotCarlos Martín Nieto2014-04-181-54/+2
| | | | | | Now that our strmap is no longer modified but replaced, we can use the same strmap for the snapshot's values and it will be freed when we don't need it anymore.
* config: refcount the values mapCarlos Martín Nieto2014-04-181-43/+131
| | | | This is mostly groundwork to let us re-use the map in the snapshots.
* config: refresh on deleteCarlos Martín Nieto2014-04-181-51/+12
| | | | | | | | | When we delete an entry, we also want to refresh the configuration to catch any changes that happened externally. This allows us to simplify the logic, as we no longer need to delete these variables internally. The whole state will be refreshed and the deleted entries won't be there.
* config: refresh before reading a valueCarlos Martín Nieto2014-04-181-3/+12
| | | | | | | | | | With the isolation of complex reads, we can now try to refresh the on-disk file before reading a value from it. This changes the semantics a bit, as before we could be sure that a string we got from the configuration was valid until we wrote or refreshed. This is no longer the case, as a read can also invalidate the pointer.
* config: refresh the values on writeCarlos Martín Nieto2014-04-181-82/+17
| | | | | | When writing out, parse the resulting file instead of adding or replacing the value locally. This has the effect of reading external changes as well.
* config: use a snapshot for the iteratorCarlos Martín Nieto2014-04-181-3/+17
|
* config: split out the refresh stepCarlos Martín Nieto2014-04-181-14/+25
| | | | This will be used by the writing commands in a later step.
* config: make refresh atomicCarlos Martín Nieto2014-04-181-23/+16
| | | | | | | | Current code sets the active map to a new one and builds it whilst it's active. This is a race condition with someone else trying to access the same config. Instead, let's build up our new map and swap the active and new one.
* config: implement config snapshottingCarlos Martín Nieto2014-04-181-67/+263
| | | | | | | | | | | 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.
* Add diff threading tests and attr file cache locksRussell Belfer2014-04-171-7/+13
| | | | | | This adds a basic test of doing simultaneous diffs on multiple threads and adds basic locking for the attr file cache because that was the immediate problem that arose from these tests.
* Move system directory cache out of utilsEdward Thomson2014-02-241-2/+2
|
* Fix a memory leak in `config_parse`.Arthur Schreiber2014-01-131-1/+3
|
* Fixed a compile error in VS2013.Robert Konrad2014-01-021-1/+1
|
* Add config read fns with controlled error behaviorRussell Belfer2013-12-111-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* config_file: styleVicent Marti2013-11-101-18/+18
|
* Merge pull request #1950 from csware/quote-config-valuesVicent Martí2013-11-101-2/+24
|\ | | | | Correctly quote config values while saving
| * Rename methodSven Strickroth2013-11-071-3/+3
| | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
| * Correctly quote config values while savingSven Strickroth2013-11-071-2/+24
| | | | | | | | | | | | If the value contains a command (; or #) char or starts or ends with space it needs to be quoted. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | Fix leaksnulltoken2013-11-051-2/+5
| |
* | Propagate ELOCKED error when updating the confignulltoken2013-11-051-4/+4
| |
* | move mode_t to filebuf_open instead of _commitEdward Thomson2013-11-041-2/+2
|/
* remote: don't write too much when dealing with multivarsCarlos Martín Nieto2013-11-021-6/+12
| | | | | | | | | | We used to move `data_start` forward, which is wrong as that needs to point to the beginning of the buffer in order to perform size calculations. Introduce a `write_start` variable which indicates where we should start writing from, which is what the `data_start` was being wrongly reused to be.
* config_file: Style fixesVicent Marti2013-11-011-9/+6
|
* Fix memory leaks.Daniel Rodríguez Troitiño2013-11-011-0/+2
|
* Fix saving remotes with several fetch/push ref specs.Daniel Rodríguez Troitiño2013-11-011-1/+89
| | | | | | | | | | | | | | | | | | | | | | 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.
* Config subsection name should allow to have ']' and '\\' should allow to ↵Linquize2013-10-011-26/+15
| | | | escape any characters
* Merge pull request #1840 from linquize/warningVicent Martí2013-09-211-2/+2
|\ | | | | Fix warning
| * Fix warningLinquize2013-09-191-2/+2
| |
* | Merge git_buf and git_bufferRussell Belfer2013-09-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | This makes the git_buf struct that was used internally into an externally available structure and eliminates the git_buffer. As part of that, some of the special cases that arose with the externally used git_buffer were blended into the git_buf, such as being careful about git_buf objects that may have a NULL ptr and allowing for bufs with a valid ptr and size but zero asize as a way of referring to externally owned data.
* | config: handle realloc issues from larger depthsCarlos Martín Nieto2013-09-071-0/+9
| | | | | | | | | | | | | | As the include depth increases, the chance of a realloc increases. This means that whenever we run git_array_alloc() or call config_parse(), we need to remember what our reader's index is so we can look it up again.
* | config: return an error when reaching the maximum include depthCarlos Martín Nieto2013-09-071-3/+4
| |
* | config: fix variable overridingCarlos Martín Nieto2013-09-071-1/+6
| | | | | | | | | | When two or more variables of the same name exist and the user asks for a scalar, we must return the latest value assign to it.
* | config: refresh included filesCarlos Martín Nieto2013-09-071-5/+16
| | | | | | | | | | | | We need to refresh the variables from the included files if they are changed, so loop over all included files and re-parse the files if any of them has changed.
* | config: keep a list of included filesCarlos Martín Nieto2013-09-071-47/+58
| | | | | | | | | | When refreshing we need to refresh if any of the files have been touched, so we need to keep the list.
* | config: add support for include directivesCarlos Martín Nieto2013-09-071-5/+52
| | | | | | | | | | Relative, absolute and home-relative paths are supported. The recursion limit it set at 10, just like in git.
* | config: decouple the backend from the reader at the low levelCarlos Martín Nieto2013-09-051-84/+96
|/ | | | | | | In order to support config includes, we must differentiate between the backend's main file and the file we are currently parsing. This lays the groundwork for includes, keeping the current behaviours.
* Merge pull request #1772 from libgit2/config-iterVicent Martí2013-08-281-141/+53
|\ | | | | Configuration iterators redux
| * config: don't special-case the multivar iteratorCarlos Martín Nieto2013-08-141-197/+4
| | | | | | | | | | Build it on top of the normal iterator instead, which lets use re-use a lot of code.