summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuangli <yuangli@mathworks.com>2022-07-29 13:53:29 +0100
committeryuangli <yuangli@mathworks.com>2022-07-29 13:53:29 +0100
commit73d25f0e7b026d7b744e249d922f248376bcce5d (patch)
treed3de8a383270ebc9dba7763b2c7a00a6deaa8bf6
parent68bbcefd35a8b3a864e9ed7598b19fefc5f74055 (diff)
downloadlibgit2-73d25f0e7b026d7b744e249d922f248376bcce5d.tar.gz
remove build errors
-rw-r--r--include/git2/remote.h12
-rw-r--r--include/git2/repository.h1
-rw-r--r--src/libgit2/clone.c2
-rw-r--r--src/libgit2/commit.c2
-rw-r--r--src/libgit2/fetch.c7
-rw-r--r--src/libgit2/repository.c109
-rw-r--r--src/libgit2/transports/smart_pkt.c16
7 files changed, 21 insertions, 128 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 871d898e5..33f5103ce 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -744,6 +744,11 @@ typedef struct {
git_proxy_options proxy_opts;
/**
+ * Depth of the fetch to perform
+ */
+ int depth;
+
+ /**
* Whether to allow off-site redirects. If this is not
* specified, the `http.followRedirects` configuration setting
* will be consulted.
@@ -754,16 +759,11 @@ typedef struct {
* Extra headers for this fetch operation
*/
git_strarray custom_headers;
-
- /**
- * Depth of the fetch to perform
- */
- int depth;
} git_fetch_options;
#define GIT_FETCH_OPTIONS_VERSION 1
#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
- GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT, { NULL }, -1 }
+ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT, -1 }
/**
* Initialize git_fetch_options structure
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 24a94118b..d6b054dc3 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -11,6 +11,7 @@
#include "types.h"
#include "oid.h"
#include "buffer.h"
+#include "oidarray.h"
/**
* @file git2/repository.h
diff --git a/src/libgit2/clone.c b/src/libgit2/clone.c
index 101c741b1..ee1f2b892 100644
--- a/src/libgit2/clone.c
+++ b/src/libgit2/clone.c
@@ -411,7 +411,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
fetch_opts.update_fetchhead = 0;
if (fetch_opts.depth == -1)
fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
- git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
+ git_str_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
if ((error = git_remote_fetch(remote, NULL, &fetch_opts, git_str_cstr(&reflog_message))) != 0)
goto cleanup;
diff --git a/src/libgit2/commit.c b/src/libgit2/commit.c
index 75cc8837c..528d8beb7 100644
--- a/src/libgit2/commit.c
+++ b/src/libgit2/commit.c
@@ -422,7 +422,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
buffer += tree_len;
}
- while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) {
+ while (git_object__parse_oid_header(&parent_id, &buffer, buffer_end, "parent ", GIT_OID_SHA1) == 0) {
git_oid *new_id = git_array_alloc(commit->parent_ids);
GIT_ERROR_CHECK_ALLOC(new_id);
diff --git a/src/libgit2/fetch.c b/src/libgit2/fetch.c
index 10155662d..e4a8f0382 100644
--- a/src/libgit2/fetch.c
+++ b/src/libgit2/fetch.c
@@ -209,12 +209,7 @@ int git_fetch_download_pack(git_remote *remote)
if (!remote->need_pack)
return 0;
- if (callbacks) {
- progress = callbacks->transfer_progress;
- payload = callbacks->payload;
- }
-
- if ((error = t->download_pack(t, remote->repo, &remote->stats, progress, payload)) < 0)
+ if ((error = t->download_pack(t, remote->repo, &remote->stats)) < 0)
return error;
if ((error = git_repository__shallow_roots_write(remote->repo, remote->nego.shallow_roots->array)) < 0)
diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c
index adb4721ad..d9bc537fe 100644
--- a/src/libgit2/repository.c
+++ b/src/libgit2/repository.c
@@ -3340,109 +3340,6 @@ int git_repository_state_cleanup(git_repository *repo)
return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files));
}
-// int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo)
-// {
-// git_buf path = GIT_BUF_INIT;
-// git_buf contents = GIT_BUF_INIT;
-// int error, updated, line_num = 1;
-// char *line;
-// chror = git_futils_readbuffer_updated(&contents, git_buf_cstr(&path), &repo->shallow_grafts->git_grafts->path_checksum, &updated);
-// git_buf_dispose(&path);
-
-// if (error < 0 && error != GIT_ENOTFOUND)
-// return error;
-
-// /* cancel out GIT_ENOTFOUND */
-// git_error_clear();
-// error = 0;
-
-// if (!updated) {
-// out = repo->shallow_grafts;
-// goto cleanup;
-// }
-
-// git_array_clear(repo->shallow_grafts);
-
-// buffer = contents.ptr;
-// while ((line = git__strsep(&buffer, "\n")) != NULL) {
-// git_oid *oid = git_array_alloc(repo->shallow_grafts);
-
-// error = git_oid_fromstr(oid, line);
-// if (error < 0) {
-// git_error_set(GIT_ERROR_REPOSITORY, "Invalid OID at line %d", line_num);
-// git_array_clear(repo->shallow_grafts);
-// error = -1;
-// goto cleanup;
-// }
-// ++line_num;
-// }
-
-// if (*buffer) {
-// git_error_set(GIT_ERROR_REPOSITORY, "No EOL at line %d", line_num);
-// git_array_clear(repo->shallow_grafts);
-// error = -1;
-// goto cleanup;
-// }
-
-// *out = repo->shallow_grafts;
-
-// cleanup:
-// git_buf_dispose(&contents);
-
-// return error;ar *buffer;
-
-// assert(out && repo);
-
-// if ((error = git_buf_joinpath(&path, repo->gitdir, "shallow")) < 0)
-// return error;
-
-// //error = git_futils_readbuffer_updated(&contents, git_buf_cstr(&path), &repo->shallow_checksum, &updated);
-// error = git_futils_readbuffer_updated(&contents, git_buf_cstr(&path), &repo->shallow_grafts->git_grafts->path_checksum, &updated);
-// git_buf_dispose(&path);
-
-// if (error < 0 && error != GIT_ENOTFOUND)
-// return error;
-
-// /* cancel out GIT_ENOTFOUND */
-// git_error_clear();
-// error = 0;
-
-// if (!updated) {
-// out = repo->shallow_grafts;
-// goto cleanup;
-// }
-
-// git_array_clear(repo->shallow_grafts);
-
-// buffer = contents.ptr;
-// while ((line = git__strsep(&buffer, "\n")) != NULL) {
-// git_oid *oid = git_array_alloc(repo->shallow_grafts);
-
-// error = git_oid_fromstr(oid, line);
-// if (error < 0) {
-// git_error_set(GIT_ERROR_REPOSITORY, "Invalid OID at line %d", line_num);
-// git_array_clear(repo->shallow_grafts);
-// error = -1;
-// goto cleanup;
-// }
-// ++line_num;
-// }
-
-// if (*buffer) {
-// git_error_set(GIT_ERROR_REPOSITORY, "No EOL at line %d", line_num);
-// git_array_clear(repo->shallow_grafts);
-// error = -1;
-// goto cleanup;
-// }
-
-// *out = repo->shallow_grafts;
-
-// cleanup:
-// git_buf_dispose(&contents);
-
-// return error;
-// }
-
int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) {
int error =0;
if (!repo->shallow_grafts)
@@ -3455,17 +3352,17 @@ int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) {
int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t roots)
{
git_filebuf file = GIT_FILEBUF_INIT;
- git_buf path = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT;
int error = 0;
size_t idx;
git_oid *oid;
assert(repo);
- if ((error = git_buf_joinpath(&path, repo->gitdir, "shallow")) < 0)
+ if ((error = git_str_joinpath(&path, repo->gitdir, "shallow")) < 0)
return error;
- if ((error = git_filebuf_open(&file, git_buf_cstr(&path), GIT_FILEBUF_HASH_CONTENTS, 0666)) < 0)
+ if ((error = git_filebuf_open(&file, git_str_cstr(&path), GIT_FILEBUF_HASH_CONTENTS, 0666)) < 0)
return error;
git_array_foreach(roots, idx, oid) {
diff --git a/src/libgit2/transports/smart_pkt.c b/src/libgit2/transports/smart_pkt.c
index e368cb7e2..f9fde00f1 100644
--- a/src/libgit2/transports/smart_pkt.c
+++ b/src/libgit2/transports/smart_pkt.c
@@ -678,23 +678,23 @@ int git_pkt_buffer_wants(
git_buf shallow_buf = GIT_BUF_INIT;
git_oid_fmt(oid, git_shallowarray_get(wants->shallow_roots, i));
- git_buf_puts(&shallow_buf, "shallow ");
- git_buf_put(&shallow_buf, oid, GIT_OID_HEXSZ);
- git_buf_putc(&shallow_buf, '\n');
+ git_str_puts(&shallow_buf, "shallow ");
+ git_str_put(&shallow_buf, oid, GIT_OID_HEXSZ);
+ git_str_putc(&shallow_buf, '\n');
- git_buf_printf(buf, "%04x%s", (unsigned int)git_buf_len(&shallow_buf) + 4, git_buf_cstr(&shallow_buf));
+ git_str_printf(buf, "%04x%s", (unsigned int)git_str_len(&shallow_buf) + 4, git_str_cstr(&shallow_buf));
- if (git_buf_oom(buf))
+ if (git_str_oom(buf))
return -1;
}
if (wants->depth > 0) {
git_buf deepen_buf = GIT_BUF_INIT;
- git_buf_printf(&deepen_buf, "deepen %d\n", wants->depth);
- git_buf_printf(buf,"%04x%s", (unsigned int)git_buf_len(&deepen_buf) + 4, git_buf_cstr(&deepen_buf));
+ 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));
- if (git_buf_oom(buf))
+ if (git_str_oom(buf))
return -1;
}