Commit Diff


commit - 56e0773df7e12fc69c1f6f9d171c93fd78a13d0e
commit + e560b7e0e2efbbf43870b8d112d4279ca7df5535
blob - 11985c8258e8f18f46f3706d26b1ed1c1ae06dec
blob + ef77dfcd0650f8cb98621ee08d6b464d4f080d0d
--- got/got.c
+++ got/got.c
@@ -653,6 +653,14 @@ cmd_import(int argc, char *argv[])
 	error = get_author(&author, repo);
 	if (error)
 		return error;
+
+	/*
+	 * Don't let the user create a branch named '-'.
+	 * While technically a valid reference name, this case is usually
+	 * an unintended typo.
+	 */
+	if (branch_name[0] == '-' && branch_name[1] == '\0')
+		return got_error_path(branch_name, GOT_ERR_BAD_REF_NAME);
 
 	if (asprintf(&refname, "refs/heads/%s", branch_name) == -1) {
 		error = got_error_from_errno("asprintf");