Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/libgit2/transports/smart_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ static int store_common(transport_smart *t)
if ((error = recv_pkt(&pkt, NULL, t)) < 0)
return error;

if (t->rpc && (pkt->type == GIT_PKT_SHALLOW ||
pkt->type == GIT_PKT_UNSHALLOW ||
pkt->type == GIT_PKT_FLUSH)) {
git__free(pkt);
continue;
}

if (pkt->type != GIT_PKT_ACK) {
git__free(pkt);
return 0;
Expand Down
46 changes: 46 additions & 0 deletions tests/libgit2/online/shallow.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,52 @@ void test_online_shallow__unshallow(void)
git_repository_free(repo);
}

void test_online_shallow__deepen_full(void)
{
git_str path = GIT_STR_INIT;
git_repository *repo;
git_revwalk *walk;
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
git_remote *origin = NULL;
git_oid oid;
git_oid *roots;
size_t roots_len;
size_t num_commits = 0;
int error = 0;

clone_opts.fetch_opts.depth = 7;
clone_opts.remote_cb = remote_single_branch;

git_str_joinpath(&path, clar_sandbox_path(), "deepen_full");
cl_git_pass(git_clone(&repo, "https://github.com/libgit2/TestGitRepository", git_str_cstr(&path), &clone_opts));
cl_assert_equal_b(true, git_repository_is_shallow(repo));

fetch_opts.depth = 8;
cl_git_pass(git_remote_lookup(&origin, repo, "origin"));
cl_git_pass(git_remote_fetch(origin, NULL, &fetch_opts, NULL));
cl_assert_equal_b(false, git_repository_is_shallow(repo));

cl_git_pass(git_repository__shallow_roots(&roots, &roots_len, repo));
cl_assert_equal_i(0, roots_len);

git_revwalk_new(&walk, repo);
git_revwalk_push_head(walk);

while ((error = git_revwalk_next(&oid, walk)) == GIT_OK) {
num_commits++;
}

cl_assert_equal_i(num_commits, 21);
cl_assert_equal_i(error, GIT_ITEROVER);

git__free(roots);
git_remote_free(origin);
git_str_dispose(&path);
git_revwalk_free(walk);
git_repository_free(repo);
}

void test_online_shallow__deepen_six(void)
{
git_str path = GIT_STR_INIT;
Expand Down
Loading