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
@@ -15,108 +15,114 @@ GIT_INLINE(void) git__set_errno(void)
|
|
15
15
|
errno = EINVAL;
|
16
16
|
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
int git_utf8_to_16(wchar_t *dest, size_t dest_size, const char *src)
|
19
|
+
{
|
20
|
+
/* Length of -1 indicates NULL termination of the input string. */
|
21
|
+
return git_utf8_to_16_with_len(dest, dest_size, src, -1);
|
22
|
+
}
|
23
|
+
|
24
|
+
int git_utf8_to_16_with_len(
|
25
|
+
wchar_t *dest,
|
26
|
+
size_t _dest_size,
|
27
|
+
const char *src,
|
28
|
+
int src_len)
|
27
29
|
{
|
30
|
+
int dest_size = (int)min(_dest_size, INT_MAX);
|
28
31
|
int len;
|
29
32
|
|
30
|
-
/*
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
/*
|
34
|
+
* Subtract 1 from the result to turn 0 into -1 (an error code) and
|
35
|
+
* to not count the NULL terminator as part of the string's length.
|
36
|
+
* MultiByteToWideChar never returns int's minvalue, so underflow
|
37
|
+
* is not possible.
|
38
|
+
*/
|
39
|
+
len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
|
40
|
+
src, src_len, dest, dest_size) - 1;
|
41
|
+
|
42
|
+
if (len < 0)
|
34
43
|
git__set_errno();
|
35
44
|
|
36
45
|
return len;
|
37
46
|
}
|
38
47
|
|
39
|
-
|
40
|
-
* Converts a wide string to UTF-8.
|
41
|
-
*
|
42
|
-
* @param dest The buffer to receive the UTF-8 string.
|
43
|
-
* @param dest_size The size of the buffer, in bytes.
|
44
|
-
* @param src The wide string to convert.
|
45
|
-
* @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure
|
46
|
-
*/
|
47
|
-
int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src)
|
48
|
+
int git_utf8_from_16(char *dest, size_t dest_size, const wchar_t *src)
|
48
49
|
{
|
50
|
+
/* Length of -1 indicates NULL termination of the input string. */
|
51
|
+
return git_utf8_from_16_with_len(dest, dest_size, src, -1);
|
52
|
+
}
|
53
|
+
|
54
|
+
int git_utf8_from_16_with_len(
|
55
|
+
char *dest,
|
56
|
+
size_t _dest_size,
|
57
|
+
const wchar_t *src,
|
58
|
+
int src_len)
|
59
|
+
{
|
60
|
+
int dest_size = (int)min(_dest_size, INT_MAX);
|
49
61
|
int len;
|
50
62
|
|
51
|
-
/*
|
52
|
-
* turn 0 into -1 (an error code) and
|
53
|
-
*
|
54
|
-
|
63
|
+
/*
|
64
|
+
* Subtract 1 from the result to turn 0 into -1 (an error code) and
|
65
|
+
* to not count the NULL terminator as part of the string's length.
|
66
|
+
* WideCharToMultiByte never returns int's minvalue, so underflow
|
67
|
+
* is not possible.
|
68
|
+
*/
|
69
|
+
len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS,
|
70
|
+
src, src_len, dest, dest_size, NULL, NULL) - 1;
|
71
|
+
|
72
|
+
if (len < 0)
|
55
73
|
git__set_errno();
|
56
74
|
|
57
75
|
return len;
|
58
76
|
}
|
59
77
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
* @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
|
68
|
-
*/
|
69
|
-
int git__utf8_to_16_alloc(wchar_t **dest, const char *src)
|
78
|
+
int git_utf8_to_16_alloc(wchar_t **dest, const char *src)
|
79
|
+
{
|
80
|
+
/* Length of -1 indicates NULL termination of the input string. */
|
81
|
+
return git_utf8_to_16_alloc_with_len(dest, src, -1);
|
82
|
+
}
|
83
|
+
|
84
|
+
int git_utf8_to_16_alloc_with_len(wchar_t **dest, const char *src, int src_len)
|
70
85
|
{
|
71
86
|
int utf16_size;
|
72
87
|
|
73
88
|
*dest = NULL;
|
74
89
|
|
75
|
-
|
76
|
-
|
90
|
+
utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
|
91
|
+
src, src_len, NULL, 0);
|
77
92
|
|
78
93
|
if (!utf16_size) {
|
79
94
|
git__set_errno();
|
80
95
|
return -1;
|
81
96
|
}
|
82
97
|
|
83
|
-
|
84
|
-
|
85
|
-
return -1;
|
86
|
-
}
|
98
|
+
*dest = git__mallocarray(utf16_size, sizeof(wchar_t));
|
99
|
+
GIT_ERROR_CHECK_ALLOC(*dest);
|
87
100
|
|
88
|
-
utf16_size =
|
89
|
-
|
90
|
-
if (!utf16_size) {
|
91
|
-
git__set_errno();
|
101
|
+
utf16_size = git_utf8_to_16_with_len(*dest, (size_t)utf16_size,
|
102
|
+
src, src_len);
|
92
103
|
|
104
|
+
if (utf16_size < 0) {
|
93
105
|
git__free(*dest);
|
94
106
|
*dest = NULL;
|
95
107
|
}
|
96
108
|
|
97
|
-
|
98
|
-
* terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue,
|
99
|
-
* so underflow is not possible */
|
100
|
-
return utf16_size - 1;
|
109
|
+
return utf16_size;
|
101
110
|
}
|
102
111
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
* @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure
|
111
|
-
*/
|
112
|
-
int git__utf16_to_8_alloc(char **dest, const wchar_t *src)
|
112
|
+
int git_utf8_from_16_alloc(char **dest, const wchar_t *src)
|
113
|
+
{
|
114
|
+
/* Length of -1 indicates NULL termination of the input string. */
|
115
|
+
return git_utf8_from_16_alloc_with_len(dest, src, -1);
|
116
|
+
}
|
117
|
+
|
118
|
+
int git_utf8_from_16_alloc_with_len(char **dest, const wchar_t *src, int src_len)
|
113
119
|
{
|
114
120
|
int utf8_size;
|
115
121
|
|
116
122
|
*dest = NULL;
|
117
123
|
|
118
|
-
|
119
|
-
|
124
|
+
utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS,
|
125
|
+
src, src_len, NULL, 0, NULL, NULL);
|
120
126
|
|
121
127
|
if (!utf8_size) {
|
122
128
|
git__set_errno();
|
@@ -124,23 +130,15 @@ int git__utf16_to_8_alloc(char **dest, const wchar_t *src)
|
|
124
130
|
}
|
125
131
|
|
126
132
|
*dest = git__malloc(utf8_size);
|
133
|
+
GIT_ERROR_CHECK_ALLOC(*dest);
|
127
134
|
|
128
|
-
|
129
|
-
|
130
|
-
return -1;
|
131
|
-
}
|
132
|
-
|
133
|
-
utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, *dest, utf8_size, NULL, NULL);
|
134
|
-
|
135
|
-
if (!utf8_size) {
|
136
|
-
git__set_errno();
|
135
|
+
utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS,
|
136
|
+
src, src_len, *dest, utf8_size, NULL, NULL);
|
137
137
|
|
138
|
+
if (utf8_size < 0) {
|
138
139
|
git__free(*dest);
|
139
140
|
*dest = NULL;
|
140
141
|
}
|
141
142
|
|
142
|
-
|
143
|
-
* terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue,
|
144
|
-
* so underflow is not possible */
|
145
|
-
return utf8_size - 1;
|
143
|
+
return utf8_size;
|
146
144
|
}
|
@@ -15,15 +15,46 @@
|
|
15
15
|
# define WC_ERR_INVALID_CHARS 0x80
|
16
16
|
#endif
|
17
17
|
|
18
|
+
/**
|
19
|
+
* Converts a NUL-terminated UTF-8 string to wide characters. This is a
|
20
|
+
* convenience function for `git_utf8_to_16_with_len`.
|
21
|
+
*
|
22
|
+
* @param dest The buffer to receive the wide string.
|
23
|
+
* @param dest_size The size of the buffer, in characters.
|
24
|
+
* @param src The UTF-8 string to convert.
|
25
|
+
* @return The length of the wide string, in characters
|
26
|
+
* (not counting the NULL terminator), or < 0 for failure
|
27
|
+
*/
|
28
|
+
int git_utf8_to_16(wchar_t *dest, size_t dest_size, const char *src);
|
29
|
+
|
18
30
|
/**
|
19
31
|
* Converts a UTF-8 string to wide characters.
|
20
32
|
*
|
21
33
|
* @param dest The buffer to receive the wide string.
|
22
34
|
* @param dest_size The size of the buffer, in characters.
|
23
35
|
* @param src The UTF-8 string to convert.
|
24
|
-
* @
|
36
|
+
* @param src_len The length of the string to convert.
|
37
|
+
* @return The length of the wide string, in characters
|
38
|
+
* (not counting the NULL terminator), or < 0 for failure
|
39
|
+
*/
|
40
|
+
int git_utf8_to_16_with_len(
|
41
|
+
wchar_t *dest,
|
42
|
+
size_t dest_size,
|
43
|
+
const char *src,
|
44
|
+
int src_len);
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Converts a NUL-terminated wide string to UTF-8. This is a convenience
|
48
|
+
* function for `git_utf8_from_16_with_len`.
|
49
|
+
*
|
50
|
+
* @param dest The buffer to receive the UTF-8 string.
|
51
|
+
* @param dest_size The size of the buffer, in bytes.
|
52
|
+
* @param src The wide string to convert.
|
53
|
+
* @param src_len The length of the string to convert.
|
54
|
+
* @return The length of the UTF-8 string, in bytes
|
55
|
+
* (not counting the NULL terminator), or < 0 for failure
|
25
56
|
*/
|
26
|
-
int
|
57
|
+
int git_utf8_from_16(char *dest, size_t dest_size, const wchar_t *src);
|
27
58
|
|
28
59
|
/**
|
29
60
|
* Converts a wide string to UTF-8.
|
@@ -31,30 +62,66 @@ int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src);
|
|
31
62
|
* @param dest The buffer to receive the UTF-8 string.
|
32
63
|
* @param dest_size The size of the buffer, in bytes.
|
33
64
|
* @param src The wide string to convert.
|
34
|
-
* @
|
65
|
+
* @param src_len The length of the string to convert.
|
66
|
+
* @return The length of the UTF-8 string, in bytes
|
67
|
+
* (not counting the NULL terminator), or < 0 for failure
|
35
68
|
*/
|
36
|
-
int
|
69
|
+
int git_utf8_from_16_with_len(char *dest, size_t dest_size, const wchar_t *src, int src_len);
|
37
70
|
|
38
71
|
/**
|
39
|
-
* Converts a UTF-8 string to wide characters.
|
40
|
-
*
|
41
|
-
*
|
72
|
+
* Converts a UTF-8 string to wide characters. Memory is allocated to hold
|
73
|
+
* the converted string. The caller is responsible for freeing the string
|
74
|
+
* with git__free.
|
42
75
|
*
|
43
76
|
* @param dest Receives a pointer to the wide string.
|
44
77
|
* @param src The UTF-8 string to convert.
|
45
|
-
* @return The length of the wide string, in characters
|
78
|
+
* @return The length of the wide string, in characters
|
79
|
+
* (not counting the NULL terminator), or < 0 for failure
|
46
80
|
*/
|
47
|
-
int
|
81
|
+
int git_utf8_to_16_alloc(wchar_t **dest, const char *src);
|
48
82
|
|
49
83
|
/**
|
50
|
-
* Converts a
|
51
|
-
*
|
52
|
-
*
|
84
|
+
* Converts a UTF-8 string to wide characters. Memory is allocated to hold
|
85
|
+
* the converted string. The caller is responsible for freeing the string
|
86
|
+
* with git__free.
|
87
|
+
*
|
88
|
+
* @param dest Receives a pointer to the wide string.
|
89
|
+
* @param src The UTF-8 string to convert.
|
90
|
+
* @param src_len The length of the string.
|
91
|
+
* @return The length of the wide string, in characters
|
92
|
+
* (not counting the NULL terminator), or < 0 for failure
|
93
|
+
*/
|
94
|
+
int git_utf8_to_16_alloc_with_len(
|
95
|
+
wchar_t **dest,
|
96
|
+
const char *src,
|
97
|
+
int src_len);
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Converts a wide string to UTF-8. Memory is allocated to hold the
|
101
|
+
* converted string. The caller is responsible for freeing the string
|
102
|
+
* with git__free.
|
103
|
+
*
|
104
|
+
* @param dest Receives a pointer to the UTF-8 string.
|
105
|
+
* @param src The wide string to convert.
|
106
|
+
* @return The length of the UTF-8 string, in bytes
|
107
|
+
* (not counting the NULL terminator), or < 0 for failure
|
108
|
+
*/
|
109
|
+
int git_utf8_from_16_alloc(char **dest, const wchar_t *src);
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Converts a wide string to UTF-8. Memory is allocated to hold the
|
113
|
+
* converted string. The caller is responsible for freeing the string
|
114
|
+
* with git__free.
|
53
115
|
*
|
54
116
|
* @param dest Receives a pointer to the UTF-8 string.
|
55
117
|
* @param src The wide string to convert.
|
56
|
-
* @
|
118
|
+
* @param src_len The length of the wide string.
|
119
|
+
* @return The length of the UTF-8 string, in bytes
|
120
|
+
* (not counting the NULL terminator), or < 0 for failure
|
57
121
|
*/
|
58
|
-
int
|
122
|
+
int git_utf8_from_16_alloc_with_len(
|
123
|
+
char **dest,
|
124
|
+
const wchar_t *src,
|
125
|
+
int src_len);
|
59
126
|
|
60
127
|
#endif
|
@@ -115,7 +115,7 @@ int git_win32__file_attribute_to_stat(
|
|
115
115
|
|
116
116
|
/* st_size gets the UTF-8 length of the target name, in bytes,
|
117
117
|
* not counting the NULL terminator */
|
118
|
-
if ((st->st_size =
|
118
|
+
if ((st->st_size = git_utf8_from_16(NULL, 0, target)) < 0) {
|
119
119
|
git_error_set(GIT_ERROR_OS, "could not convert reparse point name for '%ls'", path);
|
120
120
|
return -1;
|
121
121
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rugged
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -125,8 +125,10 @@ files:
|
|
125
125
|
- vendor/libgit2/COPYING
|
126
126
|
- vendor/libgit2/cmake/AddCFlagIfSupported.cmake
|
127
127
|
- vendor/libgit2/cmake/AddClarTest.cmake
|
128
|
+
- vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake
|
128
129
|
- vendor/libgit2/cmake/DefaultCFlags.cmake
|
129
130
|
- vendor/libgit2/cmake/EnableWarnings.cmake
|
131
|
+
- vendor/libgit2/cmake/ExperimentalFeatures.cmake
|
130
132
|
- vendor/libgit2/cmake/FindCoreFoundation.cmake
|
131
133
|
- vendor/libgit2/cmake/FindGSSAPI.cmake
|
132
134
|
- vendor/libgit2/cmake/FindGSSFramework.cmake
|
@@ -149,7 +151,7 @@ files:
|
|
149
151
|
- vendor/libgit2/cmake/SelectHashes.cmake
|
150
152
|
- vendor/libgit2/cmake/SelectRegex.cmake
|
151
153
|
- vendor/libgit2/cmake/SelectSSH.cmake
|
152
|
-
- vendor/libgit2/cmake/
|
154
|
+
- vendor/libgit2/cmake/SelectXdiff.cmake
|
153
155
|
- vendor/libgit2/cmake/SelectZlib.cmake
|
154
156
|
- vendor/libgit2/deps/chromium-zlib/CMakeLists.txt
|
155
157
|
- vendor/libgit2/deps/http-parser/CMakeLists.txt
|
@@ -218,6 +220,23 @@ files:
|
|
218
220
|
- vendor/libgit2/deps/winhttp/winhttp.def
|
219
221
|
- vendor/libgit2/deps/winhttp/winhttp.h
|
220
222
|
- vendor/libgit2/deps/winhttp/winhttp64.def
|
223
|
+
- vendor/libgit2/deps/xdiff/CMakeLists.txt
|
224
|
+
- vendor/libgit2/deps/xdiff/git-xdiff.h
|
225
|
+
- vendor/libgit2/deps/xdiff/xdiff.h
|
226
|
+
- vendor/libgit2/deps/xdiff/xdiffi.c
|
227
|
+
- vendor/libgit2/deps/xdiff/xdiffi.h
|
228
|
+
- vendor/libgit2/deps/xdiff/xemit.c
|
229
|
+
- vendor/libgit2/deps/xdiff/xemit.h
|
230
|
+
- vendor/libgit2/deps/xdiff/xhistogram.c
|
231
|
+
- vendor/libgit2/deps/xdiff/xinclude.h
|
232
|
+
- vendor/libgit2/deps/xdiff/xmacros.h
|
233
|
+
- vendor/libgit2/deps/xdiff/xmerge.c
|
234
|
+
- vendor/libgit2/deps/xdiff/xpatience.c
|
235
|
+
- vendor/libgit2/deps/xdiff/xprepare.c
|
236
|
+
- vendor/libgit2/deps/xdiff/xprepare.h
|
237
|
+
- vendor/libgit2/deps/xdiff/xtypes.h
|
238
|
+
- vendor/libgit2/deps/xdiff/xutils.c
|
239
|
+
- vendor/libgit2/deps/xdiff/xutils.h
|
221
240
|
- vendor/libgit2/deps/zlib/CMakeLists.txt
|
222
241
|
- vendor/libgit2/deps/zlib/COPYING
|
223
242
|
- vendor/libgit2/deps/zlib/adler32.c
|
@@ -263,6 +282,7 @@ files:
|
|
263
282
|
- vendor/libgit2/include/git2/diff.h
|
264
283
|
- vendor/libgit2/include/git2/email.h
|
265
284
|
- vendor/libgit2/include/git2/errors.h
|
285
|
+
- vendor/libgit2/include/git2/experimental.h
|
266
286
|
- vendor/libgit2/include/git2/filter.h
|
267
287
|
- vendor/libgit2/include/git2/global.h
|
268
288
|
- vendor/libgit2/include/git2/graph.h
|
@@ -356,7 +376,6 @@ files:
|
|
356
376
|
- vendor/libgit2/src/cli/win32/precompiled.c
|
357
377
|
- vendor/libgit2/src/cli/win32/precompiled.h
|
358
378
|
- vendor/libgit2/src/cli/win32/sighandler.c
|
359
|
-
- vendor/libgit2/src/features.h.in
|
360
379
|
- vendor/libgit2/src/libgit2/CMakeLists.txt
|
361
380
|
- vendor/libgit2/src/libgit2/annotated_commit.c
|
362
381
|
- vendor/libgit2/src/libgit2/annotated_commit.h
|
@@ -428,6 +447,7 @@ files:
|
|
428
447
|
- vendor/libgit2/src/libgit2/email.h
|
429
448
|
- vendor/libgit2/src/libgit2/errors.c
|
430
449
|
- vendor/libgit2/src/libgit2/errors.h
|
450
|
+
- vendor/libgit2/src/libgit2/experimental.h.in
|
431
451
|
- vendor/libgit2/src/libgit2/fetch.c
|
432
452
|
- vendor/libgit2/src/libgit2/fetch.h
|
433
453
|
- vendor/libgit2/src/libgit2/fetchhead.c
|
@@ -435,6 +455,8 @@ files:
|
|
435
455
|
- vendor/libgit2/src/libgit2/filter.c
|
436
456
|
- vendor/libgit2/src/libgit2/filter.h
|
437
457
|
- vendor/libgit2/src/libgit2/git2.rc
|
458
|
+
- vendor/libgit2/src/libgit2/grafts.c
|
459
|
+
- vendor/libgit2/src/libgit2/grafts.h
|
438
460
|
- vendor/libgit2/src/libgit2/graph.c
|
439
461
|
- vendor/libgit2/src/libgit2/hashsig.c
|
440
462
|
- vendor/libgit2/src/libgit2/ident.c
|
@@ -462,8 +484,6 @@ files:
|
|
462
484
|
- vendor/libgit2/src/libgit2/midx.h
|
463
485
|
- vendor/libgit2/src/libgit2/mwindow.c
|
464
486
|
- vendor/libgit2/src/libgit2/mwindow.h
|
465
|
-
- vendor/libgit2/src/libgit2/netops.c
|
466
|
-
- vendor/libgit2/src/libgit2/netops.h
|
467
487
|
- vendor/libgit2/src/libgit2/notes.c
|
468
488
|
- vendor/libgit2/src/libgit2/notes.h
|
469
489
|
- vendor/libgit2/src/libgit2/object.c
|
@@ -531,6 +551,7 @@ files:
|
|
531
551
|
- vendor/libgit2/src/libgit2/status.c
|
532
552
|
- vendor/libgit2/src/libgit2/status.h
|
533
553
|
- vendor/libgit2/src/libgit2/strarray.c
|
554
|
+
- vendor/libgit2/src/libgit2/strarray.h
|
534
555
|
- vendor/libgit2/src/libgit2/stream.h
|
535
556
|
- vendor/libgit2/src/libgit2/streams/mbedtls.c
|
536
557
|
- vendor/libgit2/src/libgit2/streams/mbedtls.h
|
@@ -542,6 +563,8 @@ files:
|
|
542
563
|
- vendor/libgit2/src/libgit2/streams/openssl_legacy.h
|
543
564
|
- vendor/libgit2/src/libgit2/streams/registry.c
|
544
565
|
- vendor/libgit2/src/libgit2/streams/registry.h
|
566
|
+
- vendor/libgit2/src/libgit2/streams/schannel.c
|
567
|
+
- vendor/libgit2/src/libgit2/streams/schannel.h
|
545
568
|
- vendor/libgit2/src/libgit2/streams/socket.c
|
546
569
|
- vendor/libgit2/src/libgit2/streams/socket.h
|
547
570
|
- vendor/libgit2/src/libgit2/streams/stransport.c
|
@@ -564,10 +587,11 @@ files:
|
|
564
587
|
- vendor/libgit2/src/libgit2/transport.c
|
565
588
|
- vendor/libgit2/src/libgit2/transports/auth.c
|
566
589
|
- vendor/libgit2/src/libgit2/transports/auth.h
|
567
|
-
- vendor/libgit2/src/libgit2/transports/
|
590
|
+
- vendor/libgit2/src/libgit2/transports/auth_gssapi.c
|
568
591
|
- vendor/libgit2/src/libgit2/transports/auth_negotiate.h
|
569
|
-
- vendor/libgit2/src/libgit2/transports/auth_ntlm.c
|
570
592
|
- vendor/libgit2/src/libgit2/transports/auth_ntlm.h
|
593
|
+
- vendor/libgit2/src/libgit2/transports/auth_ntlmclient.c
|
594
|
+
- vendor/libgit2/src/libgit2/transports/auth_sspi.c
|
571
595
|
- vendor/libgit2/src/libgit2/transports/credential.c
|
572
596
|
- vendor/libgit2/src/libgit2/transports/credential_helpers.c
|
573
597
|
- vendor/libgit2/src/libgit2/transports/git.c
|
@@ -590,22 +614,6 @@ files:
|
|
590
614
|
- vendor/libgit2/src/libgit2/userdiff.h
|
591
615
|
- vendor/libgit2/src/libgit2/worktree.c
|
592
616
|
- vendor/libgit2/src/libgit2/worktree.h
|
593
|
-
- vendor/libgit2/src/libgit2/xdiff/git-xdiff.h
|
594
|
-
- vendor/libgit2/src/libgit2/xdiff/xdiff.h
|
595
|
-
- vendor/libgit2/src/libgit2/xdiff/xdiffi.c
|
596
|
-
- vendor/libgit2/src/libgit2/xdiff/xdiffi.h
|
597
|
-
- vendor/libgit2/src/libgit2/xdiff/xemit.c
|
598
|
-
- vendor/libgit2/src/libgit2/xdiff/xemit.h
|
599
|
-
- vendor/libgit2/src/libgit2/xdiff/xhistogram.c
|
600
|
-
- vendor/libgit2/src/libgit2/xdiff/xinclude.h
|
601
|
-
- vendor/libgit2/src/libgit2/xdiff/xmacros.h
|
602
|
-
- vendor/libgit2/src/libgit2/xdiff/xmerge.c
|
603
|
-
- vendor/libgit2/src/libgit2/xdiff/xpatience.c
|
604
|
-
- vendor/libgit2/src/libgit2/xdiff/xprepare.c
|
605
|
-
- vendor/libgit2/src/libgit2/xdiff/xprepare.h
|
606
|
-
- vendor/libgit2/src/libgit2/xdiff/xtypes.h
|
607
|
-
- vendor/libgit2/src/libgit2/xdiff/xutils.c
|
608
|
-
- vendor/libgit2/src/libgit2/xdiff/xutils.h
|
609
617
|
- vendor/libgit2/src/util/CMakeLists.txt
|
610
618
|
- vendor/libgit2/src/util/alloc.c
|
611
619
|
- vendor/libgit2/src/util/alloc.h
|
@@ -627,6 +635,7 @@ files:
|
|
627
635
|
- vendor/libgit2/src/util/fs_path.h
|
628
636
|
- vendor/libgit2/src/util/futils.c
|
629
637
|
- vendor/libgit2/src/util/futils.h
|
638
|
+
- vendor/libgit2/src/util/git2_features.h.in
|
630
639
|
- vendor/libgit2/src/util/git2_util.h
|
631
640
|
- vendor/libgit2/src/util/hash.c
|
632
641
|
- vendor/libgit2/src/util/hash.h
|
@@ -668,6 +677,7 @@ files:
|
|
668
677
|
- vendor/libgit2/src/util/runtime.h
|
669
678
|
- vendor/libgit2/src/util/sortedcache.c
|
670
679
|
- vendor/libgit2/src/util/sortedcache.h
|
680
|
+
- vendor/libgit2/src/util/staticstr.h
|
671
681
|
- vendor/libgit2/src/util/str.c
|
672
682
|
- vendor/libgit2/src/util/str.h
|
673
683
|
- vendor/libgit2/src/util/strmap.c
|
@@ -694,8 +704,6 @@ files:
|
|
694
704
|
- vendor/libgit2/src/util/win32/dir.h
|
695
705
|
- vendor/libgit2/src/util/win32/error.c
|
696
706
|
- vendor/libgit2/src/util/win32/error.h
|
697
|
-
- vendor/libgit2/src/util/win32/findfile.c
|
698
|
-
- vendor/libgit2/src/util/win32/findfile.h
|
699
707
|
- vendor/libgit2/src/util/win32/map.c
|
700
708
|
- vendor/libgit2/src/util/win32/mingw-compat.h
|
701
709
|
- vendor/libgit2/src/util/win32/msvc-compat.h
|
@@ -1,17 +0,0 @@
|
|
1
|
-
if(WIN32 AND USE_WINHTTP)
|
2
|
-
set(GIT_WINHTTP 1)
|
3
|
-
|
4
|
-
# Since MinGW does not come with headers or an import library for winhttp,
|
5
|
-
# we have to include a private header and generate our own import library
|
6
|
-
if(MINGW)
|
7
|
-
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
|
8
|
-
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
|
9
|
-
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/winhttp")
|
10
|
-
else()
|
11
|
-
list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp")
|
12
|
-
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
|
13
|
-
endif()
|
14
|
-
|
15
|
-
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
|
16
|
-
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
|
17
|
-
endif()
|
@@ -1,124 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
-
*
|
4
|
-
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
-
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
-
*/
|
7
|
-
|
8
|
-
#include "netops.h"
|
9
|
-
|
10
|
-
#include <ctype.h>
|
11
|
-
#include "git2/errors.h"
|
12
|
-
|
13
|
-
#include "posix.h"
|
14
|
-
#include "str.h"
|
15
|
-
#include "runtime.h"
|
16
|
-
|
17
|
-
int gitno_recv(gitno_buffer *buf)
|
18
|
-
{
|
19
|
-
return buf->recv(buf);
|
20
|
-
}
|
21
|
-
|
22
|
-
void gitno_buffer_setup_callback(
|
23
|
-
gitno_buffer *buf,
|
24
|
-
char *data,
|
25
|
-
size_t len,
|
26
|
-
int (*recv)(gitno_buffer *buf), void *cb_data)
|
27
|
-
{
|
28
|
-
memset(data, 0x0, len);
|
29
|
-
buf->data = data;
|
30
|
-
buf->len = len;
|
31
|
-
buf->offset = 0;
|
32
|
-
buf->recv = recv;
|
33
|
-
buf->cb_data = cb_data;
|
34
|
-
}
|
35
|
-
|
36
|
-
static int recv_stream(gitno_buffer *buf)
|
37
|
-
{
|
38
|
-
git_stream *io = (git_stream *) buf->cb_data;
|
39
|
-
size_t readlen = buf->len - buf->offset;
|
40
|
-
ssize_t ret;
|
41
|
-
|
42
|
-
readlen = min(readlen, INT_MAX);
|
43
|
-
|
44
|
-
ret = git_stream_read(io, buf->data + buf->offset, (int)readlen);
|
45
|
-
if (ret < 0)
|
46
|
-
return -1;
|
47
|
-
|
48
|
-
buf->offset += ret;
|
49
|
-
return (int)ret;
|
50
|
-
}
|
51
|
-
|
52
|
-
void gitno_buffer_setup_fromstream(git_stream *st, gitno_buffer *buf, char *data, size_t len)
|
53
|
-
{
|
54
|
-
memset(data, 0x0, len);
|
55
|
-
buf->data = data;
|
56
|
-
buf->len = len;
|
57
|
-
buf->offset = 0;
|
58
|
-
buf->recv = recv_stream;
|
59
|
-
buf->cb_data = st;
|
60
|
-
}
|
61
|
-
|
62
|
-
/* Consume up to ptr and move the rest of the buffer to the beginning */
|
63
|
-
int gitno_consume(gitno_buffer *buf, const char *ptr)
|
64
|
-
{
|
65
|
-
size_t consumed;
|
66
|
-
|
67
|
-
GIT_ASSERT(ptr - buf->data >= 0);
|
68
|
-
GIT_ASSERT(ptr - buf->data <= (int) buf->len);
|
69
|
-
|
70
|
-
consumed = ptr - buf->data;
|
71
|
-
|
72
|
-
memmove(buf->data, ptr, buf->offset - consumed);
|
73
|
-
memset(buf->data + buf->offset, 0x0, buf->len - buf->offset);
|
74
|
-
buf->offset -= consumed;
|
75
|
-
|
76
|
-
return 0;
|
77
|
-
}
|
78
|
-
|
79
|
-
/* Consume const bytes and move the rest of the buffer to the beginning */
|
80
|
-
void gitno_consume_n(gitno_buffer *buf, size_t cons)
|
81
|
-
{
|
82
|
-
memmove(buf->data, buf->data + cons, buf->len - buf->offset);
|
83
|
-
memset(buf->data + cons, 0x0, buf->len - buf->offset);
|
84
|
-
buf->offset -= cons;
|
85
|
-
}
|
86
|
-
|
87
|
-
/* Match host names according to RFC 2818 rules */
|
88
|
-
int gitno__match_host(const char *pattern, const char *host)
|
89
|
-
{
|
90
|
-
for (;;) {
|
91
|
-
char c = git__tolower(*pattern++);
|
92
|
-
|
93
|
-
if (c == '\0')
|
94
|
-
return *host ? -1 : 0;
|
95
|
-
|
96
|
-
if (c == '*') {
|
97
|
-
c = *pattern;
|
98
|
-
/* '*' at the end matches everything left */
|
99
|
-
if (c == '\0')
|
100
|
-
return 0;
|
101
|
-
|
102
|
-
/*
|
103
|
-
* We've found a pattern, so move towards the next matching
|
104
|
-
* char. The '.' is handled specially because wildcards aren't
|
105
|
-
* allowed to cross subdomains.
|
106
|
-
*/
|
107
|
-
|
108
|
-
while(*host) {
|
109
|
-
char h = git__tolower(*host);
|
110
|
-
if (c == h)
|
111
|
-
return gitno__match_host(pattern, host++);
|
112
|
-
if (h == '.')
|
113
|
-
return gitno__match_host(pattern, host);
|
114
|
-
host++;
|
115
|
-
}
|
116
|
-
return -1;
|
117
|
-
}
|
118
|
-
|
119
|
-
if (c != git__tolower(*host++))
|
120
|
-
return -1;
|
121
|
-
}
|
122
|
-
|
123
|
-
return -1;
|
124
|
-
}
|