diff options
author | yuangli <yuangli@mathworks.com> | 2022-07-19 13:54:33 +0100 |
---|---|---|
committer | yuangli <yuangli@mathworks.com> | 2022-07-19 13:54:33 +0100 |
commit | c652f3d13372398fc86c72a7b05c90002d1cc763 (patch) | |
tree | 7ec8f77d2f12c2e177459107ea71060b198cd033 /tests | |
parent | 3e64f150ccfae3b7828a293fdd78daaf61e76ccf (diff) | |
download | libgit2-c652f3d13372398fc86c72a7b05c90002d1cc763.tar.gz |
enable cloning of shallow repo
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clone/shallow.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/clone/shallow.c b/tests/clone/shallow.c index b41e28d66..b3e8f1617 100644 --- a/tests/clone/shallow.c +++ b/tests/clone/shallow.c @@ -15,6 +15,15 @@ void test_clone_shallow__cleanup(void) #define CLONE_DEPTH 5 +static int remote_single_branch(git_remote **out, git_repository *repo, const char *name, const char *url, void *payload) +{ + GIT_UNUSED(payload); + + cl_git_pass(git_remote_create_with_fetchspec(out, repo, name, url, "+refs/heads/master:refs/remotes/origin/master")); + + return 0; +} + void test_clone_shallow__clone_depth(void) { git_buf path = GIT_BUF_INIT; @@ -27,6 +36,7 @@ void test_clone_shallow__clone_depth(void) int error = 0; clone_opts.fetch_opts.depth = CLONE_DEPTH; + clone_opts.remote_cb = remote_single_branch; git_buf_joinpath(&path, clar_sandbox_path(), "shallowclone"); @@ -35,21 +45,18 @@ void test_clone_shallow__clone_depth(void) cl_assert_equal_b(true, git_repository_is_shallow(repo)); cl_git_pass(git_repository_shallow_roots(&roots, repo)); - cl_assert_equal_i(1, roots.count); - cl_assert_equal_s("83834a7afdaa1a1260568567f6ad90020389f664", git_oid_tostr_s(&roots.ids[0])); + cl_assert_equal_i(3, roots.count); + cl_assert_equal_s("c070ad8c08840c8116da865b2d65593a6bb9cd2a", git_oid_tostr_s(&roots.ids[0])); + cl_assert_equal_s("0966a434eb1a025db6b71485ab63a3bfbea520b6", git_oid_tostr_s(&roots.ids[1])); + cl_assert_equal_s("83834a7afdaa1a1260568567f6ad90020389f664", git_oid_tostr_s(&roots.ids[2])); git_revwalk_new(&walk, repo); git_revwalk_push_head(walk); while ((error = git_revwalk_next(&oid, walk)) == GIT_OK) { - //if (depth + 1 > CLONE_DEPTH) - //cl_fail("expected depth mismatch"); - char str[GIT_OID_HEXSZ +1]; - git_oid_fmt(str, &oid); - printf(str); - printf("\n"); - depth++; + if (depth + 1 > CLONE_DEPTH) + cl_fail("expected depth mismatch"); } cl_git_pass(error); |