summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/clone.c4
-rwxr-xr-xt/t5706-clone-branch.sh8
2 files changed, 11 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 430307b..21ad9f9 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -946,6 +946,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
our_head_points_at = remote_head_points_at;
}
else {
+ if (option_branch)
+ die(_("Remote branch %s not found in upstream %s"),
+ option_branch, option_origin);
+
warning(_("You appear to have cloned an empty repository."));
mapped_refs = NULL;
our_head_points_at = NULL;
diff --git a/t/t5706-clone-branch.sh b/t/t5706-clone-branch.sh
index 56be67e..6e7a7be 100755
--- a/t/t5706-clone-branch.sh
+++ b/t/t5706-clone-branch.sh
@@ -20,7 +20,9 @@ test_expect_success 'setup' '
echo one >file && git add file && git commit -m one &&
git checkout -b two &&
echo two >file && git add file && git commit -m two &&
- git checkout master)
+ git checkout master) &&
+ mkdir empty &&
+ (cd empty && git init)
'
test_expect_success 'vanilla clone chooses HEAD' '
@@ -61,4 +63,8 @@ test_expect_success 'clone -b with bogus branch' '
test_must_fail git clone -b bogus parent clone-bogus
'
+test_expect_success 'clone -b not allowed with empty repos' '
+ test_must_fail git clone -b branch empty clone-branch-empty
+'
+
test_done