File tree 2 files changed +29
-0
lines changed 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -430,10 +430,15 @@ int git_clone(
430
430
}
431
431
432
432
if (error != 0 ) {
433
+ git_error_state last_error = {0 };
434
+ giterr_capture (& last_error , error );
435
+
433
436
git_repository_free (repo );
434
437
repo = NULL ;
435
438
436
439
(void )git_futils_rmdir_r (local_path , NULL , rmdir_flags );
440
+
441
+ giterr_restore (& last_error );
437
442
}
438
443
439
444
* out = repo ;
Original file line number Diff line number Diff line change @@ -85,3 +85,27 @@ void test_core_errors__new_school(void)
85
85
86
86
giterr_clear ();
87
87
}
88
+
89
+ void test_core_errors__restore (void )
90
+ {
91
+ git_error_state err_state = {0 };
92
+
93
+ giterr_clear ();
94
+ cl_assert (giterr_last () == NULL );
95
+
96
+ cl_assert_equal_i (0 , giterr_capture (& err_state , 0 ));
97
+
98
+ memset (& err_state , 0x0 , sizeof (git_error_state ));
99
+
100
+ giterr_set (42 , "Foo: %s" , "bar" );
101
+ cl_assert_equal_i (-1 , giterr_capture (& err_state , -1 ));
102
+
103
+ cl_assert (giterr_last () == NULL );
104
+
105
+ giterr_set (99 , "Bar: %s" , "foo" );
106
+
107
+ giterr_restore (& err_state );
108
+
109
+ cl_assert_equal_i (42 , giterr_last ()-> klass );
110
+ cl_assert_equal_s ("Foo: bar" , giterr_last ()-> message );
111
+ }
You can’t perform that action at this time.
0 commit comments