Commit a1ef995d by Edward Thomson

indexer: use git_indexer_progress throughout

Update internal usage of `git_transfer_progress` to
`git_indexer_progreses`.
parent 975d6722
#include "common.h"
typedef struct progress_data {
git_transfer_progress fetch_progress;
git_indexer_progress fetch_progress;
size_t completed_steps;
size_t total_steps;
const char *path;
......@@ -46,7 +46,7 @@ static int sideband_progress(const char *str, int len, void *payload)
return 0;
}
static int fetch_progress(const git_transfer_progress *stats, void *payload)
static int fetch_progress(const git_indexer_progress *stats, void *payload)
{
progress_data *pd = (progress_data*)payload;
pd->fetch_progress = *stats;
......
......@@ -38,7 +38,7 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
* data. Most frontends will probably want to show a percentage and
* the download rate.
*/
static int transfer_progress_cb(const git_transfer_progress *stats, void *payload)
static int transfer_progress_cb(const git_indexer_progress *stats, void *payload)
{
(void)payload;
......@@ -57,7 +57,7 @@ static int transfer_progress_cb(const git_transfer_progress *stats, void *payloa
int lg2_fetch(git_repository *repo, int argc, char **argv)
{
git_remote *remote = NULL;
const git_transfer_progress *stats;
const git_indexer_progress *stats;
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
if (argc < 2) {
......
......@@ -20,7 +20,7 @@
* This could be run in the main loop whilst the application waits for
* the indexing to finish in a worker thread
*/
static int index_cb(const git_transfer_progress *stats, void *data)
static int index_cb(const git_indexer_progress *stats, void *data)
{
(void)data;
printf("\rProcessing %d of %d", stats->indexed_objects, stats->total_objects);
......@@ -31,7 +31,7 @@ static int index_cb(const git_transfer_progress *stats, void *data)
int lg2_index_pack(git_repository *repo, int argc, char **argv)
{
git_indexer *idx;
git_transfer_progress stats = {0, 0};
git_indexer_progress stats = {0, 0};
int error;
char hash[GIT_OID_HEXSZ + 1] = {0};
int fd;
......
......@@ -55,7 +55,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
git_indexer *indexer = NULL;
git_transfer_progress stats = {0, 0};
git_indexer_progress stats = {0, 0};
bool append_hash = false;
git_oid id;
char hash[GIT_OID_HEXSZ + 1] = {0};
......
......@@ -64,7 +64,7 @@ typedef struct git_indexer_options {
unsigned int version;
/** progress_cb function to call with progress information */
git_transfer_progress_cb progress_cb;
git_indexer_progress_cb progress_cb;
/** progress_cb_payload payload for the progress callback */
void *progress_cb_payload;
......@@ -114,7 +114,7 @@ GIT_EXTERN(int) git_indexer_new(
* @param size the size of the data in bytes
* @param stats stat storage
*/
GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats);
GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats);
/**
* Finalize the pack and index
......@@ -123,7 +123,7 @@ GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t si
*
* @param idx the indexer
*/
GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_transfer_progress *stats);
GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_indexer_progress *stats);
/**
* Get the packfile's hash
......
......@@ -391,7 +391,7 @@ GIT_EXTERN(int) git_odb_open_rstream(
GIT_EXTERN(int) git_odb_write_pack(
git_odb_writepack **out,
git_odb *db,
git_transfer_progress_cb progress_cb,
git_indexer_progress_cb progress_cb,
void *progress_payload);
/**
......
......@@ -124,8 +124,8 @@ struct git_odb_stream {
struct git_odb_writepack {
git_odb_backend *backend;
int GIT_CALLBACK(append)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
int GIT_CALLBACK(commit)(git_odb_writepack *writepack, git_transfer_progress *stats);
int GIT_CALLBACK(append)(git_odb_writepack *writepack, const void *data, size_t size, git_indexer_progress *stats);
int GIT_CALLBACK(commit)(git_odb_writepack *writepack, git_indexer_progress *stats);
void GIT_CALLBACK(free)(git_odb_writepack *writepack);
};
......
......@@ -165,7 +165,7 @@ GIT_EXTERN(int) git_packbuilder_write(
git_packbuilder *pb,
const char *path,
unsigned int mode,
git_transfer_progress_cb progress_cb,
git_indexer_progress_cb progress_cb,
void *progress_cb_payload);
/**
......
......@@ -516,7 +516,7 @@ struct git_remote_callbacks {
* called with the current count of progress done by the
* indexer.
*/
git_transfer_progress_cb transfer_progress;
git_indexer_progress_cb transfer_progress;
/**
* Each time a reference is updated locally, this function
......@@ -832,7 +832,7 @@ GIT_EXTERN(int) git_remote_push(git_remote *remote,
/**
* Get the statistics structure that is filled in by the fetch operation.
*/
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
GIT_EXTERN(const git_indexer_progress *) git_remote_stats(git_remote *remote);
/**
* Retrieve the tag auto-follow setting
......
......@@ -82,7 +82,7 @@ struct git_odb_backend {
int GIT_CALLBACK(writepack)(
git_odb_writepack **, git_odb_backend *, git_odb *odb,
git_transfer_progress_cb progress_cb, void *progress_payload);
git_indexer_progress_cb progress_cb, void *progress_payload);
/**
* "Freshens" an already existing object, updating its last-used
......
......@@ -98,8 +98,8 @@ struct git_transport {
int GIT_CALLBACK(download_pack)(
git_transport *transport,
git_repository *repo,
git_transfer_progress *stats,
git_transfer_progress_cb progress_cb,
git_indexer_progress *stats,
git_indexer_progress_cb progress_cb,
void *progress_payload);
/** Checks to see if the transport is connected */
......
......@@ -134,7 +134,7 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks)
{
git_transport *t = remote->transport;
git_transfer_progress_cb progress = NULL;
git_indexer_progress_cb progress = NULL;
void *payload = NULL;
if (!remote->need_pack)
......
......@@ -58,7 +58,7 @@ struct git_indexer {
unsigned int fanout[256];
git_hash_ctx hash_ctx;
git_oid hash;
git_transfer_progress_cb progress_cb;
git_indexer_progress_cb progress_cb;
void *progress_payload;
char objbuf[8*1024];
......@@ -544,7 +544,7 @@ on_error:
return -1;
}
static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats)
static int do_progress_callback(git_indexer *idx, git_indexer_progress *stats)
{
if (idx->progress_cb)
return git_error_set_after_callback_function(
......@@ -652,7 +652,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
return write_at(idx, data, idx->pack->mwf.size, size);
}
static int read_stream_object(git_indexer *idx, git_transfer_progress *stats)
static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
{
git_packfile_stream *stream = &idx->stream;
git_off_t entry_start = idx->off;
......@@ -741,7 +741,7 @@ static int read_stream_object(git_indexer *idx, git_transfer_progress *stats)
return 0;
}
int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats)
int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats)
{
int error = -1;
struct git_pack_header *hdr = &idx->hdr;
......@@ -925,7 +925,7 @@ cleanup:
return error;
}
static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
{
int error, found_ref_delta = 0;
unsigned int i;
......@@ -987,7 +987,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
return 0;
}
static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
static int resolve_deltas(git_indexer *idx, git_indexer_progress *stats)
{
unsigned int i;
int error;
......@@ -1044,7 +1044,7 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
return 0;
}
static int update_header_and_rehash(git_indexer *idx, git_transfer_progress *stats)
static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stats)
{
void *ptr;
size_t chunk = 1024*1024;
......@@ -1085,7 +1085,7 @@ static int update_header_and_rehash(git_indexer *idx, git_transfer_progress *sta
return 0;
}
int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
{
git_mwindow *w = NULL;
unsigned int i, long_offsets = 0, left;
......
......@@ -1468,7 +1468,7 @@ int git_odb_open_rstream(
return error;
}
int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer_progress_cb progress_cb, void *progress_payload)
int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_indexer_progress_cb progress_cb, void *progress_payload)
{
size_t i, writes = 0;
int error = GIT_ERROR;
......
......@@ -485,7 +485,7 @@ static int pack_backend__foreach(git_odb_backend *_backend, git_odb_foreach_cb c
return 0;
}
static int pack_backend__writepack_append(struct git_odb_writepack *_writepack, const void *data, size_t size, git_transfer_progress *stats)
static int pack_backend__writepack_append(struct git_odb_writepack *_writepack, const void *data, size_t size, git_indexer_progress *stats)
{
struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
......@@ -494,7 +494,7 @@ static int pack_backend__writepack_append(struct git_odb_writepack *_writepack,
return git_indexer_append(writepack->indexer, data, size, stats);
}
static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack, git_transfer_progress *stats)
static int pack_backend__writepack_commit(struct git_odb_writepack *_writepack, git_indexer_progress *stats)
{
struct pack_writepack *writepack = (struct pack_writepack *)_writepack;
......@@ -516,7 +516,7 @@ static void pack_backend__writepack_free(struct git_odb_writepack *_writepack)
static int pack_backend__writepack(struct git_odb_writepack **out,
git_odb_backend *_backend,
git_odb *odb,
git_transfer_progress_cb progress_cb,
git_indexer_progress_cb progress_cb,
void *progress_payload)
{
git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
......
......@@ -38,7 +38,7 @@ struct tree_walk_context {
struct pack_write_context {
git_indexer *indexer;
git_transfer_progress *stats;
git_indexer_progress *stats;
};
struct walk_object {
......@@ -1379,12 +1379,12 @@ int git_packbuilder_write(
git_packbuilder *pb,
const char *path,
unsigned int mode,
git_transfer_progress_cb progress_cb,
git_indexer_progress_cb progress_cb,
void *progress_cb_payload)
{
git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
git_indexer *indexer;
git_transfer_progress stats;
git_indexer_progress stats;
struct pack_write_context ctx;
int t;
......
......@@ -1770,7 +1770,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
return 0;
}
const git_transfer_progress* git_remote_stats(git_remote *remote)
const git_indexer_progress *git_remote_stats(git_remote *remote)
{
assert(remote);
return &remote->stats;
......
......@@ -29,7 +29,7 @@ struct git_remote {
git_transport *transport;
git_repository *repo;
git_push *push;
git_transfer_progress stats;
git_indexer_progress stats;
unsigned int need_pack;
git_remote_autotag_option_t download_tags;
int prune_refs;
......
......@@ -325,7 +325,7 @@ static int local_push_update_remote_ref(
return error;
}
static int transfer_to_push_transfer(const git_transfer_progress *stats, void *payload)
static int transfer_to_push_transfer(const git_indexer_progress *stats, void *payload)
{
const git_remote_callbacks *cbs = payload;
......@@ -460,8 +460,8 @@ on_error:
}
typedef struct foreach_data {
git_transfer_progress *stats;
git_transfer_progress_cb progress_cb;
git_indexer_progress *stats;
git_indexer_progress_cb progress_cb;
void *progress_payload;
git_odb_writepack *writepack;
} foreach_data;
......@@ -533,8 +533,8 @@ static int foreach_reference_cb(git_reference *reference, void *payload)
static int local_download_pack(
git_transport *transport,
git_repository *repo,
git_transfer_progress *stats,
git_transfer_progress_cb progress_cb,
git_indexer_progress *stats,
git_indexer_progress_cb progress_cb,
void *progress_payload)
{
transport_local *t = (transport_local*)transport;
......
......@@ -177,8 +177,8 @@ int git_smart__negotiate_fetch(
int git_smart__download_pack(
git_transport *transport,
git_repository *repo,
git_transfer_progress *stats,
git_transfer_progress_cb progress_cb,
git_indexer_progress *stats,
git_indexer_progress_cb progress_cb,
void *progress_payload);
/* smart.c */
......
......@@ -492,7 +492,7 @@ on_error:
return error;
}
static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack, gitno_buffer *buf, git_transfer_progress *stats)
static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack, gitno_buffer *buf, git_indexer_progress *stats)
{
int recvd;
......@@ -519,9 +519,9 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
struct network_packetsize_payload
{
git_transfer_progress_cb callback;
git_indexer_progress_cb callback;
void *payload;
git_transfer_progress *stats;
git_indexer_progress *stats;
size_t last_fired_bytes;
};
......@@ -546,8 +546,8 @@ static int network_packetsize(size_t received, void *payload)
int git_smart__download_pack(
git_transport *transport,
git_repository *repo,
git_transfer_progress *stats,
git_transfer_progress_cb transfer_progress_cb,
git_indexer_progress *stats,
git_indexer_progress_cb progress_cb,
void *progress_payload)
{
transport_smart *t = (transport_smart *)transport;
......@@ -557,10 +557,10 @@ int git_smart__download_pack(
int error = 0;
struct network_packetsize_payload npp = {0};
memset(stats, 0, sizeof(git_transfer_progress));
memset(stats, 0, sizeof(git_indexer_progress));
if (transfer_progress_cb) {
npp.callback = transfer_progress_cb;
if (progress_cb) {
npp.callback = progress_cb;
npp.payload = progress_payload;
npp.stats = stats;
t->packetsize_cb = &network_packetsize;
......@@ -573,7 +573,7 @@ int git_smart__download_pack(
}
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
((error = git_odb_write_pack(&writepack, odb, transfer_progress_cb, progress_payload)) != 0))
((error = git_odb_write_pack(&writepack, odb, progress_cb, progress_payload)) != 0))
goto done;
/*
......@@ -626,7 +626,7 @@ int git_smart__download_pack(
} while (1);
/*
* Trailing execution of transfer_progress_cb, if necessary...
* Trailing execution of progress_cb, if necessary...
* Only the callback through the npp datastructure currently
* updates the last_fired_bytes value. It is possible that
* progress has already been reported with the correct
......@@ -645,7 +645,7 @@ int git_smart__download_pack(
done:
if (writepack)
writepack->free(writepack);
if (transfer_progress_cb) {
if (progress_cb) {
t->packetsize_cb = NULL;
t->packetsize_payload = NULL;
}
......
......@@ -171,7 +171,7 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
}
static int clone_cancel_fetch_transfer_progress_cb(
const git_transfer_progress *stats, void *data)
const git_indexer_progress *stats, void *data)
{
GIT_UNUSED(stats); GIT_UNUSED(data);
return -54321;
......
......@@ -8,7 +8,7 @@ static const char* tagger_name = "Vicent Marti";
static const char* tagger_email = "vicent@github.com";
static const char* tagger_message = "This is my tag.\n\nThere are many tags, but this one is mine\n";
static int transfer_cb(const git_transfer_progress *stats, void *payload)
static int transfer_cb(const git_indexer_progress *stats, void *payload)
{
int *callcount = (int*)payload;
GIT_UNUSED(stats);
......
......@@ -158,7 +158,7 @@ static void checkout_progress(const char *path, size_t cur, size_t tot, void *pa
(*was_called) = true;
}
static int fetch_progress(const git_transfer_progress *stats, void *payload)
static int fetch_progress(const git_indexer_progress *stats, void *payload)
{
bool *was_called = (bool*)payload;
GIT_UNUSED(stats);
......@@ -442,7 +442,7 @@ void test_online_clone__bitbucket_falls_back_to_specified_creds(void)
cl_fixture_cleanup("./foo");
}
static int cancel_at_half(const git_transfer_progress *stats, void *payload)
static int cancel_at_half(const git_indexer_progress *stats, void *payload)
{
GIT_UNUSED(payload);
......
......@@ -25,7 +25,7 @@ static int update_tips(const char *refname, const git_oid *a, const git_oid *b,
return 0;
}
static int progress(const git_transfer_progress *stats, void *payload)
static int progress(const git_indexer_progress *stats, void *payload)
{
size_t *bytes_received = (size_t *)payload;
*bytes_received = stats->received_bytes;
......@@ -92,7 +92,7 @@ void test_online_fetch__fetch_twice(void)
git_remote_free(remote);
}
static int transferProgressCallback(const git_transfer_progress *stats, void *payload)
static int transferProgressCallback(const git_indexer_progress *stats, void *payload)
{
bool *invoked = (bool *)payload;
......@@ -134,7 +134,7 @@ void test_online_fetch__doesnt_retrieve_a_pack_when_the_repository_is_up_to_date
git_repository_free(_repository);
}
static int cancel_at_half(const git_transfer_progress *stats, void *payload)
static int cancel_at_half(const git_indexer_progress *stats, void *payload)
{
GIT_UNUSED(payload);
......
......@@ -98,7 +98,7 @@ static const unsigned int base_obj_len = 2;
void test_pack_indexer__out_of_order(void)
{
git_indexer *idx = 0;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
cl_git_pass(git_indexer_append(
......@@ -115,7 +115,7 @@ void test_pack_indexer__out_of_order(void)
void test_pack_indexer__missing_trailer(void)
{
git_indexer *idx = 0;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
cl_git_pass(git_indexer_append(
......@@ -131,7 +131,7 @@ void test_pack_indexer__missing_trailer(void)
void test_pack_indexer__leaky(void)
{
git_indexer *idx = 0;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL));
cl_git_pass(git_indexer_append(
......@@ -147,7 +147,7 @@ void test_pack_indexer__leaky(void)
void test_pack_indexer__fix_thin(void)
{
git_indexer *idx = NULL;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
git_repository *repo;
git_odb *odb;
git_oid id, should_id;
......@@ -213,7 +213,7 @@ void test_pack_indexer__fix_thin(void)
void test_pack_indexer__corrupt_length(void)
{
git_indexer *idx = NULL;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
git_repository *repo;
git_odb *odb;
git_oid id, should_id;
......@@ -243,7 +243,7 @@ void test_pack_indexer__incomplete_pack_fails_with_strict(void)
{
git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
git_indexer *idx = 0;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
opts.verify = 1;
......@@ -263,7 +263,7 @@ void test_pack_indexer__out_of_order_with_connectivity_checks(void)
{
git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
git_indexer *idx = 0;
git_transfer_progress stats = { 0 };
git_indexer_progress stats = { 0 };
opts.verify = 1;
......
......@@ -12,7 +12,7 @@ static git_packbuilder *_packbuilder;
static git_indexer *_indexer;
static git_vector _commits;
static int _commits_is_initialized;
static git_transfer_progress _stats;
static git_indexer_progress _stats;
extern bool git_disable_pack_keep_file_checks;
......@@ -88,14 +88,14 @@ static void seed_packbuilder(void)
static int feed_indexer(void *ptr, size_t len, void *payload)
{
git_transfer_progress *stats = (git_transfer_progress *)payload;
git_indexer_progress *stats = (git_indexer_progress *)payload;
return git_indexer_append(_indexer, ptr, len, stats);
}
void test_pack_packbuilder__create_pack(void)
{
git_transfer_progress stats;
git_indexer_progress stats;
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
git_hash_ctx ctx;
git_oid hash;
......
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