Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a6a3c0

Browse files
authored
Merge pull request #4997 from libgit2/ethomson/transfer_progress
Rename git_transfer_progress to git_indexer_progress
2 parents 4069f92 + ca909da commit 5a6a3c0

29 files changed

+157
-107
lines changed

examples/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "common.h"
22

33
typedef struct progress_data {
4-
git_transfer_progress fetch_progress;
4+
git_indexer_progress fetch_progress;
55
size_t completed_steps;
66
size_t total_steps;
77
const char *path;
@@ -46,7 +46,7 @@ static int sideband_progress(const char *str, int len, void *payload)
4646
return 0;
4747
}
4848

49-
static int fetch_progress(const git_transfer_progress *stats, void *payload)
49+
static int fetch_progress(const git_indexer_progress *stats, void *payload)
5050
{
5151
progress_data *pd = (progress_data*)payload;
5252
pd->fetch_progress = *stats;

examples/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
3838
* data. Most frontends will probably want to show a percentage and
3939
* the download rate.
4040
*/
41-
static int transfer_progress_cb(const git_transfer_progress *stats, void *payload)
41+
static int transfer_progress_cb(const git_indexer_progress *stats, void *payload)
4242
{
4343
(void)payload;
4444

@@ -57,7 +57,7 @@ static int transfer_progress_cb(const git_transfer_progress *stats, void *payloa
5757
int lg2_fetch(git_repository *repo, int argc, char **argv)
5858
{
5959
git_remote *remote = NULL;
60-
const git_transfer_progress *stats;
60+
const git_indexer_progress *stats;
6161
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
6262

6363
if (argc < 2) {

examples/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* This could be run in the main loop whilst the application waits for
2121
* the indexing to finish in a worker thread
2222
*/
23-
static int index_cb(const git_transfer_progress *stats, void *data)
23+
static int index_cb(const git_indexer_progress *stats, void *data)
2424
{
2525
(void)data;
2626
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)
3131
int lg2_index_pack(git_repository *repo, int argc, char **argv)
3232
{
3333
git_indexer *idx;
34-
git_transfer_progress stats = {0, 0};
34+
git_indexer_progress stats = {0, 0};
3535
int error;
3636
char hash[GIT_OID_HEXSZ + 1] = {0};
3737
int fd;

fuzzers/packfile_fuzzer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
5555
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
5656
{
5757
git_indexer *indexer = NULL;
58-
git_transfer_progress stats = {0, 0};
58+
git_indexer_progress stats = {0, 0};
5959
bool append_hash = false;
6060
git_oid id;
6161
char hash[GIT_OID_HEXSZ + 1] = {0};

include/git2/deprecated.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "index.h"
1414
#include "object.h"
1515
#include "refs.h"
16+
#include "remote.h"
1617

1718
/*
1819
* Users can avoid deprecated functions by defining `GIT_DEPRECATE_HARD`.
@@ -245,6 +246,43 @@ GIT_EXTERN(void) giterr_set_oom(void);
245246

246247
/**@}*/
247248

249+
/** @name Deprecated Transfer Progress Types
250+
*
251+
* These types are retained for backward compatibility. The newer
252+
* versions of these values should be preferred in all new code.
253+
*
254+
* There is no plan to remove these backward compatibility values at
255+
* this time.
256+
*/
257+
/**@{*/
258+
259+
/**
260+
* This structure is used to provide callers information about the
261+
* progress of indexing a packfile.
262+
*
263+
* This type is deprecated, but there is no plan to remove this
264+
* type definition at this time.
265+
*/
266+
typedef git_indexer_progress git_transfer_progress;
267+
268+
/**
269+
* Type definition for progress callbacks during indexing.
270+
*
271+
* This type is deprecated, but there is no plan to remove this
272+
* type definition at this time.
273+
*/
274+
typedef git_indexer_progress_cb git_transfer_progress_cb;
275+
276+
/**
277+
* Type definition for push transfer progress callbacks.
278+
*
279+
* This type is deprecated, but there is no plan to remove this
280+
* type definition at this time.
281+
*/
282+
typedef git_push_transfer_progress_cb git_push_transfer_progress;
283+
284+
/**@}*/
285+
248286
/** @} */
249287
GIT_END_DECL
250288

include/git2/indexer.h

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,52 @@ GIT_BEGIN_DECL
1515

1616
typedef struct git_indexer git_indexer;
1717

18+
/**
19+
* This structure is used to provide callers information about the
20+
* progress of indexing a packfile, either directly or part of a
21+
* fetch or clone that downloads a packfile.
22+
*/
23+
typedef struct git_indexer_progress {
24+
/** number of objects in the packfile being indexed */
25+
unsigned int total_objects;
26+
27+
/** received objects that have been hashed */
28+
unsigned int indexed_objects;
29+
30+
/** received_objects: objects which have been downloaded */
31+
unsigned int received_objects;
32+
33+
/**
34+
* locally-available objects that have been injected in order
35+
* to fix a thin pack
36+
*/
37+
unsigned int local_objects;
38+
39+
/** number of deltas in the packfile being indexed */
40+
unsigned int total_deltas;
41+
42+
/** received deltas that have been indexed */
43+
unsigned int indexed_deltas;
44+
45+
/** size of the packfile received up to now */
46+
size_t received_bytes;
47+
} git_indexer_progress;
48+
49+
/**
50+
* Type for progress callbacks during indexing. Return a value less
51+
* than zero to cancel the indexing or download.
52+
*
53+
* @param stats Structure containing information about the state of the tran sfer
54+
* @param payload Payload provided by caller
55+
*/
56+
typedef int GIT_CALLBACK(git_indexer_progress_cb)(const git_indexer_progress *stats, void *payload);
57+
58+
1859
typedef struct git_indexer_options {
1960
unsigned int version;
2061

2162
/** progress_cb function to call with progress information */
22-
git_transfer_progress_cb progress_cb;
63+
git_indexer_progress_cb progress_cb;
2364
/** progress_cb_payload payload for the progress callback */
2465
void *progress_cb_payload;
2566

@@ -69,7 +110,7 @@ GIT_EXTERN(int) git_indexer_new(
69110
* @param size the size of the data in bytes
70111
* @param stats stat storage
71112
*/
72-
GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats);
113+
GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats);
73114

74115
/**
75116
* Finalize the pack and index
@@ -78,7 +119,7 @@ GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t si
78119
*
79120
* @param idx the indexer
80121
*/
81-
GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_transfer_progress *stats);
122+
GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_indexer_progress *stats);
82123

83124
/**
84125
* Get the packfile's hash

include/git2/odb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ GIT_EXTERN(int) git_odb_open_rstream(
391391
GIT_EXTERN(int) git_odb_write_pack(
392392
git_odb_writepack **out,
393393
git_odb *db,
394-
git_transfer_progress_cb progress_cb,
394+
git_indexer_progress_cb progress_cb,
395395
void *progress_payload);
396396

397397
/**

include/git2/odb_backend.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ struct git_odb_stream {
124124
struct git_odb_writepack {
125125
git_odb_backend *backend;
126126

127-
int GIT_CALLBACK(append)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
128-
int GIT_CALLBACK(commit)(git_odb_writepack *writepack, git_transfer_progress *stats);
127+
int GIT_CALLBACK(append)(git_odb_writepack *writepack, const void *data, size_t size, git_indexer_progress *stats);
128+
int GIT_CALLBACK(commit)(git_odb_writepack *writepack, git_indexer_progress *stats);
129129
void GIT_CALLBACK(free)(git_odb_writepack *writepack);
130130
};
131131

include/git2/pack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ GIT_EXTERN(int) git_packbuilder_write(
165165
git_packbuilder *pb,
166166
const char *path,
167167
unsigned int mode,
168-
git_transfer_progress_cb progress_cb,
168+
git_indexer_progress_cb progress_cb,
169169
void *progress_cb_payload);
170170

171171
/**

include/git2/remote.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,12 @@ typedef enum git_remote_completion_type {
422422
} git_remote_completion_type;
423423

424424
/** Push network progress notification function */
425-
typedef int GIT_CALLBACK(git_push_transfer_progress)(
425+
typedef int GIT_CALLBACK(git_push_transfer_progress_cb)(
426426
unsigned int current,
427427
unsigned int total,
428428
size_t bytes,
429429
void* payload);
430+
430431
/**
431432
* Represents an update which will be performed on the remote during push
432433
*/
@@ -516,7 +517,7 @@ struct git_remote_callbacks {
516517
* called with the current count of progress done by the
517518
* indexer.
518519
*/
519-
git_transfer_progress_cb transfer_progress;
520+
git_indexer_progress_cb transfer_progress;
520521

521522
/**
522523
* Each time a reference is updated locally, this function
@@ -537,7 +538,7 @@ struct git_remote_callbacks {
537538
* inline with pack building operations, so performance may be
538539
* affected.
539540
*/
540-
git_push_transfer_progress push_transfer_progress;
541+
git_push_transfer_progress_cb push_transfer_progress;
541542

542543
/**
543544
* See documentation of git_push_update_reference_cb
@@ -832,7 +833,7 @@ GIT_EXTERN(int) git_remote_push(git_remote *remote,
832833
/**
833834
* Get the statistics structure that is filled in by the fetch operation.
834835
*/
835-
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
836+
GIT_EXTERN(const git_indexer_progress *) git_remote_stats(git_remote *remote);
836837

837838
/**
838839
* Retrieve the tag auto-follow setting

0 commit comments

Comments
 (0)