*/
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);
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 &&