show bad reference names in error messages to make such errors more clear
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
diff --git a/got/got.c b/got/got.c
index 0c7661c..2f092a4 100644
--- a/got/got.c
+++ b/got/got.c
@@ -3035,7 +3035,7 @@ add_ref(struct got_repository *repo, const char *refname, const char *target)
* an unintended typo.
*/
if (refname[0] == '-' && refname[1] == '\0')
- return got_error(GOT_ERR_BAD_REF_NAME);
+ return got_error_path(refname, GOT_ERR_BAD_REF_NAME);
err = got_repo_match_object_id_prefix(&id, target, GOT_OBJ_TYPE_ANY,
repo);
@@ -3078,7 +3078,7 @@ add_symref(struct got_repository *repo, const char *refname, const char *target)
* an unintended typo.
*/
if (refname[0] == '-' && refname[1] == '\0')
- return got_error(GOT_ERR_BAD_REF_NAME);
+ return got_error_path(refname, GOT_ERR_BAD_REF_NAME);
err = got_ref_open(&target_ref, repo, target, 0);
if (err)
@@ -3370,7 +3370,7 @@ add_branch(struct got_repository *repo, const char *branch_name,
* an unintended typo.
*/
if (branch_name[0] == '-' && branch_name[1] == '\0')
- return got_error(GOT_ERR_BAD_REF_NAME);
+ return got_error_path(branch_name, GOT_ERR_BAD_REF_NAME);
err = match_object_id(&id, &label, base_branch,
GOT_OBJ_TYPE_COMMIT, 1, repo);
@@ -3791,7 +3791,7 @@ add_tag(struct got_repository *repo, const char *tag_name,
* an unintended typo.
*/
if (tag_name[0] == '-' && tag_name[1] == '\0')
- return got_error(GOT_ERR_BAD_REF_NAME);
+ return got_error_path(tag_name, GOT_ERR_BAD_REF_NAME);
err = get_author(&tagger, repo);
if (err)
diff --git a/lib/reference.c b/lib/reference.c
index 54de181..162f19c 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -294,7 +294,7 @@ 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);
+ return got_error_path(name, GOT_ERR_BAD_REF_NAME);
return alloc_ref(ref, name, id, 0);
}
@@ -304,7 +304,7 @@ got_ref_alloc_symref(struct got_reference **ref, const char *name,
struct got_reference *target_ref)
{
if (!is_valid_ref_name(name))
- return got_error(GOT_ERR_BAD_REF_NAME);
+ return got_error_path(name, GOT_ERR_BAD_REF_NAME);
return alloc_symref(ref, name, got_ref_get_name(target_ref), 0);
}