Skip to content

Commit bb0dab5

Browse files
keszybzgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9884e67 commit bb0dab5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

sha1_name.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,11 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
862862
*/
863863
if (!upstream)
864864
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);
866868
return error("No upstream branch found for '%s'", upstream->name);
869+
}
867870
free(cp);
868871
cp = shorten_unambiguous_ref(upstream->merge[0]->dst, 0);
869872
strbuf_reset(buf);

t/t1507-rev-parse-upstream.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ test_expect_success '@{u} error message when no upstream' '
143143

144144
test_expect_success 'branch@{u} error message with misspelt branch' '
145145
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}
147147
fatal: Needed a single revision
148148
EOF
149149
error_message no-such-branch@{u} 2>actual &&

0 commit comments

Comments
 (0)