Commit 598ec303 by yuangli

eliminate build warnings

parent 73d25f0e
...@@ -202,8 +202,6 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) ...@@ -202,8 +202,6 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
int git_fetch_download_pack(git_remote *remote) int git_fetch_download_pack(git_remote *remote)
{ {
git_transport *t = remote->transport; git_transport *t = remote->transport;
git_indexer_progress_cb progress = NULL;
void *payload = NULL;
int error; int error;
if (!remote->need_pack) if (!remote->need_pack)
......
...@@ -220,9 +220,8 @@ int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oi ...@@ -220,9 +220,8 @@ int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oi
return 0; return 0;
} }
int git_grafts_get_oids(git_oidarray *out, git_grafts *grafts) int git_grafts_get_oids(git_array_oid_t *out, git_grafts *grafts)
{ {
git_array_oid_t oids = GIT_ARRAY_INIT;
const git_oid *oid; const git_oid *oid;
size_t i = 0; size_t i = 0;
int error; int error;
...@@ -230,13 +229,11 @@ int git_grafts_get_oids(git_oidarray *out, git_grafts *grafts) ...@@ -230,13 +229,11 @@ int git_grafts_get_oids(git_oidarray *out, git_grafts *grafts)
assert(out && grafts); assert(out && grafts);
while ((error = git_oidmap_iterate(NULL, grafts->commits, &i, &oid)) == 0) { while ((error = git_oidmap_iterate(NULL, grafts->commits, &i, &oid)) == 0) {
git_oid *cpy = git_array_alloc(oids); git_oid *cpy = git_array_alloc(*out);
GIT_ERROR_CHECK_ALLOC(cpy); GIT_ERROR_CHECK_ALLOC(cpy);
git_oid_cpy(cpy, oid); git_oid_cpy(cpy, oid);
} }
git_oidarray__from_array(out, &oids);
return 0; return 0;
} }
......
...@@ -31,7 +31,7 @@ int git_grafts_parse(git_grafts *grafts, const char *content, size_t contentlen) ...@@ -31,7 +31,7 @@ int git_grafts_parse(git_grafts *grafts, const char *content, size_t contentlen)
int git_grafts_add(git_grafts *grafts, const git_oid *oid, git_array_oid_t parents); int git_grafts_add(git_grafts *grafts, const git_oid *oid, git_array_oid_t parents);
int git_grafts_remove(git_grafts *grafts, const git_oid *oid); int git_grafts_remove(git_grafts *grafts, const git_oid *oid);
int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oid); int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oid);
int git_grafts_get_oids(git_oidarray *out, git_grafts *grafts); int git_grafts_get_oids(git_array_oid_t *out, git_grafts *grafts);
size_t git_grafts_size(git_grafts *grafts); size_t git_grafts_size(git_grafts *grafts);
#endif #endif
...@@ -3341,12 +3341,20 @@ int git_repository_state_cleanup(git_repository *repo) ...@@ -3341,12 +3341,20 @@ int git_repository_state_cleanup(git_repository *repo)
} }
int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) { int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) {
int error =0; int error = 0;
if (!repo->shallow_grafts)
load_grafts(repo); if (!repo->shallow_grafts && (error = load_grafts(repo)) < 0)
return error;
if ((error = git_grafts_refresh(repo->shallow_grafts)) < 0) {
return error;
}
git_grafts_refresh(repo->shallow_grafts); if ((error = git_grafts_get_oids(out, repo->shallow_grafts)) < 0) {
return git_grafts_get_oids(out, repo->shallow_grafts); return error;
}
return 0;
} }
int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t roots) int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t roots)
......
...@@ -675,7 +675,7 @@ int git_pkt_buffer_wants( ...@@ -675,7 +675,7 @@ int git_pkt_buffer_wants(
/* Tell the server about our shallow objects */ /* Tell the server about our shallow objects */
for (i = 0; i < git_shallowarray_count(wants->shallow_roots); i++) { for (i = 0; i < git_shallowarray_count(wants->shallow_roots); i++) {
char oid[GIT_OID_HEXSZ]; char oid[GIT_OID_HEXSZ];
git_buf shallow_buf = GIT_BUF_INIT; git_str shallow_buf = GIT_STR_INIT;
git_oid_fmt(oid, git_shallowarray_get(wants->shallow_roots, i)); git_oid_fmt(oid, git_shallowarray_get(wants->shallow_roots, i));
git_str_puts(&shallow_buf, "shallow "); git_str_puts(&shallow_buf, "shallow ");
...@@ -689,7 +689,7 @@ int git_pkt_buffer_wants( ...@@ -689,7 +689,7 @@ int git_pkt_buffer_wants(
} }
if (wants->depth > 0) { if (wants->depth > 0) {
git_buf deepen_buf = GIT_BUF_INIT; git_str deepen_buf = GIT_STR_INIT;
git_str_printf(&deepen_buf, "deepen %d\n", wants->depth); git_str_printf(&deepen_buf, "deepen %d\n", wants->depth);
git_str_printf(buf,"%04x%s", (unsigned int)git_str_len(&deepen_buf) + 4, git_str_cstr(&deepen_buf)); git_str_printf(buf,"%04x%s", (unsigned int)git_str_len(&deepen_buf) + 4, git_str_cstr(&deepen_buf));
......
...@@ -24,21 +24,21 @@ static int remote_single_branch(git_remote **out, git_repository *repo, const ch ...@@ -24,21 +24,21 @@ static int remote_single_branch(git_remote **out, git_repository *repo, const ch
void test_clone_shallow__clone_depth_one(void) void test_clone_shallow__clone_depth_one(void)
{ {
git_buf path = GIT_BUF_INIT; git_str path = GIT_STR_INIT;
git_repository *repo; git_repository *repo;
git_revwalk *walk; git_revwalk *walk;
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
git_oid oid; git_oid oid;
git_oidarray roots; roots;
size_t num_commits = 0; size_t num_commits = 0;
int error = 0; int error = 0;
clone_opts.fetch_opts.depth = 1; clone_opts.fetch_opts.depth = 1;
clone_opts.remote_cb = remote_single_branch; clone_opts.remote_cb = remote_single_branch;
git_buf_joinpath(&path, clar_sandbox_path(), "shallowclone_1"); git_str_joinpath(&path, clar_sandbox_path(), "shallowclone_1");
cl_git_pass(git_clone(&repo, "https://github.com/libgit2/TestGitRepository", git_buf_cstr(&path), &clone_opts)); 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)); cl_assert_equal_b(true, git_repository_is_shallow(repo));
...@@ -57,14 +57,14 @@ void test_clone_shallow__clone_depth_one(void) ...@@ -57,14 +57,14 @@ void test_clone_shallow__clone_depth_one(void)
cl_assert_equal_i(num_commits, 1); cl_assert_equal_i(num_commits, 1);
cl_assert_equal_i(error, GIT_ITEROVER); cl_assert_equal_i(error, GIT_ITEROVER);
git_buf_dispose(&path); git_str_dispose(&path);
git_revwalk_free(walk); git_revwalk_free(walk);
git_repository_free(repo); git_repository_free(repo);
} }
void test_clone_shallow__clone_depth_five(void) void test_clone_shallow__clone_depth_five(void)
{ {
git_buf path = GIT_BUF_INIT; git_str path = GIT_STR_INIT;
git_repository *repo; git_repository *repo;
git_revwalk *walk; git_revwalk *walk;
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
...@@ -76,9 +76,9 @@ void test_clone_shallow__clone_depth_five(void) ...@@ -76,9 +76,9 @@ void test_clone_shallow__clone_depth_five(void)
clone_opts.fetch_opts.depth = 5; clone_opts.fetch_opts.depth = 5;
clone_opts.remote_cb = remote_single_branch; clone_opts.remote_cb = remote_single_branch;
git_buf_joinpath(&path, clar_sandbox_path(), "shallowclone_5"); git_str_joinpath(&path, clar_sandbox_path(), "shallowclone_5");
cl_git_pass(git_clone(&repo, "https://github.com/libgit2/TestGitRepository", git_buf_cstr(&path), &clone_opts)); 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)); cl_assert_equal_b(true, git_repository_is_shallow(repo));
...@@ -99,7 +99,7 @@ void test_clone_shallow__clone_depth_five(void) ...@@ -99,7 +99,7 @@ void test_clone_shallow__clone_depth_five(void)
cl_assert_equal_i(num_commits, 13); cl_assert_equal_i(num_commits, 13);
cl_assert_equal_i(error, GIT_ITEROVER); cl_assert_equal_i(error, GIT_ITEROVER);
git_buf_dispose(&path); git_str_dispose(&path);
git_revwalk_free(walk); git_revwalk_free(walk);
git_repository_free(repo); git_repository_free(repo);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment