From 96869a4edb2872934e0e167a726ab240f4270fea Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 3 Dec 2013 16:45:39 -0800 Subject: 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. --- src/iterator.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/iterator.c') diff --git a/src/iterator.c b/src/iterator.c index 8646399ab..c1292227c 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -991,9 +991,8 @@ static int fs_iterator__expand_dir(fs_iterator *fi) fi->base.start, fi->base.end, &ff->entries); if (error < 0) { - git_error last_error = {0}; - - giterr_detach(&last_error); + git_error_state last_error = { 0 }; + giterr_capture(&last_error, error); /* these callbacks may clear the error message */ fs_iterator__free_frame(ff); @@ -1001,12 +1000,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi) /* next time return value we skipped to */ fi->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS; - if (last_error.message) { - giterr_set_str(last_error.klass, last_error.message); - free(last_error.message); - } - - return error; + return giterr_restore(&last_error); } if (ff->entries.length == 0) { -- cgit v1.2.3