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/path.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/path.c')
-rw-r--r-- | src/path.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/path.c b/src/path.c index 750dd3ef7..8be41c17e 100644 --- a/src/path.c +++ b/src/path.c @@ -434,7 +434,8 @@ int git_path_walk_up( iter.asize = path->asize; while (scan >= stop) { - error = cb(data, &iter); + if (cb(data, &iter)) + error = giterr_user_cancel(); iter.ptr[scan] = oldc; if (error < 0) break; @@ -528,7 +529,9 @@ bool git_path_is_empty_dir(const char *path) if (!git_path_isdir(path)) return false; - if (!(error = git_buf_sets(&dir, path))) + if ((error = git_buf_sets(&dir, path)) != 0) + giterr_clear(); + else error = git_path_direach(&dir, 0, path_found_entry, NULL); git_buf_free(&dir); @@ -867,7 +870,7 @@ int git_path_direach( if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0) break; #endif - + if ((error = git_buf_put(path, de_path, de_len)) < 0) break; @@ -876,7 +879,7 @@ int git_path_direach( git_buf_truncate(path, wd_len); /* restore path */ if (error) { - error = GIT_EUSER; + error = giterr_user_cancel(); break; } } |