rugged 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -6
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +18 -5
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -34
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +156 -124
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/include/git2/apply.h +2 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +93 -42
- data/vendor/libgit2/include/git2/blob.h +31 -3
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +19 -4
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +35 -20
- data/vendor/libgit2/include/git2/errors.h +6 -6
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +3 -3
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +25 -4
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +16 -7
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +84 -39
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +42 -37
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +26 -15
- data/vendor/libgit2/src/blob.c +44 -24
- data/vendor/libgit2/src/branch.c +69 -17
- data/vendor/libgit2/src/buffer.c +334 -25
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +48 -26
- data/vendor/libgit2/src/cherrypick.c +6 -2
- data/vendor/libgit2/src/clone.c +26 -11
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +25 -2
- data/vendor/libgit2/src/config.c +37 -15
- data/vendor/libgit2/src/config_cache.c +9 -4
- data/vendor/libgit2/src/config_file.c +16 -8
- data/vendor/libgit2/src/config_parse.c +4 -6
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +6 -3
- data/vendor/libgit2/src/diff.c +11 -8
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +2 -6
- data/vendor/libgit2/src/diff_generate.c +46 -17
- data/vendor/libgit2/src/diff_print.c +19 -6
- data/vendor/libgit2/src/diff_stats.c +7 -5
- data/vendor/libgit2/src/diff_tform.c +11 -10
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +24 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +5 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +206 -110
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +5 -5
- data/vendor/libgit2/src/futils.h +1 -1
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +112 -75
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +50 -32
- data/vendor/libgit2/src/integer.h +79 -2
- data/vendor/libgit2/src/iterator.c +36 -24
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +75 -32
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +11 -3
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +471 -10
- data/vendor/libgit2/src/midx.h +28 -1
- data/vendor/libgit2/src/mwindow.c +106 -60
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +127 -3
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +22 -14
- data/vendor/libgit2/src/odb.c +289 -51
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +28 -18
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +5 -4
- data/vendor/libgit2/src/pack-objects.c +54 -48
- data/vendor/libgit2/src/pack.c +339 -125
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +2 -1
- data/vendor/libgit2/src/path.c +98 -53
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +8 -8
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +93 -49
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +125 -71
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +91 -43
- data/vendor/libgit2/src/refs.h +1 -1
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/remote.c +281 -105
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +191 -118
- data/vendor/libgit2/src/repository.h +13 -2
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +6 -2
- data/vendor/libgit2/src/revparse.c +14 -9
- data/vendor/libgit2/src/revwalk.c +32 -15
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +3 -1
- data/vendor/libgit2/src/status.c +7 -4
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +128 -62
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +4 -6
- data/vendor/libgit2/src/tag.c +47 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +19 -8
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +62 -30
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +3 -3
- data/vendor/libgit2/src/transports/smart.c +12 -7
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +138 -81
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/posix.h +3 -0
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +53 -129
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +22 -24
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +77 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +32 -14
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +32 -16
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -364
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
data/vendor/libgit2/src/midx.h
CHANGED
@@ -12,8 +12,11 @@
|
|
12
12
|
|
13
13
|
#include <ctype.h>
|
14
14
|
|
15
|
+
#include "git2/sys/midx.h"
|
16
|
+
|
15
17
|
#include "map.h"
|
16
18
|
#include "mwindow.h"
|
19
|
+
#include "odb.h"
|
17
20
|
|
18
21
|
/*
|
19
22
|
* A multi-pack-index file.
|
@@ -49,6 +52,9 @@ typedef struct git_midx_file {
|
|
49
52
|
|
50
53
|
/* The trailer of the file. Contains the SHA1-checksum of the whole file. */
|
51
54
|
git_oid checksum;
|
55
|
+
|
56
|
+
/* something like ".git/objects/pack/multi-pack-index". */
|
57
|
+
git_buf filename;
|
52
58
|
} git_midx_file;
|
53
59
|
|
54
60
|
/*
|
@@ -63,15 +69,36 @@ typedef struct git_midx_entry {
|
|
63
69
|
git_oid sha1;
|
64
70
|
} git_midx_entry;
|
65
71
|
|
72
|
+
/*
|
73
|
+
* A writer for `multi-pack-index` files.
|
74
|
+
*/
|
75
|
+
struct git_midx_writer {
|
76
|
+
/*
|
77
|
+
* The path of the directory where the .pack/.idx files are stored. The
|
78
|
+
* `multi-pack-index` file will be written to the same directory.
|
79
|
+
*/
|
80
|
+
git_buf pack_dir;
|
81
|
+
|
82
|
+
/* The list of `git_pack_file`s. */
|
83
|
+
git_vector packs;
|
84
|
+
};
|
85
|
+
|
66
86
|
int git_midx_open(
|
67
87
|
git_midx_file **idx_out,
|
68
88
|
const char *path);
|
89
|
+
bool git_midx_needs_refresh(
|
90
|
+
const git_midx_file *idx,
|
91
|
+
const char *path);
|
69
92
|
int git_midx_entry_find(
|
70
93
|
git_midx_entry *e,
|
71
94
|
git_midx_file *idx,
|
72
95
|
const git_oid *short_oid,
|
73
96
|
size_t len);
|
74
|
-
|
97
|
+
int git_midx_foreach_entry(
|
98
|
+
git_midx_file *idx,
|
99
|
+
git_odb_foreach_cb cb,
|
100
|
+
void *data);
|
101
|
+
int git_midx_close(git_midx_file *idx);
|
75
102
|
void git_midx_free(git_midx_file *idx);
|
76
103
|
|
77
104
|
/* This is exposed for use in the fuzzers. */
|
@@ -10,7 +10,7 @@
|
|
10
10
|
#include "vector.h"
|
11
11
|
#include "futils.h"
|
12
12
|
#include "map.h"
|
13
|
-
#include "
|
13
|
+
#include "runtime.h"
|
14
14
|
#include "strmap.h"
|
15
15
|
#include "pack.h"
|
16
16
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
: 32 * 1024 * 1024)
|
21
21
|
|
22
22
|
#define DEFAULT_MAPPED_LIMIT \
|
23
|
-
((1024 * 1024) * (sizeof(void*) >= 8 ?
|
23
|
+
((1024 * 1024) * (sizeof(void*) >= 8 ? UINT64_C(8192) : UINT64_C(256)))
|
24
24
|
|
25
25
|
/* default is unlimited */
|
26
26
|
#define DEFAULT_FILE_LIMIT 0
|
@@ -29,26 +29,36 @@ size_t git_mwindow__window_size = DEFAULT_WINDOW_SIZE;
|
|
29
29
|
size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT;
|
30
30
|
size_t git_mwindow__file_limit = DEFAULT_FILE_LIMIT;
|
31
31
|
|
32
|
-
/*
|
32
|
+
/* Mutex to control access to `git_mwindow__mem_ctl` and `git__pack_cache`. */
|
33
|
+
git_mutex git__mwindow_mutex;
|
34
|
+
|
35
|
+
/* Whenever you want to read or modify this, grab `git__mwindow_mutex` */
|
33
36
|
git_mwindow_ctl git_mwindow__mem_ctl;
|
34
37
|
|
35
38
|
/* Global list of mwindow files, to open packs once across repos */
|
36
39
|
git_strmap *git__pack_cache = NULL;
|
37
40
|
|
38
|
-
static void
|
41
|
+
static void git_mwindow_global_shutdown(void)
|
39
42
|
{
|
40
43
|
git_strmap *tmp = git__pack_cache;
|
41
44
|
|
45
|
+
git_mutex_free(&git__mwindow_mutex);
|
46
|
+
|
42
47
|
git__pack_cache = NULL;
|
43
48
|
git_strmap_free(tmp);
|
44
49
|
}
|
45
50
|
|
46
51
|
int git_mwindow_global_init(void)
|
47
52
|
{
|
48
|
-
|
53
|
+
int error;
|
54
|
+
|
55
|
+
GIT_ASSERT(!git__pack_cache);
|
49
56
|
|
50
|
-
|
51
|
-
|
57
|
+
if ((error = git_mutex_init(&git__mwindow_mutex)) < 0 ||
|
58
|
+
(error = git_strmap_new(&git__pack_cache)) < 0)
|
59
|
+
return error;
|
60
|
+
|
61
|
+
return git_runtime_shutdown_register(git_mwindow_global_shutdown);
|
52
62
|
}
|
53
63
|
|
54
64
|
int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
|
@@ -69,7 +79,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
|
|
69
79
|
git__free(packname);
|
70
80
|
|
71
81
|
if (pack != NULL) {
|
72
|
-
|
82
|
+
git_atomic32_inc(&pack->refcount);
|
73
83
|
git_mutex_unlock(&git__mwindow_mutex);
|
74
84
|
*out = pack;
|
75
85
|
return 0;
|
@@ -81,60 +91,49 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
|
|
81
91
|
return error;
|
82
92
|
}
|
83
93
|
|
84
|
-
|
94
|
+
git_atomic32_inc(&pack->refcount);
|
85
95
|
|
86
96
|
error = git_strmap_set(git__pack_cache, pack->pack_name, pack);
|
87
97
|
git_mutex_unlock(&git__mwindow_mutex);
|
88
|
-
|
89
98
|
if (error < 0) {
|
90
|
-
git_packfile_free(pack);
|
91
|
-
return
|
99
|
+
git_packfile_free(pack, false);
|
100
|
+
return error;
|
92
101
|
}
|
93
102
|
|
94
103
|
*out = pack;
|
95
104
|
return 0;
|
96
105
|
}
|
97
106
|
|
98
|
-
|
107
|
+
int git_mwindow_put_pack(struct git_pack_file *pack)
|
99
108
|
{
|
100
|
-
int count;
|
109
|
+
int count, error;
|
110
|
+
struct git_pack_file *pack_to_delete = NULL;
|
101
111
|
|
102
|
-
if (git_mutex_lock(&git__mwindow_mutex) < 0)
|
103
|
-
return;
|
112
|
+
if ((error = git_mutex_lock(&git__mwindow_mutex)) < 0)
|
113
|
+
return error;
|
104
114
|
|
105
115
|
/* put before get would be a corrupted state */
|
106
|
-
|
116
|
+
GIT_ASSERT(git__pack_cache);
|
107
117
|
|
108
118
|
/* if we cannot find it, the state is corrupted */
|
109
|
-
|
119
|
+
GIT_ASSERT(git_strmap_exists(git__pack_cache, pack->pack_name));
|
110
120
|
|
111
|
-
count =
|
121
|
+
count = git_atomic32_dec(&pack->refcount);
|
112
122
|
if (count == 0) {
|
113
123
|
git_strmap_delete(git__pack_cache, pack->pack_name);
|
114
|
-
|
124
|
+
pack_to_delete = pack;
|
115
125
|
}
|
116
|
-
|
117
126
|
git_mutex_unlock(&git__mwindow_mutex);
|
118
|
-
|
119
|
-
}
|
127
|
+
git_packfile_free(pack_to_delete, false);
|
120
128
|
|
121
|
-
|
122
|
-
{
|
123
|
-
if (git_mutex_lock(&git__mwindow_mutex)) {
|
124
|
-
git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
|
125
|
-
return;
|
126
|
-
}
|
127
|
-
|
128
|
-
git_mwindow_free_all_locked(mwf);
|
129
|
-
|
130
|
-
git_mutex_unlock(&git__mwindow_mutex);
|
129
|
+
return 0;
|
131
130
|
}
|
132
131
|
|
133
132
|
/*
|
134
133
|
* Free all the windows in a sequence, typically because we're done
|
135
|
-
* with the file
|
134
|
+
* with the file. Needs to hold the git__mwindow_mutex.
|
136
135
|
*/
|
137
|
-
|
136
|
+
static int git_mwindow_free_all_locked(git_mwindow_file *mwf)
|
138
137
|
{
|
139
138
|
git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
|
140
139
|
size_t i;
|
@@ -156,7 +155,7 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
|
|
156
155
|
|
157
156
|
while (mwf->windows) {
|
158
157
|
git_mwindow *w = mwf->windows;
|
159
|
-
|
158
|
+
GIT_ASSERT(w->inuse_cnt == 0);
|
160
159
|
|
161
160
|
ctl->mapped -= w->window_map.len;
|
162
161
|
ctl->open_windows--;
|
@@ -166,6 +165,24 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
|
|
166
165
|
mwf->windows = w->next;
|
167
166
|
git__free(w);
|
168
167
|
}
|
168
|
+
|
169
|
+
return 0;
|
170
|
+
}
|
171
|
+
|
172
|
+
int git_mwindow_free_all(git_mwindow_file *mwf)
|
173
|
+
{
|
174
|
+
int error;
|
175
|
+
|
176
|
+
if (git_mutex_lock(&git__mwindow_mutex)) {
|
177
|
+
git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
|
178
|
+
return -1;
|
179
|
+
}
|
180
|
+
|
181
|
+
error = git_mwindow_free_all_locked(mwf);
|
182
|
+
|
183
|
+
git_mutex_unlock(&git__mwindow_mutex);
|
184
|
+
|
185
|
+
return error;
|
169
186
|
}
|
170
187
|
|
171
188
|
/*
|
@@ -200,8 +217,8 @@ static bool git_mwindow_scan_recently_used(
|
|
200
217
|
git_mwindow *lru_window = NULL, *lru_last = NULL;
|
201
218
|
bool found = false;
|
202
219
|
|
203
|
-
|
204
|
-
|
220
|
+
GIT_ASSERT_ARG(mwf);
|
221
|
+
GIT_ASSERT_ARG(out_window);
|
205
222
|
|
206
223
|
lru_window = *out_window;
|
207
224
|
if (out_last)
|
@@ -240,9 +257,9 @@ static bool git_mwindow_scan_recently_used(
|
|
240
257
|
|
241
258
|
/*
|
242
259
|
* Close the least recently used window (that is currently not being used) out
|
243
|
-
* of all the files. Called under lock from
|
260
|
+
* of all the files. Called under lock from new_window_locked.
|
244
261
|
*/
|
245
|
-
static int
|
262
|
+
static int git_mwindow_close_lru_window_locked(void)
|
246
263
|
{
|
247
264
|
git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
|
248
265
|
git_mwindow_file *cur;
|
@@ -276,13 +293,13 @@ static int git_mwindow_close_lru_window(void)
|
|
276
293
|
}
|
277
294
|
|
278
295
|
/*
|
279
|
-
*
|
296
|
+
* Finds the file that does not have any open windows AND whose
|
280
297
|
* most-recently-used window is the least-recently used one across all
|
281
298
|
* currently open files.
|
282
299
|
*
|
283
|
-
* Called under lock from
|
300
|
+
* Called under lock from new_window_locked.
|
284
301
|
*/
|
285
|
-
static int
|
302
|
+
static int git_mwindow_find_lru_file_locked(git_mwindow_file **out)
|
286
303
|
{
|
287
304
|
git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
|
288
305
|
git_mwindow_file *lru_file = NULL, *current_file = NULL;
|
@@ -295,8 +312,10 @@ static int git_mwindow_close_lru_file(void)
|
|
295
312
|
current_file, &mru_window, NULL, true, GIT_MWINDOW__MRU)) {
|
296
313
|
continue;
|
297
314
|
}
|
298
|
-
if (!lru_window || lru_window->last_used > mru_window->last_used)
|
315
|
+
if (!lru_window || lru_window->last_used > mru_window->last_used) {
|
316
|
+
lru_window = mru_window;
|
299
317
|
lru_file = current_file;
|
318
|
+
}
|
300
319
|
}
|
301
320
|
|
302
321
|
if (!lru_file) {
|
@@ -304,15 +323,12 @@ static int git_mwindow_close_lru_file(void)
|
|
304
323
|
return -1;
|
305
324
|
}
|
306
325
|
|
307
|
-
|
308
|
-
p_close(lru_file->fd);
|
309
|
-
lru_file->fd = -1;
|
310
|
-
|
326
|
+
*out = lru_file;
|
311
327
|
return 0;
|
312
328
|
}
|
313
329
|
|
314
330
|
/* This gets called under lock from git_mwindow_open */
|
315
|
-
static git_mwindow *
|
331
|
+
static git_mwindow *new_window_locked(
|
316
332
|
git_file fd,
|
317
333
|
off64_t size,
|
318
334
|
off64_t offset)
|
@@ -322,12 +338,11 @@ static git_mwindow *new_window(
|
|
322
338
|
off64_t len;
|
323
339
|
git_mwindow *w;
|
324
340
|
|
325
|
-
w =
|
341
|
+
w = git__calloc(1, sizeof(*w));
|
326
342
|
|
327
343
|
if (w == NULL)
|
328
344
|
return NULL;
|
329
345
|
|
330
|
-
memset(w, 0x0, sizeof(*w));
|
331
346
|
w->offset = (offset / walign) * walign;
|
332
347
|
|
333
348
|
len = size - w->offset;
|
@@ -337,7 +352,7 @@ static git_mwindow *new_window(
|
|
337
352
|
ctl->mapped += (size_t)len;
|
338
353
|
|
339
354
|
while (git_mwindow__mapped_limit < ctl->mapped &&
|
340
|
-
|
355
|
+
git_mwindow_close_lru_window_locked() == 0) /* nop */;
|
341
356
|
|
342
357
|
/*
|
343
358
|
* We treat `mapped_limit` as a soft limit. If we can't find a
|
@@ -351,7 +366,7 @@ static git_mwindow *new_window(
|
|
351
366
|
* we're below our soft limits, so free up what we can and try again.
|
352
367
|
*/
|
353
368
|
|
354
|
-
while (
|
369
|
+
while (git_mwindow_close_lru_window_locked() == 0)
|
355
370
|
/* nop */;
|
356
371
|
|
357
372
|
if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) {
|
@@ -407,7 +422,7 @@ unsigned char *git_mwindow_open(
|
|
407
422
|
* one.
|
408
423
|
*/
|
409
424
|
if (!w) {
|
410
|
-
w =
|
425
|
+
w = new_window_locked(mwf->fd, mwf->size, offset);
|
411
426
|
if (w == NULL) {
|
412
427
|
git_mutex_unlock(&git__mwindow_mutex);
|
413
428
|
return NULL;
|
@@ -435,8 +450,11 @@ unsigned char *git_mwindow_open(
|
|
435
450
|
|
436
451
|
int git_mwindow_file_register(git_mwindow_file *mwf)
|
437
452
|
{
|
453
|
+
git_vector closed_files = GIT_VECTOR_INIT;
|
438
454
|
git_mwindow_ctl *ctl = &git_mwindow__mem_ctl;
|
439
|
-
int
|
455
|
+
int error;
|
456
|
+
size_t i;
|
457
|
+
git_mwindow_file *closed_file = NULL;
|
440
458
|
|
441
459
|
if (git_mutex_lock(&git__mwindow_mutex)) {
|
442
460
|
git_error_set(GIT_ERROR_THREAD, "unable to lock mwindow mutex");
|
@@ -444,20 +462,48 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
|
|
444
462
|
}
|
445
463
|
|
446
464
|
if (ctl->windowfiles.length == 0 &&
|
447
|
-
git_vector_init(&ctl->windowfiles, 8, NULL) < 0) {
|
465
|
+
(error = git_vector_init(&ctl->windowfiles, 8, NULL)) < 0) {
|
448
466
|
git_mutex_unlock(&git__mwindow_mutex);
|
449
|
-
|
467
|
+
goto cleanup;
|
450
468
|
}
|
451
469
|
|
452
470
|
if (git_mwindow__file_limit) {
|
471
|
+
git_mwindow_file *lru_file;
|
453
472
|
while (git_mwindow__file_limit <= ctl->windowfiles.length &&
|
454
|
-
|
473
|
+
git_mwindow_find_lru_file_locked(&lru_file) == 0) {
|
474
|
+
if ((error = git_vector_insert(&closed_files, lru_file)) < 0) {
|
475
|
+
/*
|
476
|
+
* Exceeding the file limit seems preferrable to being open to
|
477
|
+
* data races that can end up corrupting the heap.
|
478
|
+
*/
|
479
|
+
break;
|
480
|
+
}
|
481
|
+
git_mwindow_free_all_locked(lru_file);
|
482
|
+
}
|
455
483
|
}
|
456
484
|
|
457
|
-
|
485
|
+
error = git_vector_insert(&ctl->windowfiles, mwf);
|
458
486
|
git_mutex_unlock(&git__mwindow_mutex);
|
487
|
+
if (error < 0)
|
488
|
+
goto cleanup;
|
489
|
+
|
490
|
+
/*
|
491
|
+
* Once we have released the global windowfiles lock, we can close each
|
492
|
+
* individual file. Before doing so, acquire that file's lock to avoid
|
493
|
+
* closing a file that is currently being used.
|
494
|
+
*/
|
495
|
+
git_vector_foreach(&closed_files, i, closed_file) {
|
496
|
+
error = git_mutex_lock(&closed_file->lock);
|
497
|
+
if (error < 0)
|
498
|
+
continue;
|
499
|
+
p_close(closed_file->fd);
|
500
|
+
closed_file->fd = -1;
|
501
|
+
git_mutex_unlock(&closed_file->lock);
|
502
|
+
}
|
459
503
|
|
460
|
-
|
504
|
+
cleanup:
|
505
|
+
git_vector_free(&closed_files);
|
506
|
+
return error;
|
461
507
|
}
|
462
508
|
|
463
509
|
void git_mwindow_file_deregister(git_mwindow_file *mwf)
|
@@ -22,6 +22,7 @@ typedef struct git_mwindow {
|
|
22
22
|
} git_mwindow;
|
23
23
|
|
24
24
|
typedef struct git_mwindow_file {
|
25
|
+
git_mutex lock; /* protects updates to fd */
|
25
26
|
git_mwindow *windows;
|
26
27
|
int fd;
|
27
28
|
off64_t size;
|
@@ -38,8 +39,7 @@ typedef struct git_mwindow_ctl {
|
|
38
39
|
} git_mwindow_ctl;
|
39
40
|
|
40
41
|
int git_mwindow_contains(git_mwindow *win, off64_t offset);
|
41
|
-
|
42
|
-
void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
|
42
|
+
int git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
|
43
43
|
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off64_t offset, size_t extra, unsigned int *left);
|
44
44
|
int git_mwindow_file_register(git_mwindow_file *mwf);
|
45
45
|
void git_mwindow_file_deregister(git_mwindow_file *mwf);
|
@@ -49,6 +49,6 @@ extern int git_mwindow_global_init(void);
|
|
49
49
|
|
50
50
|
struct git_pack_file; /* just declaration to avoid cyclical includes */
|
51
51
|
int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
|
52
|
-
|
52
|
+
int git_mwindow_put_pack(struct git_pack_file *pack);
|
53
53
|
|
54
54
|
#endif
|
data/vendor/libgit2/src/net.c
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
#include "posix.h"
|
15
15
|
#include "buffer.h"
|
16
16
|
#include "http_parser.h"
|
17
|
-
#include "
|
17
|
+
#include "runtime.h"
|
18
18
|
|
19
19
|
#define DEFAULT_PORT_HTTP "80"
|
20
20
|
#define DEFAULT_PORT_HTTPS "443"
|
@@ -35,6 +35,46 @@ static const char *default_port_for_scheme(const char *scheme)
|
|
35
35
|
return NULL;
|
36
36
|
}
|
37
37
|
|
38
|
+
int git_net_url_dup(git_net_url *out, git_net_url *in)
|
39
|
+
{
|
40
|
+
if (in->scheme) {
|
41
|
+
out->scheme = git__strdup(in->scheme);
|
42
|
+
GIT_ERROR_CHECK_ALLOC(out->scheme);
|
43
|
+
}
|
44
|
+
|
45
|
+
if (in->host) {
|
46
|
+
out->host = git__strdup(in->host);
|
47
|
+
GIT_ERROR_CHECK_ALLOC(out->host);
|
48
|
+
}
|
49
|
+
|
50
|
+
if (in->port) {
|
51
|
+
out->port = git__strdup(in->port);
|
52
|
+
GIT_ERROR_CHECK_ALLOC(out->port);
|
53
|
+
}
|
54
|
+
|
55
|
+
if (in->path) {
|
56
|
+
out->path = git__strdup(in->path);
|
57
|
+
GIT_ERROR_CHECK_ALLOC(out->path);
|
58
|
+
}
|
59
|
+
|
60
|
+
if (in->query) {
|
61
|
+
out->query = git__strdup(in->query);
|
62
|
+
GIT_ERROR_CHECK_ALLOC(out->query);
|
63
|
+
}
|
64
|
+
|
65
|
+
if (in->username) {
|
66
|
+
out->username = git__strdup(in->username);
|
67
|
+
GIT_ERROR_CHECK_ALLOC(out->username);
|
68
|
+
}
|
69
|
+
|
70
|
+
if (in->password) {
|
71
|
+
out->password = git__strdup(in->password);
|
72
|
+
GIT_ERROR_CHECK_ALLOC(out->password);
|
73
|
+
}
|
74
|
+
|
75
|
+
return 0;
|
76
|
+
}
|
77
|
+
|
38
78
|
int git_net_url_parse(git_net_url *url, const char *given)
|
39
79
|
{
|
40
80
|
struct http_parser_url u = {0};
|
@@ -281,7 +321,8 @@ int git_net_url_apply_redirect(
|
|
281
321
|
git_net_url tmp = GIT_NET_URL_INIT;
|
282
322
|
int error = 0;
|
283
323
|
|
284
|
-
|
324
|
+
GIT_ASSERT(url);
|
325
|
+
GIT_ASSERT(redirect_location);
|
285
326
|
|
286
327
|
if (redirect_location[0] == '/') {
|
287
328
|
git__free(url->path);
|
@@ -334,7 +375,7 @@ bool git_net_url_valid(git_net_url *url)
|
|
334
375
|
return (url->host && url->port && url->path);
|
335
376
|
}
|
336
377
|
|
337
|
-
|
378
|
+
bool git_net_url_is_default_port(git_net_url *url)
|
338
379
|
{
|
339
380
|
const char *default_port;
|
340
381
|
|
@@ -344,6 +385,11 @@ int git_net_url_is_default_port(git_net_url *url)
|
|
344
385
|
return false;
|
345
386
|
}
|
346
387
|
|
388
|
+
bool git_net_url_is_ipv6(git_net_url *url)
|
389
|
+
{
|
390
|
+
return (strchr(url->host, ':') != NULL);
|
391
|
+
}
|
392
|
+
|
347
393
|
void git_net_url_swap(git_net_url *a, git_net_url *b)
|
348
394
|
{
|
349
395
|
git_net_url tmp = GIT_NET_URL_INIT;
|
@@ -355,6 +401,10 @@ void git_net_url_swap(git_net_url *a, git_net_url *b)
|
|
355
401
|
|
356
402
|
int git_net_url_fmt(git_buf *buf, git_net_url *url)
|
357
403
|
{
|
404
|
+
GIT_ASSERT_ARG(url);
|
405
|
+
GIT_ASSERT_ARG(url->scheme);
|
406
|
+
GIT_ASSERT_ARG(url->host);
|
407
|
+
|
358
408
|
git_buf_puts(buf, url->scheme);
|
359
409
|
git_buf_puts(buf, "://");
|
360
410
|
|
@@ -398,6 +448,80 @@ int git_net_url_fmt_path(git_buf *buf, git_net_url *url)
|
|
398
448
|
return git_buf_oom(buf) ? -1 : 0;
|
399
449
|
}
|
400
450
|
|
451
|
+
static bool matches_pattern(
|
452
|
+
git_net_url *url,
|
453
|
+
const char *pattern,
|
454
|
+
size_t pattern_len)
|
455
|
+
{
|
456
|
+
const char *domain, *port = NULL, *colon;
|
457
|
+
size_t host_len, domain_len, port_len = 0, wildcard = 0;
|
458
|
+
|
459
|
+
GIT_UNUSED(url);
|
460
|
+
GIT_UNUSED(pattern);
|
461
|
+
|
462
|
+
if (!pattern_len)
|
463
|
+
return false;
|
464
|
+
else if (pattern_len == 1 && pattern[0] == '*')
|
465
|
+
return true;
|
466
|
+
else if (pattern_len > 1 && pattern[0] == '*' && pattern[1] == '.')
|
467
|
+
wildcard = 2;
|
468
|
+
else if (pattern[0] == '.')
|
469
|
+
wildcard = 1;
|
470
|
+
|
471
|
+
domain = pattern + wildcard;
|
472
|
+
domain_len = pattern_len - wildcard;
|
473
|
+
|
474
|
+
if ((colon = memchr(domain, ':', domain_len)) != NULL) {
|
475
|
+
domain_len = colon - domain;
|
476
|
+
port = colon + 1;
|
477
|
+
port_len = pattern_len - wildcard - domain_len - 1;
|
478
|
+
}
|
479
|
+
|
480
|
+
/* A pattern's port *must* match if it's specified */
|
481
|
+
if (port_len && git__strlcmp(url->port, port, port_len) != 0)
|
482
|
+
return false;
|
483
|
+
|
484
|
+
/* No wildcard? Host must match exactly. */
|
485
|
+
if (!wildcard)
|
486
|
+
return !git__strlcmp(url->host, domain, domain_len);
|
487
|
+
|
488
|
+
/* Wildcard: ensure there's (at least) a suffix match */
|
489
|
+
if ((host_len = strlen(url->host)) < domain_len ||
|
490
|
+
memcmp(url->host + (host_len - domain_len), domain, domain_len))
|
491
|
+
return false;
|
492
|
+
|
493
|
+
/* The pattern is *.domain and the host is simply domain */
|
494
|
+
if (host_len == domain_len)
|
495
|
+
return true;
|
496
|
+
|
497
|
+
/* The pattern is *.domain and the host is foo.domain */
|
498
|
+
return (url->host[host_len - domain_len - 1] == '.');
|
499
|
+
}
|
500
|
+
|
501
|
+
bool git_net_url_matches_pattern(git_net_url *url, const char *pattern)
|
502
|
+
{
|
503
|
+
return matches_pattern(url, pattern, strlen(pattern));
|
504
|
+
}
|
505
|
+
|
506
|
+
bool git_net_url_matches_pattern_list(
|
507
|
+
git_net_url *url,
|
508
|
+
const char *pattern_list)
|
509
|
+
{
|
510
|
+
const char *pattern, *pattern_end, *sep;
|
511
|
+
|
512
|
+
for (pattern = pattern_list;
|
513
|
+
pattern && *pattern;
|
514
|
+
pattern = sep ? sep + 1 : NULL) {
|
515
|
+
sep = strchr(pattern, ',');
|
516
|
+
pattern_end = sep ? sep : strchr(pattern, '\0');
|
517
|
+
|
518
|
+
if (matches_pattern(url, pattern, (pattern_end - pattern)))
|
519
|
+
return true;
|
520
|
+
}
|
521
|
+
|
522
|
+
return false;
|
523
|
+
}
|
524
|
+
|
401
525
|
void git_net_url_dispose(git_net_url *url)
|
402
526
|
{
|
403
527
|
if (url->username)
|
data/vendor/libgit2/src/net.h
CHANGED
@@ -21,6 +21,9 @@ typedef struct git_net_url {
|
|
21
21
|
|
22
22
|
#define GIT_NET_URL_INIT { NULL }
|
23
23
|
|
24
|
+
/** Duplicate a URL */
|
25
|
+
extern int git_net_url_dup(git_net_url *out, git_net_url *in);
|
26
|
+
|
24
27
|
/** Parses a string containing a URL into a structure. */
|
25
28
|
extern int git_net_url_parse(git_net_url *url, const char *str);
|
26
29
|
|
@@ -33,8 +36,11 @@ extern int git_net_url_joinpath(
|
|
33
36
|
/** Ensures that a URL is minimally valid (contains a host, port and path) */
|
34
37
|
extern bool git_net_url_valid(git_net_url *url);
|
35
38
|
|
36
|
-
/** Returns
|
37
|
-
extern
|
39
|
+
/** Returns true if the URL is on the default port. */
|
40
|
+
extern bool git_net_url_is_default_port(git_net_url *url);
|
41
|
+
|
42
|
+
/** Returns true if the host portion of the URL is an ipv6 address. */
|
43
|
+
extern bool git_net_url_is_ipv6(git_net_url *url);
|
38
44
|
|
39
45
|
/* Applies a redirect to the URL with a git-aware service suffix. */
|
40
46
|
extern int git_net_url_apply_redirect(
|
@@ -51,6 +57,14 @@ extern int git_net_url_fmt(git_buf *out, git_net_url *url);
|
|
51
57
|
/** Place the path and query string into the given buffer. */
|
52
58
|
extern int git_net_url_fmt_path(git_buf *buf, git_net_url *url);
|
53
59
|
|
60
|
+
/** Determines if the url matches given pattern or pattern list */
|
61
|
+
extern bool git_net_url_matches_pattern(
|
62
|
+
git_net_url *url,
|
63
|
+
const char *pattern);
|
64
|
+
extern bool git_net_url_matches_pattern_list(
|
65
|
+
git_net_url *url,
|
66
|
+
const char *pattern_list);
|
67
|
+
|
54
68
|
/** Disposes the contents of the structure. */
|
55
69
|
extern void git_net_url_dispose(git_net_url *url);
|
56
70
|
|
data/vendor/libgit2/src/netops.c
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
#include "posix.h"
|
14
14
|
#include "buffer.h"
|
15
15
|
#include "http_parser.h"
|
16
|
-
#include "
|
16
|
+
#include "runtime.h"
|
17
17
|
|
18
18
|
int gitno_recv(gitno_buffer *buf)
|
19
19
|
{
|
@@ -61,18 +61,20 @@ void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data
|
|
61
61
|
}
|
62
62
|
|
63
63
|
/* Consume up to ptr and move the rest of the buffer to the beginning */
|
64
|
-
|
64
|
+
int gitno_consume(gitno_buffer *buf, const char *ptr)
|
65
65
|
{
|
66
66
|
size_t consumed;
|
67
67
|
|
68
|
-
|
69
|
-
|
68
|
+
GIT_ASSERT(ptr - buf->data >= 0);
|
69
|
+
GIT_ASSERT(ptr - buf->data <= (int) buf->len);
|
70
70
|
|
71
71
|
consumed = ptr - buf->data;
|
72
72
|
|
73
73
|
memmove(buf->data, ptr, buf->offset - consumed);
|
74
74
|
memset(buf->data + buf->offset, 0x0, buf->len - buf->offset);
|
75
75
|
buf->offset -= consumed;
|
76
|
+
|
77
|
+
return 0;
|
76
78
|
}
|
77
79
|
|
78
80
|
/* Consume const bytes and move the rest of the buffer to the beginning */
|
data/vendor/libgit2/src/netops.h
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
#include "net.h"
|
15
15
|
|
16
16
|
#ifdef GIT_OPENSSL
|
17
|
-
# include
|
17
|
+
# include "streams/openssl.h"
|
18
18
|
#endif
|
19
19
|
|
20
20
|
typedef struct gitno_ssl {
|
@@ -62,7 +62,7 @@ void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data
|
|
62
62
|
void gitno_buffer_setup_callback(gitno_buffer *buf, char *data, size_t len, int (*recv)(gitno_buffer *buf), void *cb_data);
|
63
63
|
int gitno_recv(gitno_buffer *buf);
|
64
64
|
|
65
|
-
|
65
|
+
int gitno_consume(gitno_buffer *buf, const char *ptr);
|
66
66
|
void gitno_consume_n(gitno_buffer *buf, size_t cons);
|
67
67
|
|
68
68
|
#endif
|