Commit 73d25f0e by yuangli

remove build errors

parent 68bbcefd
...@@ -744,6 +744,11 @@ typedef struct { ...@@ -744,6 +744,11 @@ typedef struct {
git_proxy_options proxy_opts; git_proxy_options proxy_opts;
/** /**
* Depth of the fetch to perform
*/
int depth;
/**
* Whether to allow off-site redirects. If this is not * Whether to allow off-site redirects. If this is not
* specified, the `http.followRedirects` configuration setting * specified, the `http.followRedirects` configuration setting
* will be consulted. * will be consulted.
...@@ -754,16 +759,11 @@ typedef struct { ...@@ -754,16 +759,11 @@ typedef struct {
* Extra headers for this fetch operation * Extra headers for this fetch operation
*/ */
git_strarray custom_headers; git_strarray custom_headers;
/**
* Depth of the fetch to perform
*/
int depth;
} git_fetch_options; } git_fetch_options;
#define GIT_FETCH_OPTIONS_VERSION 1 #define GIT_FETCH_OPTIONS_VERSION 1
#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 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 * Initialize git_fetch_options structure
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "types.h" #include "types.h"
#include "oid.h" #include "oid.h"
#include "buffer.h" #include "buffer.h"
#include "oidarray.h"
/** /**
* @file git2/repository.h * @file git2/repository.h
......
...@@ -411,7 +411,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch ...@@ -411,7 +411,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
fetch_opts.update_fetchhead = 0; fetch_opts.update_fetchhead = 0;
if (fetch_opts.depth == -1) if (fetch_opts.depth == -1)
fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; 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) if ((error = git_remote_fetch(remote, NULL, &fetch_opts, git_str_cstr(&reflog_message))) != 0)
goto cleanup; goto cleanup;
......
...@@ -422,7 +422,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig ...@@ -422,7 +422,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
buffer += tree_len; 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_oid *new_id = git_array_alloc(commit->parent_ids);
GIT_ERROR_CHECK_ALLOC(new_id); GIT_ERROR_CHECK_ALLOC(new_id);
......
...@@ -209,12 +209,7 @@ int git_fetch_download_pack(git_remote *remote) ...@@ -209,12 +209,7 @@ int git_fetch_download_pack(git_remote *remote)
if (!remote->need_pack) if (!remote->need_pack)
return 0; return 0;
if (callbacks) { if ((error = t->download_pack(t, remote->repo, &remote->stats)) < 0)
progress = callbacks->transfer_progress;
payload = callbacks->payload;
}
if ((error = t->download_pack(t, remote->repo, &remote->stats, progress, payload)) < 0)
return error; return error;
if ((error = git_repository__shallow_roots_write(remote->repo, remote->nego.shallow_roots->array)) < 0) if ((error = git_repository__shallow_roots_write(remote->repo, remote->nego.shallow_roots->array)) < 0)
......
...@@ -3340,109 +3340,6 @@ int git_repository_state_cleanup(git_repository *repo) ...@@ -3340,109 +3340,6 @@ int git_repository_state_cleanup(git_repository *repo)
return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); 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 git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) {
int error =0; int error =0;
if (!repo->shallow_grafts) if (!repo->shallow_grafts)
...@@ -3455,17 +3352,17 @@ int git_repository__shallow_roots(git_array_oid_t *out, git_repository *repo) { ...@@ -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) int git_repository__shallow_roots_write(git_repository *repo, git_array_oid_t roots)
{ {
git_filebuf file = GIT_FILEBUF_INIT; git_filebuf file = GIT_FILEBUF_INIT;
git_buf path = GIT_BUF_INIT; git_str path = GIT_STR_INIT;
int error = 0; int error = 0;
size_t idx; size_t idx;
git_oid *oid; git_oid *oid;
assert(repo); assert(repo);
if ((error = git_buf_joinpath(&path, repo->gitdir, "shallow")) < 0) if ((error = git_str_joinpath(&path, repo->gitdir, "shallow")) < 0)
return error; 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; return error;
git_array_foreach(roots, idx, oid) { git_array_foreach(roots, idx, oid) {
......
...@@ -678,23 +678,23 @@ int git_pkt_buffer_wants( ...@@ -678,23 +678,23 @@ int git_pkt_buffer_wants(
git_buf shallow_buf = GIT_BUF_INIT; git_buf shallow_buf = GIT_BUF_INIT;
git_oid_fmt(oid, git_shallowarray_get(wants->shallow_roots, i)); git_oid_fmt(oid, git_shallowarray_get(wants->shallow_roots, i));
git_buf_puts(&shallow_buf, "shallow "); git_str_puts(&shallow_buf, "shallow ");
git_buf_put(&shallow_buf, oid, GIT_OID_HEXSZ); git_str_put(&shallow_buf, oid, GIT_OID_HEXSZ);
git_buf_putc(&shallow_buf, '\n'); 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; return -1;
} }
if (wants->depth > 0) { if (wants->depth > 0) {
git_buf deepen_buf = GIT_BUF_INIT; git_buf deepen_buf = GIT_BUF_INIT;
git_buf_printf(&deepen_buf, "deepen %d\n", wants->depth); git_str_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(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; return -1;
} }
......
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