summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-05-15 12:15:45 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-22 18:13:14 +0200
commit899716b45d5a1d038a1be238c268027a73773d8e (patch)
treea5f0ceee63c0b2a11b313eaefe85c360ea7e8a14
parent900e5d3b6c825db9c397830e7e3d5fa91c74d28b (diff)
downloadlibgit2-899716b45d5a1d038a1be238c268027a73773d8e.tar.gz
path: don't let direach overwrite the callback's error message
This function deals with functions doing IO which means the amount of errors that can happen is quit large. It does not help if it always ovewrites the underlying error message with a less understandable version of "something went wrong". Instead, only use this generic message if there was no error set by the callback.
-rw-r--r--src/path.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/path.c b/src/path.c
index 58d71921b..3d1a9e448 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1038,11 +1038,13 @@ int git_path_direach(
if ((error = git_buf_put(path, de_path, de_len)) < 0)
break;
+ giterr_clear();
error = fn(arg, path);
git_buf_truncate(path, wd_len); /* restore path */
- if (error != 0) {
+ /* Only set our own error if the callback did not set one already */
+ if (error != 0 && !giterr_last()) {
giterr_set_after_callback(error);
break;
}