Commit 1df8ad01d746ef56c563f82a4f4037957ddc19d8

Edward Thomson 2014-03-06T16:00:52

clone: don't overwrite original error message

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/clone.c b/src/clone.c
index e19d02b..62f1035 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -430,10 +430,15 @@ int git_clone(
 	}
 
 	if (error != 0) {
+		git_error_state last_error = {0};
+		giterr_capture(&last_error, error);
+
 		git_repository_free(repo);
 		repo = NULL;
 
 		(void)git_futils_rmdir_r(local_path, NULL, rmdir_flags);
+
+		giterr_restore(&last_error);
 	}
 
 	*out = repo;