8000 Merge push in remote by tiennou · Pull Request #2516 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Merge push in remote #2516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make git_push_transfer_progress a git_transfer_progress_cb.
Maybe the names of `git_transfer_progress_cb` should be made clearer though.
  • Loading branch information
tiennou committed Aug 13, 2014
commit 8c06157092b1dbb875d3dbbea3d21ab5ed6738fc
9 changes: 1 addition & 8 deletions include/git2/push.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ GIT_EXTERN(int) git_push_init_options(
git_push_options *opts,
unsigned int version);

/** Push network progress notification function */
typedef int (*git_push_transfer_progress)(
unsigned int current,
unsigned int total,
size_t bytes,
void* payload);

/**
* Create a new push object
*
Expand Down Expand Up @@ -99,7 +92,7 @@ GIT_EXTERN(int) git_push_set_callbacks(
git_push *push,
git_packbuilder_progress pack_progress_cb,
void *pack_progress_cb_payload,
git_push_transfer_progress transfer_progress_cb,
git_transfer_progress_cb transfer_progress_cb,
void *transfer_progress_cb_payload);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int git_push_set_callbacks(
git_push *push,
git_packbuilder_progress pack_progress_cb,
void *pack_progress_cb_payload,
git_push_transfer_progress transfer_progress_cb,
git_transfer_progress_cb transfer_progress_cb,
void *transfer_progress_cb_payload)
{
if (!push)
Expand Down
2 changes: 1 addition & 1 deletion src/push.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct git_push {

git_packbuilder_progress pack_progress_cb;
void *pack_progress_cb_payload;
git_push_transfer_progress transfer_progress_cb;
git_transfer_progress_cb transfer_progress_cb;
void *transfer_progress_cb_payload;
};

Expand Down
22 changes: 13 additions & 9 deletions src/transports/smart_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,9 @@ struct push_packbuilder_payload
{
git_smart_subtransport_stream *stream;
git_packbuilder *pb;
git_push_transfer_progress cb;
git_transfer_progress stats;
git_transfer_progress_cb cb;
void *cb_payload;
size_t last_bytes;
double last_progress_report_time;
};

Expand All @@ -933,11 +933,16 @@ static int stream_thunk(void *buf, size_t size, void *data)

if (payload->cb) {
double current_time = git__timer();
payload->last_bytes += size;
payload->stats.total_objects = payload->pb->nr_objects;
payload->stats.received_objects = payload->pb->nr_written;
payload->stats.received_bytes += size;

if ((current_time - payload->last_progress_report_time) >= MIN_PROGRESS_UPDATE_INTERVAL) {
payload->last_progress_report_time = current_time;
error = payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload);
if (payload->cb(&payload->stats, payload->cb_payload)) {
giterr_clear();
error = GIT_EUSER;
}
}
}

Expand Down Expand Up @@ -1009,11 +1014,10 @@ int git_smart__push(git_transport *transport, git_push *push)

/* If progress is being reported write the final report */
if (push->transfer_progress_cb) {
error = push->transfer_progress_cb(
push->pb->nr_written,
push->pb->nr_objects,
packbuilder_payload.last_bytes,
push->transfer_progress_cb_payload);
packbuilder_payload.stats.received_objects = push->pb->nr_written;
packbuilder_payload.stats.total_objects = push->pb->nr_objects;

error = push->transfer_progress_cb(&packbuilder_payload.stats, push->transfer_progress_cb_payload);

if (error < 0)
goto done;
Expand Down
5 changes: 2 additions & 3 deletions tests/online/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,10 @@ static int push_pack_progress_cb(
return 0;
}

static int push_transfer_progress_cb(
unsigned int current, unsigned int total, size_t bytes, void* payload)
static int push_transfer_progress_cb(const git_transfer_progress *stats, void* payload)
{
int *calls = (int *)payload;
GIT_UNUSED(current); GIT_UNUSED(total); GIT_UNUSED(bytes);
GIT_UNUSED(stats);
if (*calls < 0)
return *calls;
(*calls)++;
Expand Down
0