]>
git.proxmox.com Git - libgit2.git/blob - tests/libgit2/fetch/local.c
20bd7adf47999941399cc949ad2dcf67551f49de
1 #include "clar_libgit2.h"
4 static git_repository
*repo
;
6 void test_fetch_local__initialize(void)
8 cl_git_pass(git_repository_init(&repo
, "./fetch", 0));
11 void test_fetch_local__cleanup(void)
13 git_repository_free(repo
);
16 cl_fixture_cleanup("./fetch");
19 void test_fetch_local__defaults(void)
25 cl_git_pass(git_remote_create(&remote
, repo
, "test",
26 cl_fixture("testrepo.git")));
27 cl_git_pass(git_remote_fetch(remote
, NULL
, NULL
, NULL
));
29 git_oid_fromstr(&expected_id
, "258f0e2a959a364e40ed6603d5d44fbb24765b10");
31 cl_git_pass(git_revparse_single(&obj
, repo
, "refs/remotes/test/haacked"));
32 cl_assert_equal_oid(&expected_id
, git_object_id(obj
));
35 git_remote_free(remote
);
38 void test_fetch_local__reachable_commit(void)
41 git_strarray refspecs
;
44 git_str fetchhead
= GIT_STR_INIT
;
45 char *refspec
= "+5b5b025afb0b4c913b4c338a42934a3863bf3644:refs/success";
47 refspecs
.strings
= &refspec
;
50 git_oid_fromstr(&expected_id
, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
52 cl_git_pass(git_remote_create(&remote
, repo
, "test",
53 cl_fixture("testrepo.git")));
54 cl_git_pass(git_remote_fetch(remote
, &refspecs
, NULL
, NULL
));
56 cl_git_pass(git_revparse_single(&obj
, repo
, "refs/success"));
57 cl_assert_equal_oid(&expected_id
, git_object_id(obj
));
59 cl_git_pass(git_futils_readbuffer(&fetchhead
, "./fetch/.git/FETCH_HEAD"));
60 cl_assert_equal_strn(fetchhead
.ptr
,
61 "5b5b025afb0b4c913b4c338a42934a3863bf3644\t\t'5b5b025afb0b4c913b4c338a42934a3863bf3644' of ",
62 strlen("5b5b025afb0b4c913b4c338a42934a3863bf3644\t\t'5b5b025afb0b4c913b4c338a42934a3863bf3644' of "));
64 git_str_dispose(&fetchhead
);
66 git_remote_free(remote
);