summaryrefslogtreecommitdiff
path: root/tests/config
Commit message (Collapse)AuthorAgeFilesLines
* leaks: fix some leaks in the testsEdward Thomson2016-03-311-0/+3
|
* Merge pull request #3712 from ethomson/config_duplicate_sectionCarlos Martín Nieto2016-03-291-0/+24
|\ | | | | config: don't write duplicate section
| * config::write::repeated: init our bufferEdward Thomson2016-03-281-1/+1
| |
| * config: show we write a spurious duplicated section headerCarlos Martín Nieto2016-03-281-0/+24
| | | | | | | | | | We should notice that we are in the correct section to add. This is a cosmetic bug, since replacing any of these settings does work.
* | config: don't special-case multivars that don't exist yetcmn/multivar-set-lockedCarlos Martín Nieto2016-03-211-1/+1
|/ | | | | | | | | | This special-casing ignores that we might have a locked file, so the hashtable does not represent the contents of the file we want to write. This causes multivar writes to overwrite entries instead of add to them when under lock. There is no need for this as the normal code-path will write to the file just fine, so simply get rid of it.
* tests: config::stress: free `git_config` structsPatrick Steinhardt2015-11-241-0/+3
|
* tests: config::global: fix memleak in open_programdataPatrick Steinhardt2015-11-241-1/+1
|
* config::global: use PROGRAMDATA configurationEdward Thomson2015-11-171-4/+6
| | | | | Query the `GIT_CONFIG_LEVEL_PROGRAMDATA` location when setting it up for tests, in case the test runner has sandboxed it.
* config: add failing test for an external modificationCarlos Martín Nieto2015-10-301-0/+20
| | | | | | | | | We currently use the timestamp in order to decide whether a config file has changed since we last read it. This scheme falls down if the file is written twice within the same second, as we fail to detect the file change after the first read in that second.
* config: add a ProgramData levelcmn/programdata-configCarlos Martín Nieto2015-10-211-0/+40
| | | | | 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: test that comments are left as with gitLinquize2015-09-181-3/+8
|
* git_futils_mkdir_*: make a relative-to-base mkdirEdward Thomson2015-09-171-3/+3
| | | | | | | | | | | | Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter assumes that we own everything beneath the base, as if it were being called with a base of the repository or working directory, and is tailored towards checkout and ensuring that there is no bogosity beneath the base that must be cleaned up. This is (at best) slow and (at worst) unsafe in the larger context of a filesystem where we do not own things and cannot do things like unlink symlinks that are in our way.
* Don't free config in `git_transaction_commit`.Arthur Schreiber2015-09-131-0/+10
| | | | The config is not owned by the transaction, so please don’t free it.
* config: perform unlocking via git_transactioncmn/config-txCarlos Martín Nieto2015-08-121-3/+4
| | | | | This makes the API for commiting or discarding changes the same as for references.
* config: expose locking via the main APICarlos Martín Nieto2015-08-121-19/+22
| | | | | | | | | 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.
* config: implement basic transactional supportCarlos Martín Nieto2015-08-121-0/+46
| | | | | | | When a configuration file is locked, any updates made to it will be done to the in-memory copy of the file. This allows for multiple updates to happen while we hold the lock, preventing races during complex config-file manipulation.
* config: test all multivars are updatedEdward Thomson2015-05-041-6/+16
| | | | | | If a multivar exists within two sections (of the same name) then they should both be updated in a `set_multivar`. Ensure that this is the case.
* config: use wildcard in test instead of empty exprEdward Thomson2015-05-041-1/+1
|
* config: cleanup some now-unused variablesEdward Thomson2015-05-041-2/+0
|
* Test setting config var under duplicate header.Ryan Roden-Corrent2015-05-041-0/+49
| | | | | | | | | | Add a test that exposes a bug in config_write. It is valid to have multiple separate headers for the same config section, but config_write will exit after finding the first matching section in certain situations. This test proves that config_write will duplicate a variable that already exists instead of overwriting it if the variable is defined under a duplicate section header.
* config: examine whole file when writingEdward Thomson2015-05-041-0/+37
| | | | | | | | | | | | | | | | Previously we would try to be clever when writing the configuration file and try to stop parsing (and simply copy the rest of the old file) when we either found the value we were trying to write, or when we left the section that value was in, the assumption being that there was no more work to do. Regrettably, you can have another section with the same name later in the file, and we must cope with that gracefully, thus we read the whole file in order to write a new file. Now, writing a file looks even more than reading. Pull the config parsing out into its own function that can be used by both reading and writing the configuration.
* config: test overwriting cvar in multiple regionsEdward Thomson2015-05-041-0/+36
|
* config: ensure we can write to an empty fileEdward Thomson2015-05-041-0/+72
|
* config: ensure we can write to an empty fileEdward Thomson2015-04-231-0/+35
|
* config: test that we validate the keyEdward Thomson2015-04-231-0/+35
|
* Specify mock config file content in test.Ryan Roden-Corrent2015-04-211-4/+11
| | | | | Instead of using a config file in resources, include the config file content to be tested directly in the test.
* Unittest to validate config entry deletion bug.Ryan Roden-Corrent2015-04-211-0/+31
| | | | | | Add a unittest to validate bug #3043, where a duplicate empty config header could cause deletion of a config entry to fail silently. The bug is currently unresolved and this test will fail.
* config_file: comment char can be invalid escapeEdward Thomson2015-04-201-0/+11
| | | | | | Don't assume that comment chars are comment chars, they may be (an attempt to be escaped). If so, \; is not a valid escape sequence, complain.
* config_file: parse multilines generouslyEdward Thomson2015-04-201-6/+34
| | | | | Combine unquoting and multiline detection to avoid ambiguity when parsing.
* Fix checking of return value for regcomp.Patrick Steinhardt2015-04-101-0/+12
| | | | | | | | The regcomp function returns a non-zero value if compilation of a regular expression fails. In most places we only check for negative values, but positive values indicate an error, as well. Fix this tree-wide, fixing a segmentation fault when calling git_config_iterator_glob_new with an invalid regexp.
* Plug a few leaksCarlos Martín Nieto2015-03-041-0/+1
|
* config: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-0310-140/+169
| | | | | | | | | | | | | | | 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.
* Add test for include.path inside included configYury G. Kudryashov2015-02-131-0/+22
| | | | | | It fails at least on my computer, though it may depend on some unpredictable factors (say, will realloc() extend the memory segment in place, or it will allocate new memory).
* config: add parsing and getter for pathscmn/config-get-pathCarlos Martín Nieto2015-01-141-0/+46
|
* tests: use p_ instead of posix func directlyEdward Thomson2014-12-101-2/+2
|
* Clean up issues include.path issues found during code review.John Fultz2014-11-021-3/+4
| | | | | | | | * 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-0/+15
| | | | | | | | | | | 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 test: clean up memory leakEdward Thomson2014-10-261-0/+1
|
* config: remove the refresh function and backend fieldcmn/config-refresh-removeCarlos Martín Nieto2014-10-233-92/+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.
* Change the length of the file so that the change is picked up.Alan Rogers2014-10-231-2/+2
|
* Add a test to make sure a new snapshot has the new value.Alan Rogers2014-10-231-1/+14
|
* config: Add test cases that have trailing spaces before comment charsLinquize2014-10-041-0/+12
|
* config: a multiline var can start immediatelyCarlos Martín Nieto2014-08-091-0/+13
| | | | | | | | | | | | | | | | | 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.
* Add unit test to test add section without lf at EOFLinquize2014-07-161-0/+16
|
* Merge pull request #2313 from libgit2/cmn/remote-deleteVicent Marti2014-05-162-0/+32
|\ | | | | Remote deletion
| * tests: Introduce count_config_entries_match() helpernulltoken2014-04-302-0/+32
| |
* | Better search path sandboxingrb/restore-search-pathsRussell Belfer2014-05-152-27/+3
| | | | | | | | | | | | | | There are a number of tests that modify the global or system search paths during the tests. This adds a helper function to make it easier to restore those paths and makes sure that they are getting restored in a manner that preserves test isolation.
* | Merge pull request #2188 from libgit2/cmn/config-snapshotRussell Belfer2014-05-124-9/+97
|\ \ | | | | | | Configuration snapshotting
| * | config: refresh on deleteCarlos Martín Nieto2014-04-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-182-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.