rugged 0.27.10.1 → 0.28.0
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 +23 -2
- data/ext/rugged/rugged.c +48 -2
- data/ext/rugged/rugged.h +5 -0
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_blob.c +3 -3
- data/ext/rugged/rugged_branch.c +1 -1
- data/ext/rugged/rugged_commit.c +8 -8
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +24 -4
- data/ext/rugged/rugged_note.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -10
- data/ext/rugged/rugged_settings.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +69 -47
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/include/git2.h +3 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +19 -8
- data/vendor/libgit2/include/git2/blame.h +41 -24
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +20 -19
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +11 -9
- data/vendor/libgit2/include/git2/commit.h +30 -2
- data/vendor/libgit2/include/git2/common.h +54 -4
- data/vendor/libgit2/include/git2/config.h +18 -7
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +193 -143
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +72 -51
- data/vendor/libgit2/include/git2/indexer.h +30 -4
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +29 -8
- data/vendor/libgit2/include/git2/net.h +1 -1
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +16 -16
- data/vendor/libgit2/include/git2/odb.h +10 -10
- data/vendor/libgit2/include/git2/odb_backend.h +7 -7
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +2 -2
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refs.h +14 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +92 -16
- data/vendor/libgit2/include/git2/repository.h +52 -37
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +13 -10
- data/vendor/libgit2/include/git2/status.h +8 -4
- data/vendor/libgit2/include/git2/submodule.h +11 -10
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +127 -81
- data/vendor/libgit2/include/git2/tag.h +2 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +47 -18
- data/vendor/libgit2/include/git2/tree.h +3 -3
- data/vendor/libgit2/include/git2/types.h +35 -28
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +47 -12
- data/vendor/libgit2/src/CMakeLists.txt +87 -26
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +490 -14
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +11 -11
- data/vendor/libgit2/src/attr_file.c +20 -15
- data/vendor/libgit2/src/attrcache.c +11 -11
- data/vendor/libgit2/src/blame.c +30 -15
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +16 -13
- data/vendor/libgit2/src/blob.c +50 -28
- data/vendor/libgit2/src/blob.h +18 -1
- data/vendor/libgit2/src/branch.c +38 -38
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +55 -50
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +16 -16
- data/vendor/libgit2/src/cache.h +2 -2
- data/vendor/libgit2/src/cc-compat.h +15 -3
- data/vendor/libgit2/src/checkout.c +83 -74
- data/vendor/libgit2/src/cherrypick.c +6 -6
- data/vendor/libgit2/src/clone.c +20 -20
- data/vendor/libgit2/src/commit.c +53 -33
- data/vendor/libgit2/src/commit.h +1 -0
- data/vendor/libgit2/src/commit_list.c +6 -10
- data/vendor/libgit2/src/common.h +32 -30
- data/vendor/libgit2/src/config.c +167 -147
- data/vendor/libgit2/src/config.h +1 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +7 -1
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +167 -439
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +69 -38
- data/vendor/libgit2/src/config_parse.h +4 -4
- data/vendor/libgit2/src/crlf.c +215 -186
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +23 -23
- data/vendor/libgit2/src/diff.c +12 -12
- data/vendor/libgit2/src/diff_driver.c +14 -15
- data/vendor/libgit2/src/diff_file.c +10 -10
- data/vendor/libgit2/src/diff_generate.c +29 -23
- data/vendor/libgit2/src/diff_generate.h +1 -1
- data/vendor/libgit2/src/diff_parse.c +3 -3
- data/vendor/libgit2/src/diff_print.c +17 -17
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +12 -12
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +42 -20
- data/vendor/libgit2/src/features.h.in +2 -1
- data/vendor/libgit2/src/fetch.c +3 -3
- data/vendor/libgit2/src/fetchhead.c +16 -16
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/fileops.c +54 -54
- data/vendor/libgit2/src/fileops.h +1 -1
- data/vendor/libgit2/src/filter.c +30 -30
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/global.c +36 -23
- data/vendor/libgit2/src/hash.h +4 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
- data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
- data/vendor/libgit2/src/hash/hash_generic.h +5 -1
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
- data/vendor/libgit2/src/hash/hash_win32.c +13 -13
- data/vendor/libgit2/src/hashsig.c +4 -4
- data/vendor/libgit2/src/idxmap.c +25 -5
- data/vendor/libgit2/src/idxmap.h +4 -18
- data/vendor/libgit2/src/ignore.c +9 -9
- data/vendor/libgit2/src/index.c +280 -198
- data/vendor/libgit2/src/index.h +16 -0
- data/vendor/libgit2/src/indexer.c +311 -139
- data/vendor/libgit2/src/integer.h +32 -22
- data/vendor/libgit2/src/iterator.c +116 -49
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/merge.c +89 -59
- data/vendor/libgit2/src/merge_driver.c +7 -7
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -8
- data/vendor/libgit2/src/netops.c +22 -13
- data/vendor/libgit2/src/netops.h +2 -0
- data/vendor/libgit2/src/notes.c +15 -10
- data/vendor/libgit2/src/object.c +118 -67
- data/vendor/libgit2/src/object.h +20 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +72 -72
- data/vendor/libgit2/src/odb.h +7 -7
- data/vendor/libgit2/src/odb_loose.c +46 -46
- data/vendor/libgit2/src/odb_mempack.c +14 -14
- data/vendor/libgit2/src/odb_pack.c +14 -10
- data/vendor/libgit2/src/offmap.c +30 -0
- data/vendor/libgit2/src/offmap.h +20 -11
- data/vendor/libgit2/src/oid.c +6 -6
- data/vendor/libgit2/src/oidmap.c +20 -0
- data/vendor/libgit2/src/oidmap.h +9 -12
- data/vendor/libgit2/src/pack-objects.c +71 -63
- data/vendor/libgit2/src/pack-objects.h +1 -7
- data/vendor/libgit2/src/pack.c +58 -58
- data/vendor/libgit2/src/pack.h +6 -6
- data/vendor/libgit2/src/parse.h +1 -1
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch_generate.c +18 -18
- data/vendor/libgit2/src/patch_parse.c +13 -13
- data/vendor/libgit2/src/path.c +93 -225
- data/vendor/libgit2/src/path.h +2 -84
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/proxy.c +1 -1
- data/vendor/libgit2/src/push.c +27 -26
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +49 -52
- data/vendor/libgit2/src/refdb.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +181 -103
- data/vendor/libgit2/src/reflog.c +3 -3
- data/vendor/libgit2/src/refs.c +98 -74
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +47 -21
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +219 -166
- data/vendor/libgit2/src/remote.h +9 -0
- data/vendor/libgit2/src/repository.c +173 -133
- data/vendor/libgit2/src/repository.h +6 -3
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +6 -6
- data/vendor/libgit2/src/revparse.c +30 -30
- data/vendor/libgit2/src/revwalk.c +60 -30
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +42 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +13 -13
- data/vendor/libgit2/src/stash.c +91 -45
- data/vendor/libgit2/src/status.c +13 -13
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
- data/vendor/libgit2/src/stream.h +17 -2
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +204 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +54 -29
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +22 -2
- data/vendor/libgit2/src/strmap.h +18 -15
- data/vendor/libgit2/src/submodule.c +179 -155
- data/vendor/libgit2/src/sysdir.c +18 -18
- data/vendor/libgit2/src/tag.c +31 -26
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transaction.c +23 -23
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +7 -4
- data/vendor/libgit2/src/transports/auth.h +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
- data/vendor/libgit2/src/transports/cred.c +18 -18
- data/vendor/libgit2/src/transports/git.c +15 -15
- data/vendor/libgit2/src/transports/http.c +606 -216
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +26 -26
- data/vendor/libgit2/src/transports/smart.c +54 -31
- data/vendor/libgit2/src/transports/smart.h +1 -2
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
- data/vendor/libgit2/src/transports/ssh.c +34 -33
- data/vendor/libgit2/src/transports/winhttp.c +99 -119
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree.c +96 -121
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +2 -2
- data/vendor/libgit2/src/util.c +22 -6
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +6 -6
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +101 -7
- data/vendor/libgit2/src/win32/path_w32.h +18 -0
- data/vendor/libgit2/src/win32/posix_w32.c +24 -43
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/win32/w32_stack.c +2 -2
- data/vendor/libgit2/src/win32/w32_util.c +1 -69
- data/vendor/libgit2/src/win32/w32_util.h +1 -19
- data/vendor/libgit2/src/worktree.c +75 -54
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -7
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -42,34 +42,44 @@ GIT_INLINE(int) git__is_int(long long p)
|
|
42
42
|
return p == (long long)r;
|
43
43
|
}
|
44
44
|
|
45
|
-
/**
|
46
|
-
* Sets `one + two` into `out`, unless the arithmetic would overflow.
|
47
|
-
* @return true if the result fits in a `uint64_t`, false on overflow.
|
48
|
-
*/
|
49
|
-
GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t two)
|
50
|
-
{
|
51
|
-
if (UINT64_MAX - one < two)
|
52
|
-
return true;
|
53
|
-
*out = one + two;
|
54
|
-
return false;
|
55
|
-
}
|
56
|
-
|
57
45
|
/* Use clang/gcc compiler intrinsics whenever possible */
|
58
|
-
#if (
|
59
|
-
|
60
|
-
|
61
|
-
#
|
62
|
-
|
63
|
-
|
46
|
+
#if (__has_builtin(__builtin_add_overflow) || \
|
47
|
+
(defined(__GNUC__) && (__GNUC__ >= 5)))
|
48
|
+
|
49
|
+
# if (SIZE_MAX == UINT_MAX)
|
50
|
+
# define git__add_sizet_overflow(out, one, two) \
|
51
|
+
__builtin_uadd_overflow(one, two, out)
|
52
|
+
# define git__multiply_sizet_overflow(out, one, two) \
|
53
|
+
__builtin_umul_overflow(one, two, out)
|
54
|
+
# elif (SIZE_MAX == ULONG_MAX)
|
55
|
+
# define git__add_sizet_overflow(out, one, two) \
|
56
|
+
__builtin_uaddl_overflow(one, two, out)
|
57
|
+
# define git__multiply_sizet_overflow(out, one, two) \
|
58
|
+
__builtin_umull_overflow(one, two, out)
|
59
|
+
# elif (SIZE_MAX == ULLONG_MAX)
|
60
|
+
# define git__add_sizet_overflow(out, one, two) \
|
61
|
+
__builtin_uaddll_overflow(one, two, out)
|
62
|
+
# define git__multiply_sizet_overflow(out, one, two) \
|
63
|
+
__builtin_umulll_overflow(one, two, out)
|
64
|
+
# else
|
65
|
+
# error compiler has add with overflow intrinsics but SIZE_MAX is unknown
|
66
|
+
# endif
|
67
|
+
|
68
|
+
/* Use Microsoft's safe integer handling functions where available */
|
69
|
+
#elif defined(_MSC_VER)
|
70
|
+
|
71
|
+
# include <intsafe.h>
|
72
|
+
|
64
73
|
# define git__add_sizet_overflow(out, one, two) \
|
65
|
-
|
74
|
+
(SizeTAdd(one, two, out) != S_OK)
|
66
75
|
# define git__multiply_sizet_overflow(out, one, two) \
|
67
|
-
|
76
|
+
(SizeTMult(one, two, out) != S_OK)
|
77
|
+
|
68
78
|
#else
|
69
79
|
|
70
80
|
/**
|
71
81
|
* Sets `one + two` into `out`, unless the arithmetic would overflow.
|
72
|
-
* @return
|
82
|
+
* @return false if the result fits in a `size_t`, true on overflow.
|
73
83
|
*/
|
74
84
|
GIT_INLINE(bool) git__add_sizet_overflow(size_t *out, size_t one, size_t two)
|
75
85
|
{
|
@@ -81,7 +91,7 @@ GIT_INLINE(bool) git__add_sizet_overflow(size_t *out, size_t one, size_t two)
|
|
81
91
|
|
82
92
|
/**
|
83
93
|
* Sets `one * two` into `out`, unless the arithmetic would overflow.
|
84
|
-
* @return
|
94
|
+
* @return false if the result fits in a `size_t`, true on overflow.
|
85
95
|
*/
|
86
96
|
GIT_INLINE(bool) git__multiply_sizet_overflow(size_t *out, size_t one, size_t two)
|
87
97
|
{
|
@@ -46,14 +46,14 @@ static int iterator_range_init(
|
|
46
46
|
{
|
47
47
|
if (start && *start) {
|
48
48
|
iter->start = git__strdup(start);
|
49
|
-
|
49
|
+
GIT_ERROR_CHECK_ALLOC(iter->start);
|
50
50
|
|
51
51
|
iter->start_len = strlen(iter->start);
|
52
52
|
}
|
53
53
|
|
54
54
|
if (end && *end) {
|
55
55
|
iter->end = git__strdup(end);
|
56
|
-
|
56
|
+
GIT_ERROR_CHECK_ALLOC(iter->end);
|
57
57
|
|
58
58
|
iter->end_len = strlen(iter->end);
|
59
59
|
}
|
@@ -146,7 +146,7 @@ static int iterator_init_common(
|
|
146
146
|
(iter->flags & GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE) == 0) {
|
147
147
|
|
148
148
|
if (git_repository__cvar(&precompose, repo, GIT_CVAR_PRECOMPOSE) < 0)
|
149
|
-
|
149
|
+
git_error_clear();
|
150
150
|
else if (precompose)
|
151
151
|
iter->flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
|
152
152
|
}
|
@@ -403,7 +403,7 @@ int git_iterator_for_nothing(
|
|
403
403
|
*out = NULL;
|
404
404
|
|
405
405
|
iter = git__calloc(1, sizeof(empty_iterator));
|
406
|
-
|
406
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
407
407
|
|
408
408
|
iter->base.type = GIT_ITERATOR_TYPE_EMPTY;
|
409
409
|
iter->base.cb = &callbacks;
|
@@ -478,14 +478,6 @@ GIT_INLINE(int) tree_entry_cmp(
|
|
478
478
|
icase ? git__strncasecmp : git__strncmp);
|
479
479
|
}
|
480
480
|
|
481
|
-
GIT_INLINE(int) tree_iterator_entry_cmp(const void *ptr_a, const void *ptr_b)
|
482
|
-
{
|
483
|
-
const tree_iterator_entry *a = (const tree_iterator_entry *)ptr_a;
|
484
|
-
const tree_iterator_entry *b = (const tree_iterator_entry *)ptr_b;
|
485
|
-
|
486
|
-
return tree_entry_cmp(a->tree_entry, b->tree_entry, false);
|
487
|
-
}
|
488
|
-
|
489
481
|
GIT_INLINE(int) tree_iterator_entry_cmp_icase(
|
490
482
|
const void *ptr_a, const void *ptr_b)
|
491
483
|
{
|
@@ -549,7 +541,7 @@ static int tree_iterator_frame_init(
|
|
549
541
|
int error = 0;
|
550
542
|
|
551
543
|
new_frame = git_array_alloc(iter->frames);
|
552
|
-
|
544
|
+
GIT_ERROR_CHECK_ALLOC(new_frame);
|
553
545
|
|
554
546
|
memset(new_frame, 0, sizeof(tree_iterator_frame));
|
555
547
|
|
@@ -572,7 +564,7 @@ static int tree_iterator_frame_init(
|
|
572
564
|
|
573
565
|
git_array_foreach(dup->entries, i, tree_entry) {
|
574
566
|
new_entry = git_pool_malloc(&iter->entry_pool, 1);
|
575
|
-
|
567
|
+
GIT_ERROR_CHECK_ALLOC(new_entry);
|
576
568
|
|
577
569
|
new_entry->tree_entry = tree_entry;
|
578
570
|
new_entry->parent_path = new_frame->path.ptr;
|
@@ -626,20 +618,20 @@ GIT_INLINE(int) tree_iterator_frame_push_neighbors(
|
|
626
618
|
break;
|
627
619
|
|
628
620
|
path = git_array_alloc(parent_frame->similar_paths);
|
629
|
-
|
621
|
+
GIT_ERROR_CHECK_ALLOC(path);
|
630
622
|
|
631
623
|
memset(path, 0, sizeof(git_buf));
|
632
624
|
|
633
625
|
if ((error = tree_iterator_compute_path(path, entry)) < 0)
|
634
626
|
break;
|
635
627
|
|
636
|
-
|
628
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&new_size,
|
637
629
|
frame->entries.length, tree->entries.size);
|
638
630
|
git_vector_size_hint(&frame->entries, new_size);
|
639
631
|
|
640
632
|
git_array_foreach(tree->entries, i, tree_entry) {
|
641
633
|
new_entry = git_pool_malloc(&iter->entry_pool, 1);
|
642
|
-
|
634
|
+
GIT_ERROR_CHECK_ALLOC(new_entry);
|
643
635
|
|
644
636
|
new_entry->tree_entry = tree_entry;
|
645
637
|
new_entry->parent_path = path->ptr;
|
@@ -701,7 +693,7 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
|
|
701
693
|
|
702
694
|
do {
|
703
695
|
buf = git_array_pop(frame->similar_paths);
|
704
|
-
|
696
|
+
git_buf_dispose(buf);
|
705
697
|
} while (buf != NULL);
|
706
698
|
|
707
699
|
git_array_clear(frame->similar_paths);
|
@@ -711,7 +703,7 @@ static void tree_iterator_frame_pop(tree_iterator *iter)
|
|
711
703
|
|
712
704
|
git_vector_free(&frame->similar_trees);
|
713
705
|
|
714
|
-
|
706
|
+
git_buf_dispose(&frame->path);
|
715
707
|
}
|
716
708
|
|
717
709
|
static int tree_iterator_current(
|
@@ -929,7 +921,7 @@ static void tree_iterator_free(git_iterator *i)
|
|
929
921
|
tree_iterator_clear(iter);
|
930
922
|
|
931
923
|
git_tree_free(iter->root);
|
932
|
-
|
924
|
+
git_buf_dispose(&iter->entry_path);
|
933
925
|
}
|
934
926
|
|
935
927
|
int git_iterator_for_tree(
|
@@ -955,7 +947,7 @@ int git_iterator_for_tree(
|
|
955
947
|
return git_iterator_for_nothing(out, options);
|
956
948
|
|
957
949
|
iter = git__calloc(1, sizeof(tree_iterator));
|
958
|
-
|
950
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
959
951
|
|
960
952
|
iter->base.type = GIT_ITERATOR_TYPE_TREE;
|
961
953
|
iter->base.cb = &callbacks;
|
@@ -1015,6 +1007,7 @@ typedef struct {
|
|
1015
1007
|
struct stat st;
|
1016
1008
|
size_t path_len;
|
1017
1009
|
iterator_pathlist_search_t match;
|
1010
|
+
git_oid id;
|
1018
1011
|
char path[GIT_FLEX_ARRAY];
|
1019
1012
|
} filesystem_iterator_entry;
|
1020
1013
|
|
@@ -1150,7 +1143,7 @@ static void filesystem_iterator_frame_push_ignores(
|
|
1150
1143
|
|
1151
1144
|
if (git_ignore__lookup(&new_frame->is_ignored,
|
1152
1145
|
&iter->ignores, path, GIT_DIR_FLAG_TRUE) < 0) {
|
1153
|
-
|
1146
|
+
git_error_clear();
|
1154
1147
|
new_frame->is_ignored = GIT_IGNORE_NOTFOUND;
|
1155
1148
|
}
|
1156
1149
|
|
@@ -1265,7 +1258,32 @@ GIT_INLINE(bool) filesystem_iterator_is_dot_git(
|
|
1265
1258
|
return (len == 4 || path[len - 5] == '/');
|
1266
1259
|
}
|
1267
1260
|
|
1268
|
-
static
|
1261
|
+
static int filesystem_iterator_entry_hash(
|
1262
|
+
filesystem_iterator *iter,
|
1263
|
+
filesystem_iterator_entry *entry)
|
1264
|
+
{
|
1265
|
+
git_buf fullpath = GIT_BUF_INIT;
|
1266
|
+
int error;
|
1267
|
+
|
1268
|
+
if (S_ISDIR(entry->st.st_mode)) {
|
1269
|
+
memset(&entry->id, 0, GIT_OID_RAWSZ);
|
1270
|
+
return 0;
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
if (iter->base.type == GIT_ITERATOR_TYPE_WORKDIR)
|
1274
|
+
return git_repository_hashfile(&entry->id,
|
1275
|
+
iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
|
1276
|
+
|
1277
|
+
if (!(error = git_buf_joinpath(&fullpath, iter->root, entry->path)))
|
1278
|
+
error = git_odb_hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB);
|
1279
|
+
|
1280
|
+
git_buf_dispose(&fullpath);
|
1281
|
+
return error;
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
static int filesystem_iterator_entry_init(
|
1285
|
+
filesystem_iterator_entry **out,
|
1286
|
+
filesystem_iterator *iter,
|
1269
1287
|
filesystem_iterator_frame *frame,
|
1270
1288
|
const char *path,
|
1271
1289
|
size_t path_len,
|
@@ -1274,15 +1292,19 @@ static filesystem_iterator_entry *filesystem_iterator_entry_init(
|
|
1274
1292
|
{
|
1275
1293
|
filesystem_iterator_entry *entry;
|
1276
1294
|
size_t entry_size;
|
1295
|
+
int error = 0;
|
1296
|
+
|
1297
|
+
*out = NULL;
|
1277
1298
|
|
1278
1299
|
/* Make sure to append two bytes, one for the path's null
|
1279
1300
|
* termination, one for a possible trailing '/' for folders.
|
1280
1301
|
*/
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1302
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&entry_size,
|
1303
|
+
sizeof(filesystem_iterator_entry), path_len);
|
1304
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&entry_size, entry_size, 2);
|
1305
|
+
|
1306
|
+
entry = git_pool_malloc(&frame->entry_pool, entry_size);
|
1307
|
+
GIT_ERROR_CHECK_ALLOC(entry);
|
1286
1308
|
|
1287
1309
|
entry->path_len = path_len;
|
1288
1310
|
entry->match = pathlist_match;
|
@@ -1295,7 +1317,13 @@ static filesystem_iterator_entry *filesystem_iterator_entry_init(
|
|
1295
1317
|
|
1296
1318
|
entry->path[entry->path_len] = '\0';
|
1297
1319
|
|
1298
|
-
|
1320
|
+
if (iter->base.flags & GIT_ITERATOR_INCLUDE_HASH)
|
1321
|
+
error = filesystem_iterator_entry_hash(iter, entry);
|
1322
|
+
|
1323
|
+
if (!error)
|
1324
|
+
*out = entry;
|
1325
|
+
|
1326
|
+
return error;
|
1299
1327
|
}
|
1300
1328
|
|
1301
1329
|
static int filesystem_iterator_frame_push(
|
@@ -1312,13 +1340,13 @@ static int filesystem_iterator_frame_push(
|
|
1312
1340
|
int error;
|
1313
1341
|
|
1314
1342
|
if (iter->frames.size == FILESYSTEM_MAX_DEPTH) {
|
1315
|
-
|
1343
|
+
git_error_set(GIT_ERROR_REPOSITORY,
|
1316
1344
|
"directory nesting too deep (%"PRIuZ")", iter->frames.size);
|
1317
1345
|
return -1;
|
1318
1346
|
}
|
1319
1347
|
|
1320
1348
|
new_frame = git_array_alloc(iter->frames);
|
1321
|
-
|
1349
|
+
GIT_ERROR_CHECK_ALLOC(new_frame);
|
1322
1350
|
|
1323
1351
|
memset(new_frame, 0, sizeof(filesystem_iterator_frame));
|
1324
1352
|
|
@@ -1418,9 +1446,9 @@ static int filesystem_iterator_frame_push(
|
|
1418
1446
|
else if (dir_expected)
|
1419
1447
|
continue;
|
1420
1448
|
|
1421
|
-
|
1422
|
-
path, path_len, &statbuf, pathlist_match)
|
1423
|
-
|
1449
|
+
if ((error = filesystem_iterator_entry_init(&entry,
|
1450
|
+
iter, new_frame, path, path_len, &statbuf, pathlist_match)) < 0)
|
1451
|
+
goto done;
|
1424
1452
|
|
1425
1453
|
git_vector_insert(&new_frame->entries, entry);
|
1426
1454
|
}
|
@@ -1435,7 +1463,7 @@ done:
|
|
1435
1463
|
if (error < 0)
|
1436
1464
|
git_array_pop(iter->frames);
|
1437
1465
|
|
1438
|
-
|
1466
|
+
git_buf_dispose(&root);
|
1439
1467
|
git_path_diriter_free(&diriter);
|
1440
1468
|
return error;
|
1441
1469
|
}
|
@@ -1457,10 +1485,17 @@ static void filesystem_iterator_set_current(
|
|
1457
1485
|
filesystem_iterator *iter,
|
1458
1486
|
filesystem_iterator_entry *entry)
|
1459
1487
|
{
|
1460
|
-
|
1461
|
-
|
1488
|
+
/*
|
1489
|
+
* Index entries are limited to 32 bit timestamps. We can safely
|
1490
|
+
* cast this since workdir times are only used in the cache; any
|
1491
|
+
* mismatch will cause a hash recomputation which is unfortunate
|
1492
|
+
* but affects only people who set their filetimes to 2038.
|
1493
|
+
* (Same with the file size.)
|
1494
|
+
*/
|
1495
|
+
iter->entry.ctime.seconds = (int32_t)entry->st.st_ctime;
|
1496
|
+
iter->entry.mtime.seconds = (int32_t)entry->st.st_mtime;
|
1462
1497
|
|
1463
|
-
#if defined(GIT_USE_NSEC)
|
1498
|
+
#if defined(GIT_USE_NSEC)
|
1464
1499
|
iter->entry.ctime.nanoseconds = entry->st.st_ctime_nsec;
|
1465
1500
|
iter->entry.mtime.nanoseconds = entry->st.st_mtime_nsec;
|
1466
1501
|
#else
|
@@ -1473,7 +1508,10 @@ static void filesystem_iterator_set_current(
|
|
1473
1508
|
iter->entry.mode = git_futils_canonical_mode(entry->st.st_mode);
|
1474
1509
|
iter->entry.uid = entry->st.st_uid;
|
1475
1510
|
iter->entry.gid = entry->st.st_gid;
|
1476
|
-
iter->entry.file_size = entry->st.st_size;
|
1511
|
+
iter->entry.file_size = (uint32_t)entry->st.st_size;
|
1512
|
+
|
1513
|
+
if (iter->base.flags & GIT_ITERATOR_INCLUDE_HASH)
|
1514
|
+
git_oid_cpy(&iter->entry.id, &entry->id);
|
1477
1515
|
|
1478
1516
|
iter->entry.path = entry->path;
|
1479
1517
|
|
@@ -1523,7 +1561,7 @@ static int filesystem_iterator_is_dir(
|
|
1523
1561
|
*is_dir = S_ISDIR(st.st_mode);
|
1524
1562
|
|
1525
1563
|
done:
|
1526
|
-
|
1564
|
+
git_buf_dispose(&fullpath);
|
1527
1565
|
return error;
|
1528
1566
|
}
|
1529
1567
|
|
@@ -1664,7 +1702,7 @@ static void filesystem_iterator_update_ignored(filesystem_iterator *iter)
|
|
1664
1702
|
|
1665
1703
|
if (git_ignore__lookup(&iter->current_is_ignored,
|
1666
1704
|
&iter->ignores, iter->entry.path, dir_flag) < 0) {
|
1667
|
-
|
1705
|
+
git_error_clear();
|
1668
1706
|
iter->current_is_ignored = GIT_IGNORE_NOTFOUND;
|
1669
1707
|
}
|
1670
1708
|
|
@@ -1804,7 +1842,7 @@ static void filesystem_iterator_clear(filesystem_iterator *iter)
|
|
1804
1842
|
git_array_clear(iter->frames);
|
1805
1843
|
git_ignore__free(&iter->ignores);
|
1806
1844
|
|
1807
|
-
|
1845
|
+
git_buf_dispose(&iter->tmp_buf);
|
1808
1846
|
|
1809
1847
|
iterator_clear(&iter->base);
|
1810
1848
|
}
|
@@ -1838,7 +1876,7 @@ static void filesystem_iterator_free(git_iterator *i)
|
|
1838
1876
|
{
|
1839
1877
|
filesystem_iterator *iter = (filesystem_iterator *)i;
|
1840
1878
|
git__free(iter->root);
|
1841
|
-
|
1879
|
+
git_buf_dispose(&iter->current_path);
|
1842
1880
|
git_tree_free(iter->tree);
|
1843
1881
|
if (iter->index)
|
1844
1882
|
git_index_snapshot_release(&iter->index_snapshot, iter->index);
|
@@ -1873,7 +1911,7 @@ static int iterator_for_filesystem(
|
|
1873
1911
|
return git_iterator_for_nothing(out, options);
|
1874
1912
|
|
1875
1913
|
iter = git__calloc(1, sizeof(filesystem_iterator));
|
1876
|
-
|
1914
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
1877
1915
|
|
1878
1916
|
iter->base.type = type;
|
1879
1917
|
iter->base.cb = &callbacks;
|
@@ -1881,7 +1919,7 @@ static int iterator_for_filesystem(
|
|
1881
1919
|
root_len = strlen(root);
|
1882
1920
|
|
1883
1921
|
iter->root = git__malloc(root_len+2);
|
1884
|
-
|
1922
|
+
GIT_ERROR_CHECK_ALLOC(iter->root);
|
1885
1923
|
|
1886
1924
|
memcpy(iter->root, root, root_len);
|
1887
1925
|
|
@@ -2176,7 +2214,7 @@ static void index_iterator_free(git_iterator *i)
|
|
2176
2214
|
index_iterator *iter = (index_iterator *)i;
|
2177
2215
|
|
2178
2216
|
git_index_snapshot_release(&iter->entries, iter->base.index);
|
2179
|
-
|
2217
|
+
git_buf_dispose(&iter->tree_buf);
|
2180
2218
|
}
|
2181
2219
|
|
2182
2220
|
int git_iterator_for_index(
|
@@ -2203,7 +2241,7 @@ int git_iterator_for_index(
|
|
2203
2241
|
return git_iterator_for_nothing(out, options);
|
2204
2242
|
|
2205
2243
|
iter = git__calloc(1, sizeof(index_iterator));
|
2206
|
-
|
2244
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
2207
2245
|
|
2208
2246
|
iter->base.type = GIT_ITERATOR_TYPE_INDEX;
|
2209
2247
|
iter->base.cb = &callbacks;
|
@@ -2259,6 +2297,35 @@ void git_iterator_free(git_iterator *iter)
|
|
2259
2297
|
git__free(iter);
|
2260
2298
|
}
|
2261
2299
|
|
2300
|
+
int git_iterator_foreach(
|
2301
|
+
git_iterator *iterator,
|
2302
|
+
git_iterator_foreach_cb cb,
|
2303
|
+
void *data)
|
2304
|
+
{
|
2305
|
+
const git_index_entry *iterator_item;
|
2306
|
+
int error = 0;
|
2307
|
+
|
2308
|
+
if ((error = git_iterator_current(&iterator_item, iterator)) < 0)
|
2309
|
+
goto done;
|
2310
|
+
|
2311
|
+
if ((error = cb(iterator_item, data)) != 0)
|
2312
|
+
goto done;
|
2313
|
+
|
2314
|
+
while (true) {
|
2315
|
+
if ((error = git_iterator_advance(&iterator_item, iterator)) < 0)
|
2316
|
+
goto done;
|
2317
|
+
|
2318
|
+
if ((error = cb(iterator_item, data)) != 0)
|
2319
|
+
goto done;
|
2320
|
+
}
|
2321
|
+
|
2322
|
+
done:
|
2323
|
+
if (error == GIT_ITEROVER)
|
2324
|
+
error = 0;
|
2325
|
+
|
2326
|
+
return error;
|
2327
|
+
}
|
2328
|
+
|
2262
2329
|
int git_iterator_walk(
|
2263
2330
|
git_iterator **iterators,
|
2264
2331
|
size_t cnt,
|
@@ -2274,8 +2341,8 @@ int git_iterator_walk(
|
|
2274
2341
|
iterator_item = git__calloc(cnt, sizeof(git_index_entry *));
|
2275
2342
|
cur_items = git__calloc(cnt, sizeof(git_index_entry *));
|
2276
2343
|
|
2277
|
-
|
2278
|
-
|
2344
|
+
GIT_ERROR_CHECK_ALLOC(iterator_item);
|
2345
|
+
GIT_ERROR_CHECK_ALLOC(cur_items);
|
2279
2346
|
|
2280
2347
|
/* Set up the iterators */
|
2281
2348
|
for (i = 0; i < cnt; i++) {
|