rugged 1.6.5 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/rugged_allocator.c +0 -54
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +3 -8
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +26 -1
- data/vendor/libgit2/include/git2/diff.h +41 -3
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +12 -2
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +20 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/src/CMakeLists.txt +34 -11
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +1 -19
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/blame.c +23 -16
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +3 -1
- data/vendor/libgit2/src/libgit2/commit.c +31 -9
- data/vendor/libgit2/src/libgit2/commit_graph.c +110 -43
- data/vendor/libgit2/src/libgit2/commit_graph.h +20 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +12 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config_file.c +14 -8
- data/vendor/libgit2/src/libgit2/describe.c +10 -7
- data/vendor/libgit2/src/libgit2/diff.c +16 -7
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +7 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +36 -15
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -4
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/fetch.c +37 -9
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +323 -120
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +10 -3
- data/vendor/libgit2/src/libgit2/iterator.c +20 -5
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +39 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +66 -37
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +40 -15
- data/vendor/libgit2/src/libgit2/object.h +6 -0
- data/vendor/libgit2/src/libgit2/odb.c +11 -5
- data/vendor/libgit2/src/libgit2/odb_pack.c +16 -3
- data/vendor/libgit2/src/libgit2/oid.c +7 -1
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +19 -12
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +3 -3
- data/vendor/libgit2/src/libgit2/parse.c +7 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +2 -2
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -84
- data/vendor/libgit2/src/libgit2/refdb_fs.c +22 -13
- data/vendor/libgit2/src/libgit2/refs.c +8 -1
- data/vendor/libgit2/src/libgit2/remote.c +15 -6
- data/vendor/libgit2/src/libgit2/remote.h +1 -0
- data/vendor/libgit2/src/libgit2/repository.c +580 -301
- data/vendor/libgit2/src/libgit2/repository.h +17 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revwalk.c +26 -4
- data/vendor/libgit2/src/libgit2/stash.c +9 -8
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +8 -16
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +237 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +7 -2
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +5 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +13 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +33 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +23 -8
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +135 -15
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +154 -47
- data/vendor/libgit2/src/libgit2/transports/ssh.c +3 -3
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +14 -15
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +1 -1
- data/vendor/libgit2/src/libgit2/worktree.c +25 -10
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +1 -1
- data/vendor/libgit2/src/util/futils.c +8 -5
- data/vendor/libgit2/src/util/git2_features.h.in +9 -3
- data/vendor/libgit2/src/util/net.c +308 -157
- data/vendor/libgit2/src/util/net.h +25 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +22 -0
- data/vendor/libgit2/src/util/rand.c +6 -4
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +24 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +28 -22
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -18,6 +18,8 @@ typedef struct git_tree_cache {
|
|
18
18
|
struct git_tree_cache **children;
|
19
19
|
size_t children_count;
|
20
20
|
|
21
|
+
git_oid_t oid_type;
|
22
|
+
|
21
23
|
ssize_t entry_count;
|
22
24
|
git_oid oid;
|
23
25
|
size_t namelen;
|
@@ -25,14 +27,14 @@ typedef struct git_tree_cache {
|
|
25
27
|
} git_tree_cache;
|
26
28
|
|
27
29
|
int git_tree_cache_write(git_str *out, git_tree_cache *tree);
|
28
|
-
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_pool *pool);
|
30
|
+
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size, git_oid_t oid_type, git_pool *pool);
|
29
31
|
void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path);
|
30
32
|
const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char *path);
|
31
|
-
int git_tree_cache_new(git_tree_cache **out, const char *name, git_pool *pool);
|
33
|
+
int git_tree_cache_new(git_tree_cache **out, const char *name, git_oid_t oid_type, git_pool *pool);
|
32
34
|
/**
|
33
35
|
* Read a tree as the root of the tree cache (like for `git read-tree`)
|
34
36
|
*/
|
35
|
-
int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_pool *pool);
|
37
|
+
int git_tree_cache_read_tree(git_tree_cache **out, const git_tree *tree, git_oid_t oid_type, git_pool *pool);
|
36
38
|
void git_tree_cache_free(git_tree_cache *tree);
|
37
39
|
|
38
40
|
#endif
|
@@ -731,7 +731,7 @@ int git_tree__write_index(
|
|
731
731
|
return ret;
|
732
732
|
|
733
733
|
/* Read the tree cache into the index */
|
734
|
-
ret = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool);
|
734
|
+
ret = git_tree_cache_read_tree(&index->tree, tree, index->oid_type, &index->tree_pool);
|
735
735
|
git_tree_free(tree);
|
736
736
|
|
737
737
|
return ret;
|
@@ -565,6 +565,8 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
565
565
|
git_worktree_prune_options *opts)
|
566
566
|
{
|
567
567
|
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
|
568
|
+
git_str path = GIT_STR_INIT;
|
569
|
+
int ret = 0;
|
568
570
|
|
569
571
|
GIT_ERROR_CHECK_VERSION(
|
570
572
|
opts, GIT_WORKTREE_PRUNE_OPTIONS_VERSION,
|
@@ -575,27 +577,40 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
575
577
|
|
576
578
|
if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) {
|
577
579
|
git_str reason = GIT_STR_INIT;
|
578
|
-
int error;
|
579
580
|
|
580
|
-
if ((
|
581
|
-
|
581
|
+
if ((ret = git_worktree__is_locked(&reason, wt)) < 0)
|
582
|
+
goto out;
|
583
|
+
|
584
|
+
if (ret) {
|
585
|
+
git_error_set(GIT_ERROR_WORKTREE,
|
586
|
+
"not pruning locked working tree: '%s'",
|
587
|
+
reason.size ? reason.ptr : "is locked");
|
582
588
|
|
583
|
-
if (error) {
|
584
|
-
if (!reason.size)
|
585
|
-
git_str_attach_notowned(&reason, "no reason given", 15);
|
586
|
-
git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
|
587
589
|
git_str_dispose(&reason);
|
588
|
-
|
590
|
+
ret = 0;
|
591
|
+
goto out;
|
589
592
|
}
|
590
593
|
}
|
591
594
|
|
592
595
|
if ((popts.flags & GIT_WORKTREE_PRUNE_VALID) == 0 &&
|
593
596
|
git_worktree_validate(wt) == 0) {
|
594
597
|
git_error_set(GIT_ERROR_WORKTREE, "not pruning valid working tree");
|
595
|
-
|
598
|
+
goto out;
|
596
599
|
}
|
597
600
|
|
598
|
-
|
601
|
+
if ((ret = git_str_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0))
|
602
|
+
goto out;
|
603
|
+
|
604
|
+
if (!git_fs_path_exists(path.ptr)) {
|
605
|
+
git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir ('%s') does not exist", path.ptr);
|
606
|
+
goto out;
|
607
|
+
}
|
608
|
+
|
609
|
+
ret = 1;
|
610
|
+
|
611
|
+
out:
|
612
|
+
git_str_dispose(&path);
|
613
|
+
return ret;
|
599
614
|
}
|
600
615
|
|
601
616
|
int git_worktree_prune(git_worktree *wt,
|
@@ -15,16 +15,75 @@
|
|
15
15
|
/* Fail any allocation until git_libgit2_init is called. */
|
16
16
|
git_allocator git__allocator = {
|
17
17
|
git_failalloc_malloc,
|
18
|
-
git_failalloc_calloc,
|
19
|
-
git_failalloc_strdup,
|
20
|
-
git_failalloc_strndup,
|
21
|
-
git_failalloc_substrdup,
|
22
18
|
git_failalloc_realloc,
|
23
|
-
git_failalloc_reallocarray,
|
24
|
-
git_failalloc_mallocarray,
|
25
19
|
git_failalloc_free
|
26
20
|
};
|
27
21
|
|
22
|
+
void *git__calloc(size_t nelem, size_t elsize)
|
23
|
+
{
|
24
|
+
size_t newsize;
|
25
|
+
void *ptr;
|
26
|
+
|
27
|
+
if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
|
28
|
+
return NULL;
|
29
|
+
|
30
|
+
if ((ptr = git__malloc(newsize)))
|
31
|
+
memset(ptr, 0, newsize);
|
32
|
+
|
33
|
+
return ptr;
|
34
|
+
}
|
35
|
+
|
36
|
+
void *git__reallocarray(void *ptr, size_t nelem, size_t elsize)
|
37
|
+
{
|
38
|
+
size_t newsize;
|
39
|
+
|
40
|
+
if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
|
41
|
+
return NULL;
|
42
|
+
|
43
|
+
return git__realloc(ptr, newsize);
|
44
|
+
}
|
45
|
+
|
46
|
+
void *git__mallocarray(size_t nelem, size_t elsize)
|
47
|
+
{
|
48
|
+
return git__reallocarray(NULL, nelem, elsize);
|
49
|
+
}
|
50
|
+
|
51
|
+
char *git__strdup(const char *str)
|
52
|
+
{
|
53
|
+
size_t len = strlen(str) + 1;
|
54
|
+
void *ptr = git__malloc(len);
|
55
|
+
|
56
|
+
if (ptr)
|
57
|
+
memcpy(ptr, str, len);
|
58
|
+
|
59
|
+
return ptr;
|
60
|
+
}
|
61
|
+
|
62
|
+
char *git__strndup(const char *str, size_t n)
|
63
|
+
{
|
64
|
+
size_t len = p_strnlen(str, n);
|
65
|
+
char *ptr = git__malloc(len + 1);
|
66
|
+
|
67
|
+
if (ptr) {
|
68
|
+
memcpy(ptr, str, len);
|
69
|
+
ptr[len] = '\0';
|
70
|
+
}
|
71
|
+
|
72
|
+
return ptr;
|
73
|
+
}
|
74
|
+
|
75
|
+
char *git__substrdup(const char *str, size_t n)
|
76
|
+
{
|
77
|
+
char *ptr = git__malloc(n + 1);
|
78
|
+
|
79
|
+
if (ptr) {
|
80
|
+
memcpy(ptr, str, n);
|
81
|
+
ptr[n] = '\0';
|
82
|
+
}
|
83
|
+
|
84
|
+
return ptr;
|
85
|
+
}
|
86
|
+
|
28
87
|
static int setup_default_allocator(void)
|
29
88
|
{
|
30
89
|
#if defined(GIT_WIN32_LEAKCHECK)
|
@@ -10,17 +10,42 @@
|
|
10
10
|
|
11
11
|
#include "git2/sys/alloc.h"
|
12
12
|
|
13
|
+
#include "git2_util.h"
|
14
|
+
|
13
15
|
extern git_allocator git__allocator;
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
GIT_INLINE(void *) git__malloc(size_t len)
|
18
|
+
{
|
19
|
+
void *p = git__allocator.gmalloc(len, __FILE__, __LINE__);
|
20
|
+
|
21
|
+
if (!p)
|
22
|
+
git_error_set_oom();
|
23
|
+
|
24
|
+
return p;
|
25
|
+
}
|
26
|
+
|
27
|
+
GIT_INLINE(void *) git__realloc(void *ptr, size_t size)
|
28
|
+
{
|
29
|
+
void *p = git__allocator.grealloc(ptr, size, __FILE__, __LINE__);
|
30
|
+
|
31
|
+
if (!p)
|
32
|
+
git_error_set_oom();
|
33
|
+
|
34
|
+
return p;
|
35
|
+
}
|
36
|
+
|
37
|
+
GIT_INLINE(void) git__free(void *ptr)
|
38
|
+
{
|
39
|
+
git__allocator.gfree(ptr);
|
40
|
+
}
|
41
|
+
|
42
|
+
extern void *git__calloc(size_t nelem, size_t elsize);
|
43
|
+
extern void *git__mallocarray(size_t nelem, size_t elsize);
|
44
|
+
extern void *git__reallocarray(void *ptr, size_t nelem, size_t elsize);
|
45
|
+
|
46
|
+
extern char *git__strdup(const char *str);
|
47
|
+
extern char *git__strndup(const char *str, size_t n);
|
48
|
+
extern char *git__substrdup(const char *str, size_t n);
|
24
49
|
|
25
50
|
/**
|
26
51
|
* This function is being called by our global setup routines to
|
@@ -16,45 +16,6 @@ void *git_failalloc_malloc(size_t len, const char *file, int line)
|
|
16
16
|
return NULL;
|
17
17
|
}
|
18
18
|
|
19
|
-
void *git_failalloc_calloc(size_t nelem, size_t elsize, const char *file, int line)
|
20
|
-
{
|
21
|
-
GIT_UNUSED(nelem);
|
22
|
-
GIT_UNUSED(elsize);
|
23
|
-
GIT_UNUSED(file);
|
24
|
-
GIT_UNUSED(line);
|
25
|
-
|
26
|
-
return NULL;
|
27
|
-
}
|
28
|
-
|
29
|
-
char *git_failalloc_strdup(const char *str, const char *file, int line)
|
30
|
-
{
|
31
|
-
GIT_UNUSED(str);
|
32
|
-
GIT_UNUSED(file);
|
33
|
-
GIT_UNUSED(line);
|
34
|
-
|
35
|
-
return NULL;
|
36
|
-
}
|
37
|
-
|
38
|
-
char *git_failalloc_strndup(const char *str, size_t n, const char *file, int line)
|
39
|
-
{
|
40
|
-
GIT_UNUSED(str);
|
41
|
-
GIT_UNUSED(n);
|
42
|
-
GIT_UNUSED(file);
|
43
|
-
GIT_UNUSED(line);
|
44
|
-
|
45
|
-
return NULL;
|
46
|
-
}
|
47
|
-
|
48
|
-
char *git_failalloc_substrdup(const char *start, size_t n, const char *file, int line)
|
49
|
-
{
|
50
|
-
GIT_UNUSED(start);
|
51
|
-
GIT_UNUSED(n);
|
52
|
-
GIT_UNUSED(file);
|
53
|
-
GIT_UNUSED(line);
|
54
|
-
|
55
|
-
return NULL;
|
56
|
-
}
|
57
|
-
|
58
19
|
void *git_failalloc_realloc(void *ptr, size_t size, const char *file, int line)
|
59
20
|
{
|
60
21
|
GIT_UNUSED(ptr);
|
@@ -65,27 +26,6 @@ void *git_failalloc_realloc(void *ptr, size_t size, const char *file, int line)
|
|
65
26
|
return NULL;
|
66
27
|
}
|
67
28
|
|
68
|
-
void *git_failalloc_reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
69
|
-
{
|
70
|
-
GIT_UNUSED(ptr);
|
71
|
-
GIT_UNUSED(nelem);
|
72
|
-
GIT_UNUSED(elsize);
|
73
|
-
GIT_UNUSED(file);
|
74
|
-
GIT_UNUSED(line);
|
75
|
-
|
76
|
-
return NULL;
|
77
|
-
}
|
78
|
-
|
79
|
-
void *git_failalloc_mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
80
|
-
{
|
81
|
-
GIT_UNUSED(nelem);
|
82
|
-
GIT_UNUSED(elsize);
|
83
|
-
GIT_UNUSED(file);
|
84
|
-
GIT_UNUSED(line);
|
85
|
-
|
86
|
-
return NULL;
|
87
|
-
}
|
88
|
-
|
89
29
|
void git_failalloc_free(void *ptr)
|
90
30
|
{
|
91
31
|
GIT_UNUSED(ptr);
|
@@ -11,13 +11,7 @@
|
|
11
11
|
#include "git2_util.h"
|
12
12
|
|
13
13
|
extern void *git_failalloc_malloc(size_t len, const char *file, int line);
|
14
|
-
extern void *git_failalloc_calloc(size_t nelem, size_t elsize, const char *file, int line);
|
15
|
-
extern char *git_failalloc_strdup(const char *str, const char *file, int line);
|
16
|
-
extern char *git_failalloc_strndup(const char *str, size_t n, const char *file, int line);
|
17
|
-
extern char *git_failalloc_substrdup(const char *start, size_t n, const char *file, int line);
|
18
14
|
extern void *git_failalloc_realloc(void *ptr, size_t size, const char *file, int line);
|
19
|
-
extern void *git_failalloc_reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line);
|
20
|
-
extern void *git_failalloc_mallocarray(size_t nelem, size_t elsize, const char *file, int line);
|
21
15
|
extern void git_failalloc_free(void *ptr);
|
22
16
|
|
23
17
|
#endif
|
@@ -9,8 +9,6 @@
|
|
9
9
|
|
10
10
|
static void *stdalloc__malloc(size_t len, const char *file, int line)
|
11
11
|
{
|
12
|
-
void *ptr;
|
13
|
-
|
14
12
|
GIT_UNUSED(file);
|
15
13
|
GIT_UNUSED(line);
|
16
14
|
|
@@ -19,86 +17,11 @@ static void *stdalloc__malloc(size_t len, const char *file, int line)
|
|
19
17
|
return NULL;
|
20
18
|
#endif
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
if (!ptr)
|
25
|
-
git_error_set_oom();
|
26
|
-
|
27
|
-
return ptr;
|
28
|
-
}
|
29
|
-
|
30
|
-
static void *stdalloc__calloc(size_t nelem, size_t elsize, const char *file, int line)
|
31
|
-
{
|
32
|
-
void *ptr;
|
33
|
-
|
34
|
-
GIT_UNUSED(file);
|
35
|
-
GIT_UNUSED(line);
|
36
|
-
|
37
|
-
#ifdef GIT_DEBUG_STRICT_ALLOC
|
38
|
-
if (!elsize || !nelem)
|
39
|
-
return NULL;
|
40
|
-
#endif
|
41
|
-
|
42
|
-
ptr = calloc(nelem, elsize);
|
43
|
-
|
44
|
-
if (!ptr)
|
45
|
-
git_error_set_oom();
|
46
|
-
|
47
|
-
return ptr;
|
48
|
-
}
|
49
|
-
|
50
|
-
static char *stdalloc__strdup(const char *str, const char *file, int line)
|
51
|
-
{
|
52
|
-
char *ptr;
|
53
|
-
|
54
|
-
GIT_UNUSED(file);
|
55
|
-
GIT_UNUSED(line);
|
56
|
-
|
57
|
-
ptr = strdup(str);
|
58
|
-
|
59
|
-
if (!ptr)
|
60
|
-
git_error_set_oom();
|
61
|
-
|
62
|
-
return ptr;
|
63
|
-
}
|
64
|
-
|
65
|
-
static char *stdalloc__strndup(const char *str, size_t n, const char *file, int line)
|
66
|
-
{
|
67
|
-
size_t length = 0, alloclength;
|
68
|
-
char *ptr;
|
69
|
-
|
70
|
-
length = p_strnlen(str, n);
|
71
|
-
|
72
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
73
|
-
!(ptr = stdalloc__malloc(alloclength, file, line)))
|
74
|
-
return NULL;
|
75
|
-
|
76
|
-
if (length)
|
77
|
-
memcpy(ptr, str, length);
|
78
|
-
|
79
|
-
ptr[length] = '\0';
|
80
|
-
|
81
|
-
return ptr;
|
82
|
-
}
|
83
|
-
|
84
|
-
static char *stdalloc__substrdup(const char *start, size_t n, const char *file, int line)
|
85
|
-
{
|
86
|
-
char *ptr;
|
87
|
-
size_t alloclen;
|
88
|
-
|
89
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
90
|
-
!(ptr = stdalloc__malloc(alloclen, file, line)))
|
91
|
-
return NULL;
|
92
|
-
|
93
|
-
memcpy(ptr, start, n);
|
94
|
-
ptr[n] = '\0';
|
95
|
-
return ptr;
|
20
|
+
return malloc(len);
|
96
21
|
}
|
97
22
|
|
98
23
|
static void *stdalloc__realloc(void *ptr, size_t size, const char *file, int line)
|
99
24
|
{
|
100
|
-
void *new_ptr;
|
101
|
-
|
102
25
|
GIT_UNUSED(file);
|
103
26
|
GIT_UNUSED(line);
|
104
27
|
|
@@ -107,27 +30,7 @@ static void *stdalloc__realloc(void *ptr, size_t size, const char *file, int lin
|
|
107
30
|
return NULL;
|
108
31
|
#endif
|
109
32
|
|
110
|
-
|
111
|
-
|
112
|
-
if (!new_ptr)
|
113
|
-
git_error_set_oom();
|
114
|
-
|
115
|
-
return new_ptr;
|
116
|
-
}
|
117
|
-
|
118
|
-
static void *stdalloc__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
119
|
-
{
|
120
|
-
size_t newsize;
|
121
|
-
|
122
|
-
if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
|
123
|
-
return NULL;
|
124
|
-
|
125
|
-
return stdalloc__realloc(ptr, newsize, file, line);
|
126
|
-
}
|
127
|
-
|
128
|
-
static void *stdalloc__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
129
|
-
{
|
130
|
-
return stdalloc__reallocarray(NULL, nelem, elsize, file, line);
|
33
|
+
return realloc(ptr, size);
|
131
34
|
}
|
132
35
|
|
133
36
|
static void stdalloc__free(void *ptr)
|
@@ -138,13 +41,7 @@ static void stdalloc__free(void *ptr)
|
|
138
41
|
int git_stdalloc_init_allocator(git_allocator *allocator)
|
139
42
|
{
|
140
43
|
allocator->gmalloc = stdalloc__malloc;
|
141
|
-
allocator->gcalloc = stdalloc__calloc;
|
142
|
-
allocator->gstrdup = stdalloc__strdup;
|
143
|
-
allocator->gstrndup = stdalloc__strndup;
|
144
|
-
allocator->gsubstrdup = stdalloc__substrdup;
|
145
44
|
allocator->grealloc = stdalloc__realloc;
|
146
|
-
allocator->greallocarray = stdalloc__reallocarray;
|
147
|
-
allocator->gmallocarray = stdalloc__mallocarray;
|
148
45
|
allocator->gfree = stdalloc__free;
|
149
46
|
return 0;
|
150
47
|
}
|
@@ -18,53 +18,6 @@ static void *leakcheck_malloc(size_t len, const char *file, int line)
|
|
18
18
|
return ptr;
|
19
19
|
}
|
20
20
|
|
21
|
-
static void *leakcheck_calloc(size_t nelem, size_t elsize, const char *file, int line)
|
22
|
-
{
|
23
|
-
void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
|
24
|
-
if (!ptr) git_error_set_oom();
|
25
|
-
return ptr;
|
26
|
-
}
|
27
|
-
|
28
|
-
static char *leakcheck_strdup(const char *str, const char *file, int line)
|
29
|
-
{
|
30
|
-
char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
|
31
|
-
if (!ptr) git_error_set_oom();
|
32
|
-
return ptr;
|
33
|
-
}
|
34
|
-
|
35
|
-
static char *leakcheck_strndup(const char *str, size_t n, const char *file, int line)
|
36
|
-
{
|
37
|
-
size_t length = 0, alloclength;
|
38
|
-
char *ptr;
|
39
|
-
|
40
|
-
length = p_strnlen(str, n);
|
41
|
-
|
42
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
43
|
-
!(ptr = leakcheck_malloc(alloclength, file, line)))
|
44
|
-
return NULL;
|
45
|
-
|
46
|
-
if (length)
|
47
|
-
memcpy(ptr, str, length);
|
48
|
-
|
49
|
-
ptr[length] = '\0';
|
50
|
-
|
51
|
-
return ptr;
|
52
|
-
}
|
53
|
-
|
54
|
-
static char *leakcheck_substrdup(const char *start, size_t n, const char *file, int line)
|
55
|
-
{
|
56
|
-
char *ptr;
|
57
|
-
size_t alloclen;
|
58
|
-
|
59
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
60
|
-
!(ptr = leakcheck_malloc(alloclen, file, line)))
|
61
|
-
return NULL;
|
62
|
-
|
63
|
-
memcpy(ptr, start, n);
|
64
|
-
ptr[n] = '\0';
|
65
|
-
return ptr;
|
66
|
-
}
|
67
|
-
|
68
21
|
static void *leakcheck_realloc(void *ptr, size_t size, const char *file, int line)
|
69
22
|
{
|
70
23
|
void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32_leakcheck_stacktrace(1,file), line);
|
@@ -72,21 +25,6 @@ static void *leakcheck_realloc(void *ptr, size_t size, const char *file, int lin
|
|
72
25
|
return new_ptr;
|
73
26
|
}
|
74
27
|
|
75
|
-
static void *leakcheck_reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
76
|
-
{
|
77
|
-
size_t newsize;
|
78
|
-
|
79
|
-
if (GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize))
|
80
|
-
return NULL;
|
81
|
-
|
82
|
-
return leakcheck_realloc(ptr, newsize, file, line);
|
83
|
-
}
|
84
|
-
|
85
|
-
static void *leakcheck_mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
86
|
-
{
|
87
|
-
return leakcheck_reallocarray(NULL, nelem, elsize, file, line);
|
88
|
-
}
|
89
|
-
|
90
28
|
static void leakcheck_free(void *ptr)
|
91
29
|
{
|
92
30
|
free(ptr);
|
@@ -95,13 +33,7 @@ static void leakcheck_free(void *ptr)
|
|
95
33
|
int git_win32_leakcheck_init_allocator(git_allocator *allocator)
|
96
34
|
{
|
97
35
|
allocator->gmalloc = leakcheck_malloc;
|
98
|
-
allocator->gcalloc = leakcheck_calloc;
|
99
|
-
allocator->gstrdup = leakcheck_strdup;
|
100
|
-
allocator->gstrndup = leakcheck_strndup;
|
101
|
-
allocator->gsubstrdup = leakcheck_substrdup;
|
102
36
|
allocator->grealloc = leakcheck_realloc;
|
103
|
-
allocator->greallocarray = leakcheck_reallocarray;
|
104
|
-
allocator->gmallocarray = leakcheck_mallocarray;
|
105
37
|
allocator->gfree = leakcheck_free;
|
106
38
|
return 0;
|
107
39
|
}
|
@@ -33,6 +33,9 @@
|
|
33
33
|
#define git_array_init_to_size(a, desired) \
|
34
34
|
do { (a).size = 0; (a).asize = desired; (a).ptr = git__calloc(desired, sizeof(*(a).ptr)); } while (0)
|
35
35
|
|
36
|
+
#define git_array_dispose(a) \
|
37
|
+
do { git__free((a).ptr); } while (0)
|
38
|
+
|
36
39
|
#define git_array_clear(a) \
|
37
40
|
do { git__free((a).ptr); git_array_init(a); } while (0)
|
38
41
|
|
@@ -85,12 +88,14 @@ on_oom:
|
|
85
88
|
#define git_array_foreach(a, i, element) \
|
86
89
|
for ((i) = 0; (i) < (a).size && ((element) = &(a).ptr[(i)]); (i)++)
|
87
90
|
|
91
|
+
typedef int (*git_array_compare_cb)(const void *, const void *);
|
92
|
+
|
88
93
|
GIT_INLINE(int) git_array__search(
|
89
94
|
size_t *out,
|
90
95
|
void *array_ptr,
|
91
96
|
size_t item_size,
|
92
97
|
size_t array_len,
|
93
|
-
|
98
|
+
git_array_compare_cb compare,
|
94
99
|
const void *key)
|
95
100
|
{
|
96
101
|
size_t lim;
|
@@ -43,8 +43,10 @@
|
|
43
43
|
__typeof__(x) _unused __attribute__((unused)); \
|
44
44
|
_unused = (x); \
|
45
45
|
} while (0)
|
46
|
+
# define GIT_UNUSED_ARG __attribute__((unused))
|
46
47
|
#else
|
47
48
|
# define GIT_UNUSED(x) ((void)(x))
|
49
|
+
# define GIT_UNUSED_ARG
|
48
50
|
#endif
|
49
51
|
|
50
52
|
/* Define the printf format specifier to use for size_t output */
|
@@ -302,11 +302,16 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
|
|
302
302
|
}
|
303
303
|
|
304
304
|
/* If we are hashing on-write, allocate a new hash context */
|
305
|
-
if (flags &
|
305
|
+
if (flags & GIT_FILEBUF_HASH_SHA1) {
|
306
306
|
file->compute_digest = 1;
|
307
307
|
|
308
308
|
if (git_hash_ctx_init(&file->digest, GIT_HASH_ALGORITHM_SHA1) < 0)
|
309
309
|
goto cleanup;
|
310
|
+
} else if (flags & GIT_FILEBUF_HASH_SHA256) {
|
311
|
+
file->compute_digest = 1;
|
312
|
+
|
313
|
+
if (git_hash_ctx_init(&file->digest, GIT_HASH_ALGORITHM_SHA256) < 0)
|
314
|
+
goto cleanup;
|
310
315
|
}
|
311
316
|
|
312
317
|
compression = flags >> GIT_FILEBUF_DEFLATE_SHIFT;
|
@@ -17,13 +17,14 @@
|
|
17
17
|
# define GIT_FILEBUF_THREADS
|
18
18
|
#endif
|
19
19
|
|
20
|
-
#define
|
21
|
-
#define
|
20
|
+
#define GIT_FILEBUF_HASH_SHA1 (1 << 0)
|
21
|
+
#define GIT_FILEBUF_HASH_SHA256 (1 << 1)
|
22
|
+
#define GIT_FILEBUF_APPEND (1 << 2)
|
22
23
|
#define GIT_FILEBUF_CREATE_LEADING_DIRS (1 << 3)
|
23
|
-
#define GIT_FILEBUF_TEMPORARY
|
24
|
-
#define GIT_FILEBUF_DO_NOT_BUFFER
|
25
|
-
#define GIT_FILEBUF_FSYNC
|
26
|
-
#define GIT_FILEBUF_DEFLATE_SHIFT
|
24
|
+
#define GIT_FILEBUF_TEMPORARY (1 << 4)
|
25
|
+
#define GIT_FILEBUF_DO_NOT_BUFFER (1 << 5)
|
26
|
+
#define GIT_FILEBUF_FSYNC (1 << 6)
|
27
|
+
#define GIT_FILEBUF_DEFLATE_SHIFT (7)
|
27
28
|
|
28
29
|
#define GIT_FILELOCK_EXTENSION ".lock\0"
|
29
30
|
#define GIT_FILELOCK_EXTLENGTH 6
|
@@ -91,4 +92,16 @@ int git_filebuf_hash(unsigned char *out, git_filebuf *file);
|
|
91
92
|
int git_filebuf_flush(git_filebuf *file);
|
92
93
|
int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file);
|
93
94
|
|
95
|
+
GIT_INLINE(int) git_filebuf_hash_flags(git_hash_algorithm_t algorithm)
|
96
|
+
{
|
97
|
+
switch (algorithm) {
|
98
|
+
case GIT_HASH_ALGORITHM_SHA1:
|
99
|
+
return GIT_FILEBUF_HASH_SHA1;
|
100
|
+
case GIT_HASH_ALGORITHM_SHA256:
|
101
|
+
return GIT_FILEBUF_HASH_SHA256;
|
102
|
+
default:
|
103
|
+
return 0;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
94
107
|
#endif
|
@@ -2015,7 +2015,7 @@ int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
|
2015
2015
|
git_win32_path fullpath_w, executable_w;
|
2016
2016
|
int error;
|
2017
2017
|
|
2018
|
-
if (
|
2018
|
+
if (git_utf8_to_16(executable_w, GIT_WIN_PATH_MAX, executable) < 0)
|
2019
2019
|
return -1;
|
2020
2020
|
|
2021
2021
|
error = git_win32_path_find_executable(fullpath_w, executable_w);
|
@@ -221,14 +221,14 @@ int git_futils_readbuffer_fd_full(git_str *buf, git_file fd)
|
|
221
221
|
int git_futils_readbuffer_updated(
|
222
222
|
git_str *out,
|
223
223
|
const char *path,
|
224
|
-
unsigned char checksum[
|
224
|
+
unsigned char checksum[GIT_HASH_SHA256_SIZE],
|
225
225
|
int *updated)
|
226
226
|
{
|
227
227
|
int error;
|
228
228
|
git_file fd;
|
229
229
|
struct stat st;
|
230
230
|
git_str buf = GIT_STR_INIT;
|
231
|
-
unsigned char checksum_new[
|
231
|
+
unsigned char checksum_new[GIT_HASH_SHA256_SIZE];
|
232
232
|
|
233
233
|
GIT_ASSERT_ARG(out);
|
234
234
|
GIT_ASSERT_ARG(path && *path);
|
@@ -261,7 +261,10 @@ int git_futils_readbuffer_updated(
|
|
261
261
|
p_close(fd);
|
262
262
|
|
263
263
|
if (checksum) {
|
264
|
-
|
264
|
+
error = git_hash_buf(checksum_new, buf.ptr,
|
265
|
+
buf.size, GIT_HASH_ALGORITHM_SHA256);
|
266
|
+
|
267
|
+
if (error < 0) {
|
265
268
|
git_str_dispose(&buf);
|
266
269
|
return error;
|
267
270
|
}
|
@@ -269,7 +272,7 @@ int git_futils_readbuffer_updated(
|
|
269
272
|
/*
|
270
273
|
* If we were given a checksum, we only want to use it if it's different
|
271
274
|
*/
|
272
|
-
if (!memcmp(checksum, checksum_new,
|
275
|
+
if (!memcmp(checksum, checksum_new, GIT_HASH_SHA256_SIZE)) {
|
273
276
|
git_str_dispose(&buf);
|
274
277
|
if (updated)
|
275
278
|
*updated = 0;
|
@@ -277,7 +280,7 @@ int git_futils_readbuffer_updated(
|
|
277
280
|
return 0;
|
278
281
|
}
|
279
282
|
|
280
|
-
memcpy(checksum, checksum_new,
|
283
|
+
memcpy(checksum, checksum_new, GIT_HASH_SHA256_SIZE);
|
281
284
|
}
|
282
285
|
|
283
286
|
/*
|