diff options
| author | Russell Belfer <rb@github.com> | 2013-12-03 16:45:39 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-12-11 10:57:49 -0800 |
| commit | 96869a4edb2872934e0e167a726ab240f4270fea (patch) | |
| tree | 2d770414acef2d1d45a609e004c0aa6fa56d06d7 /src/pool.c | |
| parent | 9f77b3f6f5ce6944ec49dfc666ef6b8df0af0c6b (diff) | |
| download | libgit2-96869a4edb2872934e0e167a726ab240f4270fea.tar.gz | |
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.
Diffstat (limited to 'src/pool.c')
| -rw-r--r-- | src/pool.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/pool.c b/src/pool.c index d484769e9..4796d0a81 100644 --- a/src/pool.c +++ b/src/pool.c @@ -217,7 +217,14 @@ char *git_pool_strdup(git_pool *pool, const char *str) char *git_pool_strdup_safe(git_pool *pool, const char *str) { - return str ? git_pool_strdup(pool, str) : NULL; + if (!str) + return NULL; + else { + char *result = git_pool_strdup(pool, str); + if (!result) + giterr_clear(); + return result; + } } char *git_pool_strcat(git_pool *pool, const char *a, const char *b) |
