Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-12-07 03:07:57 +0400
committerRussell Belfer <rb@github.com>2013-12-11 22:57:49 +0400
commit25e0b1576d5f9e5248603f81d3198a65bfccf0ed (patch)
treedac0da29acfbd6478bed93bcab3557e2877dabaa /tests/config/rename.c
parentfcd324c625d8be3f368c924d787e945e5812d8dd (diff)
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.
Diffstat (limited to 'tests/config/rename.c')
-rw-r--r--tests/config/rename.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/config/rename.c b/tests/config/rename.c
index 29ade7b00..db07c798f 100644
--- a/tests/config/rename.c
+++ b/tests/config/rename.c
@@ -44,7 +44,6 @@ void test_config_rename__can_rename(void)
void test_config_rename__prevent_overwrite(void)
{
const git_config_entry *ce;
- const git_error *err;
cl_git_pass(git_config_set_string(
g_config, "branch.local-track.remote", "yellow"));
@@ -60,8 +59,12 @@ void test_config_rename__prevent_overwrite(void)
&ce, g_config, "branch.local-track.remote"));
cl_assert_equal_s(".", ce->value);
-// cl_assert((err = giterr_last()) != NULL);
-// cl_assert(err->message != NULL);
+ /* so, we don't currently prevent overwrite... */
+ /* {
+ const git_error *err;
+ cl_assert((err = giterr_last()) != NULL);
+ cl_assert(err->message != NULL);
+ } */
}
static void assert_invalid_config_section_name(