diff options
author | Russell Belfer <rb@github.com> | 2013-12-04 21:22:57 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-12-11 10:57:49 -0800 |
commit | dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7 (patch) | |
tree | c7f4f4738dfb249b7534635226128d2e20dac6a5 /src/refs.c | |
parent | 96869a4edb2872934e0e167a726ab240f4270fea (diff) | |
download | libgit2-dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7.tar.gz |
Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper. As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.
Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up. A number of
those fixes are included in the this commit as well.
Diffstat (limited to 'src/refs.c')
-rw-r--r-- | src/refs.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/refs.c b/src/refs.c index bae62158b..60ed9ffb1 100644 --- a/src/refs.c +++ b/src/refs.c @@ -513,20 +513,19 @@ int git_reference_foreach( git_reference *ref; int error; - if (git_reference_iterator_new(&iter, repo) < 0) - return -1; + if ((error = git_reference_iterator_new(&iter, repo)) < 0) + return error; while ((error = git_reference_next(&ref, iter)) == 0) { if (callback(ref, payload)) { - error = GIT_EUSER; - goto out; + error = giterr_user_cancel(); + break; } } if (error == GIT_ITEROVER) error = 0; -out: git_reference_iterator_free(iter); return error; } @@ -540,20 +539,19 @@ int git_reference_foreach_name( const char *refname; int error; - if (git_reference_iterator_new(&iter, repo) < 0) - return -1; + if ((error = git_reference_iterator_new(&iter, repo)) < 0) + return error; while ((error = git_reference_next_name(&refname, iter)) == 0) { if (callback(refname, payload)) { - error = GIT_EUSER; - goto out; + error = giterr_user_cancel(); + break; } } if (error == GIT_ITEROVER) error = 0; -out: git_reference_iterator_free(iter); return error; } @@ -568,20 +566,19 @@ int git_reference_foreach_glob( const char *refname; int error; - if (git_reference_iterator_glob_new(&iter, repo, glob) < 0) - return -1; + if ((error = git_reference_iterator_glob_new(&iter, repo, glob)) < 0) + return error; while ((error = git_reference_next_name(&refname, iter)) == 0) { if (callback(refname, payload)) { - error = GIT_EUSER; - goto out; + error = giterr_user_cancel(); + break; } } if (error == GIT_ITEROVER) error = 0; -out: git_reference_iterator_free(iter); return error; } |