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
@@ -9,12 +9,30 @@
|
|
9
9
|
|
10
10
|
#include "git2_util.h"
|
11
11
|
|
12
|
+
/*
|
13
|
+
* Hostname handling
|
14
|
+
*/
|
15
|
+
|
16
|
+
/*
|
17
|
+
* See if a given hostname matches a certificate name pattern, according
|
18
|
+
* to RFC2818 rules (which specifies HTTP over TLS). Mainly, an asterisk
|
19
|
+
* matches anything, but is limited to a single url component.
|
20
|
+
*/
|
21
|
+
extern bool git_net_hostname_matches_cert(
|
22
|
+
const char *hostname,
|
23
|
+
const char *pattern);
|
24
|
+
|
25
|
+
/*
|
26
|
+
* URL handling
|
27
|
+
*/
|
28
|
+
|
12
29
|
typedef struct git_net_url {
|
13
30
|
char *scheme;
|
14
31
|
char *host;
|
15
32
|
char *port;
|
16
33
|
char *path;
|
17
34
|
char *query;
|
35
|
+
char *fragment;
|
18
36
|
char *username;
|
19
37
|
char *password;
|
20
38
|
} git_net_url;
|
@@ -33,6 +51,20 @@ extern int git_net_url_parse(git_net_url *url, const char *str);
|
|
33
51
|
/** Parses a string containing an SCP style path into a URL structure. */
|
34
52
|
extern int git_net_url_parse_scp(git_net_url *url, const char *str);
|
35
53
|
|
54
|
+
/**
|
55
|
+
* Parses a string containing a standard URL or an SCP style path into
|
56
|
+
* a URL structure.
|
57
|
+
*/
|
58
|
+
extern int git_net_url_parse_standard_or_scp(git_net_url *url, const char *str);
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Parses a string containing an HTTP endpoint that may not be a
|
62
|
+
* well-formed URL. For example, "localhost" or "localhost:port".
|
63
|
+
*/
|
64
|
+
extern int git_net_url_parse_http(
|
65
|
+
git_net_url *url,
|
66
|
+
const char *str);
|
67
|
+
|
36
68
|
/** Appends a path and/or query string to the given URL */
|
37
69
|
extern int git_net_url_joinpath(
|
38
70
|
git_net_url *out,
|
@@ -301,3 +301,57 @@ int p_munmap(git_map *map)
|
|
301
301
|
}
|
302
302
|
|
303
303
|
#endif
|
304
|
+
|
305
|
+
#if defined(GIT_IO_POLL) || defined(GIT_IO_WSAPOLL)
|
306
|
+
|
307
|
+
/* Handled by posix.h; this test simplifies the final else */
|
308
|
+
|
309
|
+
#elif defined(GIT_IO_SELECT)
|
310
|
+
|
311
|
+
int p_poll(struct pollfd *fds, unsigned int nfds, int timeout_ms)
|
312
|
+
{
|
313
|
+
fd_set read_fds, write_fds, except_fds;
|
314
|
+
struct timeval timeout = { 0, 0 };
|
315
|
+
unsigned int i;
|
316
|
+
int max_fd = -1, ret;
|
317
|
+
|
318
|
+
FD_ZERO(&read_fds);
|
319
|
+
FD_ZERO(&write_fds);
|
320
|
+
FD_ZERO(&except_fds);
|
321
|
+
|
322
|
+
for (i = 0; i < nfds; i++) {
|
323
|
+
if ((fds[i].events & POLLIN))
|
324
|
+
FD_SET(fds[i].fd, &read_fds);
|
325
|
+
|
326
|
+
if ((fds[i].events & POLLOUT))
|
327
|
+
FD_SET(fds[i].fd, &write_fds);
|
328
|
+
|
329
|
+
if ((fds[i].events & POLLPRI))
|
330
|
+
FD_SET(fds[i].fd, &except_fds);
|
331
|
+
|
332
|
+
max_fd = MAX(max_fd, fds[i].fd);
|
333
|
+
}
|
334
|
+
|
335
|
+
if (timeout_ms > 0) {
|
336
|
+
timeout.tv_sec = timeout_ms / 1000;
|
337
|
+
timeout.tv_usec = (timeout_ms % 1000) * 1000;
|
338
|
+
}
|
339
|
+
|
340
|
+
if ((ret = select(max_fd + 1, &read_fds, &write_fds, &except_fds,
|
341
|
+
timeout_ms < 0 ? NULL : &timeout)) < 0)
|
342
|
+
goto done;
|
343
|
+
|
344
|
+
for (i = 0; i < nfds; i++) {
|
345
|
+
fds[i].revents = 0 |
|
346
|
+
FD_ISSET(fds[i].fd, &read_fds) ? POLLIN : 0 |
|
347
|
+
FD_ISSET(fds[i].fd, &write_fds) ? POLLOUT : 0 |
|
348
|
+
FD_ISSET(fds[i].fd, &except_fds) ? POLLPRI : 0;
|
349
|
+
}
|
350
|
+
|
351
|
+
done:
|
352
|
+
return ret;
|
353
|
+
}
|
354
|
+
|
355
|
+
#else
|
356
|
+
# error no poll compatible implementation
|
357
|
+
#endif
|
@@ -104,6 +104,8 @@ typedef __int64 off64_t;
|
|
104
104
|
typedef __haiku_std_int64 off64_t;
|
105
105
|
#elif defined(__APPLE__)
|
106
106
|
typedef __int64_t off64_t;
|
107
|
+
#elif defined(_AIX)
|
108
|
+
typedef long long off64_t;
|
107
109
|
#else
|
108
110
|
typedef int64_t off64_t;
|
109
111
|
#endif
|
@@ -193,4 +195,26 @@ extern const char *p_gai_strerror(int ret);
|
|
193
195
|
# define p_gai_strerror(c) gai_strerror(c)
|
194
196
|
#endif /* NO_ADDRINFO */
|
195
197
|
|
198
|
+
#ifdef GIT_IO_POLL
|
199
|
+
# include <poll.h>
|
200
|
+
# define p_poll poll
|
201
|
+
#elif GIT_IO_WSAPOLL
|
202
|
+
# include <winsock2.h>
|
203
|
+
# define p_poll WSAPoll
|
204
|
+
#else
|
205
|
+
# define POLLIN 0x01
|
206
|
+
# define POLLPRI 0x02
|
207
|
+
# define POLLOUT 0x04
|
208
|
+
# define POLLERR 0x08
|
209
|
+
# define POLLHUP 0x10
|
210
|
+
|
211
|
+
struct pollfd {
|
212
|
+
int fd;
|
213
|
+
short events;
|
214
|
+
short revents;
|
215
|
+
};
|
216
|
+
|
217
|
+
extern int p_poll(struct pollfd *fds, unsigned int nfds, int timeout);
|
218
|
+
#endif
|
219
|
+
|
196
220
|
#endif
|
@@ -14,6 +14,10 @@ See <http://creativecommons.org/publicdomain/zero/1.0/>. */
|
|
14
14
|
# include <sys/random.h>
|
15
15
|
#endif
|
16
16
|
|
17
|
+
#if defined(GIT_WIN32)
|
18
|
+
# include <wincrypt.h>
|
19
|
+
#endif
|
20
|
+
|
17
21
|
static uint64_t state[4];
|
18
22
|
static git_mutex state_lock;
|
19
23
|
|
@@ -28,7 +32,6 @@ GIT_INLINE(int) getseed(uint64_t *seed)
|
|
28
32
|
HCRYPTPROV provider;
|
29
33
|
SYSTEMTIME systemtime;
|
30
34
|
FILETIME filetime, idletime, kerneltime, usertime;
|
31
|
-
bits convert;
|
32
35
|
|
33
36
|
if (CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL,
|
34
37
|
CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) {
|
@@ -63,7 +66,7 @@ GIT_INLINE(int) getseed(uint64_t *seed)
|
|
63
66
|
*seed ^= ((uint64_t)GetCurrentProcessId() << 32);
|
64
67
|
*seed ^= ((uint64_t)GetCurrentThreadId() << 48);
|
65
68
|
|
66
|
-
|
69
|
+
*seed ^= git_time_monotonic();
|
67
70
|
|
68
71
|
/* Mix in the addresses of some functions and variables */
|
69
72
|
*seed ^= (((uint64_t)((uintptr_t)seed) << 32));
|
@@ -78,9 +81,12 @@ GIT_INLINE(int) getseed(uint64_t *seed)
|
|
78
81
|
{
|
79
82
|
struct timeval tv;
|
80
83
|
double loadavg[3];
|
81
|
-
bits convert;
|
82
84
|
int fd;
|
83
85
|
|
86
|
+
# if defined(GIT_RAND_GETLOADAVG)
|
87
|
+
bits convert;
|
88
|
+
# endif
|
89
|
+
|
84
90
|
# if defined(GIT_RAND_GETENTROPY)
|
85
91
|
GIT_UNUSED((fd = 0));
|
86
92
|
|
@@ -127,7 +133,7 @@ GIT_INLINE(int) getseed(uint64_t *seed)
|
|
127
133
|
GIT_UNUSED(loadavg[0]);
|
128
134
|
# endif
|
129
135
|
|
130
|
-
|
136
|
+
*seed ^= git_time_monotonic();
|
131
137
|
|
132
138
|
/* Mix in the addresses of some variables */
|
133
139
|
*seed ^= ((uint64_t)((size_t)((void *)seed)) << 32);
|
@@ -108,11 +108,11 @@ int git_regexp_match(const git_regexp *r, const char *string)
|
|
108
108
|
data = pcre2_match_data_create(1, NULL);
|
109
109
|
GIT_ERROR_CHECK_ALLOC(data);
|
110
110
|
|
111
|
-
|
112
|
-
|
111
|
+
error = pcre2_match(*r, (const unsigned char *) string, strlen(string), 0, 0, data, NULL);
|
112
|
+
pcre2_match_data_free(data);
|
113
|
+
if (error < 0)
|
113
114
|
return (error == PCRE2_ERROR_NOMATCH) ? GIT_ENOTFOUND : GIT_EINVALIDSPEC;
|
114
115
|
|
115
|
-
pcre2_match_data_free(data);
|
116
116
|
return 0;
|
117
117
|
}
|
118
118
|
|
@@ -0,0 +1,66 @@
|
|
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
|
+
#ifndef INCLUDE_stackstr_h__
|
8
|
+
#define INCLUDE_stackstr_h__
|
9
|
+
|
10
|
+
#include "git2_util.h"
|
11
|
+
|
12
|
+
typedef struct {
|
13
|
+
/* Length of / number of bytes used by `data`. */
|
14
|
+
size_t len;
|
15
|
+
|
16
|
+
/* Size of the allocated `data` buffer. */
|
17
|
+
size_t size;
|
18
|
+
|
19
|
+
/* The actual string buffer data. */
|
20
|
+
char data[GIT_FLEX_ARRAY];
|
21
|
+
} git_staticstr;
|
22
|
+
|
23
|
+
#define git_staticstr_with_size(__size) \
|
24
|
+
struct { \
|
25
|
+
size_t len; \
|
26
|
+
size_t size; \
|
27
|
+
char data[__size]; \
|
28
|
+
}
|
29
|
+
|
30
|
+
#define git_staticstr_init(__str, __size) \
|
31
|
+
do { \
|
32
|
+
(__str)->len = 0; \
|
33
|
+
(__str)->size = __size; \
|
34
|
+
(__str)->data[0] = '\0'; \
|
35
|
+
} while(0)
|
36
|
+
|
37
|
+
#define git_staticstr_offset(__str) \
|
38
|
+
((__str)->data + (__str)->len)
|
39
|
+
|
40
|
+
#define git_staticstr_remain(__str) \
|
41
|
+
((__str)->len > (__str)->size ? 0 : ((__str)->size - (__str)->len))
|
42
|
+
|
43
|
+
#define git_staticstr_increase(__str, __len) \
|
44
|
+
do { ((__str)->len += __len); } while(0)
|
45
|
+
|
46
|
+
#define git_staticstr_consume_bytes(__str, __len) \
|
47
|
+
do { git_staticstr_consume(__str, (__str)->data + __len); } while(0)
|
48
|
+
|
49
|
+
#define git_staticstr_consume(__str, __end) \
|
50
|
+
do { \
|
51
|
+
if (__end > (__str)->data && \
|
52
|
+
__end <= (__str)->data + (__str)->len) { \
|
53
|
+
size_t __consumed = __end - (__str)->data; \
|
54
|
+
memmove((__str)->data, __end, (__str)->len - __consumed); \
|
55
|
+
(__str)->len -= __consumed; \
|
56
|
+
(__str)->data[(__str)->len] = '\0'; \
|
57
|
+
} \
|
58
|
+
} while(0)
|
59
|
+
|
60
|
+
#define git_staticstr_clear(__str) \
|
61
|
+
do { \
|
62
|
+
(__str)->len = 0; \
|
63
|
+
(__str)->data[0] = 0; \
|
64
|
+
} while(0)
|
65
|
+
|
66
|
+
#endif
|
@@ -260,36 +260,37 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
|
|
260
260
|
|
261
261
|
#else
|
262
262
|
|
263
|
-
#define git_threads_global_init
|
263
|
+
#define git_threads_global_init git__noop
|
264
264
|
|
265
265
|
#define git_thread unsigned int
|
266
|
-
#define git_thread_create(
|
267
|
-
#define git_thread_join(
|
266
|
+
#define git_thread_create(t, s, a) git__noop(t, s, a)
|
267
|
+
#define git_thread_join(i, s) git__noop_args(i, s)
|
268
268
|
|
269
269
|
/* Pthreads Mutex */
|
270
270
|
#define git_mutex unsigned int
|
271
|
-
#define git_mutex_init(a)
|
272
|
-
#define git_mutex_init(a)
|
273
|
-
#define git_mutex_lock(a)
|
274
|
-
#define git_mutex_unlock(a)
|
275
|
-
#define git_mutex_free(a)
|
271
|
+
#define git_mutex_init(a) git__noop_args(a)
|
272
|
+
#define git_mutex_init(a) git__noop_args(a)
|
273
|
+
#define git_mutex_lock(a) git__noop_args(a)
|
274
|
+
#define git_mutex_unlock(a) git__noop_args(a)
|
275
|
+
#define git_mutex_free(a) git__noop_args(a)
|
276
276
|
|
277
277
|
/* Pthreads condition vars */
|
278
278
|
#define git_cond unsigned int
|
279
|
-
#define git_cond_init(c)
|
280
|
-
#define git_cond_free(c)
|
281
|
-
#define git_cond_wait(c, l)
|
282
|
-
#define git_cond_signal(c)
|
283
|
-
#define git_cond_broadcast(c)
|
279
|
+
#define git_cond_init(c) git__noop_args(c)
|
280
|
+
#define git_cond_free(c) git__noop_args(c)
|
281
|
+
#define git_cond_wait(c, l) git__noop_args(c, l)
|
282
|
+
#define git_cond_signal(c) git__noop_args(c)
|
283
|
+
#define git_cond_broadcast(c) git__noop_args(c)
|
284
284
|
|
285
285
|
/* Pthreads rwlock */
|
286
286
|
#define git_rwlock unsigned int
|
287
|
-
#define git_rwlock_init(a)
|
288
|
-
#define git_rwlock_rdlock(a)
|
289
|
-
#define git_rwlock_rdunlock(a)
|
290
|
-
#define git_rwlock_wrlock(a)
|
291
|
-
#define git_rwlock_wrunlock(a)
|
292
|
-
#define git_rwlock_free(a)
|
287
|
+
#define git_rwlock_init(a) git__noop_args(a)
|
288
|
+
#define git_rwlock_rdlock(a) git__noop_args(a)
|
289
|
+
#define git_rwlock_rdunlock(a) git__noop_args(a)
|
290
|
+
#define git_rwlock_wrlock(a) git__noop_args(a)
|
291
|
+
#define git_rwlock_wrunlock(a) git__noop_args(a)
|
292
|
+
#define git_rwlock_free(a) git__noop_args(a)
|
293
|
+
|
293
294
|
#define GIT_RWLOCK_STATIC_INIT 0
|
294
295
|
|
295
296
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# endif
|
19
19
|
# include <windows.h>
|
20
20
|
|
21
|
-
# ifdef
|
21
|
+
# ifdef GIT_QSORT_MSC
|
22
22
|
# include <search.h>
|
23
23
|
# endif
|
24
24
|
#endif
|
@@ -673,7 +673,7 @@ size_t git__unescape(char *str)
|
|
673
673
|
return (pos - str);
|
674
674
|
}
|
675
675
|
|
676
|
-
#if defined(
|
676
|
+
#if defined(GIT_QSORT_MSC) || defined(GIT_QSORT_BSD)
|
677
677
|
typedef struct {
|
678
678
|
git__sort_r_cmp cmp;
|
679
679
|
void *payload;
|
@@ -688,9 +688,11 @@ static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
|
|
688
688
|
#endif
|
689
689
|
|
690
690
|
|
691
|
-
#if !defined(
|
692
|
-
|
693
|
-
|
691
|
+
#if !defined(GIT_QSORT_BSD) && \
|
692
|
+
!defined(GIT_QSORT_GNU) && \
|
693
|
+
!defined(GIT_QSORT_C11) && \
|
694
|
+
!defined(GIT_QSORT_MSC)
|
695
|
+
|
694
696
|
static void swap(uint8_t *a, uint8_t *b, size_t elsize)
|
695
697
|
{
|
696
698
|
char tmp[256];
|
@@ -716,17 +718,20 @@ static void insertsort(
|
|
716
718
|
for (j = i; j > base && cmp(j, j - elsize, payload) < 0; j -= elsize)
|
717
719
|
swap(j, j - elsize, elsize);
|
718
720
|
}
|
721
|
+
|
719
722
|
#endif
|
720
723
|
|
721
724
|
void git__qsort_r(
|
722
725
|
void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload)
|
723
726
|
{
|
724
|
-
#if defined(
|
727
|
+
#if defined(GIT_QSORT_GNU)
|
728
|
+
qsort_r(els, nel, elsize, cmp, payload);
|
729
|
+
#elif defined(GIT_QSORT_C11)
|
730
|
+
qsort_s(els, nel, elsize, cmp, payload);
|
731
|
+
#elif defined(GIT_QSORT_BSD)
|
725
732
|
git__qsort_r_glue glue = { cmp, payload };
|
726
733
|
qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp);
|
727
|
-
#elif defined(
|
728
|
-
qsort_r(els, nel, elsize, cmp, payload);
|
729
|
-
#elif defined(GIT_QSORT_S)
|
734
|
+
#elif defined(GIT_QSORT_MSC)
|
730
735
|
git__qsort_r_glue glue = { cmp, payload };
|
731
736
|
qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue);
|
732
737
|
#else
|
@@ -743,7 +748,7 @@ int git__getenv(git_str *out, const char *name)
|
|
743
748
|
|
744
749
|
git_str_clear(out);
|
745
750
|
|
746
|
-
if (
|
751
|
+
if (git_utf8_to_16_alloc(&wide_name, name) < 0)
|
747
752
|
return -1;
|
748
753
|
|
749
754
|
if ((value_len = GetEnvironmentVariableW(wide_name, NULL, 0)) > 0) {
|
@@ -319,59 +319,67 @@ GIT_INLINE(void) git__memzero(void *data, size_t size)
|
|
319
319
|
|
320
320
|
#ifdef GIT_WIN32
|
321
321
|
|
322
|
-
GIT_INLINE(
|
322
|
+
GIT_INLINE(uint64_t) git_time_monotonic(void)
|
323
323
|
{
|
324
324
|
/* GetTickCount64 returns the number of milliseconds that have
|
325
325
|
* elapsed since the system was started. */
|
326
|
-
return
|
326
|
+
return GetTickCount64();
|
327
327
|
}
|
328
328
|
|
329
329
|
#elif __APPLE__
|
330
330
|
|
331
331
|
#include <mach/mach_time.h>
|
332
|
+
#include <sys/time.h>
|
332
333
|
|
333
|
-
GIT_INLINE(
|
334
|
+
GIT_INLINE(uint64_t) git_time_monotonic(void)
|
334
335
|
{
|
335
|
-
|
336
|
-
|
336
|
+
static double scaling_factor = 0;
|
337
|
+
|
338
|
+
if (scaling_factor == 0) {
|
339
|
+
mach_timebase_info_data_t info;
|
337
340
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
341
|
+
scaling_factor = mach_timebase_info(&info) == KERN_SUCCESS ?
|
342
|
+
((double)info.numer / (double)info.denom) / 1.0E6 :
|
343
|
+
-1;
|
344
|
+
} else if (scaling_factor < 0) {
|
345
|
+
struct timeval tv;
|
346
|
+
|
347
|
+
/* mach_timebase_info failed; fall back to gettimeofday */
|
348
|
+
gettimeofday(&tv, NULL);
|
349
|
+
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
350
|
+
}
|
343
351
|
|
344
|
-
|
352
|
+
return (uint64_t)(mach_absolute_time() * scaling_factor);
|
345
353
|
}
|
346
354
|
|
347
355
|
#elif defined(__amigaos4__)
|
348
356
|
|
349
357
|
#include <proto/timer.h>
|
350
358
|
|
351
|
-
GIT_INLINE(
|
359
|
+
GIT_INLINE(uint64_t) git_time_monotonic(void)
|
352
360
|
{
|
353
361
|
struct TimeVal tv;
|
354
362
|
ITimer->GetUpTime(&tv);
|
355
|
-
return (
|
363
|
+
return (tv.Seconds * 1000) + (tv.Microseconds / 1000);
|
356
364
|
}
|
357
365
|
|
358
366
|
#else
|
359
367
|
|
360
368
|
#include <sys/time.h>
|
361
369
|
|
362
|
-
GIT_INLINE(
|
370
|
+
GIT_INLINE(uint64_t) git_time_monotonic(void)
|
363
371
|
{
|
364
372
|
struct timeval tv;
|
365
373
|
|
366
374
|
#ifdef CLOCK_MONOTONIC
|
367
375
|
struct timespec tp;
|
368
376
|
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
|
369
|
-
return (
|
377
|
+
return (tp.tv_sec * 1000) + (tp.tv_nsec / 1.0E6);
|
370
378
|
#endif
|
371
379
|
|
372
380
|
/* Fall back to using gettimeofday */
|
373
381
|
gettimeofday(&tv, NULL);
|
374
|
-
return (
|
382
|
+
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
375
383
|
}
|
376
384
|
|
377
385
|
#endif
|
@@ -381,6 +389,7 @@ extern int git__getenv(git_str *out, const char *name);
|
|
381
389
|
extern int git__online_cpus(void);
|
382
390
|
|
383
391
|
GIT_INLINE(int) git__noop(void) { return 0; }
|
392
|
+
GIT_INLINE(int) git__noop_args(void *a, ...) { GIT_UNUSED(a); return 0; }
|
384
393
|
|
385
394
|
#include "alloc.h"
|
386
395
|
|
@@ -43,7 +43,7 @@ char *git_win32_get_error_message(DWORD error_code)
|
|
43
43
|
(LPWSTR)&lpMsgBuf, 0, NULL)) {
|
44
44
|
/* Convert the message to UTF-8. If this fails, we will
|
45
45
|
* return NULL, which is a condition expected by the caller */
|
46
|
-
if (
|
46
|
+
if (git_utf8_from_16_alloc(&utf8_msg, lpMsgBuf) < 0)
|
47
47
|
utf8_msg = NULL;
|
48
48
|
|
49
49
|
LocalFree(lpMsgBuf);
|
@@ -336,13 +336,13 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
|
|
336
336
|
|
337
337
|
/* See if this is an absolute path (beginning with a drive letter) */
|
338
338
|
if (git_fs_path_is_absolute(src)) {
|
339
|
-
if (
|
339
|
+
if (git_utf8_to_16(dest, GIT_WIN_PATH_MAX, src) < 0)
|
340
340
|
goto on_error;
|
341
341
|
}
|
342
342
|
/* File-prefixed NT-style paths beginning with \\?\ */
|
343
343
|
else if (path__is_nt_namespace(src)) {
|
344
344
|
/* Skip the NT prefix, the destination already contains it */
|
345
|
-
if (
|
345
|
+
if (git_utf8_to_16(dest, GIT_WIN_PATH_MAX, src + PATH__NT_NAMESPACE_LEN) < 0)
|
346
346
|
goto on_error;
|
347
347
|
}
|
348
348
|
/* UNC paths */
|
@@ -351,7 +351,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
|
|
351
351
|
dest += 4;
|
352
352
|
|
353
353
|
/* Skip the leading "\\" */
|
354
|
-
if (
|
354
|
+
if (git_utf8_to_16(dest, GIT_WIN_PATH_MAX - 2, src + 2) < 0)
|
355
355
|
goto on_error;
|
356
356
|
}
|
357
357
|
/* Absolute paths omitting the drive letter */
|
@@ -365,7 +365,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
|
|
365
365
|
}
|
366
366
|
|
367
367
|
/* Skip the drive letter specification ("C:") */
|
368
|
-
if (
|
368
|
+
if (git_utf8_to_16(dest + 2, GIT_WIN_PATH_MAX - 2, src) < 0)
|
369
369
|
goto on_error;
|
370
370
|
}
|
371
371
|
/* Relative paths */
|
@@ -377,7 +377,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src)
|
|
377
377
|
|
378
378
|
dest[cwd_len++] = L'\\';
|
379
379
|
|
380
|
-
if (
|
380
|
+
if (git_utf8_to_16(dest + cwd_len, GIT_WIN_PATH_MAX - cwd_len, src) < 0)
|
381
381
|
goto on_error;
|
382
382
|
}
|
383
383
|
|
@@ -404,7 +404,7 @@ int git_win32_path_relative_from_utf8(git_win32_path out, const char *src)
|
|
404
404
|
return git_win32_path_from_utf8(out, src);
|
405
405
|
}
|
406
406
|
|
407
|
-
if ((len =
|
407
|
+
if ((len = git_utf8_to_16(dest, GIT_WIN_PATH_MAX, src)) < 0)
|
408
408
|
return -1;
|
409
409
|
|
410
410
|
for (p = dest; p < (dest + len); p++) {
|
@@ -433,7 +433,7 @@ int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src)
|
|
433
433
|
}
|
434
434
|
}
|
435
435
|
|
436
|
-
if ((len =
|
436
|
+
if ((len = git_utf8_from_16(out, GIT_WIN_PATH_UTF8, src)) < 0)
|
437
437
|
return len;
|
438
438
|
|
439
439
|
git_fs_path_mkposix(dest);
|
@@ -471,7 +471,7 @@ char *git_win32_path_8dot3_name(const char *path)
|
|
471
471
|
if (namelen > 12 || (shortname = git__malloc(namelen + 1)) == NULL)
|
472
472
|
return NULL;
|
473
473
|
|
474
|
-
if ((len =
|
474
|
+
if ((len = git_utf8_from_16(shortname, namelen + 1, start)) < 0)
|
475
475
|
return NULL;
|
476
476
|
|
477
477
|
return shortname;
|
@@ -649,7 +649,7 @@ int p_getcwd(char *buffer_out, size_t size)
|
|
649
649
|
git_win32_path_remove_namespace(cwd, wcslen(cwd));
|
650
650
|
|
651
651
|
/* Convert the working directory back to UTF-8 */
|
652
|
-
if (
|
652
|
+
if (git_utf8_from_16(buffer_out, size, cwd) < 0) {
|
653
653
|
DWORD code = GetLastError();
|
654
654
|
|
655
655
|
if (code == ERROR_INSUFFICIENT_BUFFER)
|