Commit 7d222e13121aebc269b2923a66c7ba5b734e1a90

Ben Straub 2012-10-24T13:29:14

Network progress: rename things git_indexer_stats and friends -> git_transfer_progress* Also made git_transfer_progress members more sanely named.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index f7b2fd9..39cb0de 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -69,7 +69,7 @@ int fetch(git_repository *repo, int argc, char **argv)
 {
 	git_remote *remote = NULL;
 	git_off_t bytes = 0;
-	const git_indexer_stats *stats;
+	const git_transfer_progress *stats;
 	pthread_t worker;
 	struct dl_data data;
 	git_remote_callbacks callbacks;
diff --git a/include/git2/clone.h b/include/git2/clone.h
index 847295a..7d8d321 100644
--- a/include/git2/clone.h
+++ b/include/git2/clone.h
@@ -42,7 +42,7 @@ GIT_EXTERN(int) git_clone(
 		git_repository **out,
 		const char *origin_url,
 		const char *workdir_path,
-		git_indexer_progress_callback fetch_progress_cb,
+		git_transfer_progress_callback fetch_progress_cb,
 		void *fetch_progress_payload,
 		git_checkout_opts *checkout_opts);
 
@@ -62,7 +62,7 @@ GIT_EXTERN(int) git_clone_bare(
 		git_repository **out,
 		const char *origin_url,
 		const char *dest_path,
-		git_indexer_progress_callback fetch_progress_cb,
+		git_transfer_progress_callback fetch_progress_cb,
 		void *fetch_progress_payload);
 
 /** @} */
diff --git a/include/git2/indexer.h b/include/git2/indexer.h
index ae01fd6..a2a1554 100644
--- a/include/git2/indexer.h
+++ b/include/git2/indexer.h
@@ -16,18 +16,18 @@ GIT_BEGIN_DECL
  * This is passed as the first argument to the callback to allow the
  * user to see the progress.
  */
-typedef struct git_indexer_stats {
-	unsigned int total;
-	unsigned int processed;
-	unsigned int received;
-	size_t bytes;
-} git_indexer_stats;
+typedef struct git_transfer_progress {
+	unsigned int total_objects;
+	unsigned int indexed_objects;
+	unsigned int received_objects;
+	size_t received_bytes;
+} git_transfer_progress;
 
 
 /**
  * Type for progress callbacks during indexing
  */
-typedef void (*git_indexer_progress_callback)(const git_indexer_stats *stats, void *payload);
+typedef void (*git_transfer_progress_callback)(const git_transfer_progress *stats, void *payload);
 
 typedef struct git_indexer git_indexer;
 typedef struct git_indexer_stream git_indexer_stream;
@@ -43,7 +43,7 @@ typedef struct git_indexer_stream git_indexer_stream;
 GIT_EXTERN(int) git_indexer_stream_new(
 		git_indexer_stream **out,
 		const char *path,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_callback_payload);
 
 /**
@@ -54,7 +54,7 @@ GIT_EXTERN(int) git_indexer_stream_new(
  * @param size the size of the data
  * @param stats stat storage
  */
-GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats);
+GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_transfer_progress *stats);
 
 /**
  * Finalize the pack and index
@@ -63,7 +63,7 @@ GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data
  *
  * @param idx the indexer
  */
-GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats);
+GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *stats);
 
 /**
  * Get the packfile's hash
@@ -100,7 +100,7 @@ GIT_EXTERN(int) git_indexer_new(git_indexer **out, const char *packname);
  * @param idx the indexer instance
  * @param stats storage for the running state
  */
-GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_indexer_stats *stats);
+GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_transfer_progress *stats);
 
 /**
  * Write the index file to disk.
diff --git a/include/git2/remote.h b/include/git2/remote.h
index e23997d..897dfde 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -194,7 +194,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void 
 GIT_EXTERN(int) git_remote_download(
 		git_remote *remote,
 		git_off_t *bytes,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload);
 
 /**
@@ -325,7 +325,7 @@ GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbac
 /**
  * Get the statistics structure that is filled in by the fetch operation.
  */
-GIT_EXTERN(const git_indexer_stats *) git_remote_stats(git_remote *remote);
+GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
 
 enum {
 	GIT_REMOTE_DOWNLOAD_TAGS_UNSET,
diff --git a/src/clone.c b/src/clone.c
index 61e5e85..fc2bfa1 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -251,7 +251,7 @@ cleanup:
 static int setup_remotes_and_fetch(
 		git_repository *repo,
 		const char *origin_url,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload)
 {
 	int retcode = GIT_ERROR;
@@ -310,7 +310,7 @@ static int clone_internal(
 	git_repository **out,
 	const char *origin_url,
 	const char *path,
-	git_indexer_progress_callback fetch_progress_cb,
+	git_transfer_progress_callback fetch_progress_cb,
 	void *fetch_progress_payload,
 	git_checkout_opts *checkout_opts,
 	bool is_bare)
@@ -344,7 +344,7 @@ int git_clone_bare(
 		git_repository **out,
 		const char *origin_url,
 		const char *dest_path,
-		git_indexer_progress_callback fetch_progress_cb,
+		git_transfer_progress_callback fetch_progress_cb,
 		void *fetch_progress_payload)
 {
 	assert(out && origin_url && dest_path);
@@ -364,7 +364,7 @@ int git_clone(
 		git_repository **out,
 		const char *origin_url,
 		const char *workdir_path,
-		git_indexer_progress_callback fetch_progress_cb,
+		git_transfer_progress_callback fetch_progress_cb,
 		void *fetch_progress_payload,
 		git_checkout_opts *checkout_opts)
 {
diff --git a/src/fetch.c b/src/fetch.c
index 3f69c2c..ee85f08 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -307,7 +307,7 @@ on_error:
 int git_fetch_download_pack(
 		git_remote *remote,
 		git_off_t *bytes,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload)
 {
 	git_transport *t = remote->transport;
@@ -323,7 +323,7 @@ int git_fetch_download_pack(
 
 }
 
-static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *buf, git_off_t *bytes, git_indexer_stats *stats)
+static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *buf, git_off_t *bytes, git_transfer_progress *stats)
 {
 	int recvd;
 
@@ -352,9 +352,9 @@ static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *
 
 struct network_packetsize_payload
 {
-	git_indexer_progress_callback callback;
+	git_transfer_progress_callback callback;
 	void *payload;
-	git_indexer_stats *stats;
+	git_transfer_progress *stats;
 	git_off_t last_fired_bytes;
 };
 
@@ -363,11 +363,11 @@ static void network_packetsize(int received, void *payload)
 	struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload;
 
 	/* Accumulate bytes */
-	npp->stats->bytes += received;
+	npp->stats->received_bytes += received;
 
 	/* Fire notification if the threshold is reached */
-	if ((npp->stats->bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) {
-		npp->last_fired_bytes = npp->stats->bytes;
+	if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) {
+		npp->last_fired_bytes = npp->stats->received_bytes;
 		npp->callback(npp->stats, npp->payload);
 	}
 }
@@ -377,8 +377,8 @@ int git_fetch__download_pack(
 	git_transport *t,
 	git_repository *repo,
 	git_off_t *bytes,
-	git_indexer_stats *stats,
-	git_indexer_progress_callback progress_cb,
+	git_transfer_progress *stats,
+	git_transfer_progress_callback progress_cb,
 	void *progress_payload)
 {
 	git_buf path = GIT_BUF_INIT;
@@ -402,7 +402,7 @@ int git_fetch__download_pack(
 		goto on_error;
 
 	git_buf_free(&path);
-	memset(stats, 0, sizeof(git_indexer_stats));
+	memset(stats, 0, sizeof(git_transfer_progress));
 	*bytes = 0;
 
 	/*
diff --git a/src/fetch.h b/src/fetch.h
index c109734..23d0cf6 100644
--- a/src/fetch.h
+++ b/src/fetch.h
@@ -14,15 +14,15 @@ int git_fetch_negotiate(git_remote *remote);
 int git_fetch_download_pack(
 		git_remote *remote,
 		git_off_t *bytes,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload);
 
 int git_fetch__download_pack(
 		git_transport *t,
 		git_repository *repo,
 		git_off_t *bytes,
-		git_indexer_stats *stats,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress *stats,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload);
 
 int git_fetch_setup_walk(git_revwalk **out, git_repository *repo);
diff --git a/src/index.c b/src/index.c
index 362c2c6..f92c48d 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1034,7 +1034,7 @@ int git_index_entry_stage(const git_index_entry *entry)
 
 typedef struct read_tree_data {
 	git_index *index;
-	git_indexer_stats *stats;
+	git_transfer_progress *stats;
 } read_tree_data;
 
 static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *data)
diff --git a/src/indexer.c b/src/indexer.c
index 450d90e..4ebcdc6 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -49,7 +49,7 @@ struct git_indexer_stream {
 	git_vector deltas;
 	unsigned int fanout[256];
 	git_oid hash;
-	git_indexer_progress_callback progress_cb;
+	git_transfer_progress_callback progress_cb;
 	void *progress_payload;
 };
 
@@ -143,7 +143,7 @@ static int cache_cmp(const void *a, const void *b)
 int git_indexer_stream_new(
 		git_indexer_stream **out,
 		const char *prefix,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload)
 {
 	git_indexer_stream *idx;
@@ -281,13 +281,13 @@ on_error:
 	return -1;
 }
 
-static void do_progress_callback(git_indexer_stream *idx, git_indexer_stats *stats)
+static void do_progress_callback(git_indexer_stream *idx, git_transfer_progress *stats)
 {
 	if (!idx->progress_cb) return;
 	idx->progress_cb(stats, idx->progress_payload);
 }
 
-int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats)
+int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_transfer_progress *stats)
 {
 	int error;
 	struct git_pack_header hdr;
@@ -296,7 +296,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 
 	assert(idx && data && stats);
 
-	processed = stats->processed;
+	processed = stats->indexed_objects;
 
 	if (git_filebuf_write(&idx->pack_file, data, size) < 0)
 		return -1;
@@ -338,8 +338,8 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 		if (git_vector_init(&idx->deltas, (unsigned int)(idx->nr_objects / 2), NULL) < 0)
 			return -1;
 
-		memset(stats, 0, sizeof(git_indexer_stats));
-		stats->total = (unsigned int)idx->nr_objects;
+		memset(stats, 0, sizeof(git_transfer_progress));
+		stats->total_objects = (unsigned int)idx->nr_objects;
 		do_progress_callback(idx, stats);
 	}
 
@@ -376,7 +376,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 			if (error < 0)
 				return error;
 
-			stats->received++;
+			stats->received_objects++;
 			do_progress_callback(idx, stats);
 			continue;
 		}
@@ -395,8 +395,8 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
 
 		git__free(obj.data);
 
-		stats->processed = (unsigned int)++processed;
-		stats->received++;
+		stats->indexed_objects = (unsigned int)++processed;
+		stats->received_objects++;
 		do_progress_callback(idx, stats);
 	}
 
@@ -429,7 +429,7 @@ static int index_path_stream(git_buf *path, git_indexer_stream *idx, const char 
 	return git_buf_oom(path) ? -1 : 0;
 }
 
-static int resolve_deltas(git_indexer_stream *idx, git_indexer_stats *stats)
+static int resolve_deltas(git_indexer_stream *idx, git_transfer_progress *stats)
 {
 	unsigned int i;
 	struct delta_info *delta;
@@ -445,14 +445,14 @@ static int resolve_deltas(git_indexer_stream *idx, git_indexer_stats *stats)
 			return -1;
 
 		git__free(obj.data);
-		stats->processed++;
+		stats->indexed_objects++;
 		do_progress_callback(idx, stats);
 	}
 
 	return 0;
 }
 
-int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats)
+int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *stats)
 {
 	git_mwindow *w = NULL;
 	unsigned int i, long_offsets = 0, left;
@@ -473,7 +473,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stat
 		if (resolve_deltas(idx, stats) < 0)
 			return -1;
 
-	if (stats->processed != stats->total) {
+	if (stats->indexed_objects != stats->total_objects) {
 		giterr_set(GITERR_INDEXER, "Indexing error: early EOF");
 		return -1;
 	}
@@ -800,7 +800,7 @@ cleanup:
 	return error;
 }
 
-int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
+int git_indexer_run(git_indexer *idx, git_transfer_progress *stats)
 {
 	git_mwindow_file *mwf;
 	git_off_t off = sizeof(struct git_pack_header);
@@ -815,8 +815,8 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
 	if (error < 0)
 		return error;
 
-	stats->total = (unsigned int)idx->nr_objects;
-	stats->processed = processed = 0;
+	stats->total_objects = (unsigned int)idx->nr_objects;
+	stats->indexed_objects = processed = 0;
 
 	while (processed < idx->nr_objects) {
 		git_rawobj obj;
@@ -886,7 +886,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
 
 		git__free(obj.data);
 
-		stats->processed = ++processed;
+		stats->indexed_objects = ++processed;
 	}
 
 cleanup:
diff --git a/src/remote.c b/src/remote.c
index 662b8cc..3e9a757 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -436,7 +436,7 @@ int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload)
 int git_remote_download(
 		git_remote *remote,
 		git_off_t *bytes,
-		git_indexer_progress_callback progress_cb,
+		git_transfer_progress_callback progress_cb,
 		void *progress_payload)
 {
 	int error;
@@ -707,7 +707,7 @@ void git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callback
 	}
 }
 
-inline const git_indexer_stats* git_remote_stats(git_remote *remote)
+inline const git_transfer_progress* git_remote_stats(git_remote *remote)
 {
 	assert(remote);
 	return &remote->stats;
diff --git a/src/remote.h b/src/remote.h
index 1ba8260..1b382e1 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -25,7 +25,7 @@ struct git_remote {
 	git_transport *transport;
 	git_repository *repo;
 	git_remote_callbacks callbacks;
-	git_indexer_stats stats;
+	git_transfer_progress stats;
 	unsigned int need_pack:1,
 		download_tags:2, /* There are four possible values */
 		check_cert:1;
diff --git a/src/transport.h b/src/transport.h
index 4c944b9..79afae0 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -113,7 +113,7 @@ struct git_transport {
 	/**
 	 * Download the packfile
 	 */
-	int (*download_pack)(struct git_transport *transport, git_repository *repo, git_off_t *bytes, git_indexer_stats *stats);
+	int (*download_pack)(struct git_transport *transport, git_repository *repo, git_off_t *bytes, git_transfer_progress *stats);
 	/**
 	 * Close the connection
 	 */
diff --git a/tests-clar/clone/network.c b/tests-clar/clone/network.c
index 3d78d43..0faaa5c 100644
--- a/tests-clar/clone/network.c
+++ b/tests-clar/clone/network.c
@@ -98,7 +98,7 @@ static void checkout_progress(const char *path, size_t cur, size_t tot, void *pa
 	(*was_called) = true;
 }
 
-static void fetch_progress(const git_indexer_stats *stats, void *payload)
+static void fetch_progress(const git_transfer_progress *stats, void *payload)
 {
 	GIT_UNUSED(stats);
 	bool *was_called = (bool*)payload;
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index 134e8fe..c3fb15e 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -28,7 +28,7 @@ static int update_tips(const char *refname, const git_oid *a, const git_oid *b, 
 	return 0;
 }
 
-static void progress(const git_indexer_stats *stats, void *payload)
+static void progress(const git_transfer_progress *stats, void *payload)
 {
 	GIT_UNUSED(stats);
 	bool *was_called = (bool*)payload;
diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c
index fa7bec1..6d17a70 100644
--- a/tests-clar/pack/packbuilder.c
+++ b/tests-clar/pack/packbuilder.c
@@ -33,7 +33,7 @@ void test_pack_packbuilder__cleanup(void)
 
 void test_pack_packbuilder__create_pack(void)
 {
-	git_indexer_stats stats;
+	git_transfer_progress stats;
 	git_oid oid, *o;
 	unsigned int i;