[PATCH v2 3/5] Provide better message for barnhc_wiht_tpyo@{u}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of just saying that no upstream exists for such branch,
which is true but not very helpful, check that there's no
refs/heads/barnhc_wiht_tpyo and tell it to the user.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@xxxxxxxxx>
---
 sha1_name.c                   |    5 ++++-
 t/t1507-rev-parse-upstream.sh |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index c2fe1aa..e2d576a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -862,8 +862,11 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
 	 */
 	if (!upstream)
 		return error("HEAD does not point to a branch");
-	if (!upstream->merge || !upstream->merge[0]->dst)
+	if (!upstream->merge || !upstream->merge[0]->dst) {
+		if (!ref_exists(upstream->refname))
+			return error("No such branch: '%s'", cp);
 		return error("No upstream branch found for '%s'", upstream->name);
+	}
 	free(cp);
 	cp = shorten_unambiguous_ref(upstream->merge[0]->dst, 0);
 	strbuf_reset(buf);
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index 2f4f0d1..2b8ba31 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -143,7 +143,7 @@ test_expect_success '@{u} error message when no upstream' '
 
 test_expect_success 'branch@{u} error message with misspelt branch' '
 	cat >expect <<-EOF &&
-	error: No upstream branch found for ${sq}no-such-branch${sq}
+	error: No such branch: ${sq}no-such-branch${sq}
 	fatal: Needed a single revision
 	EOF
 	error_message no-such-branch@{u} 2>actual &&
-- 
1.7.10.226.gfe575

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]