Skip to content

Commit

Permalink
Provide better message for barnhc_wiht_tpyo@{u}
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zbigniew Jędrzejewski-Szmek authored and Junio C Hamano committed Apr 15, 2012
1 parent 9884e67 commit bb0dab5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion t/t1507-rev-parse-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit bb0dab5

Please sign in to comment.