summaryrefslogtreecommitdiff
path: root/builtin-clone.c
diff options
context:
space:
mode:
authorSverre Rabbelier <srabbelier@gmail.com>2009-01-23 01:07:32 +0100
committerJunio C Hamano <gitster@pobox.com>2009-01-23 00:19:49 -0800
commit86ac751859033741a120e9e4a91133d075d9d898 (patch)
treea417cdbc68de4f23cb8ae6ebd0269108d771f580 /builtin-clone.c
parent9a01387b9714452ebcae431705a288e1a7e099c3 (diff)
downloadgit-86ac751859033741a120e9e4a91133d075d9d898.tar.gz
Allow cloning an empty repository
Cloning an empty repository manually (that is, doing 'git init' and then doing all configuration by hand) can be a lot of work. Save the user this work by allowing the cloning of empty repositories. Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-clone.c')
-rw-r--r--builtin-clone.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/builtin-clone.c b/builtin-clone.c
index f7e5a7b0a0..1e9c9aa844 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -522,14 +522,23 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
option_upload_pack);
refs = transport_get_remote_refs(transport);
- transport_fetch_refs(transport, refs);
+ if(refs)
+ transport_fetch_refs(transport, refs);
}
- clear_extra_refs();
+ if (refs) {
+ clear_extra_refs();
- mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);
+ mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);
- head_points_at = locate_head(refs, mapped_refs, &remote_head);
+ head_points_at = locate_head(refs, mapped_refs, &remote_head);
+ }
+ else {
+ warning("You appear to have cloned an empty repository.");
+ head_points_at = NULL;
+ remote_head = NULL;
+ option_no_checkout = 1;
+ }
if (head_points_at) {
/* Local default branch link */