diff options
author | yuangli <yuangli@mathworks.com> | 2022-07-29 15:04:17 +0100 |
---|---|---|
committer | yuangli <yuangli@mathworks.com> | 2022-07-29 15:04:17 +0100 |
commit | 598ec303c6862f581c22c49228d543442e30257a (patch) | |
tree | bee246cfd37ecde10b6329a9d1c7b6be3675f351 | |
parent | 73d25f0e7b026d7b744e249d922f248376bcce5d (diff) | |
download | libgit2-598ec303c6862f581c22c49228d543442e30257a.tar.gz |
eliminate build warnings
-rw-r--r-- | src/libgit2/fetch.c | 2 | ||||
-rw-r--r-- | src/libgit2/grafts.c | 7 | ||||
-rw-r--r-- | src/libgit2/grafts.h | 2 | ||||
-rw-r--r-- | src/libgit2/repository.c | 18 | ||||
-rw-r--r-- | src/libgit2/transports/smart_pkt.c | 4 | ||||
-rw-r--r-- | tests/libgit2/clone/shallow.c (renamed from tests/clone/shallow.c) | 18 |
6 files changed, 27 insertions, 24 deletions
diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c index e4a8f0382..b90ce2ee8 100644 --- a/src/libgit2/fetch.c +++ b/src/libgit2/fetch.c @@ -202,8 +202,6 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts) int git_fetch_download_pack(git_remote *remote) { git_transport *t = remote->transport; - git_indexer_progress_cb progress = NULL; - void *payload = NULL; int error; if (!remote->need_pack) diff --git a/src/libgit2/grafts.c b/src/libgit2/grafts.c index 82be2a680..f1054fa36 100644 --- a/src/libgit2/grafts.c +++ b/src/libgit2/grafts.c @@ -220,9 +220,8 @@ int git_grafts_get(git_commit_graft **out, git_grafts *grafts, const git_oid *oi 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; size_t i = 0; int error; @@ -230,13 +229,11 @@ int git_grafts_get_oids(git_oidarray *out, git_grafts *grafts) assert(out && grafts); 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_oid_cpy(cpy, oid); } - git_oidarray__from_array(out, &oids); - return 0; } diff --git a/src/libgit2/grafts.h b/src/libgit2/grafts.h index fd9ef6736..4139438bb 100644 --- a/src/libgit2/grafts.h +++ b/src/libgit2/grafts.h @@ -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_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_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); #endif diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c index d9bc537fe..bc2aba324 100644 --- a/src/libgit2/repository.c +++ b/src/libgit2/repository.c @@ -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 error =0; - if (!repo->shallow_grafts) - load_grafts(repo); + int error = 0; + + 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); - return git_grafts_get_oids(out, repo->shallow_grafts); + if ((error = git_grafts_get_oids(out, repo->shallow_grafts)) < 0) { + return error; + } + + return 0; } int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t roots) diff --git a/src/libgit2/transports/smart_pkt.c b/src/libgit2/transports/smart_pkt.c index f9fde00f1..951356c29 100644 --- a/src/libgit2/transports/smart_pkt.c +++ b/src/libgit2/transports/smart_pkt.c @@ -675,7 +675,7 @@ int git_pkt_buffer_wants( /* Tell the server about our shallow objects */ for (i = 0; i < git_shallowarray_count(wants->shallow_roots); i++) { 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_str_puts(&shallow_buf, "shallow "); @@ -689,7 +689,7 @@ int git_pkt_buffer_wants( } 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(buf,"%04x%s", (unsigned int)git_str_len(&deepen_buf) + 4, git_str_cstr(&deepen_buf)); diff --git a/tests/clone/shallow.c b/tests/libgit2/clone/shallow.c index 01852dfed..2cd3d6cac 100644 --- a/tests/clone/shallow.c +++ b/tests/libgit2/clone/shallow.c @@ -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) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; git_repository *repo; git_revwalk *walk; git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; git_oid oid; - git_oidarray roots; + roots; size_t num_commits = 0; int error = 0; clone_opts.fetch_opts.depth = 1; 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)); @@ -57,14 +57,14 @@ void test_clone_shallow__clone_depth_one(void) cl_assert_equal_i(num_commits, 1); cl_assert_equal_i(error, GIT_ITEROVER); - git_buf_dispose(&path); + git_str_dispose(&path); git_revwalk_free(walk); git_repository_free(repo); } void test_clone_shallow__clone_depth_five(void) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; git_repository *repo; git_revwalk *walk; git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; @@ -76,9 +76,9 @@ void test_clone_shallow__clone_depth_five(void) clone_opts.fetch_opts.depth = 5; 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)); @@ -99,7 +99,7 @@ void test_clone_shallow__clone_depth_five(void) cl_assert_equal_i(num_commits, 13); cl_assert_equal_i(error, GIT_ITEROVER); - git_buf_dispose(&path); + git_str_dispose(&path); git_revwalk_free(walk); git_repository_free(repo); } |