Commit bd376bb34a8202c56697e2564e95408b1fb3f6d9

Stefan Sperling 2019-02-01T21:13:57

handle absolute refs being passed to open_packed_ref()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/reference.c b/lib/reference.c
index 5730c82..c93b831 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -202,7 +202,11 @@ open_packed_ref(struct got_reference **ref, FILE *f, const char *subdir,
 	size_t len;
 	const char delim[3] = {'\0', '\0', '\0'};
 
-	if (asprintf(&abs_refname, "refs/%s/%s", subdir, refname) == -1)
+	if (strncmp(refname, "refs/", 5) == 0) {
+		abs_refname = strdup(refname);
+		if (abs_refname == NULL)
+			return got_error_from_errno();
+	} else if (asprintf(&abs_refname, "refs/%s/%s", subdir, refname) == -1)
 		return got_error_from_errno();
 
 	do {