rugged 0.23.0b2 → 0.23.0b4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/rugged_blob.c +39 -0
- data/ext/rugged/rugged_diff.c +7 -3
- data/ext/rugged/rugged_index.c +2 -2
- data/ext/rugged/rugged_remote.c +27 -148
- data/ext/rugged/rugged_remote_collection.c +134 -12
- data/ext/rugged/rugged_repo.c +74 -5
- data/ext/rugged/rugged_submodule.c +18 -208
- data/ext/rugged/rugged_submodule_collection.c +148 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +33 -25
- data/vendor/libgit2/deps/winhttp/winhttp.def +29 -29
- data/vendor/libgit2/include/git2.h +1 -1
- data/vendor/libgit2/include/git2/blob.h +4 -6
- data/vendor/libgit2/include/git2/checkout.h +10 -1
- data/vendor/libgit2/include/git2/clone.h +6 -7
- data/vendor/libgit2/include/git2/commit.h +11 -0
- data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
- data/vendor/libgit2/include/git2/describe.h +1 -1
- data/vendor/libgit2/include/git2/diff.h +68 -11
- data/vendor/libgit2/include/git2/errors.h +4 -1
- data/vendor/libgit2/include/git2/filter.h +16 -0
- data/vendor/libgit2/include/git2/index.h +38 -11
- data/vendor/libgit2/include/git2/odb.h +1 -1
- data/vendor/libgit2/include/git2/odb_backend.h +2 -2
- data/vendor/libgit2/include/git2/remote.h +300 -207
- data/vendor/libgit2/include/git2/reset.h +1 -0
- data/vendor/libgit2/include/git2/stash.h +135 -4
- data/vendor/libgit2/include/git2/status.h +1 -0
- data/vendor/libgit2/include/git2/submodule.h +46 -75
- data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +2 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -21
- data/vendor/libgit2/include/git2/transport.h +27 -0
- data/vendor/libgit2/include/git2/types.h +20 -10
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/libgit2.pc.in +4 -2
- data/vendor/libgit2/src/attr.c +2 -1
- data/vendor/libgit2/src/attr_file.c +18 -37
- data/vendor/libgit2/src/blame.c +2 -2
- data/vendor/libgit2/src/blob.c +4 -3
- data/vendor/libgit2/src/branch.c +6 -3
- data/vendor/libgit2/src/buf_text.c +4 -6
- data/vendor/libgit2/src/buf_text.h +1 -2
- data/vendor/libgit2/src/buffer.c +8 -6
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +1 -0
- data/vendor/libgit2/src/checkout.c +34 -20
- data/vendor/libgit2/src/clone.c +29 -29
- data/vendor/libgit2/src/commit.c +65 -0
- data/vendor/libgit2/src/common.h +5 -0
- data/vendor/libgit2/src/config.c +20 -0
- data/vendor/libgit2/src/config.h +6 -0
- data/vendor/libgit2/src/config_file.c +2 -2
- data/vendor/libgit2/src/crlf.c +39 -17
- data/vendor/libgit2/src/curl_stream.c +257 -0
- data/vendor/libgit2/src/curl_stream.h +14 -0
- data/vendor/libgit2/src/diff.c +223 -88
- data/vendor/libgit2/src/diff.h +21 -1
- data/vendor/libgit2/src/diff_file.c +23 -13
- data/vendor/libgit2/src/diff_file.h +4 -2
- data/vendor/libgit2/src/diff_patch.c +266 -71
- data/vendor/libgit2/src/diff_patch.h +36 -0
- data/vendor/libgit2/src/diff_print.c +156 -126
- data/vendor/libgit2/src/diff_tform.c +32 -54
- data/vendor/libgit2/src/fetch.c +27 -10
- data/vendor/libgit2/src/fetch.h +2 -2
- data/vendor/libgit2/src/filebuf.c +1 -1
- data/vendor/libgit2/src/fileops.c +6 -2
- data/vendor/libgit2/src/filter.c +28 -7
- data/vendor/libgit2/src/fnmatch.c +5 -5
- data/vendor/libgit2/src/global.c +16 -0
- data/vendor/libgit2/src/ident.c +2 -2
- data/vendor/libgit2/src/ignore.c +1 -0
- data/vendor/libgit2/src/index.c +338 -80
- data/vendor/libgit2/src/index.h +4 -1
- data/vendor/libgit2/src/indexer.c +19 -5
- data/vendor/libgit2/src/iterator.c +118 -11
- data/vendor/libgit2/src/iterator.h +25 -0
- data/vendor/libgit2/src/merge.c +96 -106
- data/vendor/libgit2/src/merge.h +14 -4
- data/vendor/libgit2/src/netops.c +3 -3
- data/vendor/libgit2/src/odb.c +17 -9
- data/vendor/libgit2/src/odb.h +1 -1
- data/vendor/libgit2/src/odb_loose.c +2 -2
- data/vendor/libgit2/src/odb_pack.c +1 -1
- data/vendor/libgit2/src/openssl_stream.c +118 -27
- data/vendor/libgit2/src/pack-objects.c +28 -0
- data/vendor/libgit2/src/pack-objects.h +1 -0
- data/vendor/libgit2/src/pack.c +18 -10
- data/vendor/libgit2/src/path.c +16 -11
- data/vendor/libgit2/src/path.h +1 -1
- data/vendor/libgit2/src/push.c +26 -42
- data/vendor/libgit2/src/push.h +2 -34
- data/vendor/libgit2/src/rebase.c +1 -1
- data/vendor/libgit2/src/refs.c +1 -1
- data/vendor/libgit2/src/refspec.c +6 -0
- data/vendor/libgit2/src/remote.c +381 -274
- data/vendor/libgit2/src/remote.h +0 -4
- data/vendor/libgit2/src/repository.c +33 -12
- data/vendor/libgit2/src/repository.h +0 -1
- data/vendor/libgit2/src/reset.c +1 -0
- data/vendor/libgit2/src/stash.c +439 -17
- data/vendor/libgit2/src/status.c +6 -0
- data/vendor/libgit2/src/stransport_stream.c +58 -21
- data/vendor/libgit2/src/stream.h +15 -0
- data/vendor/libgit2/src/submodule.c +410 -664
- data/vendor/libgit2/src/submodule.h +0 -24
- data/vendor/libgit2/src/transaction.c +1 -0
- data/vendor/libgit2/src/transports/cred.c +55 -1
- data/vendor/libgit2/src/transports/http.c +18 -2
- data/vendor/libgit2/src/transports/local.c +60 -59
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -11
- data/vendor/libgit2/src/transports/ssh.c +46 -7
- data/vendor/libgit2/src/unix/posix.h +4 -0
- data/vendor/libgit2/src/util.c +9 -9
- data/vendor/libgit2/src/util.h +9 -0
- data/vendor/libgit2/src/win32/posix.h +3 -0
- data/vendor/libgit2/src/win32/posix_w32.c +38 -0
- data/vendor/libgit2/src/win32/w32_util.h +10 -0
- metadata +4 -3
- data/vendor/libgit2/include/git2/push.h +0 -94
@@ -99,23 +99,6 @@ struct git_submodule {
|
|
99
99
|
git_oid wd_oid;
|
100
100
|
};
|
101
101
|
|
102
|
-
/**
|
103
|
-
* The git_submodule_cache stores known submodules along with timestamps,
|
104
|
-
* etc. about when they were loaded
|
105
|
-
*/
|
106
|
-
typedef struct {
|
107
|
-
git_repository *repo;
|
108
|
-
git_strmap *submodules;
|
109
|
-
git_mutex lock;
|
110
|
-
|
111
|
-
/* cache invalidation data */
|
112
|
-
git_oid head_id;
|
113
|
-
git_futils_filestamp index_stamp;
|
114
|
-
git_buf gitmodules_path;
|
115
|
-
git_futils_filestamp gitmodules_stamp;
|
116
|
-
git_futils_filestamp config_stamp;
|
117
|
-
} git_submodule_cache;
|
118
|
-
|
119
102
|
/* Force revalidation of submodule data cache (alloc as needed) */
|
120
103
|
extern int git_submodule_cache_refresh(git_repository *repo);
|
121
104
|
|
@@ -137,9 +120,6 @@ enum {
|
|
137
120
|
#define GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(S) \
|
138
121
|
((S) & ~(0xFFFFFFFFu << 20))
|
139
122
|
|
140
|
-
/* Internal submodule check does not attempt to refresh cached data */
|
141
|
-
extern bool git_submodule__is_submodule(git_repository *repo, const char *name);
|
142
|
-
|
143
123
|
/* Internal lookup does not attempt to refresh cached data */
|
144
124
|
extern int git_submodule__lookup(
|
145
125
|
git_submodule **out, git_repository *repo, const char *path);
|
@@ -163,8 +143,4 @@ extern int git_submodule_parse_ignore(
|
|
163
143
|
extern int git_submodule_parse_update(
|
164
144
|
git_submodule_update_t *out, const char *value);
|
165
145
|
|
166
|
-
extern const char *git_submodule_ignore_to_str(git_submodule_ignore_t);
|
167
|
-
extern const char *git_submodule_update_to_str(git_submodule_update_t);
|
168
|
-
extern const char *git_submodule_recurse_to_str(git_submodule_recurse_t);
|
169
|
-
|
170
146
|
#endif
|
@@ -9,6 +9,14 @@
|
|
9
9
|
#include "smart.h"
|
10
10
|
#include "git2/cred_helpers.h"
|
11
11
|
|
12
|
+
static int git_cred_ssh_key_type_new(
|
13
|
+
git_cred **cred,
|
14
|
+
const char *username,
|
15
|
+
const char *publickey,
|
16
|
+
const char *privatekey,
|
17
|
+
const char *passphrase,
|
18
|
+
git_credtype_t credtype);
|
19
|
+
|
12
20
|
int git_cred_has_username(git_cred *cred)
|
13
21
|
{
|
14
22
|
if (cred->credtype == GIT_CREDTYPE_DEFAULT)
|
@@ -31,6 +39,7 @@ const char *git_cred__username(git_cred *cred)
|
|
31
39
|
return c->username;
|
32
40
|
}
|
33
41
|
case GIT_CREDTYPE_SSH_KEY:
|
42
|
+
case GIT_CREDTYPE_SSH_MEMORY:
|
34
43
|
{
|
35
44
|
git_cred_ssh_key *c = (git_cred_ssh_key *) cred;
|
36
45
|
return c->username;
|
@@ -174,6 +183,51 @@ int git_cred_ssh_key_new(
|
|
174
183
|
const char *publickey,
|
175
184
|
const char *privatekey,
|
176
185
|
const char *passphrase)
|
186
|
+
{
|
187
|
+
return git_cred_ssh_key_type_new(
|
188
|
+
cred,
|
189
|
+
username,
|
190
|
+
publickey,
|
191
|
+
privatekey,
|
192
|
+
passphrase,
|
193
|
+
GIT_CREDTYPE_SSH_KEY);
|
194
|
+
}
|
195
|
+
|
196
|
+
int git_cred_ssh_key_memory_new(
|
197
|
+
git_cred **cred,
|
198
|
+
const char *username,
|
199
|
+
const char *publickey,
|
200
|
+
const char *privatekey,
|
201
|
+
const char *passphrase)
|
202
|
+
{
|
203
|
+
#ifdef GIT_SSH_MEMORY_CREDENTIALS
|
204
|
+
return git_cred_ssh_key_type_new(
|
205
|
+
cred,
|
206
|
+
username,
|
207
|
+
publickey,
|
208
|
+
privatekey,
|
209
|
+
passphrase,
|
210
|
+
GIT_CREDTYPE_SSH_MEMORY);
|
211
|
+
#else
|
212
|
+
GIT_UNUSED(cred);
|
213
|
+
GIT_UNUSED(username);
|
214
|
+
GIT_UNUSED(publickey);
|
215
|
+
GIT_UNUSED(privatekey);
|
216
|
+
GIT_UNUSED(passphrase);
|
217
|
+
|
218
|
+
giterr_set(GITERR_INVALID,
|
219
|
+
"This version of libgit2 was not built with ssh memory credentials.");
|
220
|
+
return -1;
|
221
|
+
#endif
|
222
|
+
}
|
223
|
+
|
224
|
+
static int git_cred_ssh_key_type_new(
|
225
|
+
git_cred **cred,
|
226
|
+
const char *username,
|
227
|
+
const char *publickey,
|
228
|
+
const char *privatekey,
|
229
|
+
const char *passphrase,
|
230
|
+
git_credtype_t credtype)
|
177
231
|
{
|
178
232
|
git_cred_ssh_key *c;
|
179
233
|
|
@@ -182,7 +236,7 @@ int git_cred_ssh_key_new(
|
|
182
236
|
c = git__calloc(1, sizeof(git_cred_ssh_key));
|
183
237
|
GITERR_CHECK_ALLOC(c);
|
184
238
|
|
185
|
-
c->parent.credtype =
|
239
|
+
c->parent.credtype = credtype;
|
186
240
|
c->parent.free = ssh_key_free;
|
187
241
|
|
188
242
|
c->username = git__strdup(username);
|
@@ -10,11 +10,13 @@
|
|
10
10
|
#include "http_parser.h"
|
11
11
|
#include "buffer.h"
|
12
12
|
#include "netops.h"
|
13
|
+
#include "remote.h"
|
13
14
|
#include "smart.h"
|
14
15
|
#include "auth.h"
|
15
16
|
#include "auth_negotiate.h"
|
16
17
|
#include "tls_stream.h"
|
17
18
|
#include "socket_stream.h"
|
19
|
+
#include "curl_stream.h"
|
18
20
|
|
19
21
|
git_http_auth_scheme auth_schemes[] = {
|
20
22
|
{ GIT_AUTHTYPE_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate },
|
@@ -70,7 +72,7 @@ typedef struct {
|
|
70
72
|
gitno_buffer parse_buffer;
|
71
73
|
git_buf parse_header_name;
|
72
74
|
git_buf parse_header_value;
|
73
|
-
char parse_buffer_data[
|
75
|
+
char parse_buffer_data[NETIO_BUFSIZE];
|
74
76
|
char *content_type;
|
75
77
|
char *location;
|
76
78
|
git_vector www_authenticate;
|
@@ -532,6 +534,7 @@ static int write_chunk(git_stream *io, const char *buffer, size_t len)
|
|
532
534
|
static int http_connect(http_subtransport *t)
|
533
535
|
{
|
534
536
|
int error;
|
537
|
+
char *proxy_url;
|
535
538
|
|
536
539
|
if (t->connected &&
|
537
540
|
http_should_keep_alive(&t->parser) &&
|
@@ -547,7 +550,11 @@ static int http_connect(http_subtransport *t)
|
|
547
550
|
if (t->connection_data.use_ssl) {
|
548
551
|
error = git_tls_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
|
549
552
|
} else {
|
553
|
+
#ifdef GIT_CURL
|
554
|
+
error = git_curl_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
|
555
|
+
#else
|
550
556
|
error = git_socket_stream_new(&t->io, t->connection_data.host, t->connection_data.port);
|
557
|
+
#endif
|
551
558
|
}
|
552
559
|
|
553
560
|
if (error < 0)
|
@@ -555,9 +562,18 @@ static int http_connect(http_subtransport *t)
|
|
555
562
|
|
556
563
|
GITERR_CHECK_VERSION(t->io, GIT_STREAM_VERSION, "git_stream");
|
557
564
|
|
565
|
+
if (git_stream_supports_proxy(t->io) &&
|
566
|
+
!git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url)) {
|
567
|
+
error = git_stream_set_proxy(t->io, proxy_url);
|
568
|
+
git__free(proxy_url);
|
569
|
+
|
570
|
+
if (error < 0)
|
571
|
+
return error;
|
572
|
+
}
|
573
|
+
|
558
574
|
error = git_stream_connect(t->io);
|
559
575
|
|
560
|
-
#if defined(GIT_OPENSSL) || defined(GIT_SECURE_TRANSPORT)
|
576
|
+
#if defined(GIT_OPENSSL) || defined(GIT_SECURE_TRANSPORT) || defined(GIT_CURL)
|
561
577
|
if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL &&
|
562
578
|
git_stream_is_encrypted(t->io)) {
|
563
579
|
git_cert *cert;
|
@@ -16,7 +16,6 @@
|
|
16
16
|
#include "git2/pack.h"
|
17
17
|
#include "git2/commit.h"
|
18
18
|
#include "git2/revparse.h"
|
19
|
-
#include "git2/push.h"
|
20
19
|
#include "pack-objects.h"
|
21
20
|
#include "refs.h"
|
22
21
|
#include "posix.h"
|
@@ -290,50 +289,6 @@ static int local_negotiate_fetch(
|
|
290
289
|
return 0;
|
291
290
|
}
|
292
291
|
|
293
|
-
static int local_push_copy_object(
|
294
|
-
git_odb *local_odb,
|
295
|
-
git_odb *remote_odb,
|
296
|
-
git_pobject *obj)
|
297
|
-
{
|
298
|
-
int error = 0;
|
299
|
-
git_odb_object *odb_obj = NULL;
|
300
|
-
git_odb_stream *odb_stream;
|
301
|
-
size_t odb_obj_size;
|
302
|
-
git_otype odb_obj_type;
|
303
|
-
git_oid remote_odb_obj_oid;
|
304
|
-
|
305
|
-
/* Object already exists in the remote ODB; do nothing and return 0*/
|
306
|
-
if (git_odb_exists(remote_odb, &obj->id))
|
307
|
-
return 0;
|
308
|
-
|
309
|
-
if ((error = git_odb_read(&odb_obj, local_odb, &obj->id)) < 0)
|
310
|
-
return error;
|
311
|
-
|
312
|
-
odb_obj_size = git_odb_object_size(odb_obj);
|
313
|
-
odb_obj_type = git_odb_object_type(odb_obj);
|
314
|
-
|
315
|
-
if ((error = git_odb_open_wstream(&odb_stream, remote_odb,
|
316
|
-
odb_obj_size, odb_obj_type)) < 0)
|
317
|
-
goto on_error;
|
318
|
-
|
319
|
-
if (git_odb_stream_write(odb_stream, (char *)git_odb_object_data(odb_obj),
|
320
|
-
odb_obj_size) < 0 ||
|
321
|
-
git_odb_stream_finalize_write(&remote_odb_obj_oid, odb_stream) < 0) {
|
322
|
-
error = -1;
|
323
|
-
} else if (git_oid__cmp(&obj->id, &remote_odb_obj_oid) != 0) {
|
324
|
-
giterr_set(GITERR_ODB, "Error when writing object to remote odb "
|
325
|
-
"during local push operation. Remote odb object oid does not "
|
326
|
-
"match local oid.");
|
327
|
-
error = -1;
|
328
|
-
}
|
329
|
-
|
330
|
-
git_odb_stream_free(odb_stream);
|
331
|
-
|
332
|
-
on_error:
|
333
|
-
git_odb_object_free(odb_obj);
|
334
|
-
return error;
|
335
|
-
}
|
336
|
-
|
337
292
|
static int local_push_update_remote_ref(
|
338
293
|
git_repository *remote_repo,
|
339
294
|
const char *lref,
|
@@ -364,22 +319,33 @@ static int local_push_update_remote_ref(
|
|
364
319
|
return error;
|
365
320
|
}
|
366
321
|
|
322
|
+
static int transfer_to_push_transfer(const git_transfer_progress *stats, void *payload)
|
323
|
+
{
|
324
|
+
const git_remote_callbacks *cbs = payload;
|
325
|
+
|
326
|
+
if (!cbs || !cbs->push_transfer_progress)
|
327
|
+
return 0;
|
328
|
+
|
329
|
+
return cbs->push_transfer_progress(stats->received_objects, stats->total_objects, stats->received_bytes,
|
330
|
+
cbs->payload);
|
331
|
+
}
|
332
|
+
|
367
333
|
static int local_push(
|
368
334
|
git_transport *transport,
|
369
|
-
git_push *push
|
335
|
+
git_push *push,
|
336
|
+
const git_remote_callbacks *cbs)
|
370
337
|
{
|
371
338
|
transport_local *t = (transport_local *)transport;
|
372
|
-
git_odb *remote_odb = NULL;
|
373
|
-
git_odb *local_odb = NULL;
|
374
339
|
git_repository *remote_repo = NULL;
|
375
340
|
push_spec *spec;
|
376
341
|
char *url = NULL;
|
377
342
|
const char *path;
|
378
|
-
git_buf buf = GIT_BUF_INIT;
|
343
|
+
git_buf buf = GIT_BUF_INIT, odb_path = GIT_BUF_INIT;
|
379
344
|
int error;
|
380
|
-
unsigned int i;
|
381
345
|
size_t j;
|
382
346
|
|
347
|
+
GIT_UNUSED(cbs);
|
348
|
+
|
383
349
|
/* 'push->remote->url' may be a url or path; convert to a path */
|
384
350
|
if ((error = git_path_from_url_or_path(&buf, push->remote->url)) < 0) {
|
385
351
|
git_buf_free(&buf);
|
@@ -396,22 +362,24 @@ static int local_push(
|
|
396
362
|
|
397
363
|
/* We don't currently support pushing locally to non-bare repos. Proper
|
398
364
|
non-bare repo push support would require checking configs to see if
|
399
|
-
we should override the default 'don't let this happen' behavior
|
365
|
+
we should override the default 'don't let this happen' behavior.
|
366
|
+
|
367
|
+
Note that this is only an issue when pushing to the current branch,
|
368
|
+
but we forbid all pushes just in case */
|
400
369
|
if (!remote_repo->is_bare) {
|
401
370
|
error = GIT_EBAREREPO;
|
402
371
|
giterr_set(GITERR_INVALID, "Local push doesn't (yet) support pushing to non-bare repos.");
|
403
372
|
goto on_error;
|
404
373
|
}
|
405
374
|
|
406
|
-
if ((error =
|
407
|
-
(error = git_repository_odb__weakptr(&local_odb, push->repo)) < 0)
|
375
|
+
if ((error = git_buf_joinpath(&odb_path, git_repository_path(remote_repo), "objects/pack")) < 0)
|
408
376
|
goto on_error;
|
409
377
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
378
|
+
error = git_packbuilder_write(push->pb, odb_path.ptr, 0, transfer_to_push_transfer, (void *) cbs);
|
379
|
+
git_buf_free(&odb_path);
|
380
|
+
|
381
|
+
if (error < 0)
|
382
|
+
goto on_error;
|
415
383
|
|
416
384
|
push->unpack_ok = 1;
|
417
385
|
|
@@ -471,7 +439,7 @@ static int local_push(
|
|
471
439
|
|
472
440
|
if (!url || t->parent.close(&t->parent) < 0 ||
|
473
441
|
t->parent.connect(&t->parent, url,
|
474
|
-
|
442
|
+
NULL, NULL, GIT_DIRECTION_PUSH, flags))
|
475
443
|
goto on_error;
|
476
444
|
}
|
477
445
|
|
@@ -500,6 +468,37 @@ static int foreach_cb(void *buf, size_t len, void *payload)
|
|
500
468
|
}
|
501
469
|
|
502
470
|
static const char *counting_objects_fmt = "Counting objects %d\r";
|
471
|
+
static const char *compressing_objects_fmt = "Compressing objects: %.0f%% (%d/%d)";
|
472
|
+
|
473
|
+
static int local_counting(int stage, unsigned int current, unsigned int total, void *payload)
|
474
|
+
{
|
475
|
+
git_buf progress_info = GIT_BUF_INIT;
|
476
|
+
transport_local *t = payload;
|
477
|
+
int error;
|
478
|
+
|
479
|
+
if (!t->progress_cb)
|
480
|
+
return 0;
|
481
|
+
|
482
|
+
if (stage == GIT_PACKBUILDER_ADDING_OBJECTS) {
|
483
|
+
git_buf_printf(&progress_info, counting_objects_fmt, current);
|
484
|
+
} else if (stage == GIT_PACKBUILDER_DELTAFICATION) {
|
485
|
+
float perc = (((float) current) / total) * 100;
|
486
|
+
git_buf_printf(&progress_info, compressing_objects_fmt, perc, current, total);
|
487
|
+
if (current == total)
|
488
|
+
git_buf_printf(&progress_info, ", done\n");
|
489
|
+
else
|
490
|
+
git_buf_putc(&progress_info, '\r');
|
491
|
+
|
492
|
+
}
|
493
|
+
|
494
|
+
if (git_buf_oom(&progress_info))
|
495
|
+
return -1;
|
496
|
+
|
497
|
+
error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload);
|
498
|
+
git_buf_free(&progress_info);
|
499
|
+
|
500
|
+
return error;
|
501
|
+
}
|
503
502
|
|
504
503
|
static int local_download_pack(
|
505
504
|
git_transport *transport,
|
@@ -525,6 +524,8 @@ static int local_download_pack(
|
|
525
524
|
if ((error = git_packbuilder_new(&pack, t->repo)) < 0)
|
526
525
|
goto cleanup;
|
527
526
|
|
527
|
+
git_packbuilder_set_callbacks(pack, local_counting, t);
|
528
|
+
|
528
529
|
stats->total_objects = 0;
|
529
530
|
stats->indexed_objects = 0;
|
530
531
|
stats->received_objects = 0;
|
@@ -158,7 +158,7 @@ typedef struct {
|
|
158
158
|
/* smart_protocol.c */
|
159
159
|
int git_smart__store_refs(transport_smart *t, int flushes);
|
160
160
|
int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs);
|
161
|
-
int git_smart__push(git_transport *transport, git_push *push);
|
161
|
+
int git_smart__push(git_transport *transport, git_push *push, const git_remote_callbacks *cbs);
|
162
162
|
|
163
163
|
int git_smart__negotiate_fetch(
|
164
164
|
git_transport *transport,
|
@@ -51,8 +51,8 @@ int git_smart__store_refs(transport_smart *t, int flushes)
|
|
51
51
|
return recvd;
|
52
52
|
|
53
53
|
if (recvd == 0 && !flush) {
|
54
|
-
giterr_set(GITERR_NET, "
|
55
|
-
return
|
54
|
+
giterr_set(GITERR_NET, "early EOF");
|
55
|
+
return GIT_EEOF;
|
56
56
|
}
|
57
57
|
|
58
58
|
continue;
|
@@ -769,8 +769,8 @@ static int parse_report(transport_smart *transport, git_push *push)
|
|
769
769
|
return recvd;
|
770
770
|
|
771
771
|
if (recvd == 0) {
|
772
|
-
giterr_set(GITERR_NET, "
|
773
|
-
return
|
772
|
+
giterr_set(GITERR_NET, "early EOF");
|
773
|
+
return GIT_EEOF;
|
774
774
|
}
|
775
775
|
continue;
|
776
776
|
}
|
@@ -946,7 +946,7 @@ static int stream_thunk(void *buf, size_t size, void *data)
|
|
946
946
|
return error;
|
947
947
|
}
|
948
948
|
|
949
|
-
int git_smart__push(git_transport *transport, git_push *push)
|
949
|
+
int git_smart__push(git_transport *transport, git_push *push, const git_remote_callbacks *cbs)
|
950
950
|
{
|
951
951
|
transport_smart *t = (transport_smart *)transport;
|
952
952
|
struct push_packbuilder_payload packbuilder_payload = {0};
|
@@ -957,9 +957,9 @@ int git_smart__push(git_transport *transport, git_push *push)
|
|
957
957
|
|
958
958
|
packbuilder_payload.pb = push->pb;
|
959
959
|
|
960
|
-
if (
|
961
|
-
packbuilder_payload.cb =
|
962
|
-
packbuilder_payload.cb_payload =
|
960
|
+
if (cbs && cbs->transfer_progress) {
|
961
|
+
packbuilder_payload.cb = cbs->push_transfer_progress;
|
962
|
+
packbuilder_payload.cb_payload = cbs->payload;
|
963
963
|
}
|
964
964
|
|
965
965
|
#ifdef PUSH_DEBUG
|
@@ -1010,12 +1010,12 @@ int git_smart__push(git_transport *transport, git_push *push)
|
|
1010
1010
|
goto done;
|
1011
1011
|
|
1012
1012
|
/* If progress is being reported write the final report */
|
1013
|
-
if (
|
1014
|
-
error =
|
1013
|
+
if (cbs && cbs->push_transfer_progress) {
|
1014
|
+
error = cbs->push_transfer_progress(
|
1015
1015
|
push->pb->nr_written,
|
1016
1016
|
push->pb->nr_objects,
|
1017
1017
|
packbuilder_payload.last_bytes,
|
1018
|
-
|
1018
|
+
cbs->payload);
|
1019
1019
|
|
1020
1020
|
if (error < 0)
|
1021
1021
|
goto done;
|