diff options
| author | Russell Belfer <rb@github.com> | 2012-08-03 17:08:01 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2012-08-03 17:08:01 -0700 |
| commit | 5dca201072724e4230141796d7c9f8836a277de8 (patch) | |
| tree | 7eb6b8f3e08c8abc608ee43c0ddc32d4d043a2c6 /src/config_file.c | |
| parent | 2031760c626711cc69b4d63ac9798ff333583ca0 (diff) | |
| download | libgit2-5dca201072724e4230141796d7c9f8836a277de8.tar.gz | |
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.
Diffstat (limited to 'src/config_file.c')
| -rw-r--r-- | src/config_file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/config_file.c b/src/config_file.c index 7ced1e5ba..80c63d2a3 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -218,8 +218,10 @@ static int file_foreach( continue; /* abort iterator on non-zero return value */ - if ((result = fn(key, var->value, data)) != 0) + if (fn(key, var->value, data)) { + result = GIT_EUSER; goto cleanup; + } } ); |
