rugged 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -6
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +93 -42
- data/vendor/libgit2/include/git2/blob.h +14 -2
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +14 -4
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +34 -19
- data/vendor/libgit2/include/git2/errors.h +6 -6
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +2 -2
- data/vendor/libgit2/include/git2/odb.h +29 -0
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +6 -2
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/tree.h +0 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +25 -4
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +16 -7
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +84 -39
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +42 -37
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +11 -5
- data/vendor/libgit2/src/blob.c +35 -24
- data/vendor/libgit2/src/branch.c +69 -17
- data/vendor/libgit2/src/buffer.c +334 -25
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +48 -26
- data/vendor/libgit2/src/cherrypick.c +6 -2
- data/vendor/libgit2/src/clone.c +41 -47
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +25 -2
- data/vendor/libgit2/src/config.c +37 -15
- data/vendor/libgit2/src/config_cache.c +5 -3
- data/vendor/libgit2/src/config_file.c +16 -8
- data/vendor/libgit2/src/config_parse.c +4 -6
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +6 -3
- data/vendor/libgit2/src/diff.c +11 -8
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +2 -6
- data/vendor/libgit2/src/diff_generate.c +46 -17
- data/vendor/libgit2/src/diff_print.c +19 -6
- data/vendor/libgit2/src/diff_stats.c +7 -5
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +24 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +5 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +206 -110
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +5 -5
- data/vendor/libgit2/src/futils.h +1 -1
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +106 -70
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +31 -29
- data/vendor/libgit2/src/integer.h +64 -2
- data/vendor/libgit2/src/iterator.c +36 -24
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +70 -30
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +11 -3
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +471 -10
- data/vendor/libgit2/src/midx.h +28 -1
- data/vendor/libgit2/src/mwindow.c +103 -59
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +127 -3
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +22 -14
- data/vendor/libgit2/src/odb.c +285 -48
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +28 -18
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +5 -4
- data/vendor/libgit2/src/pack-objects.c +54 -48
- data/vendor/libgit2/src/pack.c +329 -119
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +2 -1
- data/vendor/libgit2/src/path.c +98 -53
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +8 -8
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +11 -3
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +93 -49
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +121 -69
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +76 -41
- data/vendor/libgit2/src/refspec.c +32 -12
- data/vendor/libgit2/src/remote.c +272 -102
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +176 -103
- data/vendor/libgit2/src/repository.h +12 -1
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +6 -2
- data/vendor/libgit2/src/revparse.c +14 -9
- data/vendor/libgit2/src/revwalk.c +32 -15
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +3 -1
- data/vendor/libgit2/src/status.c +7 -4
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +128 -62
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +4 -6
- data/vendor/libgit2/src/tag.c +47 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +19 -8
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +53 -26
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +3 -3
- data/vendor/libgit2/src/transports/smart.c +12 -7
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +41 -31
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +53 -129
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +22 -24
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +7 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +27 -16
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +32 -16
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -369
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
data/vendor/libgit2/src/index.h
CHANGED
|
@@ -33,7 +33,7 @@ struct git_index {
|
|
|
33
33
|
git_idxmap *entries_map;
|
|
34
34
|
|
|
35
35
|
git_vector deleted; /* deleted entries if readers > 0 */
|
|
36
|
-
|
|
36
|
+
git_atomic32 readers; /* number of active iterators */
|
|
37
37
|
|
|
38
38
|
unsigned int on_disk:1;
|
|
39
39
|
unsigned int ignore_case:1;
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
#include "zstream.h"
|
|
25
25
|
#include "object.h"
|
|
26
26
|
|
|
27
|
-
extern git_mutex git__mwindow_mutex;
|
|
28
|
-
|
|
29
27
|
size_t git_indexer__max_objects = UINT32_MAX;
|
|
30
28
|
|
|
31
29
|
#define UINT31_MAX (0x7FFFFFFF)
|
|
@@ -239,7 +237,8 @@ static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream)
|
|
|
239
237
|
{
|
|
240
238
|
ssize_t read;
|
|
241
239
|
|
|
242
|
-
|
|
240
|
+
GIT_ASSERT_ARG(idx);
|
|
241
|
+
GIT_ASSERT_ARG(stream);
|
|
243
242
|
|
|
244
243
|
do {
|
|
245
244
|
if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0)
|
|
@@ -262,7 +261,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
|
|
|
262
261
|
{
|
|
263
262
|
git_mwindow *w = NULL;
|
|
264
263
|
|
|
265
|
-
|
|
264
|
+
GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
|
|
266
265
|
|
|
267
266
|
if (type == GIT_OBJECT_REF_DELTA) {
|
|
268
267
|
idx->off += GIT_OID_RAWSZ;
|
|
@@ -282,7 +281,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
|
|
|
282
281
|
{
|
|
283
282
|
ssize_t read;
|
|
284
283
|
|
|
285
|
-
|
|
284
|
+
GIT_ASSERT_ARG(stream);
|
|
286
285
|
|
|
287
286
|
do {
|
|
288
287
|
read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf));
|
|
@@ -629,7 +628,8 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
|
|
|
629
628
|
git_map map;
|
|
630
629
|
int error;
|
|
631
630
|
|
|
632
|
-
|
|
631
|
+
GIT_ASSERT_ARG(data);
|
|
632
|
+
GIT_ASSERT_ARG(size);
|
|
633
633
|
|
|
634
634
|
if ((error = git__mmap_alignment(&mmap_alignment)) < 0)
|
|
635
635
|
return error;
|
|
@@ -693,7 +693,7 @@ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
|
|
|
693
693
|
return GIT_EBUFS;
|
|
694
694
|
|
|
695
695
|
if (!idx->have_stream) {
|
|
696
|
-
error = git_packfile_unpack_header(&entry_size, &type,
|
|
696
|
+
error = git_packfile_unpack_header(&entry_size, &type, idx->pack, &w, &idx->off);
|
|
697
697
|
if (error == GIT_EBUFS) {
|
|
698
698
|
idx->off = entry_start;
|
|
699
699
|
return error;
|
|
@@ -775,7 +775,9 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
|
|
|
775
775
|
struct git_pack_header *hdr = &idx->hdr;
|
|
776
776
|
git_mwindow_file *mwf = &idx->pack->mwf;
|
|
777
777
|
|
|
778
|
-
|
|
778
|
+
GIT_ASSERT_ARG(idx);
|
|
779
|
+
GIT_ASSERT_ARG(data);
|
|
780
|
+
GIT_ASSERT_ARG(stats);
|
|
779
781
|
|
|
780
782
|
if ((error = append_to_pack(idx, data, size)) < 0)
|
|
781
783
|
return error;
|
|
@@ -829,7 +831,8 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
|
|
|
829
831
|
/* Now that we have data in the pack, let's try to parse it */
|
|
830
832
|
|
|
831
833
|
/* As the file grows any windows we try to use will be out of date */
|
|
832
|
-
git_mwindow_free_all(mwf)
|
|
834
|
+
if ((error = git_mwindow_free_all(mwf)) < 0)
|
|
835
|
+
goto on_error;
|
|
833
836
|
|
|
834
837
|
while (stats->indexed_objects < idx->nr_objects) {
|
|
835
838
|
if ((error = read_stream_object(idx, stats)) != 0) {
|
|
@@ -873,16 +876,16 @@ static int index_path(git_buf *path, git_indexer *idx, const char *suffix)
|
|
|
873
876
|
* Rewind the packfile by the trailer, as we might need to fix the
|
|
874
877
|
* packfile by injecting objects at the tail and must overwrite it.
|
|
875
878
|
*/
|
|
876
|
-
static
|
|
879
|
+
static int seek_back_trailer(git_indexer *idx)
|
|
877
880
|
{
|
|
878
881
|
idx->pack->mwf.size -= GIT_OID_RAWSZ;
|
|
879
|
-
git_mwindow_free_all(&idx->pack->mwf);
|
|
882
|
+
return git_mwindow_free_all(&idx->pack->mwf);
|
|
880
883
|
}
|
|
881
884
|
|
|
882
885
|
static int inject_object(git_indexer *idx, git_oid *id)
|
|
883
886
|
{
|
|
884
|
-
git_odb_object *obj;
|
|
885
|
-
struct entry *entry;
|
|
887
|
+
git_odb_object *obj = NULL;
|
|
888
|
+
struct entry *entry = NULL;
|
|
886
889
|
struct git_pack_entry *pentry = NULL;
|
|
887
890
|
git_oid foo = {{0}};
|
|
888
891
|
unsigned char hdr[64];
|
|
@@ -892,12 +895,14 @@ static int inject_object(git_indexer *idx, git_oid *id)
|
|
|
892
895
|
size_t len, hdr_len;
|
|
893
896
|
int error;
|
|
894
897
|
|
|
895
|
-
seek_back_trailer(idx)
|
|
898
|
+
if ((error = seek_back_trailer(idx)) < 0)
|
|
899
|
+
goto cleanup;
|
|
900
|
+
|
|
896
901
|
entry_start = idx->pack->mwf.size;
|
|
897
902
|
|
|
898
|
-
if (git_odb_read(&obj, idx->odb, id) < 0) {
|
|
903
|
+
if ((error = git_odb_read(&obj, idx->odb, id)) < 0) {
|
|
899
904
|
git_error_set(GIT_ERROR_INDEXER, "missing delta bases");
|
|
900
|
-
|
|
905
|
+
goto cleanup;
|
|
901
906
|
}
|
|
902
907
|
|
|
903
908
|
data = git_odb_object_data(obj);
|
|
@@ -909,8 +914,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
|
|
|
909
914
|
entry->crc = crc32(0L, Z_NULL, 0);
|
|
910
915
|
|
|
911
916
|
/* Write out the object header */
|
|
912
|
-
|
|
913
|
-
|
|
917
|
+
if ((error = git_packfile__object_header(&hdr_len, hdr, len, git_odb_object_type(obj))) < 0 ||
|
|
918
|
+
(error = append_to_pack(idx, hdr, hdr_len)) < 0)
|
|
914
919
|
goto cleanup;
|
|
915
920
|
|
|
916
921
|
idx->pack->mwf.size += hdr_len;
|
|
@@ -966,7 +971,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
|
|
|
966
971
|
unsigned int left = 0;
|
|
967
972
|
git_oid base;
|
|
968
973
|
|
|
969
|
-
|
|
974
|
+
GIT_ASSERT(git_vector_length(&idx->deltas) > 0);
|
|
970
975
|
|
|
971
976
|
if (idx->odb == NULL) {
|
|
972
977
|
git_error_set(GIT_ERROR_INDEXER, "cannot fix a thin pack without an ODB");
|
|
@@ -979,7 +984,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
|
|
|
979
984
|
continue;
|
|
980
985
|
|
|
981
986
|
curpos = delta->delta_off;
|
|
982
|
-
error = git_packfile_unpack_header(&size, &type,
|
|
987
|
+
error = git_packfile_unpack_header(&size, &type, idx->pack, &w, &curpos);
|
|
983
988
|
if (error < 0)
|
|
984
989
|
return error;
|
|
985
990
|
|
|
@@ -1097,7 +1102,9 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
|
|
|
1097
1102
|
* hash_partially() keep the existing trailer out of the
|
|
1098
1103
|
* calculation.
|
|
1099
1104
|
*/
|
|
1100
|
-
git_mwindow_free_all(mwf)
|
|
1105
|
+
if (git_mwindow_free_all(mwf) < 0)
|
|
1106
|
+
return -1;
|
|
1107
|
+
|
|
1101
1108
|
idx->inbuf_len = 0;
|
|
1102
1109
|
while (hashed < mwf->size) {
|
|
1103
1110
|
ptr = git_mwindow_open(mwf, &w, hashed, chunk, &left);
|
|
@@ -1269,7 +1276,8 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
|
1269
1276
|
if (git_filebuf_commit_at(&index_file, filename.ptr) < 0)
|
|
1270
1277
|
goto on_error;
|
|
1271
1278
|
|
|
1272
|
-
git_mwindow_free_all(&idx->pack->mwf)
|
|
1279
|
+
if (git_mwindow_free_all(&idx->pack->mwf) < 0)
|
|
1280
|
+
goto on_error;
|
|
1273
1281
|
|
|
1274
1282
|
/* Truncate file to undo rounding up to next page_size in append_to_pack */
|
|
1275
1283
|
if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
|
|
@@ -1339,13 +1347,7 @@ void git_indexer_free(git_indexer *idx)
|
|
|
1339
1347
|
|
|
1340
1348
|
git_vector_free_deep(&idx->deltas);
|
|
1341
1349
|
|
|
1342
|
-
|
|
1343
|
-
if (!idx->pack_committed)
|
|
1344
|
-
git_packfile_close(idx->pack, true);
|
|
1345
|
-
|
|
1346
|
-
git_packfile_free(idx->pack);
|
|
1347
|
-
git_mutex_unlock(&git__mwindow_mutex);
|
|
1348
|
-
}
|
|
1350
|
+
git_packfile_free(idx->pack, !idx->pack_committed);
|
|
1349
1351
|
|
|
1350
1352
|
iter = 0;
|
|
1351
1353
|
while (git_oidmap_iterate((void **) &value, idx->expected_oids, &iter, &key) == 0)
|
|
@@ -43,10 +43,10 @@ GIT_INLINE(int) git__is_ulong(int64_t p)
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** @return true if p fits into the range of an int */
|
|
46
|
-
GIT_INLINE(int) git__is_int(
|
|
46
|
+
GIT_INLINE(int) git__is_int(int64_t p)
|
|
47
47
|
{
|
|
48
48
|
int r = (int)p;
|
|
49
|
-
return p == (
|
|
49
|
+
return p == (int64_t)r;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/* Use clang/gcc compiler intrinsics whenever possible */
|
|
@@ -80,6 +80,12 @@ GIT_INLINE(int) git__is_int(long long p)
|
|
|
80
80
|
# define git__add_int64_overflow(out, one, two) \
|
|
81
81
|
__builtin_add_overflow(one, two, out)
|
|
82
82
|
|
|
83
|
+
/* clang on 32-bit systems produces an undefined reference to `__mulodi4`. */
|
|
84
|
+
# if !defined(__clang__) || !defined(GIT_ARCH_32)
|
|
85
|
+
# define git__multiply_int64_overflow(out, one, two) \
|
|
86
|
+
__builtin_mul_overflow(one, two, out)
|
|
87
|
+
# endif
|
|
88
|
+
|
|
83
89
|
/* Use Microsoft's safe integer handling functions where available */
|
|
84
90
|
#elif defined(_MSC_VER)
|
|
85
91
|
|
|
@@ -90,6 +96,7 @@ GIT_INLINE(int) git__is_int(long long p)
|
|
|
90
96
|
(SizeTAdd(one, two, out) != S_OK)
|
|
91
97
|
# define git__multiply_sizet_overflow(out, one, two) \
|
|
92
98
|
(SizeTMult(one, two, out) != S_OK)
|
|
99
|
+
|
|
93
100
|
#define git__add_int_overflow(out, one, two) \
|
|
94
101
|
(IntAdd(one, two, out) != S_OK)
|
|
95
102
|
#define git__sub_int_overflow(out, one, two) \
|
|
@@ -97,6 +104,8 @@ GIT_INLINE(int) git__is_int(long long p)
|
|
|
97
104
|
|
|
98
105
|
#define git__add_int64_overflow(out, one, two) \
|
|
99
106
|
(LongLongAdd(one, two, out) != S_OK)
|
|
107
|
+
#define git__multiply_int64_overflow(out, one, two) \
|
|
108
|
+
(LongLongMult(one, two, out) != S_OK)
|
|
100
109
|
|
|
101
110
|
#else
|
|
102
111
|
|
|
@@ -153,4 +162,57 @@ GIT_INLINE(bool) git__add_int64_overflow(int64_t *out, int64_t one, int64_t two)
|
|
|
153
162
|
|
|
154
163
|
#endif
|
|
155
164
|
|
|
165
|
+
/* If we could not provide an intrinsic implementation for this, provide a (slow) fallback. */
|
|
166
|
+
#if !defined(git__multiply_int64_overflow)
|
|
167
|
+
GIT_INLINE(bool) git__multiply_int64_overflow(int64_t *out, int64_t one, int64_t two)
|
|
168
|
+
{
|
|
169
|
+
/*
|
|
170
|
+
* Detects whether `INT64_MAX < (one * two) || INT64_MIN > (one * two)`,
|
|
171
|
+
* without incurring in undefined behavior. That is done by performing the
|
|
172
|
+
* comparison with a division instead of a multiplication, which translates
|
|
173
|
+
* to `INT64_MAX / one < two || INT64_MIN / one > two`. Some caveats:
|
|
174
|
+
*
|
|
175
|
+
* - The comparison sign is inverted when both sides of the inequality are
|
|
176
|
+
* multiplied/divided by a negative number, so if `one < 0` the comparison
|
|
177
|
+
* needs to be flipped.
|
|
178
|
+
* - `INT64_MAX / -1` itself overflows (or traps), so that case should be
|
|
179
|
+
* avoided.
|
|
180
|
+
* - Since the overflow flag is defined as the discrepance between the result
|
|
181
|
+
* of performing the multiplication in a signed integer at twice the width
|
|
182
|
+
* of the operands, and the truncated+sign-extended version of that same
|
|
183
|
+
* result, there are four cases where the result is the opposite of what
|
|
184
|
+
* would be expected:
|
|
185
|
+
* * `INT64_MIN * -1` / `-1 * INT64_MIN`
|
|
186
|
+
* * `INT64_MIN * 1 / `1 * INT64_MIN`
|
|
187
|
+
*/
|
|
188
|
+
if (one && two) {
|
|
189
|
+
if (one > 0 && two > 0) {
|
|
190
|
+
if (INT64_MAX / one < two)
|
|
191
|
+
return true;
|
|
192
|
+
} else if (one < 0 && two < 0) {
|
|
193
|
+
if ((one == -1 && two == INT64_MIN) ||
|
|
194
|
+
(two == -1 && one == INT64_MIN)) {
|
|
195
|
+
*out = INT64_MIN;
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
if (INT64_MAX / one > two)
|
|
199
|
+
return true;
|
|
200
|
+
} else if (one > 0 && two < 0) {
|
|
201
|
+
if ((one == 1 && two == INT64_MIN) ||
|
|
202
|
+
(INT64_MIN / one > two))
|
|
203
|
+
return true;
|
|
204
|
+
} else if (one == -1) {
|
|
205
|
+
if (INT64_MIN / two > one)
|
|
206
|
+
return true;
|
|
207
|
+
} else {
|
|
208
|
+
if ((one == INT64_MIN && two == 1) ||
|
|
209
|
+
(INT64_MIN / one < two))
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
*out = one * two;
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
#endif
|
|
217
|
+
|
|
156
218
|
#endif
|
|
@@ -330,7 +330,7 @@ static iterator_pathlist_search_t iterator_pathlist_search(
|
|
|
330
330
|
break;
|
|
331
331
|
|
|
332
332
|
/* an exact match would have been matched by the bsearch above */
|
|
333
|
-
|
|
333
|
+
GIT_ASSERT_WITH_RETVAL(p[path_len], ITERATOR_PATHLIST_NONE);
|
|
334
334
|
|
|
335
335
|
/* is this a literal directory entry (eg `foo/`) or a file beneath */
|
|
336
336
|
if (p[path_len] == '/') {
|
|
@@ -678,14 +678,14 @@ done:
|
|
|
678
678
|
return error;
|
|
679
679
|
}
|
|
680
680
|
|
|
681
|
-
static
|
|
681
|
+
static int tree_iterator_frame_pop(tree_iterator *iter)
|
|
682
682
|
{
|
|
683
683
|
tree_iterator_frame *frame;
|
|
684
684
|
git_buf *buf = NULL;
|
|
685
685
|
git_tree *tree;
|
|
686
686
|
size_t i;
|
|
687
687
|
|
|
688
|
-
|
|
688
|
+
GIT_ASSERT(iter->frames.size);
|
|
689
689
|
|
|
690
690
|
frame = git_array_pop(iter->frames);
|
|
691
691
|
|
|
@@ -705,6 +705,8 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
|
|
|
705
705
|
git_vector_free(&frame->similar_trees);
|
|
706
706
|
|
|
707
707
|
git_buf_dispose(&frame->path);
|
|
708
|
+
|
|
709
|
+
return 0;
|
|
708
710
|
}
|
|
709
711
|
|
|
710
712
|
static int tree_iterator_current(
|
|
@@ -760,7 +762,9 @@ static int tree_iterator_advance(const git_index_entry **out, git_iterator *i)
|
|
|
760
762
|
|
|
761
763
|
/* no more entries in this frame. pop the frame out */
|
|
762
764
|
if (frame->next_idx == frame->entries.length) {
|
|
763
|
-
tree_iterator_frame_pop(iter)
|
|
765
|
+
if ((error = tree_iterator_frame_pop(iter)) < 0)
|
|
766
|
+
break;
|
|
767
|
+
|
|
764
768
|
continue;
|
|
765
769
|
}
|
|
766
770
|
|
|
@@ -838,7 +842,7 @@ static int tree_iterator_advance_into(
|
|
|
838
842
|
const git_index_entry **out, git_iterator *i)
|
|
839
843
|
{
|
|
840
844
|
tree_iterator *iter = (tree_iterator *)i;
|
|
841
|
-
|
|
845
|
+
tree_iterator_frame *frame;
|
|
842
846
|
tree_iterator_entry *prev_entry;
|
|
843
847
|
int error;
|
|
844
848
|
|
|
@@ -855,7 +859,7 @@ static int tree_iterator_advance_into(
|
|
|
855
859
|
* we will have pushed a new (empty) frame on to the stack for this
|
|
856
860
|
* new directory. since it's empty, its current_entry should be null.
|
|
857
861
|
*/
|
|
858
|
-
|
|
862
|
+
GIT_ASSERT(iterator__do_autoexpand(i) ^ (prev_entry != NULL));
|
|
859
863
|
|
|
860
864
|
if (prev_entry) {
|
|
861
865
|
if (!git_tree_entry__is_tree(prev_entry->tree_entry))
|
|
@@ -973,7 +977,7 @@ int git_iterator_current_tree_entry(
|
|
|
973
977
|
tree_iterator_frame *frame;
|
|
974
978
|
tree_iterator_entry *entry;
|
|
975
979
|
|
|
976
|
-
|
|
980
|
+
GIT_ASSERT(i->type == GIT_ITERATOR_TREE);
|
|
977
981
|
|
|
978
982
|
iter = (tree_iterator *)i;
|
|
979
983
|
|
|
@@ -990,11 +994,11 @@ int git_iterator_current_parent_tree(
|
|
|
990
994
|
tree_iterator *iter;
|
|
991
995
|
tree_iterator_frame *frame;
|
|
992
996
|
|
|
993
|
-
|
|
997
|
+
GIT_ASSERT(i->type == GIT_ITERATOR_TREE);
|
|
994
998
|
|
|
995
999
|
iter = (tree_iterator *)i;
|
|
996
1000
|
|
|
997
|
-
|
|
1001
|
+
GIT_ASSERT(depth < iter->frames.size);
|
|
998
1002
|
frame = &iter->frames.ptr[iter->frames.size-depth-1];
|
|
999
1003
|
|
|
1000
1004
|
*parent_tree = frame->tree;
|
|
@@ -1274,7 +1278,8 @@ static int filesystem_iterator_entry_hash(
|
|
|
1274
1278
|
return git_repository_hashfile(&entry->id,
|
|
1275
1279
|
iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
|
|
1276
1280
|
|
|
1277
|
-
if (!(error = git_buf_joinpath(&fullpath, iter->root, entry->path))
|
|
1281
|
+
if (!(error = git_buf_joinpath(&fullpath, iter->root, entry->path)) &&
|
|
1282
|
+
!(error = git_path_validate_workdir_buf(iter->base.repo, &fullpath)))
|
|
1278
1283
|
error = git_odb_hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB);
|
|
1279
1284
|
|
|
1280
1285
|
git_buf_dispose(&fullpath);
|
|
@@ -1355,7 +1360,8 @@ static int filesystem_iterator_frame_push(
|
|
|
1355
1360
|
else
|
|
1356
1361
|
git_buf_puts(&root, iter->root);
|
|
1357
1362
|
|
|
1358
|
-
if (git_buf_oom(&root)
|
|
1363
|
+
if (git_buf_oom(&root) ||
|
|
1364
|
+
git_path_validate_workdir_buf(iter->base.repo, &root) < 0) {
|
|
1359
1365
|
error = -1;
|
|
1360
1366
|
goto done;
|
|
1361
1367
|
}
|
|
@@ -1385,10 +1391,11 @@ static int filesystem_iterator_frame_push(
|
|
|
1385
1391
|
iterator_pathlist_search_t pathlist_match = ITERATOR_PATHLIST_FULL;
|
|
1386
1392
|
bool dir_expected = false;
|
|
1387
1393
|
|
|
1388
|
-
if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0
|
|
1394
|
+
if ((error = git_path_diriter_fullpath(&path, &path_len, &diriter)) < 0 ||
|
|
1395
|
+
(error = git_path_validate_workdir_with_len(iter->base.repo, path, path_len)) < 0)
|
|
1389
1396
|
goto done;
|
|
1390
1397
|
|
|
1391
|
-
|
|
1398
|
+
GIT_ASSERT(path_len > iter->root_len);
|
|
1392
1399
|
|
|
1393
1400
|
/* remove the prefix if requested */
|
|
1394
1401
|
path += iter->root_len;
|
|
@@ -1469,17 +1476,19 @@ done:
|
|
|
1469
1476
|
return error;
|
|
1470
1477
|
}
|
|
1471
1478
|
|
|
1472
|
-
GIT_INLINE(
|
|
1479
|
+
GIT_INLINE(int) filesystem_iterator_frame_pop(filesystem_iterator *iter)
|
|
1473
1480
|
{
|
|
1474
1481
|
filesystem_iterator_frame *frame;
|
|
1475
1482
|
|
|
1476
|
-
|
|
1483
|
+
GIT_ASSERT(iter->frames.size);
|
|
1477
1484
|
|
|
1478
1485
|
frame = git_array_pop(iter->frames);
|
|
1479
1486
|
filesystem_iterator_frame_pop_ignores(iter);
|
|
1480
1487
|
|
|
1481
1488
|
git_pool_clear(&frame->entry_pool);
|
|
1482
1489
|
git_vector_free(&frame->entries);
|
|
1490
|
+
|
|
1491
|
+
return 0;
|
|
1483
1492
|
}
|
|
1484
1493
|
|
|
1485
1494
|
static void filesystem_iterator_set_current(
|
|
@@ -1556,7 +1565,8 @@ static int filesystem_iterator_is_dir(
|
|
|
1556
1565
|
}
|
|
1557
1566
|
|
|
1558
1567
|
if ((error = git_buf_joinpath(&fullpath, iter->root, entry->path)) < 0 ||
|
|
1559
|
-
|
|
1568
|
+
(error = git_path_validate_workdir_buf(iter->base.repo, &fullpath)) < 0 ||
|
|
1569
|
+
(error = p_stat(fullpath.ptr, &st)) < 0)
|
|
1560
1570
|
goto done;
|
|
1561
1571
|
|
|
1562
1572
|
*is_dir = S_ISDIR(st.st_mode);
|
|
@@ -1646,7 +1656,7 @@ static int filesystem_iterator_advance_into(
|
|
|
1646
1656
|
* we will have pushed a new (empty) frame on to the stack for this
|
|
1647
1657
|
* new directory. since it's empty, its current_entry should be null.
|
|
1648
1658
|
*/
|
|
1649
|
-
|
|
1659
|
+
GIT_ASSERT(iterator__do_autoexpand(i) ^ (prev_entry != NULL));
|
|
1650
1660
|
|
|
1651
1661
|
if (prev_entry) {
|
|
1652
1662
|
if (prev_entry->st.st_mode != GIT_FILEMODE_COMMIT &&
|
|
@@ -1762,12 +1772,13 @@ static int filesystem_iterator_advance_over(
|
|
|
1762
1772
|
*out = NULL;
|
|
1763
1773
|
*status = GIT_ITERATOR_STATUS_NORMAL;
|
|
1764
1774
|
|
|
1765
|
-
|
|
1775
|
+
GIT_ASSERT(iterator__has_been_accessed(i));
|
|
1766
1776
|
|
|
1767
1777
|
current_frame = filesystem_iterator_current_frame(iter);
|
|
1768
|
-
|
|
1778
|
+
GIT_ASSERT(current_frame);
|
|
1779
|
+
|
|
1769
1780
|
current_entry = filesystem_iterator_current_entry(current_frame);
|
|
1770
|
-
|
|
1781
|
+
GIT_ASSERT(current_entry);
|
|
1771
1782
|
|
|
1772
1783
|
if ((error = git_iterator_current(&entry, i)) < 0)
|
|
1773
1784
|
return error;
|
|
@@ -2065,8 +2076,8 @@ static bool index_iterator_create_pseudotree(
|
|
|
2065
2076
|
|
|
2066
2077
|
static int index_iterator_skip_pseudotree(index_iterator *iter)
|
|
2067
2078
|
{
|
|
2068
|
-
|
|
2069
|
-
|
|
2079
|
+
GIT_ASSERT(iterator__has_been_accessed(&iter->base));
|
|
2080
|
+
GIT_ASSERT(S_ISDIR(iter->entry->mode));
|
|
2070
2081
|
|
|
2071
2082
|
while (true) {
|
|
2072
2083
|
const git_index_entry *next_entry = NULL;
|
|
@@ -2280,10 +2291,11 @@ int git_iterator_reset_range(
|
|
|
2280
2291
|
return i->cb->reset(i);
|
|
2281
2292
|
}
|
|
2282
2293
|
|
|
2283
|
-
|
|
2294
|
+
int git_iterator_set_ignore_case(git_iterator *i, bool ignore_case)
|
|
2284
2295
|
{
|
|
2285
|
-
|
|
2296
|
+
GIT_ASSERT(!iterator__has_been_accessed(i));
|
|
2286
2297
|
iterator_set_ignore_case(i, ignore_case);
|
|
2298
|
+
return 0;
|
|
2287
2299
|
}
|
|
2288
2300
|
|
|
2289
2301
|
void git_iterator_free(git_iterator *iter)
|