]> git.proxmox.com Git - libgit2.git/commitdiff
clone: fix detection of remote HEAD
authornulltoken <emeric.fermas@gmail.com>
Mon, 15 Oct 2012 05:06:22 +0000 (07:06 +0200)
committernulltoken <emeric.fermas@gmail.com>
Mon, 15 Oct 2012 18:40:37 +0000 (20:40 +0200)
src/clone.c
tests-clar/clone/network.c

index 71931664c0a34afc39f70448aac944abf790d2dd..82042a46a198015a28e8e6d632a966b95d2a883a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "common.h"
 #include "remote.h"
+#include "pkt.h"
 #include "fileops.h"
 #include "refs.h"
 #include "path.h"
@@ -174,6 +175,7 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
 {
        int retcode = -1;
        git_remote_head *remote_head;
+       git_pkt_ref *pkt;
        struct head_info head_info;
        git_buf remote_master_name = GIT_BUF_INIT;
 
@@ -187,7 +189,8 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
        }
 
        /* Get the remote's HEAD. This is always the first ref in remote->refs. */
-       remote_head = remote->refs.contents[0];
+       pkt = remote->transport->refs.contents[0];
+       remote_head = &pkt->head;
        git_oid_cpy(&head_info.remote_head_oid, &remote_head->oid);
        git_buf_init(&head_info.branchname, 16);
        head_info.repo = repo;
index af1eca1be55a6603c5df7bf414787f3b3fb9e3fc..30c4a47cc7ca58a7152331049ac84824a20caf95 100644 (file)
@@ -89,6 +89,7 @@ void test_clone_network__can_checkout_a_cloned_repo(void)
 {
        git_checkout_opts opts;
        git_buf path = GIT_BUF_INIT;
+       git_reference *head;
 
        memset(&opts, 0, sizeof(opts));
        opts.checkout_strategy = GIT_CHECKOUT_CREATE_MISSING;
@@ -99,4 +100,8 @@ void test_clone_network__can_checkout_a_cloned_repo(void)
 
        cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "master.txt"));
        cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&path)));
+
+       cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
+       cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head));
+       cl_assert_equal_s("refs/heads/master", git_reference_target(head));
 }