summaryrefslogtreecommitdiff
path: root/tests/config/write.c
Commit message (Collapse)AuthorAgeFilesLines
* fileops: rename to "futils.h" to match function signaturesPatrick Steinhardt2019-07-201-1/+1
| | | | | | | | | Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
* config: rename "config_file.h" to "config_backend.h"Patrick Steinhardt2018-09-281-1/+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.
* treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-131-2/+2
| | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-11/+11
|
* Merge remote-tracking branch 'upstream/master' into pks/conditional-includesCarlos Martín Nieto2017-11-041-0/+23
|\
| * config: add failing test for preserving case when writing keysCarlos Martín Nieto2017-10-301-0/+23
| | | | | | | | | | While most parts of a configuration key are case-insensitive, we should still be case-preserving and write down whatever string the caller provided.
* | config: pass repository when opening config filesPatrick Steinhardt2017-10-091-4/+4
|/ | | | | | | | | | | | | | | | | 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`.
* leaks: fix some leaks in the testsEdward Thomson2016-03-311-0/+3
|
* 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: test that comments are left as with gitLinquize2015-09-181-3/+8
|
* 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
|
* 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: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-031-25/+38
| | | | | | | | | | | | | | | 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.
* config: remove the refresh function and backend fieldcmn/config-refresh-removeCarlos Martín Nieto2014-10-231-5/+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.
* Add unit test to test add section without lf at EOFLinquize2014-07-161-0/+16
|
* config: refresh the values on writeCarlos Martín Nieto2014-04-181-1/+1
| | | | | | 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: document current write behaviour in a testCarlos Martín Nieto2014-04-181-0/+27
| | | | | | | On set, we set/add the value written to the config's internal values, but we do not refresh old values. Document this in a test in preparation for the refresh changes.
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-0/+1
| | | | | | | | | | | This adds giterr_user_cancel to return GIT_EUSER and clear any error message that is sitting around. As a result of using that in places, we need to be more thorough with capturing errors that happen inside a callback when used internally. To help with that, this also adds giterr_capture and giterr_restore so that when we internally use a foreach-type function that clears errors and converts them to GIT_EUSER, it is easier to restore not just the return value, but the actual error message text.
* Rename tests-clar to testsBen Straub2013-11-141-0/+305