Provide better message for barnhc_wiht_tpyo@{u}
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 14 Apr 2012 07:54:33 +0000 (09:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 Apr 2012 21:25:19 +0000 (14:25 -0700)
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>
sha1_name.c
t/t1507-rev-parse-upstream.sh
index c2fe1aae523cd077000a333febcbb1ce4be27c77..e2d576ad7b86f967e4986dd7792e8d6e18a80350 100644 (file)
@@ -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);
index 2f4f0d1c02953756d58ec7ca996fd8f23ad0b6f7..2b8ba314a99d70fa2c69a8bc16692699319e7d5f 100755 (executable)
@@ -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 &&