Commit 24b5452abe8f7dca6abf6cc0199101c2b950d141

Stefan Sperling 2019-10-09T06:50:28

show bad reference names in error messages to make such errors more clear

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);
 }