Commit Diff


commit - 9e672c7443bebadbd8806c9a4366543f852eb372
commit + 58908ed09b094dbcf8c976c0a726b76f0ff2cae5
blob - 18fca1ae9be06a6b5840128d6f6bc4454d04ab49
blob + 3d68a01374b6f19b2d40248fa60d15e894896183
--- lib/reference.c
+++ lib/reference.c
@@ -322,10 +322,12 @@ open_ref(struct got_reference **ref, const char *path_
 			return got_error_from_errno();
 		absname = (char *)name;
 	} else {
-		if (asprintf(&path, "%s/%s/%s", path_refs, subdir, name) == -1)
+		if (asprintf(&path, "%s/%s%s%s", path_refs, subdir,
+		    subdir[0] ? "/" : "", name) == -1)
 			return got_error_from_errno();
 
-		if (asprintf(&absname, "refs/%s/%s", subdir, name) == -1) {
+		if (asprintf(&absname, "refs/%s%s%s",
+		    subdir, subdir[0] ? "/" : "", name) == -1) {
 			err = got_error_from_errno();
 			goto done;
 		}