|
2d449a11
|
2018-10-09T02:42:14
|
|
config: Refactor `git_config_backend_from_string` to take a length
|
|
2be39cef
|
2018-08-10T19:38:57
|
|
config: introduce new read-only in-memory backend
Now that we have abstracted away how to store and retrieve config
entries, it became trivial to implement a new in-memory backend by
making use of this. And thus we do so.
This commit implements a new read-only in-memory backend that can parse
a chunk of memory into a `git_config_backend` structure.
|
|
b944e137
|
2018-08-10T13:03:33
|
|
config: rename "config_file.h" to "config_backend.h"
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.
|
|
6698e056
|
2018-08-14T04:22:14
|
|
Fix the test and comment.
|
|
f1409500
|
2018-08-14T03:54:01
|
|
Write a test.
|
|
9994cd3f
|
2018-06-25T11:56:52
|
|
treewide: remove use of C++ style comments
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.
|
|
ecf4f33a
|
2018-02-08T11:14:48
|
|
Convert usage of `git_buf_free` to new `git_buf_dispose`
|
|
6a15f657
|
2018-02-09T13:02:26
|
|
config_file: iterate over keys in the order they were added
Currently, all configuration entries were only held in a string map,
making iteration order mostly based on the hash of each entry's key. Now
that we have extended the `diskfile_entries` structure by a list of
config entries, we can effectively iterate through entries in the order
they were added, though.
|
|
2eea5f1c
|
2018-02-08T10:27:31
|
|
config_parse: fix reading files with BOM
The function `skip_bom` is being used to detect and skip BOM marks
previously to parsing a configuration file. To do so, it simply uses
`git_buf_text_detect_bom`. But since the refactoring to use the parser
interface in commit 9e66590bd (config_parse: use common parser
interface, 2017-07-21), the BOM detection was actually broken.
The issue stems from a misunderstanding of `git_buf_text_detect_bom`. It
was assumed that its third parameter limits the length of the character
sequence that is to be analyzed, while in fact it was an offset at which
we want to detect the BOM. Fix the parameter to be `0` instead of the
buffer length, as we always want to check the beginning of the
configuration file.
|
|
848153f3
|
2018-02-08T10:02:29
|
|
config_parse: handle empty lines with CRLF
Currently, the configuration parser will fail reading empty lines with
just an CRLF-style line ending. Special-case the '\r' character in order
to handle it the same as Unix-style line endings. Add tests to spot this
regression in the future.
|
|
42627933
|
2017-11-04T18:03:26
|
|
Merge remote-tracking branch 'upstream/master' into pks/conditional-includes
|
|
c44b9170
|
2017-10-31T09:52:33
|
|
tests: resolve the real path for the sandbox in includeIf tests
We put our repository in the temporary directory which makes macOS map the path
into a virtual path. `realpath(3)` can resolve it and we do so during repository
opening, but that makes its path have a different prefix from the sandbox path
clar thinks we have.
Resolve the sandbox path before putting it into the test config files so the
paths match as expected.
|
|
bb8bc4b8
|
2017-10-30T06:21:55
|
|
config: add failing test for preserving case when writing keys
While most parts of a configuration key are case-insensitive, we should still be
case-preserving and write down whatever string the caller provided.
|
|
f7d837c8
|
2017-05-24T12:12:29
|
|
config_file: implement "gitdir/i" conditional
Next to the "gitdir" conditional for including other configuration
files, there's also a "gitdir/i" conditional. In contrast to the former
one, path matching with "gitdir/i" is done case-insensitively. This
commit implements the case-insensitive condition.
|
|
071b6c06
|
2017-05-24T11:13:36
|
|
config_file: implement conditional "gitdir" includes
Upstream git.git has implemented the ability to include other
configuration files based on conditions. Right now, this only includes
the ability to include a file based on the gitdir-location of the
repository the currently parsed configuration file belongs to. This
commit implements handling these conditional includes for the
case-sensitive "gitdir" condition.
|
|
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`.
|
|
1b329089
|
2017-05-31T22:27:19
|
|
config_file: refuse modifying included variables
Modifying variables pulled in by an included file currently succeeds,
but it doesn't actually do what one would expect, as refreshing the
configuration will cause the values to reappear. As we are currently not
really able to support this use case, we will instead just return an
error for deleting and setting variables which were included via an
include.
|
|
28c2cc3d
|
2017-05-31T16:41:44
|
|
config_file: move reader into `config_read` only
Right now, we have multiple call sites which initialize a `reader`
structure. As the structure is only actually used inside of
`config_read`, we can instead just move the reader inside of the
`config_read` function. Instead, we can just pass in the configuration
file into `config_read`, which eases code readability.
|
|
83bcd3a1
|
2017-05-31T22:45:25
|
|
config_file: refresh all files if includes were modified
Currently, we only re-parse the top-level configuration file when it has
changed itself. This can cause problems when an include is changed, as
we were not updating all values correctly.
Instead of conditionally reparsing only refreshed files, the logic
becomes much clearer and easier to follow if we always re-parse the
top-level configuration file when either the file itself or one of its
included configuration files has changed on disk. This commit implements
this logic.
Note that this might impact performance in some cases, as we need to
re-read all configuration files whenever any of the included files
changed. It could increase performance to just re-parse include files
which have actually changed, but this would compromise maintainability
of the code without much gain. The only case where we will gain anything
is when we actually use includes and when only these includes are
updated, which will probably be quite an unusual scenario to actually be
worthwhile to optimize.
|
|
6f7aab0c
|
2017-06-06T09:45:11
|
|
tests: config::include: use init and cleanup functions
|
|
1f7af277
|
2017-07-05T11:52:47
|
|
tests: config: fix missing declaration causing error
On systems where we pull in our distributed version of the regex
library, all tests in config::readonly fail. This error is actually
quite interesting: the test suite is unable to find the declaration of
`git_path_exists` and assumes it has a signature of `int
git_path_exists(const char *)`. But actually, it has a `bool` return
value. Due to this confusion, some wrong conversion is done by the
compiler and the `cl_assert(!git_path_exists("file"))` checks
erroneously fail, even when the function does in fact return the correct
value.
The error is actually introduced by 56893bb9a (cmake: consistently use
TARGET_INCLUDE_DIRECTORIES if available, 2017-06-28), unfortunately
introduced by myself. Due to the delayed addition of include
directories, we will now find the "config.h" header inside of the
"deps/regex" directory instead of inside the "src/" directory, where it
should be. As such, we are missing definitions for the
`git_config_file__ondisk` and `git_path_exists` symbols.
The correct fix here would be to fix the order in which include search
directories are added. But due to the current restructuring of
CMakeBuild.txt, I'm refraining from doing so and delay the proper fix a
bit. Instead, we paper over the issue by explicitly including "path.h"
to fix its prototype. This ignores the issue that
`git_config_file__ondisk` is undeclared, as its signature is correctly
identified by the compiler.
|
|
a1023a43
|
2017-05-20T17:18:07
|
|
Merge pull request #4179 from libgit2/ethomson/expand_tilde
Introduce home directory expansion function for config files, attribute files
|
|
2a7086fa
|
2017-04-25T13:23:04
|
|
tests: config: verify functionality with read-only backends
|
|
ed812ee7
|
2017-03-23T12:03:29
|
|
config::include: sanitize homedir
Sanitize the home directory to ensure that we do not accidentally locate
a file called `~/.nonexistentfile`.
|
|
047fe29c
|
2016-06-20T13:05:48
|
|
add failing test to include a missing config file relative to home dir
|
|
17442b28
|
2016-03-30T17:47:05
|
|
leaks: fix some leaks in the tests
|
|
2f0450f4
|
2016-03-29T03:26:43
|
|
Merge pull request #3712 from ethomson/config_duplicate_section
config: don't write duplicate section
|
|
76e1a679
|
2016-03-28T08:56:13
|
|
config::write::repeated: init our buffer
|
|
3e95bd36
|
2016-03-04T14:51:16
|
|
config: show we write a spurious duplicated section header
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.
|
|
6f09911c
|
2016-03-21T21:10:26
|
|
config: don't special-case multivars that don't exist yet
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.
|
|
9031be18
|
2015-11-24T14:38:17
|
|
tests: config::stress: free `git_config` structs
|
|
c8fab201
|
2015-11-24T14:29:32
|
|
tests: config::global: fix memleak in open_programdata
|
|
6f7c4118
|
2015-11-17T08:38:46
|
|
config::global: use PROGRAMDATA configuration
Query the `GIT_CONFIG_LEVEL_PROGRAMDATA` location when setting it up
for tests, in case the test runner has sandboxed it.
|
|
a2f96479
|
2015-10-29T20:31:25
|
|
config: add failing test for an external modification
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.
|
|
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.
|
|
08313c4b
|
2015-09-18T11:30:50
|
|
config: test that comments are left as with git
|
|
ac2fba0e
|
2015-09-16T15:07:27
|
|
git_futils_mkdir_*: make a relative-to-base mkdir
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.
|
|
548cb334
|
2015-09-13T16:32:24
|
|
Don't free config in `git_transaction_commit`.
The config is not owned by the transaction, so please don’t free it.
|
|
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.
|
|
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.
|
|
b1667039
|
2015-06-01T19:17:03
|
|
config: implement basic transactional support
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.
|
|
d6b7e404
|
2015-05-04T07:36:21
|
|
config: test all multivars are updated
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.
|
|
0daf998d
|
2015-04-27T16:31:18
|
|
config: use wildcard in test instead of empty expr
|
|
63c0cc65
|
2015-04-27T16:29:00
|
|
config: cleanup some now-unused variables
|
|
5a70df94
|
2015-04-21T15:57:20
|
|
Test setting config var under duplicate header.
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.
|
|
bf99390e
|
2015-04-23T16:54:36
|
|
config: examine whole file when writing
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.
|
|
f79c7322
|
2015-04-23T12:00:05
|
|
config: test overwriting cvar in multiple regions
|
|
7ee61b8e
|
2015-04-21T17:18:21
|
|
config: ensure we can write to an empty file
|
|
6dc55872
|
2015-04-21T17:18:21
|
|
config: ensure we can write to an empty file
|
|
23fb4004
|
2015-04-21T12:49:57
|
|
config: test that we validate the key
|
|
f56a417d
|
2015-04-16T15:20:33
|
|
Specify mock config file content in test.
Instead of using a config file in resources, include the config file content to
be tested directly in the test.
|
|
a060cccc
|
2015-04-16T10:53:22
|
|
Unittest to validate config entry deletion bug.
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.
|
|
e009a705
|
2015-04-20T00:22:20
|
|
config_file: comment char can be invalid escape
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.
|
|
7f2e61f3
|
2015-04-19T23:55:02
|
|
config_file: parse multilines generously
Combine unquoting and multiline detection to avoid ambiguity when
parsing.
|
|
129022ee
|
2015-04-10T09:36:38
|
|
Fix checking of return value for regcomp.
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.
|
|
fe21d708
|
2015-03-04T00:29:37
|
|
Plug a few leaks
|
|
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.
|
|
3ea78f24
|
2015-02-09T19:40:22
|
|
Add test for include.path inside included config
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).
|
|
eac773d9
|
2015-01-14T15:05:43
|
|
config: add parsing and getter for paths
|
|
34100846
|
2014-11-26T16:24:37
|
|
tests: use p_ instead of posix func directly
|
|
ebc13b2b
|
2014-11-02T19:16:49
|
|
Clean up issues include.path issues found during code review.
* 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.
|
|
727ae380
|
2014-11-01T11:21:45
|
|
Make config reading continue after hitting a missing include file.
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.
|
|
90aa2bf3
|
2014-10-25T19:51:12
|
|
config test: clean up memory leak
|
|
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.
|
|
1e2fe921
|
2014-10-21T09:29:17
|
|
Change the length of the file so that the change is picked up.
|
|
5490c9d4
|
2014-10-16T13:52:55
|
|
Add a test to make sure a new snapshot has the new value.
|
|
a447a7e4
|
2014-10-04T23:28:40
|
|
config: Add test cases that have trailing spaces before comment chars
|
|
9dac1f95
|
2014-08-09T10:56:50
|
|
config: a multiline var can start immediately
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.
|
|
69374869
|
2014-07-16T21:54:53
|
|
Add unit test to test add section without lf at EOF
|
|
228272ef
|
2014-05-16T11:56:37
|
|
Merge pull request #2313 from libgit2/cmn/remote-delete
Remote deletion
|
|
8487e237
|
2014-05-15T10:56:28
|
|
Better search path sandboxing
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.
|
|
d2c4d1c6
|
2014-05-12T10:04:52
|
|
Merge pull request #2188 from libgit2/cmn/config-snapshot
Configuration snapshotting
|
|
0f603132
|
2014-05-01T14:47:33
|
|
Improve handling of fake home directory
There are a few tests that set up a fake home directory and a
fake GLOBAL search path so that we can test things in global
ignore or attribute or config files. This cleans up that code to
work more robustly even if there is a test failure. This also
fixes some valgrind warnings where scanning search paths for
separators could end up doing a little bit of sketchy data access
when coming to the end of search list.
|
|
48ebea66
|
2013-01-07T00:20:13
|
|
tests: Introduce count_config_entries_match() helper
|
|
8c1f4ab4
|
2014-04-09T12:26:53
|
|
config: refresh on delete
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.
|
|
523032cd
|
2014-03-31T09:58:44
|
|
config: refresh before reading a value
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.
|
|
eaf37034
|
2014-03-31T08:53:56
|
|
config: refresh the values on write
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.
|
|
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.
|
|
36913b8c
|
2014-03-06T15:11:11
|
|
config: document current write behaviour in a test
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.
|
|
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.
|
|
96869a4e
|
2013-12-03T16:45:39
|
|
Improve GIT_EUSER handling
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.
|
|
17820381
|
2013-11-14T14:05:52
|
|
Rename tests-clar to tests
|