rugged 1.5.0.1 → 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/extconf.rb +2 -2
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +2 -0
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +1 -0
- data/ext/rugged/rugged_repo.c +5 -2
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +7 -8
- data/vendor/libgit2/COPYING +30 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -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/ntlmclient/CMakeLists.txt +2 -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 +38 -6
- data/vendor/libgit2/include/git2/deprecated.h +6 -0
- data/vendor/libgit2/include/git2/diff.h +42 -4
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/indexer.h +29 -0
- data/vendor/libgit2/include/git2/object.h +28 -2
- data/vendor/libgit2/include/git2/odb.h +58 -7
- data/vendor/libgit2/include/git2/odb_backend.h +106 -18
- data/vendor/libgit2/include/git2/oid.h +116 -16
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +32 -3
- data/vendor/libgit2/include/git2/stash.h +60 -6
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- 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/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +32 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +34 -17
- data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
- data/vendor/libgit2/src/cli/opt.c +1 -1
- 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 +25 -34
- 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/attr_file.c +1 -1
- data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
- data/vendor/libgit2/src/libgit2/blame.c +23 -14
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/blob.c +4 -2
- data/vendor/libgit2/src/libgit2/blob.h +2 -2
- 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 +34 -3
- data/vendor/libgit2/src/libgit2/commit.c +78 -21
- data/vendor/libgit2/src/libgit2/commit.h +25 -7
- data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
- data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +6 -3
- data/vendor/libgit2/src/libgit2/config_file.c +16 -10
- data/vendor/libgit2/src/libgit2/describe.c +11 -8
- data/vendor/libgit2/src/libgit2/diff.c +19 -6
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
- 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 -0
- 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/experimental.h.in +13 -0
- data/vendor/libgit2/src/libgit2/fetch.c +38 -13
- 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 +327 -123
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +116 -46
- data/vendor/libgit2/src/libgit2/iterator.c +21 -4
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +58 -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 +68 -38
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +118 -29
- data/vendor/libgit2/src/libgit2/object.h +17 -2
- data/vendor/libgit2/src/libgit2/odb.c +224 -55
- data/vendor/libgit2/src/libgit2/odb.h +43 -4
- data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
- data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
- data/vendor/libgit2/src/libgit2/oid.c +141 -77
- data/vendor/libgit2/src/libgit2/oid.h +183 -9
- 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 +31 -13
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +93 -70
- data/vendor/libgit2/src/libgit2/pack.h +29 -15
- data/vendor/libgit2/src/libgit2/parse.c +8 -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 +13 -3
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -83
- data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
- data/vendor/libgit2/src/libgit2/reflog.c +7 -5
- data/vendor/libgit2/src/libgit2/reflog.h +1 -2
- data/vendor/libgit2/src/libgit2/refs.c +9 -0
- data/vendor/libgit2/src/libgit2/remote.c +47 -37
- data/vendor/libgit2/src/libgit2/remote.h +41 -0
- data/vendor/libgit2/src/libgit2/repository.c +784 -329
- data/vendor/libgit2/src/libgit2/repository.h +26 -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 +23 -7
- data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
- data/vendor/libgit2/src/libgit2/stash.c +209 -33
- data/vendor/libgit2/src/libgit2/strarray.c +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
- 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 +240 -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.c +6 -2
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
- data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
- data/vendor/libgit2/src/libgit2/tag.c +29 -10
- data/vendor/libgit2/src/libgit2/tag.h +2 -2
- 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 +15 -9
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
- data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
- data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
- 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 +23 -17
- data/vendor/libgit2/src/libgit2/tree.h +2 -2
- data/vendor/libgit2/src/libgit2/worktree.c +30 -10
- data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
- 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 +2 -2
- data/vendor/libgit2/src/util/futils.c +8 -8
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
- data/vendor/libgit2/src/util/git2_util.h +2 -2
- data/vendor/libgit2/src/util/hash/openssl.c +4 -3
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
- data/vendor/libgit2/src/util/hash.h +13 -0
- data/vendor/libgit2/src/util/net.c +492 -87
- data/vendor/libgit2/src/util/net.h +32 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +24 -0
- data/vendor/libgit2/src/util/rand.c +10 -4
- data/vendor/libgit2/src/util/regexp.c +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/thread.h +20 -19
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +25 -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 +34 -26
- 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/util/win32/findfile.c +0 -286
- data/vendor/libgit2/src/util/win32/findfile.h +0 -22
- /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
@@ -27,11 +27,11 @@ bool git_smart__ofs_delta_enabled = true;
|
|
27
27
|
|
28
28
|
int git_smart__store_refs(transport_smart *t, int flushes)
|
29
29
|
{
|
30
|
-
gitno_buffer *buf = &t->buffer;
|
31
30
|
git_vector *refs = &t->refs;
|
32
31
|
int error, flush = 0, recvd;
|
33
32
|
const char *line_end = NULL;
|
34
33
|
git_pkt *pkt = NULL;
|
34
|
+
git_pkt_parse_data pkt_parse_data = { 0 };
|
35
35
|
size_t i;
|
36
36
|
|
37
37
|
/* Clear existing refs in case git_remote_connect() is called again
|
@@ -44,8 +44,10 @@ int git_smart__store_refs(transport_smart *t, int flushes)
|
|
44
44
|
pkt = NULL;
|
45
45
|
|
46
46
|
do {
|
47
|
-
if (
|
48
|
-
error = git_pkt_parse_line(&pkt, &line_end,
|
47
|
+
if (t->buffer.len > 0)
|
48
|
+
error = git_pkt_parse_line(&pkt, &line_end,
|
49
|
+
t->buffer.data, t->buffer.len,
|
50
|
+
&pkt_parse_data);
|
49
51
|
else
|
50
52
|
error = GIT_EBUFS;
|
51
53
|
|
@@ -53,7 +55,7 @@ int git_smart__store_refs(transport_smart *t, int flushes)
|
|
53
55
|
return error;
|
54
56
|
|
55
57
|
if (error == GIT_EBUFS) {
|
56
|
-
if ((recvd =
|
58
|
+
if ((recvd = git_smart__recv(t)) < 0)
|
57
59
|
return recvd;
|
58
60
|
|
59
61
|
if (recvd == 0) {
|
@@ -64,8 +66,7 @@ int git_smart__store_refs(transport_smart *t, int flushes)
|
|
64
66
|
continue;
|
65
67
|
}
|
66
68
|
|
67
|
-
|
68
|
-
return -1;
|
69
|
+
git_staticstr_consume(&t->buffer, line_end);
|
69
70
|
|
70
71
|
if (pkt->type == GIT_PKT_ERR) {
|
71
72
|
git_error_set(GIT_ERROR_NET, "remote error: %s", ((git_pkt_err *)pkt)->error);
|
@@ -133,9 +134,12 @@ on_invalid:
|
|
133
134
|
return -1;
|
134
135
|
}
|
135
136
|
|
136
|
-
int git_smart__detect_caps(
|
137
|
+
int git_smart__detect_caps(
|
138
|
+
git_pkt_ref *pkt,
|
139
|
+
transport_smart_caps *caps,
|
140
|
+
git_vector *symrefs)
|
137
141
|
{
|
138
|
-
const char *ptr;
|
142
|
+
const char *ptr, *start;
|
139
143
|
|
140
144
|
/* No refs or capabilities, odd but not a problem */
|
141
145
|
if (pkt == NULL || pkt->capabilities == NULL)
|
@@ -207,13 +211,41 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec
|
|
207
211
|
|
208
212
|
if (!git__prefixcmp(ptr, GIT_CAP_WANT_TIP_SHA1)) {
|
209
213
|
caps->common = caps->want_tip_sha1 = 1;
|
210
|
-
ptr += strlen(
|
214
|
+
ptr += strlen(GIT_CAP_WANT_TIP_SHA1);
|
211
215
|
continue;
|
212
216
|
}
|
213
217
|
|
214
218
|
if (!git__prefixcmp(ptr, GIT_CAP_WANT_REACHABLE_SHA1)) {
|
215
219
|
caps->common = caps->want_reachable_sha1 = 1;
|
216
|
-
ptr += strlen(
|
220
|
+
ptr += strlen(GIT_CAP_WANT_REACHABLE_SHA1);
|
221
|
+
continue;
|
222
|
+
}
|
223
|
+
|
224
|
+
if (!git__prefixcmp(ptr, GIT_CAP_OBJECT_FORMAT)) {
|
225
|
+
ptr += strlen(GIT_CAP_OBJECT_FORMAT);
|
226
|
+
|
227
|
+
start = ptr;
|
228
|
+
ptr = strchr(ptr, ' ');
|
229
|
+
|
230
|
+
if ((caps->object_format = git__strndup(start, (ptr - start))) == NULL)
|
231
|
+
return -1;
|
232
|
+
continue;
|
233
|
+
}
|
234
|
+
|
235
|
+
if (!git__prefixcmp(ptr, GIT_CAP_AGENT)) {
|
236
|
+
ptr += strlen(GIT_CAP_AGENT);
|
237
|
+
|
238
|
+
start = ptr;
|
239
|
+
ptr = strchr(ptr, ' ');
|
240
|
+
|
241
|
+
if ((caps->agent = git__strndup(start, (ptr - start))) == NULL)
|
242
|
+
return -1;
|
243
|
+
continue;
|
244
|
+
}
|
245
|
+
|
246
|
+
if (!git__prefixcmp(ptr, GIT_CAP_SHALLOW)) {
|
247
|
+
caps->common = caps->shallow = 1;
|
248
|
+
ptr += strlen(GIT_CAP_SHALLOW);
|
217
249
|
continue;
|
218
250
|
}
|
219
251
|
|
@@ -224,15 +256,23 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec
|
|
224
256
|
return 0;
|
225
257
|
}
|
226
258
|
|
227
|
-
static int recv_pkt(
|
259
|
+
static int recv_pkt(
|
260
|
+
git_pkt **out_pkt,
|
261
|
+
git_pkt_type *out_type,
|
262
|
+
transport_smart *t)
|
228
263
|
{
|
229
|
-
const char *ptr =
|
264
|
+
const char *ptr = t->buffer.data, *line_end = ptr;
|
230
265
|
git_pkt *pkt = NULL;
|
266
|
+
git_pkt_parse_data pkt_parse_data = { 0 };
|
231
267
|
int error = 0, ret;
|
232
268
|
|
269
|
+
pkt_parse_data.oid_type = t->owner->repo->oid_type;
|
270
|
+
pkt_parse_data.seen_capabilities = 1;
|
271
|
+
|
233
272
|
do {
|
234
|
-
if (
|
235
|
-
error = git_pkt_parse_line(&pkt, &line_end, ptr,
|
273
|
+
if (t->buffer.len > 0)
|
274
|
+
error = git_pkt_parse_line(&pkt, &line_end, ptr,
|
275
|
+
t->buffer.len, &pkt_parse_data);
|
236
276
|
else
|
237
277
|
error = GIT_EBUFS;
|
238
278
|
|
@@ -242,7 +282,7 @@ static int recv_pkt(git_pkt **out_pkt, git_pkt_type *out_type, gitno_buffer *buf
|
|
242
282
|
if (error < 0 && error != GIT_EBUFS)
|
243
283
|
return error;
|
244
284
|
|
245
|
-
if ((ret =
|
285
|
+
if ((ret = git_smart__recv(t)) < 0) {
|
246
286
|
return ret;
|
247
287
|
} else if (ret == 0) {
|
248
288
|
git_error_set(GIT_ERROR_NET, "early EOF");
|
@@ -250,8 +290,7 @@ static int recv_pkt(git_pkt **out_pkt, git_pkt_type *out_type, gitno_buffer *buf
|
|
250
290
|
}
|
251
291
|
} while (error);
|
252
292
|
|
253
|
-
|
254
|
-
return -1;
|
293
|
+
git_staticstr_consume(&t->buffer, line_end);
|
255
294
|
|
256
295
|
if (out_type != NULL)
|
257
296
|
*out_type = pkt->type;
|
@@ -266,11 +305,10 @@ static int recv_pkt(git_pkt **out_pkt, git_pkt_type *out_type, gitno_buffer *buf
|
|
266
305
|
static int store_common(transport_smart *t)
|
267
306
|
{
|
268
307
|
git_pkt *pkt = NULL;
|
269
|
-
gitno_buffer *buf = &t->buffer;
|
270
308
|
int error;
|
271
309
|
|
272
310
|
do {
|
273
|
-
if ((error = recv_pkt(&pkt, NULL,
|
311
|
+
if ((error = recv_pkt(&pkt, NULL, t)) < 0)
|
274
312
|
return error;
|
275
313
|
|
276
314
|
if (pkt->type != GIT_PKT_ACK) {
|
@@ -287,7 +325,7 @@ static int store_common(transport_smart *t)
|
|
287
325
|
return 0;
|
288
326
|
}
|
289
327
|
|
290
|
-
static int wait_while_ack(
|
328
|
+
static int wait_while_ack(transport_smart *t)
|
291
329
|
{
|
292
330
|
int error;
|
293
331
|
git_pkt *pkt = NULL;
|
@@ -296,7 +334,7 @@ static int wait_while_ack(gitno_buffer *buf)
|
|
296
334
|
while (1) {
|
297
335
|
git_pkt_free(pkt);
|
298
336
|
|
299
|
-
if ((error = recv_pkt(&pkt, NULL,
|
337
|
+
if ((error = recv_pkt(&pkt, NULL, t)) < 0)
|
300
338
|
return error;
|
301
339
|
|
302
340
|
if (pkt->type == GIT_PKT_NAK)
|
@@ -317,11 +355,51 @@ static int wait_while_ack(gitno_buffer *buf)
|
|
317
355
|
return 0;
|
318
356
|
}
|
319
357
|
|
320
|
-
int
|
358
|
+
static int cap_not_sup_err(const char *cap_name)
|
359
|
+
{
|
360
|
+
git_error_set(GIT_ERROR_NET, "server doesn't support %s", cap_name);
|
361
|
+
return GIT_EINVALID;
|
362
|
+
}
|
363
|
+
|
364
|
+
/* Disables server capabilities we're not interested in */
|
365
|
+
static int setup_caps(
|
366
|
+
transport_smart_caps *caps,
|
367
|
+
const git_fetch_negotiation *wants)
|
368
|
+
{
|
369
|
+
if (wants->depth > 0) {
|
370
|
+
if (!caps->shallow)
|
371
|
+
return cap_not_sup_err(GIT_CAP_SHALLOW);
|
372
|
+
} else {
|
373
|
+
caps->shallow = 0;
|
374
|
+
}
|
375
|
+
|
376
|
+
return 0;
|
377
|
+
}
|
378
|
+
|
379
|
+
static int setup_shallow_roots(
|
380
|
+
git_array_oid_t *out,
|
381
|
+
const git_fetch_negotiation *wants)
|
382
|
+
{
|
383
|
+
git_array_clear(*out);
|
384
|
+
|
385
|
+
if (wants->shallow_roots_len > 0) {
|
386
|
+
git_array_init_to_size(*out, wants->shallow_roots_len);
|
387
|
+
GIT_ERROR_CHECK_ALLOC(out->ptr);
|
388
|
+
|
389
|
+
memcpy(out->ptr, wants->shallow_roots,
|
390
|
+
sizeof(git_oid) * wants->shallow_roots_len);
|
391
|
+
}
|
392
|
+
|
393
|
+
return 0;
|
394
|
+
}
|
395
|
+
|
396
|
+
int git_smart__negotiate_fetch(
|
397
|
+
git_transport *transport,
|
398
|
+
git_repository *repo,
|
399
|
+
const git_fetch_negotiation *wants)
|
321
400
|
{
|
322
401
|
transport_smart *t = (transport_smart *)transport;
|
323
402
|
git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT;
|
324
|
-
gitno_buffer *buf = &t->buffer;
|
325
403
|
git_str data = GIT_STR_INIT;
|
326
404
|
git_revwalk *walk = NULL;
|
327
405
|
int error = -1;
|
@@ -329,7 +407,11 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
329
407
|
unsigned int i;
|
330
408
|
git_oid oid;
|
331
409
|
|
332
|
-
if ((error =
|
410
|
+
if ((error = setup_caps(&t->caps, wants)) < 0 ||
|
411
|
+
(error = setup_shallow_roots(&t->shallow_roots, wants)) < 0)
|
412
|
+
return error;
|
413
|
+
|
414
|
+
if ((error = git_pkt_buffer_wants(wants, &t->caps, &data)) < 0)
|
333
415
|
return error;
|
334
416
|
|
335
417
|
if ((error = git_revwalk_new(&walk, repo)) < 0)
|
@@ -339,6 +421,37 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
339
421
|
if ((error = git_revwalk__push_glob(walk, "refs/*", &opts)) < 0)
|
340
422
|
goto on_error;
|
341
423
|
|
424
|
+
if (wants->depth > 0) {
|
425
|
+
git_pkt_shallow *pkt;
|
426
|
+
|
427
|
+
if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0)
|
428
|
+
goto on_error;
|
429
|
+
|
430
|
+
while ((error = recv_pkt((git_pkt **)&pkt, NULL, t)) == 0) {
|
431
|
+
bool complete = false;
|
432
|
+
|
433
|
+
if (pkt->type == GIT_PKT_SHALLOW) {
|
434
|
+
error = git_oidarray__add(&t->shallow_roots, &pkt->oid);
|
435
|
+
} else if (pkt->type == GIT_PKT_UNSHALLOW) {
|
436
|
+
git_oidarray__remove(&t->shallow_roots, &pkt->oid);
|
437
|
+
} else if (pkt->type == GIT_PKT_FLUSH) {
|
438
|
+
/* Server is done, stop processing shallow oids */
|
439
|
+
complete = true;
|
440
|
+
} else {
|
441
|
+
git_error_set(GIT_ERROR_NET, "unexpected packet type");
|
442
|
+
error = -1;
|
443
|
+
}
|
444
|
+
|
445
|
+
git_pkt_free((git_pkt *) pkt);
|
446
|
+
|
447
|
+
if (complete || error < 0)
|
448
|
+
break;
|
449
|
+
}
|
450
|
+
|
451
|
+
if (error < 0)
|
452
|
+
goto on_error;
|
453
|
+
}
|
454
|
+
|
342
455
|
/*
|
343
456
|
* Our support for ACK extensions is simply to parse them. On
|
344
457
|
* the first ACK we will accept that as enough common
|
@@ -379,7 +492,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
379
492
|
if ((error = store_common(t)) < 0)
|
380
493
|
goto on_error;
|
381
494
|
} else {
|
382
|
-
if ((error = recv_pkt(NULL, &pkt_type,
|
495
|
+
if ((error = recv_pkt(NULL, &pkt_type, t)) < 0)
|
383
496
|
goto on_error;
|
384
497
|
|
385
498
|
if (pkt_type == GIT_PKT_ACK) {
|
@@ -401,7 +514,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
401
514
|
git_pkt_ack *pkt;
|
402
515
|
unsigned int j;
|
403
516
|
|
404
|
-
if ((error = git_pkt_buffer_wants(wants,
|
517
|
+
if ((error = git_pkt_buffer_wants(wants, &t->caps, &data)) < 0)
|
405
518
|
goto on_error;
|
406
519
|
|
407
520
|
git_vector_foreach(&t->common, j, pkt) {
|
@@ -421,7 +534,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
421
534
|
git_pkt_ack *pkt;
|
422
535
|
unsigned int j;
|
423
536
|
|
424
|
-
if ((error = git_pkt_buffer_wants(wants,
|
537
|
+
if ((error = git_pkt_buffer_wants(wants, &t->caps, &data)) < 0)
|
425
538
|
goto on_error;
|
426
539
|
|
427
540
|
git_vector_foreach(&t->common, j, pkt) {
|
@@ -439,10 +552,11 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
439
552
|
goto on_error;
|
440
553
|
|
441
554
|
if (t->cancelled.val) {
|
442
|
-
git_error_set(GIT_ERROR_NET, "
|
555
|
+
git_error_set(GIT_ERROR_NET, "the fetch was cancelled");
|
443
556
|
error = GIT_EUSER;
|
444
557
|
goto on_error;
|
445
558
|
}
|
559
|
+
|
446
560
|
if ((error = git_smart__negotiation_step(&t->parent, data.ptr, data.size)) < 0)
|
447
561
|
goto on_error;
|
448
562
|
|
@@ -451,7 +565,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
451
565
|
|
452
566
|
/* Now let's eat up whatever the server gives us */
|
453
567
|
if (!t->caps.multi_ack && !t->caps.multi_ack_detailed) {
|
454
|
-
if ((error = recv_pkt(NULL, &pkt_type,
|
568
|
+
if ((error = recv_pkt(NULL, &pkt_type, t)) < 0)
|
455
569
|
return error;
|
456
570
|
|
457
571
|
if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {
|
@@ -459,7 +573,7 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
|
|
459
573
|
return -1;
|
460
574
|
}
|
461
575
|
} else {
|
462
|
-
error = wait_while_ack(
|
576
|
+
error = wait_while_ack(t);
|
463
577
|
}
|
464
578
|
|
465
579
|
return error;
|
@@ -470,7 +584,29 @@ on_error:
|
|
470
584
|
return error;
|
471
585
|
}
|
472
586
|
|
473
|
-
|
587
|
+
int git_smart__shallow_roots(git_oidarray *out, git_transport *transport)
|
588
|
+
{
|
589
|
+
transport_smart *t = (transport_smart *)transport;
|
590
|
+
size_t len;
|
591
|
+
|
592
|
+
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&len, t->shallow_roots.size, sizeof(git_oid));
|
593
|
+
|
594
|
+
out->count = t->shallow_roots.size;
|
595
|
+
|
596
|
+
if (len) {
|
597
|
+
out->ids = git__malloc(len);
|
598
|
+
memcpy(out->ids, t->shallow_roots.ptr, len);
|
599
|
+
} else {
|
600
|
+
out->ids = NULL;
|
601
|
+
}
|
602
|
+
|
603
|
+
return 0;
|
604
|
+
}
|
605
|
+
|
606
|
+
static int no_sideband(
|
607
|
+
transport_smart *t,
|
608
|
+
struct git_odb_writepack *writepack,
|
609
|
+
git_indexer_progress *stats)
|
474
610
|
{
|
475
611
|
int recvd;
|
476
612
|
|
@@ -480,12 +616,12 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
|
|
480
616
|
return GIT_EUSER;
|
481
617
|
}
|
482
618
|
|
483
|
-
if (writepack->append(writepack,
|
619
|
+
if (writepack->append(writepack, t->buffer.data, t->buffer.len, stats) < 0)
|
484
620
|
return -1;
|
485
621
|
|
486
|
-
|
622
|
+
git_staticstr_clear(&t->buffer);
|
487
623
|
|
488
|
-
if ((recvd =
|
624
|
+
if ((recvd = git_smart__recv(t)) < 0)
|
489
625
|
return recvd;
|
490
626
|
} while(recvd > 0);
|
491
627
|
|
@@ -527,7 +663,6 @@ int git_smart__download_pack(
|
|
527
663
|
git_indexer_progress *stats)
|
528
664
|
{
|
529
665
|
transport_smart *t = (transport_smart *)transport;
|
530
|
-
gitno_buffer *buf = &t->buffer;
|
531
666
|
git_odb *odb;
|
532
667
|
struct git_odb_writepack *writepack = NULL;
|
533
668
|
int error = 0;
|
@@ -546,9 +681,10 @@ int git_smart__download_pack(
|
|
546
681
|
t->packetsize_payload = &npp;
|
547
682
|
|
548
683
|
/* We might have something in the buffer already from negotiate_fetch */
|
549
|
-
if (t->buffer.
|
550
|
-
if (t->packetsize_cb(t->buffer.
|
684
|
+
if (t->buffer.len > 0 && !t->cancelled.val) {
|
685
|
+
if (t->packetsize_cb(t->buffer.len, t->packetsize_payload))
|
551
686
|
git_atomic32_set(&t->cancelled, 1);
|
687
|
+
}
|
552
688
|
}
|
553
689
|
|
554
690
|
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
|
@@ -561,7 +697,7 @@ int git_smart__download_pack(
|
|
561
697
|
* check which one belongs there.
|
562
698
|
*/
|
563
699
|
if (!t->caps.side_band && !t->caps.side_band_64k) {
|
564
|
-
error = no_sideband(t, writepack,
|
700
|
+
error = no_sideband(t, writepack, stats);
|
565
701
|
goto done;
|
566
702
|
}
|
567
703
|
|
@@ -575,7 +711,7 @@ int git_smart__download_pack(
|
|
575
711
|
goto done;
|
576
712
|
}
|
577
713
|
|
578
|
-
if ((error = recv_pkt(&pkt, NULL,
|
714
|
+
if ((error = recv_pkt(&pkt, NULL, t)) >= 0) {
|
579
715
|
/* Check cancellation after network call */
|
580
716
|
if (t->cancelled.val) {
|
581
717
|
git_error_clear();
|
@@ -643,12 +779,12 @@ static int gen_pktline(git_str *buf, git_push *push)
|
|
643
779
|
{
|
644
780
|
push_spec *spec;
|
645
781
|
size_t i, len;
|
646
|
-
char old_id[
|
782
|
+
char old_id[GIT_OID_SHA1_HEXSIZE+1], new_id[GIT_OID_SHA1_HEXSIZE+1];
|
647
783
|
|
648
|
-
old_id[
|
784
|
+
old_id[GIT_OID_SHA1_HEXSIZE] = '\0'; new_id[GIT_OID_SHA1_HEXSIZE] = '\0';
|
649
785
|
|
650
786
|
git_vector_foreach(&push->specs, i, spec) {
|
651
|
-
len = 2*
|
787
|
+
len = 2*GIT_OID_SHA1_HEXSIZE + 7 + strlen(spec->refspec.dst);
|
652
788
|
|
653
789
|
if (i == 0) {
|
654
790
|
++len; /* '\0' */
|
@@ -723,6 +859,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
|
|
723
859
|
static int add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt, git_str *data_pkt_buf)
|
724
860
|
{
|
725
861
|
git_pkt *pkt;
|
862
|
+
git_pkt_parse_data pkt_parse_data = { 0 };
|
726
863
|
const char *line, *line_end = NULL;
|
727
864
|
size_t line_len;
|
728
865
|
int error;
|
@@ -741,7 +878,7 @@ static int add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt,
|
|
741
878
|
}
|
742
879
|
|
743
880
|
while (line_len > 0) {
|
744
|
-
error = git_pkt_parse_line(&pkt, &line_end, line, line_len);
|
881
|
+
error = git_pkt_parse_line(&pkt, &line_end, line, line_len, &pkt_parse_data);
|
745
882
|
|
746
883
|
if (error == GIT_EBUFS) {
|
747
884
|
/* Buffer the data when the inner packet is split
|
@@ -777,15 +914,17 @@ done:
|
|
777
914
|
static int parse_report(transport_smart *transport, git_push *push)
|
778
915
|
{
|
779
916
|
git_pkt *pkt = NULL;
|
917
|
+
git_pkt_parse_data pkt_parse_data = { 0 };
|
780
918
|
const char *line_end = NULL;
|
781
|
-
gitno_buffer *buf = &transport->buffer;
|
782
919
|
int error, recvd;
|
783
920
|
git_str data_pkt_buf = GIT_STR_INIT;
|
784
921
|
|
785
922
|
for (;;) {
|
786
|
-
if (
|
923
|
+
if (transport->buffer.len > 0)
|
787
924
|
error = git_pkt_parse_line(&pkt, &line_end,
|
788
|
-
|
925
|
+
transport->buffer.data,
|
926
|
+
transport->buffer.len,
|
927
|
+
&pkt_parse_data);
|
789
928
|
else
|
790
929
|
error = GIT_EBUFS;
|
791
930
|
|
@@ -795,7 +934,7 @@ static int parse_report(transport_smart *transport, git_push *push)
|
|
795
934
|
}
|
796
935
|
|
797
936
|
if (error == GIT_EBUFS) {
|
798
|
-
if ((recvd =
|
937
|
+
if ((recvd = git_smart__recv(transport)) < 0) {
|
799
938
|
error = recvd;
|
800
939
|
goto done;
|
801
940
|
}
|
@@ -808,9 +947,7 @@ static int parse_report(transport_smart *transport, git_push *push)
|
|
808
947
|
continue;
|
809
948
|
}
|
810
949
|
|
811
|
-
|
812
|
-
return -1;
|
813
|
-
|
950
|
+
git_staticstr_consume(&transport->buffer, line_end);
|
814
951
|
error = 0;
|
815
952
|
|
816
953
|
switch (pkt->type) {
|
@@ -975,7 +1112,7 @@ struct push_packbuilder_payload
|
|
975
1112
|
git_push_transfer_progress_cb cb;
|
976
1113
|
void *cb_payload;
|
977
1114
|
size_t last_bytes;
|
978
|
-
|
1115
|
+
uint64_t last_progress_report_time;
|
979
1116
|
};
|
980
1117
|
|
981
1118
|
static int stream_thunk(void *buf, size_t size, void *data)
|
@@ -987,11 +1124,11 @@ static int stream_thunk(void *buf, size_t size, void *data)
|
|
987
1124
|
return error;
|
988
1125
|
|
989
1126
|
if (payload->cb) {
|
990
|
-
|
991
|
-
|
1127
|
+
uint64_t current_time = git_time_monotonic();
|
1128
|
+
uint64_t elapsed = current_time - payload->last_progress_report_time;
|
992
1129
|
payload->last_bytes += size;
|
993
1130
|
|
994
|
-
if (elapsed
|
1131
|
+
if (elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
|
995
1132
|
payload->last_progress_report_time = current_time;
|
996
1133
|
error = payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload);
|
997
1134
|
}
|
@@ -1020,7 +1157,7 @@ int git_smart__push(git_transport *transport, git_push *push)
|
|
1020
1157
|
#ifdef PUSH_DEBUG
|
1021
1158
|
{
|
1022
1159
|
git_remote_head *head;
|
1023
|
-
char hex[
|
1160
|
+
char hex[GIT_OID_SHA1_HEXSIZE+1]; hex[GIT_OID_SHA1_HEXSIZE] = '\0';
|
1024
1161
|
|
1025
1162
|
git_vector_foreach(&push->remote->refs, i, head) {
|
1026
1163
|
git_oid_fmt(hex, &head->oid);
|