Commit e265eb2f51a13d0a1172330075bdd1c69aed5e8c

Edward Thomson 2021-08-24T13:58:24

tests: show errors when libgit2_init fails

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/tests/main.c b/tests/main.c
index 207a6a8..56751c2 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -18,7 +18,9 @@ int main(int argc, char *argv[])
 
 	res = git_libgit2_init();
 	if (res < 0) {
-		fprintf(stderr, "failed to init libgit2");
+		const git_error *err = git_error_last();
+		const char *msg = err ? err->message : "unknown failure";
+		fprintf(stderr, "failed to init libgit2: %s\n", msg);
 		return res;
 	}