commit - 6e472abb219118bbb338c67086cf830c57de2c85
commit + 0f148cb77a71142fd9317f1a705b5f03903bb35b
blob - 1ddd447e91d264e0d48cdf1ce2c7dd79af85be0d
blob + e572d687ec4e83e49ea1d418f2c5a61f9f67cc3e
--- lib/reference.c
+++ lib/reference.c
got_ref_alloc(struct got_reference **ref, const char *name,
struct got_object_id *id)
{
- const struct got_error *err;
- char *absname = NULL;
+ if (!is_valid_ref_name(name))
+ return got_error(GOT_ERR_BAD_REF_NAME);
- 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;
+ return alloc_ref(ref, name, id, 0);
}
static const struct got_error *