Commit 8a4d77f990b4453e42e3c2cc61df5175b39586d3

Carlos Martín Nieto 2015-05-15T12:15:45

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/path.c b/src/path.c
index df6762c..81b4d51 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1060,11 +1060,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;
 		}