summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9a01387)
raw | patch | inline | side by side (parent: 9a01387)
author | Sverre Rabbelier <srabbelier@gmail.com> | |
Fri, 23 Jan 2009 00:07:32 +0000 (01:07 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 23 Jan 2009 08:19:49 +0000 (00:19 -0800) |
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>
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>
builtin-clone.c | patch | blob | history | |
t/t5701-clone-local.sh | patch | blob | history |
diff --git a/builtin-clone.c b/builtin-clone.c
index f7e5a7b0a060c15432162fefc2e0ff89baf451b0..1e9c9aa8446370070d56126ad851701c4c418de0 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
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 */
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 8dfaaa456e115e85e36c438bb998d8053534104e..fbd9bfa57350e42d21ecfd3e1ccce13cc26b67dc 100755 (executable)
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
test ! -e .git/refs/heads/master
'
+test_expect_success 'clone empty repository' '
+ cd "$D" &&
+ mkdir empty &&
+ (cd empty && git init) &&
+ git clone empty empty-clone &&
+ test_tick &&
+ (cd empty-clone
+ echo "content" >> foo &&
+ git add foo &&
+ git commit -m "Initial commit" &&
+ git push origin master &&
+ expected=$(git rev-parse master) &&
+ actual=$(git --git-dir=../empty/.git rev-parse master) &&
+ test $actual = $expected)
+'
+
test_done