Commit Diff


commit - 314a6357a2a91eaa8a8f0f04dcfa5b26a59c4fb2
commit + c191ed664f6c437ebc3e0c859c53e48b445401f1
blob - c2d7153928e0760cd9d259ef3aa6621137d0d05f
blob + 240d979aea718cc2ca5e8b74db07aff36553667a
--- lib/reference.c
+++ lib/reference.c
@@ -290,10 +290,19 @@ const struct got_error *
 got_ref_alloc(struct got_reference **ref, const char *name,
     struct got_object_id *id)
 {
-	if (!is_valid_ref_name(name))
-		return got_error(GOT_ERR_BAD_REF_NAME);
+	const struct got_error *err;
+	char *absname = NULL;
 
-	return alloc_ref(ref, name, id, 0);
+	if (!is_valid_ref_name(name)) {
+		if (strchr(name, '/') != NULL)
+			return got_error(GOT_ERR_BAD_REF_NAME);
+		if (asprintf(&absname, "refs/heads/%s", name) == -1)
+			return got_error_from_errno("asprintf");
+	}
+
+	err = alloc_ref(ref, absname ? absname : name, id, 0);
+	free(absname);
+	return err;
 }
 
 static const struct got_error *