Skip to content

Commit 9768648

Browse files
committed
Merge branch 'maint'
* maint: git-prune-packed.txt: fix reference to GIT_OBJECT_DIRECTORY clone --branch: refuse to clone if upstream repo is empty
2 parents 6fb0216 + 3991e91 commit 9768648

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Documentation/git-prune-packed.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SYNOPSIS
1414

1515
DESCRIPTION
1616
-----------
17-
This program searches the `$GIT_OBJECT_DIR` for all objects that currently
17+
This program searches the `$GIT_OBJECT_DIRECTORY` for all objects that currently
1818
exist in a pack file as well as the independent object directories.
1919

2020
All such extra objects are removed.

builtin/clone.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
945945
our_head_points_at = remote_head_points_at;
946946
}
947947
else {
948+
if (option_branch)
949+
die(_("Remote branch %s not found in upstream %s"),
950+
option_branch, option_origin);
951+
948952
warning(_("You appear to have cloned an empty repository."));
949953
mapped_refs = NULL;
950954
our_head_points_at = NULL;

t/t5706-clone-branch.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ test_expect_success 'setup' '
2020
echo one >file && git add file && git commit -m one &&
2121
git checkout -b two &&
2222
echo two >file && git add file && git commit -m two &&
23-
git checkout master)
23+
git checkout master) &&
24+
mkdir empty &&
25+
(cd empty && git init)
2426
'
2527

2628
test_expect_success 'vanilla clone chooses HEAD' '
@@ -61,4 +63,8 @@ test_expect_success 'clone -b with bogus branch' '
6163
test_must_fail git clone -b bogus parent clone-bogus
6264
'
6365

66+
test_expect_success 'clone -b not allowed with empty repos' '
67+
test_must_fail git clone -b branch empty clone-branch-empty
68+
'
69+
6470
test_done

0 commit comments

Comments
 (0)