rugged 1.6.5 → 1.7.1
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_allocator.c +0 -54
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +3 -8
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +26 -1
- data/vendor/libgit2/include/git2/diff.h +41 -3
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +12 -2
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +20 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/src/CMakeLists.txt +34 -11
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +1 -19
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/blame.c +23 -16
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +3 -1
- data/vendor/libgit2/src/libgit2/commit.c +31 -9
- data/vendor/libgit2/src/libgit2/commit_graph.c +110 -43
- data/vendor/libgit2/src/libgit2/commit_graph.h +20 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +12 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config_file.c +14 -8
- data/vendor/libgit2/src/libgit2/describe.c +10 -7
- data/vendor/libgit2/src/libgit2/diff.c +16 -7
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +7 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +36 -15
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -4
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/fetch.c +37 -9
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +325 -125
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +10 -3
- data/vendor/libgit2/src/libgit2/iterator.c +20 -5
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +39 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +66 -37
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +40 -15
- data/vendor/libgit2/src/libgit2/object.h +6 -0
- data/vendor/libgit2/src/libgit2/odb.c +11 -5
- data/vendor/libgit2/src/libgit2/odb_pack.c +16 -3
- data/vendor/libgit2/src/libgit2/oid.c +7 -1
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +19 -12
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +3 -3
- data/vendor/libgit2/src/libgit2/parse.c +7 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +2 -2
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -84
- data/vendor/libgit2/src/libgit2/refdb_fs.c +22 -13
- data/vendor/libgit2/src/libgit2/refs.c +8 -1
- data/vendor/libgit2/src/libgit2/remote.c +15 -6
- data/vendor/libgit2/src/libgit2/remote.h +1 -0
- data/vendor/libgit2/src/libgit2/repository.c +580 -301
- data/vendor/libgit2/src/libgit2/repository.h +17 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revparse.c +1 -4
- data/vendor/libgit2/src/libgit2/revwalk.c +26 -4
- data/vendor/libgit2/src/libgit2/stash.c +9 -8
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +8 -16
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +237 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +7 -2
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +5 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +13 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +33 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +23 -8
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +136 -17
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +154 -47
- data/vendor/libgit2/src/libgit2/transports/ssh.c +3 -3
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +14 -15
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +1 -1
- data/vendor/libgit2/src/libgit2/worktree.c +25 -10
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +1 -1
- data/vendor/libgit2/src/util/futils.c +8 -5
- data/vendor/libgit2/src/util/git2_features.h.in +9 -3
- data/vendor/libgit2/src/util/net.c +308 -157
- data/vendor/libgit2/src/util/net.h +25 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +22 -0
- data/vendor/libgit2/src/util/rand.c +6 -4
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +24 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +29 -23
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -837,6 +837,11 @@ GIT_INLINE(int) server_setup_from_url(
|
|
837
837
|
git_http_server *server,
|
838
838
|
git_net_url *url)
|
839
839
|
{
|
840
|
+
GIT_ASSERT_ARG(url);
|
841
|
+
GIT_ASSERT_ARG(url->scheme);
|
842
|
+
GIT_ASSERT_ARG(url->host);
|
843
|
+
GIT_ASSERT_ARG(url->port);
|
844
|
+
|
840
845
|
if (!server->url.scheme || strcmp(server->url.scheme, url->scheme) ||
|
841
846
|
!server->url.host || strcmp(server->url.host, url->host) ||
|
842
847
|
!server->url.port || strcmp(server->url.port, url->port)) {
|
@@ -295,15 +295,13 @@ static int local_ls(const git_remote_head ***out, size_t *size, git_transport *t
|
|
295
295
|
static int local_negotiate_fetch(
|
296
296
|
git_transport *transport,
|
297
297
|
git_repository *repo,
|
298
|
-
const
|
299
|
-
size_t count)
|
298
|
+
const git_fetch_negotiation *wants)
|
300
299
|
{
|
301
300
|
transport_local *t = (transport_local*)transport;
|
302
301
|
git_remote_head *rhead;
|
303
302
|
unsigned int i;
|
304
303
|
|
305
|
-
GIT_UNUSED(
|
306
|
-
GIT_UNUSED(count);
|
304
|
+
GIT_UNUSED(wants);
|
307
305
|
|
308
306
|
/* Fill in the loids */
|
309
307
|
git_vector_foreach(&t->refs, i, rhead) {
|
@@ -322,6 +320,16 @@ static int local_negotiate_fetch(
|
|
322
320
|
return 0;
|
323
321
|
}
|
324
322
|
|
323
|
+
static int local_shallow_roots(
|
324
|
+
git_oidarray *out,
|
325
|
+
git_transport *transport)
|
326
|
+
{
|
327
|
+
GIT_UNUSED(out);
|
328
|
+
GIT_UNUSED(transport);
|
329
|
+
|
330
|
+
return 0;
|
331
|
+
}
|
332
|
+
|
325
333
|
static int local_push_update_remote_ref(
|
326
334
|
git_repository *remote_repo,
|
327
335
|
const char *lref,
|
@@ -747,6 +755,7 @@ int git_transport_local(git_transport **out, git_remote *owner, void *param)
|
|
747
755
|
t->parent.oid_type = local_oid_type;
|
748
756
|
#endif
|
749
757
|
t->parent.negotiate_fetch = local_negotiate_fetch;
|
758
|
+
t->parent.shallow_roots = local_shallow_roots;
|
750
759
|
t->parent.download_pack = local_download_pack;
|
751
760
|
t->parent.push = local_push;
|
752
761
|
t->parent.close = local_close;
|
@@ -13,30 +13,42 @@
|
|
13
13
|
#include "refspec.h"
|
14
14
|
#include "proxy.h"
|
15
15
|
|
16
|
-
|
16
|
+
int git_smart__recv(transport_smart *t)
|
17
17
|
{
|
18
|
-
|
19
|
-
|
20
|
-
int error;
|
18
|
+
size_t bytes_read;
|
19
|
+
int ret;
|
21
20
|
|
21
|
+
GIT_ASSERT_ARG(t);
|
22
22
|
GIT_ASSERT(t->current_stream);
|
23
23
|
|
24
|
-
|
24
|
+
if (git_staticstr_remain(&t->buffer) == 0) {
|
25
|
+
git_error_set(GIT_ERROR_NET, "out of buffer space");
|
26
|
+
return -1;
|
27
|
+
}
|
25
28
|
|
26
|
-
|
27
|
-
|
29
|
+
ret = t->current_stream->read(t->current_stream,
|
30
|
+
git_staticstr_offset(&t->buffer),
|
31
|
+
git_staticstr_remain(&t->buffer),
|
32
|
+
&bytes_read);
|
28
33
|
|
29
|
-
|
34
|
+
if (ret < 0)
|
35
|
+
return ret;
|
36
|
+
|
37
|
+
GIT_ASSERT(bytes_read <= INT_MAX);
|
38
|
+
GIT_ASSERT(bytes_read <= git_staticstr_remain(&t->buffer));
|
39
|
+
|
40
|
+
git_staticstr_increase(&t->buffer, bytes_read);
|
30
41
|
|
31
42
|
if (t->packetsize_cb && !t->cancelled.val) {
|
32
|
-
|
33
|
-
|
43
|
+
ret = t->packetsize_cb(bytes_read, t->packetsize_payload);
|
44
|
+
|
45
|
+
if (ret) {
|
34
46
|
git_atomic32_set(&t->cancelled, 1);
|
35
47
|
return GIT_EUSER;
|
36
48
|
}
|
37
49
|
}
|
38
50
|
|
39
|
-
return (int)
|
51
|
+
return (int)bytes_read;
|
40
52
|
}
|
41
53
|
|
42
54
|
GIT_INLINE(int) git_smart__reset_stream(transport_smart *t, bool close_subtransport)
|
@@ -155,8 +167,6 @@ static int git_smart__connect(
|
|
155
167
|
/* Save off the current stream (i.e. socket) that we are working with */
|
156
168
|
t->current_stream = stream;
|
157
169
|
|
158
|
-
gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t);
|
159
|
-
|
160
170
|
/* 2 flushes for RPC; 1 for stateful */
|
161
171
|
if ((error = git_smart__store_refs(t, t->rpc ? 2 : 1)) < 0)
|
162
172
|
return error;
|
@@ -313,8 +323,6 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
|
|
313
323
|
if ((error = stream->write(stream, (const char *)data, len)) < 0)
|
314
324
|
return error;
|
315
325
|
|
316
|
-
gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t);
|
317
|
-
|
318
326
|
return 0;
|
319
327
|
}
|
320
328
|
|
@@ -339,8 +347,6 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
|
|
339
347
|
/* Save off the current stream (i.e. socket) that we are working with */
|
340
348
|
t->current_stream = *stream;
|
341
349
|
|
342
|
-
gitno_buffer_setup_callback(&t->buffer, t->buffer_data, sizeof(t->buffer_data), git_smart__recv_cb, t);
|
343
|
-
|
344
350
|
return 0;
|
345
351
|
}
|
346
352
|
|
@@ -416,6 +422,8 @@ static void git_smart__free(git_transport *transport)
|
|
416
422
|
|
417
423
|
git_remote_connect_options_dispose(&t->connect_opts);
|
418
424
|
|
425
|
+
git_array_dispose(t->shallow_roots);
|
426
|
+
|
419
427
|
git__free(t->caps.object_format);
|
420
428
|
git__free(t->caps.agent);
|
421
429
|
git__free(t);
|
@@ -490,6 +498,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
|
|
490
498
|
t->parent.close = git_smart__close;
|
491
499
|
t->parent.free = git_smart__free;
|
492
500
|
t->parent.negotiate_fetch = git_smart__negotiate_fetch;
|
501
|
+
t->parent.shallow_roots = git_smart__shallow_roots;
|
493
502
|
t->parent.download_pack = git_smart__download_pack;
|
494
503
|
t->parent.push = git_smart__push;
|
495
504
|
t->parent.ls = git_smart__ls;
|
@@ -499,20 +508,17 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
|
|
499
508
|
t->owner = owner;
|
500
509
|
t->rpc = definition->rpc;
|
501
510
|
|
502
|
-
if (git_vector_init(&t->refs, 16, ref_name_cmp) < 0
|
511
|
+
if (git_vector_init(&t->refs, 16, ref_name_cmp) < 0 ||
|
512
|
+
git_vector_init(&t->heads, 16, ref_name_cmp) < 0 ||
|
513
|
+
definition->callback(&t->wrapped, &t->parent, definition->param) < 0) {
|
514
|
+
git_vector_free(&t->refs);
|
515
|
+
git_vector_free(&t->heads);
|
516
|
+
t->wrapped->free(t->wrapped);
|
503
517
|
git__free(t);
|
504
518
|
return -1;
|
505
519
|
}
|
506
520
|
|
507
|
-
|
508
|
-
git__free(t);
|
509
|
-
return -1;
|
510
|
-
}
|
511
|
-
|
512
|
-
if (definition->callback(&t->wrapped, &t->parent, definition->param) < 0) {
|
513
|
-
git__free(t);
|
514
|
-
return -1;
|
515
|
-
}
|
521
|
+
git_staticstr_init(&t->buffer, GIT_SMART_BUFFER_SIZE);
|
516
522
|
|
517
523
|
*out = (git_transport *) t;
|
518
524
|
return 0;
|
@@ -11,11 +11,14 @@
|
|
11
11
|
|
12
12
|
#include "git2.h"
|
13
13
|
#include "vector.h"
|
14
|
-
#include "netops.h"
|
15
14
|
#include "push.h"
|
16
15
|
#include "str.h"
|
16
|
+
#include "oidarray.h"
|
17
|
+
#include "staticstr.h"
|
17
18
|
#include "git2/sys/transport.h"
|
18
19
|
|
20
|
+
#define GIT_SMART_BUFFER_SIZE 65536
|
21
|
+
|
19
22
|
#define GIT_SIDE_BAND_DATA 1
|
20
23
|
#define GIT_SIDE_BAND_PROGRESS 2
|
21
24
|
#define GIT_SIDE_BAND_ERROR 3
|
@@ -32,6 +35,7 @@
|
|
32
35
|
#define GIT_CAP_SYMREF "symref"
|
33
36
|
#define GIT_CAP_WANT_TIP_SHA1 "allow-tip-sha1-in-want"
|
34
37
|
#define GIT_CAP_WANT_REACHABLE_SHA1 "allow-reachable-sha1-in-want"
|
38
|
+
#define GIT_CAP_SHALLOW "shallow"
|
35
39
|
#define GIT_CAP_OBJECT_FORMAT "object-format="
|
36
40
|
#define GIT_CAP_AGENT "agent="
|
37
41
|
|
@@ -50,7 +54,9 @@ typedef enum {
|
|
50
54
|
GIT_PKT_PROGRESS,
|
51
55
|
GIT_PKT_OK,
|
52
56
|
GIT_PKT_NG,
|
53
|
-
GIT_PKT_UNPACK
|
57
|
+
GIT_PKT_UNPACK,
|
58
|
+
GIT_PKT_SHALLOW,
|
59
|
+
GIT_PKT_UNSHALLOW
|
54
60
|
} git_pkt_type;
|
55
61
|
|
56
62
|
/* Used for multi_ack and multi_ack_detailed */
|
@@ -122,6 +128,11 @@ typedef struct {
|
|
122
128
|
int unpack_ok;
|
123
129
|
} git_pkt_unpack;
|
124
130
|
|
131
|
+
typedef struct {
|
132
|
+
git_pkt_type type;
|
133
|
+
git_oid oid;
|
134
|
+
} git_pkt_shallow;
|
135
|
+
|
125
136
|
typedef struct transport_smart_caps {
|
126
137
|
unsigned int common:1,
|
127
138
|
ofs_delta:1,
|
@@ -134,7 +145,8 @@ typedef struct transport_smart_caps {
|
|
134
145
|
report_status:1,
|
135
146
|
thin_pack:1,
|
136
147
|
want_tip_sha1:1,
|
137
|
-
want_reachable_sha1:1
|
148
|
+
want_reachable_sha1:1,
|
149
|
+
shallow:1;
|
138
150
|
char *object_format;
|
139
151
|
char *agent;
|
140
152
|
} transport_smart_caps;
|
@@ -153,14 +165,14 @@ typedef struct {
|
|
153
165
|
git_vector refs;
|
154
166
|
git_vector heads;
|
155
167
|
git_vector common;
|
168
|
+
git_array_oid_t shallow_roots;
|
156
169
|
git_atomic32 cancelled;
|
157
170
|
packetsize_cb packetsize_cb;
|
158
171
|
void *packetsize_payload;
|
159
172
|
unsigned rpc : 1,
|
160
173
|
have_refs : 1,
|
161
174
|
connected : 1;
|
162
|
-
|
163
|
-
char buffer_data[65536];
|
175
|
+
git_staticstr_with_size(GIT_SMART_BUFFER_SIZE) buffer;
|
164
176
|
} transport_smart;
|
165
177
|
|
166
178
|
/* smart_protocol.c */
|
@@ -171,8 +183,9 @@ int git_smart__push(git_transport *transport, git_push *push);
|
|
171
183
|
int git_smart__negotiate_fetch(
|
172
184
|
git_transport *transport,
|
173
185
|
git_repository *repo,
|
174
|
-
const
|
175
|
-
|
186
|
+
const git_fetch_negotiation *wants);
|
187
|
+
|
188
|
+
int git_smart__shallow_roots(git_oidarray *out, git_transport *transport);
|
176
189
|
|
177
190
|
int git_smart__download_pack(
|
178
191
|
git_transport *transport,
|
@@ -180,6 +193,8 @@ int git_smart__download_pack(
|
|
180
193
|
git_indexer_progress *stats);
|
181
194
|
|
182
195
|
/* smart.c */
|
196
|
+
int git_smart__recv(transport_smart *t);
|
197
|
+
|
183
198
|
int git_smart__negotiation_step(git_transport *transport, void *data, size_t len);
|
184
199
|
int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **out);
|
185
200
|
|
@@ -195,7 +210,7 @@ int git_pkt_parse_line(git_pkt **head, const char **endptr, const char *line, si
|
|
195
210
|
int git_pkt_buffer_flush(git_str *buf);
|
196
211
|
int git_pkt_send_flush(GIT_SOCKET s);
|
197
212
|
int git_pkt_buffer_done(git_str *buf);
|
198
|
-
int git_pkt_buffer_wants(const
|
213
|
+
int git_pkt_buffer_wants(const git_fetch_negotiation *wants, transport_smart_caps *caps, git_str *buf);
|
199
214
|
int git_pkt_buffer_have(git_oid *oid, git_str *buf);
|
200
215
|
void git_pkt_free(git_pkt *pkt);
|
201
216
|
|
@@ -9,7 +9,6 @@
|
|
9
9
|
|
10
10
|
#include "smart.h"
|
11
11
|
#include "util.h"
|
12
|
-
#include "netops.h"
|
13
12
|
#include "posix.h"
|
14
13
|
#include "str.h"
|
15
14
|
#include "oid.h"
|
@@ -44,9 +43,16 @@ static int flush_pkt(git_pkt **out)
|
|
44
43
|
}
|
45
44
|
|
46
45
|
/* the rest of the line will be useful for multi_ack and multi_ack_detailed */
|
47
|
-
static int ack_pkt(
|
46
|
+
static int ack_pkt(
|
47
|
+
git_pkt **out,
|
48
|
+
const char *line,
|
49
|
+
size_t len,
|
50
|
+
git_pkt_parse_data *data)
|
48
51
|
{
|
49
52
|
git_pkt_ack *pkt;
|
53
|
+
size_t oid_hexsize = git_oid_hexsize(data->oid_type);
|
54
|
+
|
55
|
+
GIT_ASSERT(data && data->oid_type);
|
50
56
|
|
51
57
|
pkt = git__calloc(1, sizeof(git_pkt_ack));
|
52
58
|
GIT_ERROR_CHECK_ALLOC(pkt);
|
@@ -57,11 +63,11 @@ static int ack_pkt(git_pkt **out, const char *line, size_t len)
|
|
57
63
|
line += 4;
|
58
64
|
len -= 4;
|
59
65
|
|
60
|
-
if (len <
|
61
|
-
git_oid__fromstr(&pkt->oid, line,
|
66
|
+
if (len < oid_hexsize ||
|
67
|
+
git_oid__fromstr(&pkt->oid, line, data->oid_type) < 0)
|
62
68
|
goto out_err;
|
63
|
-
line +=
|
64
|
-
len -=
|
69
|
+
line += oid_hexsize;
|
70
|
+
len -= oid_hexsize;
|
65
71
|
|
66
72
|
if (len && line[0] == ' ') {
|
67
73
|
line++;
|
@@ -226,8 +232,7 @@ static int set_data(
|
|
226
232
|
|
227
233
|
GIT_ASSERT_ARG(data);
|
228
234
|
|
229
|
-
if ((caps = memchr(line, '\0', len)) != NULL
|
230
|
-
len > (size_t)((caps - line) + 1)) {
|
235
|
+
if ((caps = memchr(line, '\0', len)) != NULL) {
|
231
236
|
caps++;
|
232
237
|
|
233
238
|
if (strncmp(caps, "object-format=", CONST_STRLEN("object-format=")) == 0)
|
@@ -437,6 +442,84 @@ static int unpack_pkt(git_pkt **out, const char *line, size_t len)
|
|
437
442
|
return 0;
|
438
443
|
}
|
439
444
|
|
445
|
+
static int shallow_pkt(
|
446
|
+
git_pkt **out,
|
447
|
+
const char *line,
|
448
|
+
size_t len,
|
449
|
+
git_pkt_parse_data *data)
|
450
|
+
{
|
451
|
+
git_pkt_shallow *pkt;
|
452
|
+
size_t oid_hexsize = git_oid_hexsize(data->oid_type);
|
453
|
+
|
454
|
+
GIT_ASSERT(data && data->oid_type);
|
455
|
+
|
456
|
+
pkt = git__calloc(1, sizeof(git_pkt_shallow));
|
457
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
458
|
+
|
459
|
+
pkt->type = GIT_PKT_SHALLOW;
|
460
|
+
|
461
|
+
if (git__prefixncmp(line, len, "shallow "))
|
462
|
+
goto out_err;
|
463
|
+
|
464
|
+
line += 8;
|
465
|
+
len -= 8;
|
466
|
+
|
467
|
+
if (len != oid_hexsize)
|
468
|
+
goto out_err;
|
469
|
+
|
470
|
+
git_oid__fromstr(&pkt->oid, line, data->oid_type);
|
471
|
+
line += oid_hexsize + 1;
|
472
|
+
len -= oid_hexsize + 1;
|
473
|
+
|
474
|
+
*out = (git_pkt *)pkt;
|
475
|
+
|
476
|
+
return 0;
|
477
|
+
|
478
|
+
out_err:
|
479
|
+
git_error_set(GIT_ERROR_NET, "invalid packet line");
|
480
|
+
git__free(pkt);
|
481
|
+
return -1;
|
482
|
+
}
|
483
|
+
|
484
|
+
static int unshallow_pkt(
|
485
|
+
git_pkt **out,
|
486
|
+
const char *line,
|
487
|
+
size_t len,
|
488
|
+
git_pkt_parse_data *data)
|
489
|
+
{
|
490
|
+
git_pkt_shallow *pkt;
|
491
|
+
size_t oid_hexsize = git_oid_hexsize(data->oid_type);
|
492
|
+
|
493
|
+
GIT_ASSERT(data && data->oid_type);
|
494
|
+
|
495
|
+
pkt = git__calloc(1, sizeof(git_pkt_shallow));
|
496
|
+
GIT_ERROR_CHECK_ALLOC(pkt);
|
497
|
+
|
498
|
+
pkt->type = GIT_PKT_UNSHALLOW;
|
499
|
+
|
500
|
+
if (git__prefixncmp(line, len, "unshallow "))
|
501
|
+
goto out_err;
|
502
|
+
|
503
|
+
line += 10;
|
504
|
+
len -= 10;
|
505
|
+
|
506
|
+
if (len != oid_hexsize)
|
507
|
+
goto out_err;
|
508
|
+
|
509
|
+
git_oid__fromstr(&pkt->oid, line, data->oid_type);
|
510
|
+
line += oid_hexsize + 1;
|
511
|
+
len -= oid_hexsize + 1;
|
512
|
+
|
513
|
+
*out = (git_pkt *) pkt;
|
514
|
+
|
515
|
+
return 0;
|
516
|
+
|
517
|
+
out_err:
|
518
|
+
git_error_set(GIT_ERROR_NET, "invalid packet line");
|
519
|
+
git__free(pkt);
|
520
|
+
return -1;
|
521
|
+
}
|
522
|
+
|
440
523
|
static int parse_len(size_t *out, const char *line, size_t linelen)
|
441
524
|
{
|
442
525
|
char num[PKT_LEN_SIZE + 1];
|
@@ -554,7 +637,7 @@ int git_pkt_parse_line(
|
|
554
637
|
else if (*line == GIT_SIDE_BAND_ERROR)
|
555
638
|
error = sideband_error_pkt(pkt, line, len);
|
556
639
|
else if (!git__prefixncmp(line, len, "ACK"))
|
557
|
-
error = ack_pkt(pkt, line, len);
|
640
|
+
error = ack_pkt(pkt, line, len, data);
|
558
641
|
else if (!git__prefixncmp(line, len, "NAK"))
|
559
642
|
error = nak_pkt(pkt);
|
560
643
|
else if (!git__prefixncmp(line, len, "ERR"))
|
@@ -567,6 +650,10 @@ int git_pkt_parse_line(
|
|
567
650
|
error = ng_pkt(pkt, line, len);
|
568
651
|
else if (!git__prefixncmp(line, len, "unpack"))
|
569
652
|
error = unpack_pkt(pkt, line, len);
|
653
|
+
else if (!git__prefixcmp(line, "shallow"))
|
654
|
+
error = shallow_pkt(pkt, line, len, data);
|
655
|
+
else if (!git__prefixcmp(line, "unshallow"))
|
656
|
+
error = unshallow_pkt(pkt, line, len, data);
|
570
657
|
else
|
571
658
|
error = ref_pkt(pkt, line, len, data);
|
572
659
|
|
@@ -639,6 +726,9 @@ static int buffer_want_with_caps(
|
|
639
726
|
if (caps->ofs_delta)
|
640
727
|
git_str_puts(&str, GIT_CAP_OFS_DELTA " ");
|
641
728
|
|
729
|
+
if (caps->shallow)
|
730
|
+
git_str_puts(&str, GIT_CAP_SHALLOW " ");
|
731
|
+
|
642
732
|
if (git_str_oom(&str))
|
643
733
|
return -1;
|
644
734
|
|
@@ -669,8 +759,7 @@ static int buffer_want_with_caps(
|
|
669
759
|
*/
|
670
760
|
|
671
761
|
int git_pkt_buffer_wants(
|
672
|
-
const
|
673
|
-
size_t count,
|
762
|
+
const git_fetch_negotiation *wants,
|
674
763
|
transport_smart_caps *caps,
|
675
764
|
git_str *buf)
|
676
765
|
{
|
@@ -680,7 +769,7 @@ int git_pkt_buffer_wants(
|
|
680
769
|
size_t oid_hexsize, want_len, i = 0;
|
681
770
|
|
682
771
|
#ifdef GIT_EXPERIMENTAL_SHA256
|
683
|
-
oid_type =
|
772
|
+
oid_type = wants->refs_len > 0 ? wants->refs[0]->oid.type : GIT_OID_SHA1;
|
684
773
|
#else
|
685
774
|
oid_type = GIT_OID_SHA1;
|
686
775
|
#endif
|
@@ -691,20 +780,20 @@ int git_pkt_buffer_wants(
|
|
691
780
|
oid_hexsize + 1 /* LF */;
|
692
781
|
|
693
782
|
if (caps->common) {
|
694
|
-
for (; i <
|
695
|
-
head = refs[i];
|
783
|
+
for (; i < wants->refs_len; ++i) {
|
784
|
+
head = wants->refs[i];
|
696
785
|
if (!head->local)
|
697
786
|
break;
|
698
787
|
}
|
699
788
|
|
700
|
-
if (buffer_want_with_caps(refs[i], caps, oid_type, buf) < 0)
|
789
|
+
if (buffer_want_with_caps(wants->refs[i], caps, oid_type, buf) < 0)
|
701
790
|
return -1;
|
702
791
|
|
703
792
|
i++;
|
704
793
|
}
|
705
794
|
|
706
|
-
for (; i <
|
707
|
-
head = refs[i];
|
795
|
+
for (; i < wants->refs_len; ++i) {
|
796
|
+
head = wants->refs[i];
|
708
797
|
|
709
798
|
if (head->local)
|
710
799
|
continue;
|
@@ -719,6 +808,36 @@ int git_pkt_buffer_wants(
|
|
719
808
|
return -1;
|
720
809
|
}
|
721
810
|
|
811
|
+
/* Tell the server about our shallow objects */
|
812
|
+
for (i = 0; i < wants->shallow_roots_len; i++) {
|
813
|
+
char oid[GIT_OID_MAX_HEXSIZE + 1];
|
814
|
+
git_str shallow_buf = GIT_STR_INIT;
|
815
|
+
|
816
|
+
git_oid_tostr(oid, GIT_OID_MAX_HEXSIZE + 1, &wants->shallow_roots[i]);
|
817
|
+
git_str_puts(&shallow_buf, "shallow ");
|
818
|
+
git_str_puts(&shallow_buf, oid);
|
819
|
+
git_str_putc(&shallow_buf, '\n');
|
820
|
+
|
821
|
+
git_str_printf(buf, "%04x%s", (unsigned int)git_str_len(&shallow_buf) + 4, git_str_cstr(&shallow_buf));
|
822
|
+
|
823
|
+
git_str_dispose(&shallow_buf);
|
824
|
+
|
825
|
+
if (git_str_oom(buf))
|
826
|
+
return -1;
|
827
|
+
}
|
828
|
+
|
829
|
+
if (wants->depth > 0) {
|
830
|
+
git_str deepen_buf = GIT_STR_INIT;
|
831
|
+
|
832
|
+
git_str_printf(&deepen_buf, "deepen %d\n", wants->depth);
|
833
|
+
git_str_printf(buf,"%04x%s", (unsigned int)git_str_len(&deepen_buf) + 4, git_str_cstr(&deepen_buf));
|
834
|
+
|
835
|
+
git_str_dispose(&deepen_buf);
|
836
|
+
|
837
|
+
if (git_str_oom(buf))
|
838
|
+
return -1;
|
839
|
+
}
|
840
|
+
|
722
841
|
return git_pkt_buffer_flush(buf);
|
723
842
|
}
|
724
843
|
|