Commit Graph

19 Commits

Author SHA1 Message Date
Sebastian Bauer
a7f8065f8c Use cl_assert_equal_s() instead of strcmp().
Replaced all cl_assert(!strcmp()) or semantically equivalent forms
by cl_assert_equal_s().
2013-01-25 06:55:56 +01:00
Vicent Marti
f6fded8f91 Proper cleanup jeez 2013-01-03 19:07:41 +01:00
Ben Straub
600d8dbf6d Move test cleanup into cleanup functions 2013-01-03 09:10:38 -08:00
Ben Straub
bffbeebbec Cleanup after tests 2013-01-03 08:38:00 -08:00
Michael Schubert
0066955d97 Fix a couple of warnings 2012-11-18 04:27:49 +01:00
nulltoken
270160b91a config: Opening a nonexistent file returns ENOTFOUND 2012-11-17 18:30:34 -08:00
Carlos Martín Nieto
0da81d2b39 config: return an emtpy string when there is no value
Returning NULL for the string when we haven't signaled an error
condition is counter-intuitive and causes unnecessary edge
cases. Return an empty string when asking for a string value for a
configuration variable such as '[section] var' to avoid these edge
cases.

If the distinction between no value and an empty value is needed, this
can be retrieved from the entry directly. As a side-effect, this
change stops the int parsing functions from segfaulting on such a
variable.
2012-11-13 14:49:16 -08:00
Carlos Martín Nieto
47db054df0 config: distinguish between a lone variable name and one without rhs
'[section] variable' and '[section] variable =' behave differently
when parsed as booleans, so we need to store that distinction
internally.
2012-11-13 13:53:41 -08:00
Carlos Martín Nieto
3ee078c0f7 config: rename get_config_entry -> config_entry
We're already in the git_config namespace, there is no need to repeat
it.
2012-11-13 13:46:17 -08:00
yorah
a1abe66aca Add config level support in the config API
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
2012-10-23 12:48:38 +02:00
Russell Belfer
a1ecddf01c Fix config parser boundary logic
The config file parser was not working right if there was no
whitespace between the value name and the equals sign.  This
fixes that.
2012-08-12 07:59:30 -07:00
Russell Belfer
5dca201072 Update iterators for consistency across library
This updates all the `foreach()` type functions across the library
that take callbacks from the user to have a consistent behavior.
The rules are:

* A callback terminates the loop by returning any non-zero value
* Once the callback returns non-zero, it will not be called again
  (i.e. the loop stops all iteration regardless of state)
* If the callback returns non-zero, the parent fn returns GIT_EUSER
* Although the parent returns GIT_EUSER, no error will be set in
  the library and `giterr_last()` will return NULL if called.

This commit makes those changes across the library and adds tests
for most of the iteration APIs to make sure that they follow the
above rules.
2012-08-03 17:08:01 -07:00
Russell Belfer
b3ff1dab31 Adding git_config_foreach_match() iteration fn
Adding a new config iteration function that let's you iterate
over just the config entries that match a particular regular
expression.  The old foreach becomes a simple use of this with
an empty pattern.

This also fixes an apparent bug in the existing `git_config_foreach`
where returning a non-zero value from the iteration callback was
not correctly aborting the iteration and the returned value was
not being propogated back to the caller of foreach.

Added to tests to cover all these changes.
2012-07-10 23:19:47 -07:00
Vicent Martí
255c38c500 global: Fix unit tests after reordering 2012-05-18 01:25:57 +02:00
Vicent Martí
946a6dc4e6 Update test suite 2012-05-02 16:14:30 -07:00
Vicent Martí
40879facad Merge branch 'new-error-handling' into development
Conflicts:
	.travis.yml
	include/git2/diff.h
	src/config_file.c
	src/diff.c
	src/diff_output.c
	src/mwindow.c
	src/path.c
	tests-clar/clar_helpers.c
	tests-clar/object/tree/frompath.c
	tests/t00-core.c
	tests/t03-objwrite.c
	tests/t08-tag.c
	tests/t10-refs.c
	tests/t12-repo.c
	tests/t18-status.c
	tests/test_helpers.c
	tests/test_main.c
2012-05-02 15:59:02 -07:00
Carlos Martín Nieto
a7d19b975a config: also allow escaping outside of a quoted string
This limitation was a misparsing of the documentation.
2012-04-25 15:47:53 +02:00
Ben Straub
20ec426dde Discovered cl_git_strequal! Mounted a crusade! 2012-03-31 19:47:59 -07:00
Vicent Martí
3fd1520cd4 Rename the Clay test suite to Clar
Clay is the name of a programming language on the makings, and we want
to avoid confusions. Sorry for the huge diff!
2012-01-24 20:35:15 -08:00