fix path construction with empty subdir in open_ref()
diff --git a/lib/reference.c b/lib/reference.c
index 18fca1a..3d68a01 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -322,10 +322,12 @@ open_ref(struct got_reference **ref, const char *path_refs, const char *subdir,
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;
}