It's possible that users make a typo in the branch name. Stop and let users recheck. Falling back to remote's HEAD is not documented any way. Except when using remote helper, the pack has not been transferred at this stage yet so we don't waste much bandwidth. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/clone.c | 13 +++++-------- t/t5706-clone-branch.sh | 8 ++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index 89ba6f0..6a2886a 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -474,8 +474,7 @@ static void update_head(const struct ref *our, const struct ref *remote, } else if (remote) { /* * We know remote HEAD points to a non-branch, or - * HEAD points to a branch but we don't know which one, or - * we asked for a specific branch but it did not exist. + * HEAD points to a branch but we don't know which one. * Detach HEAD in all these cases. */ update_ref(msg, "HEAD", remote->old_sha1, @@ -771,12 +770,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) find_ref_by_name(mapped_refs, head.buf); strbuf_release(&head); - if (!our_head_points_at) { - warning(_("Remote branch %s not found in " - "upstream %s, using HEAD instead"), - option_branch, option_origin); - our_head_points_at = remote_head_points_at; - } + if (!our_head_points_at) + die(_("Remote branch %s not found in " + "upstream %s, using HEAD instead"), + option_branch, option_origin); } else our_head_points_at = remote_head_points_at; diff --git a/t/t5706-clone-branch.sh b/t/t5706-clone-branch.sh index f3f9a76..56be67e 100755 --- a/t/t5706-clone-branch.sh +++ b/t/t5706-clone-branch.sh @@ -57,12 +57,8 @@ test_expect_success 'clone -b does not munge remotes/origin/HEAD' ' ) ' -test_expect_success 'clone -b with bogus branch chooses HEAD' ' - git clone -b bogus parent clone-bogus && - (cd clone-bogus && - check_HEAD master && - check_file one - ) +test_expect_success 'clone -b with bogus branch' ' + test_must_fail git clone -b bogus parent clone-bogus ' test_done -- 1.7.3.1.256.g2539c.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html