rugged 1.0.0 → 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 +3 -3
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_commit.c +1 -1
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_remote.c +32 -2
- data/ext/rugged/rugged_repo.c +13 -3
- data/lib/rugged/commit.rb +17 -4
- data/lib/rugged/repository.rb +7 -8
- data/lib/rugged/submodule_collection.rb +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +41 -74
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
- data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
- data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
- 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 +164 -135
- 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/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/deps/pcre/LICENCE +93 -0
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
- data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/apply.h +2 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +95 -42
- data/vendor/libgit2/include/git2/blob.h +31 -3
- 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 +33 -6
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +248 -8
- data/vendor/libgit2/include/git2/diff.h +35 -20
- data/vendor/libgit2/include/git2/errors.h +8 -7
- 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 +4 -5
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/pack.h +1 -1
- 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 +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/strarray.h +6 -10
- 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/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +77 -44
- 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 +21 -8
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +92 -42
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +44 -40
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +28 -15
- data/vendor/libgit2/src/blame_git.c +6 -3
- data/vendor/libgit2/src/blob.c +46 -24
- data/vendor/libgit2/src/branch.c +87 -37
- data/vendor/libgit2/src/buffer.c +339 -27
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +3 -24
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +97 -98
- data/vendor/libgit2/src/cherrypick.c +8 -2
- data/vendor/libgit2/src/clone.c +104 -29
- 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 +26 -2
- data/vendor/libgit2/src/config.c +40 -22
- data/vendor/libgit2/src/config_cache.c +9 -4
- data/vendor/libgit2/src/config_entries.c +35 -27
- data/vendor/libgit2/src/config_file.c +25 -8
- data/vendor/libgit2/src/config_parse.c +5 -7
- data/vendor/libgit2/src/config_snapshot.c +2 -1
- 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 +11 -4
- data/vendor/libgit2/src/diff.c +23 -19
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +5 -7
- data/vendor/libgit2/src/diff_generate.c +56 -28
- data/vendor/libgit2/src/diff_parse.c +2 -3
- data/vendor/libgit2/src/diff_print.c +81 -65
- data/vendor/libgit2/src/diff_stats.c +19 -16
- data/vendor/libgit2/src/diff_tform.c +13 -13
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +26 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +7 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +209 -113
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +8 -8
- data/vendor/libgit2/src/futils.h +4 -4
- 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/idxmap.c +0 -22
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +126 -84
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +60 -36
- data/vendor/libgit2/src/integer.h +79 -2
- data/vendor/libgit2/src/iterator.c +40 -28
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +125 -49
- 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 +108 -46
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +15 -9
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +879 -0
- data/vendor/libgit2/src/midx.h +110 -0
- data/vendor/libgit2/src/mwindow.c +214 -95
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +133 -4
- 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 +24 -15
- data/vendor/libgit2/src/odb.c +298 -57
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +31 -21
- data/vendor/libgit2/src/odb_mempack.c +3 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +7 -4
- data/vendor/libgit2/src/pack-objects.c +83 -69
- data/vendor/libgit2/src/pack.c +383 -150
- data/vendor/libgit2/src/pack.h +44 -9
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +3 -5
- data/vendor/libgit2/src/patch_parse.c +6 -3
- data/vendor/libgit2/src/path.c +102 -57
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +12 -11
- data/vendor/libgit2/src/pool.c +34 -22
- data/vendor/libgit2/src/pool.h +9 -1
- data/vendor/libgit2/src/posix.c +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- data/vendor/libgit2/src/proxy.c +2 -0
- data/vendor/libgit2/src/push.c +2 -0
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +95 -49
- data/vendor/libgit2/src/refdb.c +165 -13
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +144 -152
- data/vendor/libgit2/src/reflog.c +21 -20
- data/vendor/libgit2/src/refs.c +151 -231
- data/vendor/libgit2/src/refs.h +2 -20
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/regexp.c +2 -2
- data/vendor/libgit2/src/remote.c +312 -121
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +351 -189
- data/vendor/libgit2/src/repository.h +23 -29
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +8 -2
- data/vendor/libgit2/src/revparse.c +19 -13
- data/vendor/libgit2/src/revwalk.c +35 -20
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.c +2 -3
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +7 -3
- data/vendor/libgit2/src/status.c +9 -4
- data/vendor/libgit2/src/strarray.c +64 -0
- 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 +113 -207
- 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 +10 -9
- 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 +134 -66
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +8 -26
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +49 -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 +21 -9
- 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 +17 -7
- data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
- 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 +84 -42
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +5 -5
- data/vendor/libgit2/src/transports/smart.c +14 -9
- 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 +156 -88
- 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/posix.h +16 -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 +74 -183
- 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/git2.rc +18 -3
- 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 +23 -25
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +77 -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 +37 -15
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +56 -38
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- 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 -361
- 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 -246
- 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)
|
|
@@ -123,10 +121,12 @@ int git_indexer_options_init(git_indexer_options *opts, unsigned int version)
|
|
|
123
121
|
return 0;
|
|
124
122
|
}
|
|
125
123
|
|
|
124
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
126
125
|
int git_indexer_init_options(git_indexer_options *opts, unsigned int version)
|
|
127
126
|
{
|
|
128
127
|
return git_indexer_options_init(opts, version);
|
|
129
128
|
}
|
|
129
|
+
#endif
|
|
130
130
|
|
|
131
131
|
int git_indexer_new(
|
|
132
132
|
git_indexer **out,
|
|
@@ -237,7 +237,8 @@ static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream)
|
|
|
237
237
|
{
|
|
238
238
|
ssize_t read;
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
GIT_ASSERT_ARG(idx);
|
|
241
|
+
GIT_ASSERT_ARG(stream);
|
|
241
242
|
|
|
242
243
|
do {
|
|
243
244
|
if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0)
|
|
@@ -260,15 +261,16 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
|
|
|
260
261
|
{
|
|
261
262
|
git_mwindow *w = NULL;
|
|
262
263
|
|
|
263
|
-
|
|
264
|
+
GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
|
|
264
265
|
|
|
265
266
|
if (type == GIT_OBJECT_REF_DELTA) {
|
|
266
267
|
idx->off += GIT_OID_RAWSZ;
|
|
267
268
|
} else {
|
|
268
|
-
off64_t base_off
|
|
269
|
+
off64_t base_off;
|
|
270
|
+
int error = get_delta_base(&base_off, idx->pack, &w, &idx->off, type, idx->entry_start);
|
|
269
271
|
git_mwindow_close(&w);
|
|
270
|
-
if (
|
|
271
|
-
return
|
|
272
|
+
if (error < 0)
|
|
273
|
+
return error;
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
return 0;
|
|
@@ -279,7 +281,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
|
|
|
279
281
|
{
|
|
280
282
|
ssize_t read;
|
|
281
283
|
|
|
282
|
-
|
|
284
|
+
GIT_ASSERT_ARG(stream);
|
|
283
285
|
|
|
284
286
|
do {
|
|
285
287
|
read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf));
|
|
@@ -424,7 +426,10 @@ static int store_object(git_indexer *idx)
|
|
|
424
426
|
pentry = git__calloc(1, sizeof(struct git_pack_entry));
|
|
425
427
|
GIT_ERROR_CHECK_ALLOC(pentry);
|
|
426
428
|
|
|
427
|
-
git_hash_final(&oid, &idx->hash_ctx)
|
|
429
|
+
if (git_hash_final(&oid, &idx->hash_ctx)) {
|
|
430
|
+
git__free(pentry);
|
|
431
|
+
goto on_error;
|
|
432
|
+
}
|
|
428
433
|
entry_size = idx->off - entry_start;
|
|
429
434
|
if (entry_start > UINT31_MAX) {
|
|
430
435
|
entry->offset = UINT32_MAX;
|
|
@@ -598,6 +603,23 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
|
|
|
598
603
|
|
|
599
604
|
static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
|
|
600
605
|
{
|
|
606
|
+
#ifdef NO_MMAP
|
|
607
|
+
size_t remaining_size = size;
|
|
608
|
+
const char *ptr = (const char *)data;
|
|
609
|
+
|
|
610
|
+
/* Handle data size larger that ssize_t */
|
|
611
|
+
while (remaining_size > 0) {
|
|
612
|
+
ssize_t nb;
|
|
613
|
+
HANDLE_EINTR(nb, p_pwrite(idx->pack->mwf.fd, (void *)ptr,
|
|
614
|
+
remaining_size, offset));
|
|
615
|
+
if (nb <= 0)
|
|
616
|
+
return -1;
|
|
617
|
+
|
|
618
|
+
ptr += nb;
|
|
619
|
+
offset += nb;
|
|
620
|
+
remaining_size -= nb;
|
|
621
|
+
}
|
|
622
|
+
#else
|
|
601
623
|
git_file fd = idx->pack->mwf.fd;
|
|
602
624
|
size_t mmap_alignment;
|
|
603
625
|
size_t page_offset;
|
|
@@ -606,7 +628,8 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
|
|
|
606
628
|
git_map map;
|
|
607
629
|
int error;
|
|
608
630
|
|
|
609
|
-
|
|
631
|
+
GIT_ASSERT_ARG(data);
|
|
632
|
+
GIT_ASSERT_ARG(size);
|
|
610
633
|
|
|
611
634
|
if ((error = git__mmap_alignment(&mmap_alignment)) < 0)
|
|
612
635
|
return error;
|
|
@@ -621,6 +644,7 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
|
|
|
621
644
|
map_data = (unsigned char *)map.data;
|
|
622
645
|
memcpy(map_data + page_offset, data, size);
|
|
623
646
|
p_munmap(&map);
|
|
647
|
+
#endif
|
|
624
648
|
|
|
625
649
|
return 0;
|
|
626
650
|
}
|
|
@@ -632,7 +656,6 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
|
|
|
632
656
|
size_t page_offset;
|
|
633
657
|
off64_t page_start;
|
|
634
658
|
off64_t current_size = idx->pack->mwf.size;
|
|
635
|
-
int fd = idx->pack->mwf.fd;
|
|
636
659
|
int error;
|
|
637
660
|
|
|
638
661
|
if (!size)
|
|
@@ -649,8 +672,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
|
|
|
649
672
|
page_offset = new_size % mmap_alignment;
|
|
650
673
|
page_start = new_size - page_offset;
|
|
651
674
|
|
|
652
|
-
if (
|
|
653
|
-
p_write(idx->pack->mwf.fd, data, 1) < 0) {
|
|
675
|
+
if (p_pwrite(idx->pack->mwf.fd, data, 1, page_start + mmap_alignment - 1) < 0) {
|
|
654
676
|
git_error_set(GIT_ERROR_OS, "cannot extend packfile '%s'", idx->pack->pack_name);
|
|
655
677
|
return -1;
|
|
656
678
|
}
|
|
@@ -671,7 +693,7 @@ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
|
|
|
671
693
|
return GIT_EBUFS;
|
|
672
694
|
|
|
673
695
|
if (!idx->have_stream) {
|
|
674
|
-
error = git_packfile_unpack_header(&entry_size, &type,
|
|
696
|
+
error = git_packfile_unpack_header(&entry_size, &type, idx->pack, &w, &idx->off);
|
|
675
697
|
if (error == GIT_EBUFS) {
|
|
676
698
|
idx->off = entry_start;
|
|
677
699
|
return error;
|
|
@@ -753,7 +775,9 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
|
|
|
753
775
|
struct git_pack_header *hdr = &idx->hdr;
|
|
754
776
|
git_mwindow_file *mwf = &idx->pack->mwf;
|
|
755
777
|
|
|
756
|
-
|
|
778
|
+
GIT_ASSERT_ARG(idx);
|
|
779
|
+
GIT_ASSERT_ARG(data);
|
|
780
|
+
GIT_ASSERT_ARG(stats);
|
|
757
781
|
|
|
758
782
|
if ((error = append_to_pack(idx, data, size)) < 0)
|
|
759
783
|
return error;
|
|
@@ -807,7 +831,8 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
|
|
|
807
831
|
/* Now that we have data in the pack, let's try to parse it */
|
|
808
832
|
|
|
809
833
|
/* As the file grows any windows we try to use will be out of date */
|
|
810
|
-
git_mwindow_free_all(mwf)
|
|
834
|
+
if ((error = git_mwindow_free_all(mwf)) < 0)
|
|
835
|
+
goto on_error;
|
|
811
836
|
|
|
812
837
|
while (stats->indexed_objects < idx->nr_objects) {
|
|
813
838
|
if ((error = read_stream_object(idx, stats)) != 0) {
|
|
@@ -851,16 +876,16 @@ static int index_path(git_buf *path, git_indexer *idx, const char *suffix)
|
|
|
851
876
|
* Rewind the packfile by the trailer, as we might need to fix the
|
|
852
877
|
* packfile by injecting objects at the tail and must overwrite it.
|
|
853
878
|
*/
|
|
854
|
-
static
|
|
879
|
+
static int seek_back_trailer(git_indexer *idx)
|
|
855
880
|
{
|
|
856
881
|
idx->pack->mwf.size -= GIT_OID_RAWSZ;
|
|
857
|
-
git_mwindow_free_all(&idx->pack->mwf);
|
|
882
|
+
return git_mwindow_free_all(&idx->pack->mwf);
|
|
858
883
|
}
|
|
859
884
|
|
|
860
885
|
static int inject_object(git_indexer *idx, git_oid *id)
|
|
861
886
|
{
|
|
862
|
-
git_odb_object *obj;
|
|
863
|
-
struct entry *entry;
|
|
887
|
+
git_odb_object *obj = NULL;
|
|
888
|
+
struct entry *entry = NULL;
|
|
864
889
|
struct git_pack_entry *pentry = NULL;
|
|
865
890
|
git_oid foo = {{0}};
|
|
866
891
|
unsigned char hdr[64];
|
|
@@ -870,12 +895,14 @@ static int inject_object(git_indexer *idx, git_oid *id)
|
|
|
870
895
|
size_t len, hdr_len;
|
|
871
896
|
int error;
|
|
872
897
|
|
|
873
|
-
seek_back_trailer(idx)
|
|
898
|
+
if ((error = seek_back_trailer(idx)) < 0)
|
|
899
|
+
goto cleanup;
|
|
900
|
+
|
|
874
901
|
entry_start = idx->pack->mwf.size;
|
|
875
902
|
|
|
876
|
-
if (git_odb_read(&obj, idx->odb, id) < 0) {
|
|
903
|
+
if ((error = git_odb_read(&obj, idx->odb, id)) < 0) {
|
|
877
904
|
git_error_set(GIT_ERROR_INDEXER, "missing delta bases");
|
|
878
|
-
|
|
905
|
+
goto cleanup;
|
|
879
906
|
}
|
|
880
907
|
|
|
881
908
|
data = git_odb_object_data(obj);
|
|
@@ -887,8 +914,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
|
|
|
887
914
|
entry->crc = crc32(0L, Z_NULL, 0);
|
|
888
915
|
|
|
889
916
|
/* Write out the object header */
|
|
890
|
-
|
|
891
|
-
|
|
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)
|
|
892
919
|
goto cleanup;
|
|
893
920
|
|
|
894
921
|
idx->pack->mwf.size += hdr_len;
|
|
@@ -944,7 +971,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
|
|
|
944
971
|
unsigned int left = 0;
|
|
945
972
|
git_oid base;
|
|
946
973
|
|
|
947
|
-
|
|
974
|
+
GIT_ASSERT(git_vector_length(&idx->deltas) > 0);
|
|
948
975
|
|
|
949
976
|
if (idx->odb == NULL) {
|
|
950
977
|
git_error_set(GIT_ERROR_INDEXER, "cannot fix a thin pack without an ODB");
|
|
@@ -957,7 +984,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
|
|
|
957
984
|
continue;
|
|
958
985
|
|
|
959
986
|
curpos = delta->delta_off;
|
|
960
|
-
error = git_packfile_unpack_header(&size, &type,
|
|
987
|
+
error = git_packfile_unpack_header(&size, &type, idx->pack, &w, &curpos);
|
|
961
988
|
if (error < 0)
|
|
962
989
|
return error;
|
|
963
990
|
|
|
@@ -1075,7 +1102,9 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
|
|
|
1075
1102
|
* hash_partially() keep the existing trailer out of the
|
|
1076
1103
|
* calculation.
|
|
1077
1104
|
*/
|
|
1078
|
-
git_mwindow_free_all(mwf)
|
|
1105
|
+
if (git_mwindow_free_all(mwf) < 0)
|
|
1106
|
+
return -1;
|
|
1107
|
+
|
|
1079
1108
|
idx->inbuf_len = 0;
|
|
1080
1109
|
while (hashed < mwf->size) {
|
|
1081
1110
|
ptr = git_mwindow_open(mwf, &w, hashed, chunk, &left);
|
|
@@ -1247,7 +1276,8 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
|
|
|
1247
1276
|
if (git_filebuf_commit_at(&index_file, filename.ptr) < 0)
|
|
1248
1277
|
goto on_error;
|
|
1249
1278
|
|
|
1250
|
-
git_mwindow_free_all(&idx->pack->mwf)
|
|
1279
|
+
if (git_mwindow_free_all(&idx->pack->mwf) < 0)
|
|
1280
|
+
goto on_error;
|
|
1251
1281
|
|
|
1252
1282
|
/* Truncate file to undo rounding up to next page_size in append_to_pack */
|
|
1253
1283
|
if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
|
|
@@ -1317,13 +1347,7 @@ void git_indexer_free(git_indexer *idx)
|
|
|
1317
1347
|
|
|
1318
1348
|
git_vector_free_deep(&idx->deltas);
|
|
1319
1349
|
|
|
1320
|
-
|
|
1321
|
-
if (!idx->pack_committed)
|
|
1322
|
-
git_packfile_close(idx->pack, true);
|
|
1323
|
-
|
|
1324
|
-
git_packfile_free(idx->pack);
|
|
1325
|
-
git_mutex_unlock(&git__mwindow_mutex);
|
|
1326
|
-
}
|
|
1350
|
+
git_packfile_free(idx->pack, !idx->pack_committed);
|
|
1327
1351
|
|
|
1328
1352
|
iter = 0;
|
|
1329
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 */
|
|
@@ -77,6 +77,15 @@ GIT_INLINE(int) git__is_int(long long p)
|
|
|
77
77
|
# define git__sub_int_overflow(out, one, two) \
|
|
78
78
|
__builtin_ssub_overflow(one, two, out)
|
|
79
79
|
|
|
80
|
+
# define git__add_int64_overflow(out, one, two) \
|
|
81
|
+
__builtin_add_overflow(one, two, out)
|
|
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
|
+
|
|
80
89
|
/* Use Microsoft's safe integer handling functions where available */
|
|
81
90
|
#elif defined(_MSC_VER)
|
|
82
91
|
|
|
@@ -87,11 +96,17 @@ GIT_INLINE(int) git__is_int(long long p)
|
|
|
87
96
|
(SizeTAdd(one, two, out) != S_OK)
|
|
88
97
|
# define git__multiply_sizet_overflow(out, one, two) \
|
|
89
98
|
(SizeTMult(one, two, out) != S_OK)
|
|
99
|
+
|
|
90
100
|
#define git__add_int_overflow(out, one, two) \
|
|
91
101
|
(IntAdd(one, two, out) != S_OK)
|
|
92
102
|
#define git__sub_int_overflow(out, one, two) \
|
|
93
103
|
(IntSub(one, two, out) != S_OK)
|
|
94
104
|
|
|
105
|
+
#define git__add_int64_overflow(out, one, two) \
|
|
106
|
+
(LongLongAdd(one, two, out) != S_OK)
|
|
107
|
+
#define git__multiply_int64_overflow(out, one, two) \
|
|
108
|
+
(LongLongMult(one, two, out) != S_OK)
|
|
109
|
+
|
|
95
110
|
#else
|
|
96
111
|
|
|
97
112
|
/**
|
|
@@ -136,6 +151,68 @@ GIT_INLINE(bool) git__sub_int_overflow(int *out, int one, int two)
|
|
|
136
151
|
return false;
|
|
137
152
|
}
|
|
138
153
|
|
|
154
|
+
GIT_INLINE(bool) git__add_int64_overflow(int64_t *out, int64_t one, int64_t two)
|
|
155
|
+
{
|
|
156
|
+
if ((two > 0 && one > (INT64_MAX - two)) ||
|
|
157
|
+
(two < 0 && one < (INT64_MIN - two)))
|
|
158
|
+
return true;
|
|
159
|
+
*out = one + two;
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#endif
|
|
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
|
+
}
|
|
139
216
|
#endif
|
|
140
217
|
|
|
141
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))
|
|
@@ -897,9 +901,8 @@ static int tree_iterator_init(tree_iterator *iter)
|
|
|
897
901
|
{
|
|
898
902
|
int error;
|
|
899
903
|
|
|
900
|
-
git_pool_init(&iter->entry_pool, sizeof(tree_iterator_entry))
|
|
901
|
-
|
|
902
|
-
if ((error = tree_iterator_frame_init(iter, iter->root, NULL)) < 0)
|
|
904
|
+
if ((error = git_pool_init(&iter->entry_pool, sizeof(tree_iterator_entry))) < 0 ||
|
|
905
|
+
(error = tree_iterator_frame_init(iter, iter->root, NULL)) < 0)
|
|
903
906
|
return error;
|
|
904
907
|
|
|
905
908
|
iter->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS;
|
|
@@ -974,7 +977,7 @@ int git_iterator_current_tree_entry(
|
|
|
974
977
|
tree_iterator_frame *frame;
|
|
975
978
|
tree_iterator_entry *entry;
|
|
976
979
|
|
|
977
|
-
|
|
980
|
+
GIT_ASSERT(i->type == GIT_ITERATOR_TREE);
|
|
978
981
|
|
|
979
982
|
iter = (tree_iterator *)i;
|
|
980
983
|
|
|
@@ -991,11 +994,11 @@ int git_iterator_current_parent_tree(
|
|
|
991
994
|
tree_iterator *iter;
|
|
992
995
|
tree_iterator_frame *frame;
|
|
993
996
|
|
|
994
|
-
|
|
997
|
+
GIT_ASSERT(i->type == GIT_ITERATOR_TREE);
|
|
995
998
|
|
|
996
999
|
iter = (tree_iterator *)i;
|
|
997
1000
|
|
|
998
|
-
|
|
1001
|
+
GIT_ASSERT(depth < iter->frames.size);
|
|
999
1002
|
frame = &iter->frames.ptr[iter->frames.size-depth-1];
|
|
1000
1003
|
|
|
1001
1004
|
*parent_tree = frame->tree;
|
|
@@ -1275,7 +1278,8 @@ static int filesystem_iterator_entry_hash(
|
|
|
1275
1278
|
return git_repository_hashfile(&entry->id,
|
|
1276
1279
|
iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
|
|
1277
1280
|
|
|
1278
|
-
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)))
|
|
1279
1283
|
error = git_odb_hashfile(&entry->id, fullpath.ptr, GIT_OBJECT_BLOB);
|
|
1280
1284
|
|
|
1281
1285
|
git_buf_dispose(&fullpath);
|
|
@@ -1356,7 +1360,8 @@ static int filesystem_iterator_frame_push(
|
|
|
1356
1360
|
else
|
|
1357
1361
|
git_buf_puts(&root, iter->root);
|
|
1358
1362
|
|
|
1359
|
-
if (git_buf_oom(&root)
|
|
1363
|
+
if (git_buf_oom(&root) ||
|
|
1364
|
+
git_path_validate_workdir_buf(iter->base.repo, &root) < 0) {
|
|
1360
1365
|
error = -1;
|
|
1361
1366
|
goto done;
|
|
1362
1367
|
}
|
|
@@ -1376,7 +1381,8 @@ static int filesystem_iterator_frame_push(
|
|
|
1376
1381
|
filesystem_iterator_entry_cmp)) < 0)
|
|
1377
1382
|
goto done;
|
|
1378
1383
|
|
|
1379
|
-
git_pool_init(&new_frame->entry_pool, 1)
|
|
1384
|
+
if ((error = git_pool_init(&new_frame->entry_pool, 1)) < 0)
|
|
1385
|
+
goto done;
|
|
1380
1386
|
|
|
1381
1387
|
/* check if this directory is ignored */
|
|
1382
1388
|
filesystem_iterator_frame_push_ignores(iter, frame_entry, new_frame);
|
|
@@ -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)
|