commit - 23794ad3ee282e996bc24eeb04eb1364a2140632
commit + 65ad15fa440d89e976ce1bd3bd02d5440e86d5d3
blob - 03f07f0502bcb5b56cfa17c892cce593e261e917
blob + ee9093dbcc252384d25fdce40f0631a837c3cf52
--- lib/repository.c
+++ lib/repository.c
return err;
}
- err = got_repo_match_object_id_prefix(id, id_str, obj_type, repo);
- if (err) {
- if (err->code != GOT_ERR_BAD_OBJ_ID_STR)
- return err;
- err = got_ref_open(&ref, repo, id_str, 0);
- if (err != NULL)
+ err = got_ref_open(&ref, repo, id_str, 0);
+ if (err == NULL) {
+ err = got_ref_resolve(id, repo, ref);
+ if (err)
goto done;
if (label) {
*label = strdup(got_ref_get_name(ref));
goto done;
}
}
- err = got_ref_resolve(id, repo, ref);
- } else if (label) {
- err = got_object_id_str(label, *id);
- if (*label == NULL) {
- err = got_error_from_errno("strdup");
+ } else {
+ if (err->code != GOT_ERR_NOT_REF &&
+ err->code != GOT_ERR_BAD_REF_NAME)
goto done;
+ err = got_repo_match_object_id_prefix(id, id_str,
+ obj_type, repo);
+ if (err) {
+ if (err->code == GOT_ERR_BAD_OBJ_ID_STR)
+ err = got_error_not_ref(id_str);
+ goto done;
}
+ if (label) {
+ err = got_object_id_str(label, *id);
+ if (*label == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
+ }
+ }
}
done:
if (ref)