Skip to content

Commit ef4cffd

Browse files
peffgitster
authored andcommitted
git-clone: print an error message when trying to clone empty repo
Previously, cloning an empty repository looked like this: $ (mkdir parent && cd parent && git --bare init) $ git-clone parent child Initialized empty Git repository in /home/peff/clone/child/.git/ $ cd child -bash: cd: child: No such file or directory $ echo 'wtf?' | mail git@vger.kernel.org Now we at least report that the clone was not successful. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 18ff365 commit ef4cffd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

git-clone.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ yes)
297297
find objects -type f -print | sed -e 1q)
298298
# objects directory should not be empty because
299299
# we are cloning!
300-
test -f "$repo/$sample_file" || exit
300+
test -f "$repo/$sample_file" ||
301+
die "fatal: cannot clone empty repository"
301302
if ln "$repo/$sample_file" "$GIT_DIR/objects/sample" 2>/dev/null
302303
then
303304
rm -f "$GIT_DIR/objects/sample"

0 commit comments

Comments
 (0)