Provide better message for barnhc_wiht_tpyo@{u}

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@in.waw.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Zbigniew Jędrzejewski-Szmek committed Apr 14, 2012 at 09:54 UTC bb0dab5d617219d7efe8815cadef6d98c4bc3df8
2 files changed +5 -2
sha1_name.c
+4 -1
@@ -862,8 +862,11 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
862 */
863 if (!upstream)
864 return error("HEAD does not point to a branch");
865 - if (!upstream->merge || !upstream->merge[0]->dst)
865 + if (!upstream->merge || !upstream->merge[0]->dst) {
866 + if (!ref_exists(upstream->refname))
867 + return error("No such branch: '%s'", cp);
868 return error("No upstream branch found for '%s'", upstream->name);
869 + }
870 free(cp);
871 cp = shorten_unambiguous_ref(upstream->merge[0]->dst, 0);
872 strbuf_reset(buf);
t/t1507-rev-parse-upstream.sh
+1 -1
@@ -143,7 +143,7 @@ test_expect_success '@{u} error message when no upstream' '
143
144 test_expect_success 'branch@{u} error message with misspelt branch' '
145 cat >expect <<-EOF &&
146 - error: No upstream branch found for ${sq}no-such-branch${sq}
146 + error: No such branch: ${sq}no-such-branch${sq}
147 fatal: Needed a single revision
148 EOF
149 error_message no-such-branch@{u} 2>actual &&