rugged 1.1.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/extconf.rb +2 -2
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_config.c +7 -2
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_remote.c +17 -0
- 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 +103 -271
- data/vendor/libgit2/COPYING +149 -24
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
- data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
- data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
- 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 +154 -122
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
- 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/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +106 -2
- data/vendor/libgit2/include/git2/blame.h +97 -43
- data/vendor/libgit2/include/git2/blob.h +33 -2
- data/vendor/libgit2/include/git2/branch.h +27 -0
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +43 -6
- data/vendor/libgit2/include/git2/checkout.h +32 -13
- data/vendor/libgit2/include/git2/clone.h +4 -4
- data/vendor/libgit2/include/git2/commit.h +37 -19
- data/vendor/libgit2/include/git2/common.h +46 -5
- data/vendor/libgit2/include/git2/config.h +19 -3
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +326 -6
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +50 -121
- data/vendor/libgit2/include/git2/email.h +127 -0
- data/vendor/libgit2/include/git2/errors.h +7 -6
- data/vendor/libgit2/include/git2/filter.h +69 -18
- data/vendor/libgit2/include/git2/graph.h +21 -2
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +13 -7
- data/vendor/libgit2/include/git2/indexer.h +19 -0
- data/vendor/libgit2/include/git2/merge.h +23 -3
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/notes.h +2 -2
- data/vendor/libgit2/include/git2/object.h +23 -0
- data/vendor/libgit2/include/git2/odb.h +65 -6
- data/vendor/libgit2/include/git2/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/oidarray.h +5 -8
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +16 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +34 -2
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +8 -4
- data/vendor/libgit2/include/git2/remote.h +246 -46
- data/vendor/libgit2/include/git2/repository.h +25 -18
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +4 -4
- data/vendor/libgit2/include/git2/status.h +124 -62
- data/vendor/libgit2/include/git2/stdint.h +3 -3
- data/vendor/libgit2/include/git2/submodule.h +16 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/email.h +45 -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 +9 -5
- data/vendor/libgit2/include/git2/sys/remote.h +31 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +26 -34
- data/vendor/libgit2/include/git2/tag.h +13 -0
- data/vendor/libgit2/include/git2/tree.h +4 -17
- data/vendor/libgit2/include/git2/types.h +16 -7
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +13 -2
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +192 -290
- 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/annotated_commit.h +1 -1
- data/vendor/libgit2/src/apply.c +34 -25
- data/vendor/libgit2/src/apply.h +2 -2
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +204 -82
- data/vendor/libgit2/src/attr_file.c +105 -52
- data/vendor/libgit2/src/attr_file.h +36 -15
- data/vendor/libgit2/src/attrcache.c +55 -45
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +15 -9
- data/vendor/libgit2/src/blame_git.c +2 -2
- data/vendor/libgit2/src/blob.c +76 -52
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +203 -110
- data/vendor/libgit2/src/branch.h +15 -3
- data/vendor/libgit2/src/buf.c +126 -0
- data/vendor/libgit2/src/buf.h +50 -0
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +11 -9
- data/vendor/libgit2/src/checkout.c +118 -91
- data/vendor/libgit2/src/cherrypick.c +16 -12
- data/vendor/libgit2/src/clone.c +97 -103
- data/vendor/libgit2/src/commit.c +167 -84
- data/vendor/libgit2/src/commit.h +24 -1
- data/vendor/libgit2/src/commit_graph.c +1224 -0
- data/vendor/libgit2/src/commit_graph.h +169 -0
- data/vendor/libgit2/src/commit_list.c +48 -3
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +35 -5
- data/vendor/libgit2/src/config.c +119 -64
- data/vendor/libgit2/src/config.h +15 -2
- data/vendor/libgit2/src/config_cache.c +5 -3
- data/vendor/libgit2/src/config_file.c +120 -100
- data/vendor/libgit2/src/config_mem.c +9 -9
- data/vendor/libgit2/src/config_parse.c +29 -27
- data/vendor/libgit2/src/crlf.c +36 -23
- data/vendor/libgit2/src/date.c +13 -19
- data/vendor/libgit2/src/date.h +33 -0
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +32 -21
- data/vendor/libgit2/src/diff.c +71 -183
- data/vendor/libgit2/src/diff.h +2 -4
- data/vendor/libgit2/src/diff_driver.c +53 -51
- data/vendor/libgit2/src/diff_driver.h +3 -3
- data/vendor/libgit2/src/diff_file.c +31 -26
- data/vendor/libgit2/src/diff_generate.c +76 -23
- data/vendor/libgit2/src/diff_generate.h +5 -3
- data/vendor/libgit2/src/diff_print.c +120 -95
- data/vendor/libgit2/src/diff_stats.c +47 -34
- data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
- data/vendor/libgit2/src/diff_tform.c +18 -16
- data/vendor/libgit2/src/diff_xdiff.c +7 -10
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/email.c +315 -0
- data/vendor/libgit2/src/email.h +25 -0
- data/vendor/libgit2/src/errors.c +37 -32
- data/vendor/libgit2/src/features.h.in +11 -2
- data/vendor/libgit2/src/fetch.c +77 -26
- data/vendor/libgit2/src/fetch.h +1 -1
- data/vendor/libgit2/src/fetchhead.c +27 -23
- data/vendor/libgit2/src/filebuf.c +36 -34
- data/vendor/libgit2/src/filebuf.h +1 -1
- data/vendor/libgit2/src/filter.c +278 -132
- data/vendor/libgit2/src/filter.h +46 -6
- data/vendor/libgit2/src/fs_path.c +2071 -0
- data/vendor/libgit2/src/fs_path.h +772 -0
- data/vendor/libgit2/src/futils.c +96 -90
- data/vendor/libgit2/src/futils.h +27 -15
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
- data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
- data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
- data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
- data/vendor/libgit2/src/hash/sha1.h +3 -1
- data/vendor/libgit2/src/hash.c +71 -36
- data/vendor/libgit2/src/hash.h +13 -13
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +30 -20
- data/vendor/libgit2/src/ignore.c +63 -46
- data/vendor/libgit2/src/ignore.h +2 -2
- data/vendor/libgit2/src/index.c +184 -149
- data/vendor/libgit2/src/index.h +7 -4
- data/vendor/libgit2/src/indexer.c +143 -89
- data/vendor/libgit2/src/integer.h +64 -2
- data/vendor/libgit2/src/iterator.c +93 -73
- data/vendor/libgit2/src/iterator.h +6 -6
- data/vendor/libgit2/src/khash.h +3 -12
- data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +60 -45
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +104 -61
- data/vendor/libgit2/src/merge.h +3 -15
- data/vendor/libgit2/src/merge_driver.c +21 -15
- data/vendor/libgit2/src/merge_file.c +24 -6
- data/vendor/libgit2/src/message.c +21 -8
- data/vendor/libgit2/src/midx.c +501 -18
- data/vendor/libgit2/src/midx.h +29 -2
- data/vendor/libgit2/src/mwindow.c +103 -59
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +405 -71
- data/vendor/libgit2/src/net.h +26 -5
- data/vendor/libgit2/src/netops.c +7 -5
- data/vendor/libgit2/src/netops.h +3 -3
- data/vendor/libgit2/src/notes.c +40 -49
- data/vendor/libgit2/src/object.c +68 -20
- data/vendor/libgit2/src/object.h +1 -1
- data/vendor/libgit2/src/odb.c +320 -80
- data/vendor/libgit2/src/odb.h +17 -3
- data/vendor/libgit2/src/odb_loose.c +96 -86
- data/vendor/libgit2/src/odb_mempack.c +19 -6
- data/vendor/libgit2/src/odb_pack.c +402 -125
- data/vendor/libgit2/src/oid.c +16 -8
- data/vendor/libgit2/src/oid.h +15 -0
- data/vendor/libgit2/src/oidarray.c +10 -1
- data/vendor/libgit2/src/pack-objects.c +90 -69
- data/vendor/libgit2/src/pack-objects.h +11 -6
- data/vendor/libgit2/src/pack.c +337 -127
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +17 -10
- data/vendor/libgit2/src/patch.h +1 -0
- data/vendor/libgit2/src/patch_generate.c +29 -13
- data/vendor/libgit2/src/patch_generate.h +5 -5
- data/vendor/libgit2/src/patch_parse.c +26 -25
- data/vendor/libgit2/src/path.c +86 -1768
- data/vendor/libgit2/src/path.h +39 -635
- data/vendor/libgit2/src/pathspec.c +12 -12
- data/vendor/libgit2/src/pathspec.h +2 -2
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +14 -6
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/pqueue.h +1 -1
- data/vendor/libgit2/src/proxy.c +4 -1
- data/vendor/libgit2/src/proxy.h +1 -1
- data/vendor/libgit2/src/push.c +30 -35
- data/vendor/libgit2/src/push.h +4 -16
- data/vendor/libgit2/src/rand.c +226 -0
- data/vendor/libgit2/src/rand.h +37 -0
- data/vendor/libgit2/src/reader.c +18 -14
- data/vendor/libgit2/src/reader.h +2 -2
- data/vendor/libgit2/src/rebase.c +177 -132
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +548 -222
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +107 -72
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +53 -38
- data/vendor/libgit2/src/refspec.h +5 -2
- data/vendor/libgit2/src/regexp.c +1 -1
- data/vendor/libgit2/src/remote.c +960 -486
- data/vendor/libgit2/src/remote.h +16 -10
- data/vendor/libgit2/src/repository.c +702 -422
- data/vendor/libgit2/src/repository.h +26 -8
- data/vendor/libgit2/src/reset.c +16 -12
- data/vendor/libgit2/src/revert.c +16 -12
- data/vendor/libgit2/src/revparse.c +66 -48
- data/vendor/libgit2/src/revwalk.c +39 -22
- 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 +18 -11
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +1 -1
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +39 -38
- data/vendor/libgit2/src/status.c +11 -5
- data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
- data/vendor/libgit2/src/str.h +357 -0
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +22 -23
- 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 +290 -212
- data/vendor/libgit2/src/submodule.h +10 -10
- data/vendor/libgit2/src/sysdir.c +70 -56
- data/vendor/libgit2/src/sysdir.h +15 -10
- data/vendor/libgit2/src/tag.c +72 -34
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +84 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +3 -16
- data/vendor/libgit2/src/trace.h +17 -30
- data/vendor/libgit2/src/trailer.c +2 -2
- data/vendor/libgit2/src/transaction.c +20 -9
- data/vendor/libgit2/src/transport.c +13 -13
- data/vendor/libgit2/src/transports/auth.c +8 -10
- data/vendor/libgit2/src/transports/auth.h +2 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
- data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +10 -14
- data/vendor/libgit2/src/transports/http.c +56 -34
- data/vendor/libgit2/src/transports/http.h +3 -3
- data/vendor/libgit2/src/transports/httpclient.c +106 -79
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +127 -119
- data/vendor/libgit2/src/transports/smart.c +61 -144
- data/vendor/libgit2/src/transports/smart.h +26 -32
- data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
- data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
- data/vendor/libgit2/src/transports/ssh.c +100 -131
- data/vendor/libgit2/src/transports/winhttp.c +86 -82
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree-cache.h +2 -2
- data/vendor/libgit2/src/tree.c +150 -116
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -3
- data/vendor/libgit2/src/unix/posix.h +1 -4
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/unix/realpath.c +0 -2
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +68 -144
- data/vendor/libgit2/src/util.h +36 -68
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +5 -3
- data/vendor/libgit2/src/win32/findfile.c +172 -114
- data/vendor/libgit2/src/win32/findfile.h +7 -4
- 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 +162 -33
- data/vendor/libgit2/src/win32/path_w32.h +2 -1
- data/vendor/libgit2/src/win32/posix.h +6 -7
- data/vendor/libgit2/src/win32/posix_w32.c +26 -33
- 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 +5 -6
- data/vendor/libgit2/src/win32/w32_buffer.h +2 -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 +138 -105
- data/vendor/libgit2/src/worktree.h +1 -1
- data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
- data/vendor/libgit2/src/xdiff/xemit.c +23 -7
- data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
- data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
- data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
- data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
- data/vendor/libgit2/src/xdiff/xutils.c +18 -7
- data/vendor/libgit2/src/zstream.c +6 -6
- data/vendor/libgit2/src/zstream.h +4 -4
- metadata +60 -24
- 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/buffer.h +0 -222
- 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/midx.c
CHANGED
@@ -7,13 +7,16 @@
|
|
7
7
|
|
8
8
|
#include "midx.h"
|
9
9
|
|
10
|
-
#include "
|
10
|
+
#include "array.h"
|
11
|
+
#include "buf.h"
|
12
|
+
#include "filebuf.h"
|
11
13
|
#include "futils.h"
|
12
14
|
#include "hash.h"
|
13
15
|
#include "odb.h"
|
14
16
|
#include "pack.h"
|
15
|
-
|
16
|
-
#
|
17
|
+
#include "fs_path.h"
|
18
|
+
#include "repository.h"
|
19
|
+
#include "str.h"
|
17
20
|
|
18
21
|
#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
|
19
22
|
#define MIDX_VERSION 1
|
@@ -38,6 +41,8 @@ struct git_midx_chunk {
|
|
38
41
|
size_t length;
|
39
42
|
};
|
40
43
|
|
44
|
+
typedef int (*midx_write_cb)(const char *buf, size_t size, void *cb_data);
|
45
|
+
|
41
46
|
static int midx_error(const char *message)
|
42
47
|
{
|
43
48
|
git_error_set(GIT_ERROR_ODB, "invalid multi-pack-index file - %s", message);
|
@@ -116,7 +121,7 @@ static int midx_parse_oid_lookup(
|
|
116
121
|
return midx_error("missing OID Lookup chunk");
|
117
122
|
if (chunk_oid_lookup->length == 0)
|
118
123
|
return midx_error("empty OID Lookup chunk");
|
119
|
-
if (chunk_oid_lookup->length != idx->num_objects *
|
124
|
+
if (chunk_oid_lookup->length != idx->num_objects * GIT_OID_RAWSZ)
|
120
125
|
return midx_error("OID Lookup chunk has wrong length");
|
121
126
|
|
122
127
|
idx->oid_lookup = oid = (git_oid *)(data + chunk_oid_lookup->offset);
|
@@ -173,7 +178,8 @@ int git_midx_parse(
|
|
173
178
|
struct git_midx_chunk *last_chunk;
|
174
179
|
uint32_t i;
|
175
180
|
off64_t last_chunk_offset, chunk_offset, trailer_offset;
|
176
|
-
|
181
|
+
size_t checksum_size;
|
182
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
177
183
|
int error;
|
178
184
|
struct git_midx_chunk chunk_packfile_names = {0},
|
179
185
|
chunk_oid_fanout = {0},
|
@@ -181,9 +187,9 @@ int git_midx_parse(
|
|
181
187
|
chunk_object_offsets = {0},
|
182
188
|
chunk_object_large_offsets = {0};
|
183
189
|
|
184
|
-
|
190
|
+
GIT_ASSERT_ARG(idx);
|
185
191
|
|
186
|
-
if (size < sizeof(struct git_midx_header) +
|
192
|
+
if (size < sizeof(struct git_midx_header) + GIT_OID_RAWSZ)
|
187
193
|
return midx_error("multi-pack index is too short");
|
188
194
|
|
189
195
|
hdr = ((struct git_midx_header *)data);
|
@@ -203,21 +209,29 @@ int git_midx_parse(
|
|
203
209
|
last_chunk_offset =
|
204
210
|
sizeof(struct git_midx_header) +
|
205
211
|
(1 + hdr->chunks) * 12;
|
206
|
-
|
212
|
+
|
213
|
+
checksum_size = GIT_HASH_SHA1_SIZE;
|
214
|
+
trailer_offset = size - checksum_size;
|
215
|
+
|
207
216
|
if (trailer_offset < last_chunk_offset)
|
208
217
|
return midx_error("wrong index size");
|
209
|
-
|
218
|
+
memcpy(idx->checksum, data + trailer_offset, checksum_size);
|
210
219
|
|
211
|
-
if (git_hash_buf(
|
220
|
+
if (git_hash_buf(checksum, data, (size_t)trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
|
212
221
|
return midx_error("could not calculate signature");
|
213
|
-
if (
|
222
|
+
if (memcmp(checksum, idx->checksum, checksum_size) != 0)
|
214
223
|
return midx_error("index signature mismatch");
|
215
224
|
|
216
225
|
chunk_hdr = data + sizeof(struct git_midx_header);
|
217
226
|
last_chunk = NULL;
|
218
227
|
for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
|
219
|
-
|
220
|
-
|
228
|
+
uint32_t chunk_id = ntohl(*((uint32_t *)(chunk_hdr + 0)));
|
229
|
+
uint64_t high_offset = ((uint64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) & 0xffffffffu;
|
230
|
+
uint64_t low_offset = ((uint64_t)ntohl(*((uint32_t *)(chunk_hdr + 8)))) & 0xffffffffu;
|
231
|
+
|
232
|
+
if (high_offset >= INT32_MAX)
|
233
|
+
return midx_error("chunk offset out of range");
|
234
|
+
chunk_offset = (off64_t)(high_offset << 32 | low_offset);
|
221
235
|
if (chunk_offset < last_chunk_offset)
|
222
236
|
return midx_error("chunks are non-monotonic");
|
223
237
|
if (chunk_offset >= trailer_offset)
|
@@ -226,7 +240,7 @@ int git_midx_parse(
|
|
226
240
|
last_chunk->length = (size_t)(chunk_offset - last_chunk_offset);
|
227
241
|
last_chunk_offset = chunk_offset;
|
228
242
|
|
229
|
-
switch (
|
243
|
+
switch (chunk_id) {
|
230
244
|
case MIDX_PACKFILE_NAMES_ID:
|
231
245
|
chunk_packfile_names.offset = last_chunk_offset;
|
232
246
|
last_chunk = &chunk_packfile_names;
|
@@ -309,6 +323,10 @@ int git_midx_open(
|
|
309
323
|
idx = git__calloc(1, sizeof(git_midx_file));
|
310
324
|
GIT_ERROR_CHECK_ALLOC(idx);
|
311
325
|
|
326
|
+
error = git_str_sets(&idx->filename, path);
|
327
|
+
if (error < 0)
|
328
|
+
return error;
|
329
|
+
|
312
330
|
error = git_futils_mmap_ro(&idx->index_map, fd, 0, idx_size);
|
313
331
|
p_close(fd);
|
314
332
|
if (error < 0) {
|
@@ -325,6 +343,43 @@ int git_midx_open(
|
|
325
343
|
return 0;
|
326
344
|
}
|
327
345
|
|
346
|
+
bool git_midx_needs_refresh(
|
347
|
+
const git_midx_file *idx,
|
348
|
+
const char *path)
|
349
|
+
{
|
350
|
+
git_file fd = -1;
|
351
|
+
struct stat st;
|
352
|
+
ssize_t bytes_read;
|
353
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
354
|
+
size_t checksum_size;
|
355
|
+
|
356
|
+
/* TODO: properly open the file without access time using O_NOATIME */
|
357
|
+
fd = git_futils_open_ro(path);
|
358
|
+
if (fd < 0)
|
359
|
+
return true;
|
360
|
+
|
361
|
+
if (p_fstat(fd, &st) < 0) {
|
362
|
+
p_close(fd);
|
363
|
+
return true;
|
364
|
+
}
|
365
|
+
|
366
|
+
if (!S_ISREG(st.st_mode) ||
|
367
|
+
!git__is_sizet(st.st_size) ||
|
368
|
+
(size_t)st.st_size != idx->index_map.len) {
|
369
|
+
p_close(fd);
|
370
|
+
return true;
|
371
|
+
}
|
372
|
+
|
373
|
+
checksum_size = GIT_HASH_SHA1_SIZE;
|
374
|
+
bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - GIT_OID_RAWSZ);
|
375
|
+
p_close(fd);
|
376
|
+
|
377
|
+
if (bytes_read != (ssize_t)checksum_size)
|
378
|
+
return true;
|
379
|
+
|
380
|
+
return (memcmp(checksum, idx->checksum, checksum_size) != 0);
|
381
|
+
}
|
382
|
+
|
328
383
|
int git_midx_entry_find(
|
329
384
|
git_midx_entry *e,
|
330
385
|
git_midx_file *idx,
|
@@ -338,12 +393,12 @@ int git_midx_entry_find(
|
|
338
393
|
const unsigned char *object_offset;
|
339
394
|
off64_t offset;
|
340
395
|
|
341
|
-
|
396
|
+
GIT_ASSERT_ARG(idx);
|
342
397
|
|
343
398
|
hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]);
|
344
399
|
lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
|
345
400
|
|
346
|
-
pos = git_pack__lookup_sha1(idx->oid_lookup,
|
401
|
+
pos = git_pack__lookup_sha1(idx->oid_lookup, GIT_OID_RAWSZ, lo, hi, short_oid->id);
|
347
402
|
|
348
403
|
if (pos >= 0) {
|
349
404
|
/* An object matching exactly the oid was found */
|
@@ -399,13 +454,34 @@ int git_midx_entry_find(
|
|
399
454
|
return 0;
|
400
455
|
}
|
401
456
|
|
402
|
-
|
457
|
+
int git_midx_foreach_entry(
|
458
|
+
git_midx_file *idx,
|
459
|
+
git_odb_foreach_cb cb,
|
460
|
+
void *data)
|
403
461
|
{
|
404
|
-
|
462
|
+
size_t i;
|
463
|
+
int error;
|
464
|
+
|
465
|
+
GIT_ASSERT_ARG(idx);
|
466
|
+
|
467
|
+
for (i = 0; i < idx->num_objects; ++i) {
|
468
|
+
if ((error = cb(&idx->oid_lookup[i], data)) != 0)
|
469
|
+
return git_error_set_after_callback(error);
|
470
|
+
}
|
471
|
+
|
472
|
+
return error;
|
473
|
+
}
|
474
|
+
|
475
|
+
int git_midx_close(git_midx_file *idx)
|
476
|
+
{
|
477
|
+
GIT_ASSERT_ARG(idx);
|
405
478
|
|
406
479
|
if (idx->index_map.data)
|
407
480
|
git_futils_mmap_free(&idx->index_map);
|
481
|
+
|
408
482
|
git_vector_free(&idx->packfile_names);
|
483
|
+
|
484
|
+
return 0;
|
409
485
|
}
|
410
486
|
|
411
487
|
void git_midx_free(git_midx_file *idx)
|
@@ -413,6 +489,413 @@ void git_midx_free(git_midx_file *idx)
|
|
413
489
|
if (!idx)
|
414
490
|
return;
|
415
491
|
|
492
|
+
git_str_dispose(&idx->filename);
|
416
493
|
git_midx_close(idx);
|
417
494
|
git__free(idx);
|
418
495
|
}
|
496
|
+
|
497
|
+
static int packfile__cmp(const void *a_, const void *b_)
|
498
|
+
{
|
499
|
+
const struct git_pack_file *a = a_;
|
500
|
+
const struct git_pack_file *b = b_;
|
501
|
+
|
502
|
+
return strcmp(a->pack_name, b->pack_name);
|
503
|
+
}
|
504
|
+
|
505
|
+
int git_midx_writer_new(
|
506
|
+
git_midx_writer **out,
|
507
|
+
const char *pack_dir)
|
508
|
+
{
|
509
|
+
git_midx_writer *w = git__calloc(1, sizeof(git_midx_writer));
|
510
|
+
GIT_ERROR_CHECK_ALLOC(w);
|
511
|
+
|
512
|
+
if (git_str_sets(&w->pack_dir, pack_dir) < 0) {
|
513
|
+
git__free(w);
|
514
|
+
return -1;
|
515
|
+
}
|
516
|
+
git_fs_path_squash_slashes(&w->pack_dir);
|
517
|
+
|
518
|
+
if (git_vector_init(&w->packs, 0, packfile__cmp) < 0) {
|
519
|
+
git_str_dispose(&w->pack_dir);
|
520
|
+
git__free(w);
|
521
|
+
return -1;
|
522
|
+
}
|
523
|
+
|
524
|
+
*out = w;
|
525
|
+
return 0;
|
526
|
+
}
|
527
|
+
|
528
|
+
void git_midx_writer_free(git_midx_writer *w)
|
529
|
+
{
|
530
|
+
struct git_pack_file *p;
|
531
|
+
size_t i;
|
532
|
+
|
533
|
+
if (!w)
|
534
|
+
return;
|
535
|
+
|
536
|
+
git_vector_foreach (&w->packs, i, p)
|
537
|
+
git_mwindow_put_pack(p);
|
538
|
+
git_vector_free(&w->packs);
|
539
|
+
git_str_dispose(&w->pack_dir);
|
540
|
+
git__free(w);
|
541
|
+
}
|
542
|
+
|
543
|
+
int git_midx_writer_add(
|
544
|
+
git_midx_writer *w,
|
545
|
+
const char *idx_path)
|
546
|
+
{
|
547
|
+
git_str idx_path_buf = GIT_STR_INIT;
|
548
|
+
int error;
|
549
|
+
struct git_pack_file *p;
|
550
|
+
|
551
|
+
error = git_fs_path_prettify(&idx_path_buf, idx_path, git_str_cstr(&w->pack_dir));
|
552
|
+
if (error < 0)
|
553
|
+
return error;
|
554
|
+
|
555
|
+
error = git_mwindow_get_pack(&p, git_str_cstr(&idx_path_buf));
|
556
|
+
git_str_dispose(&idx_path_buf);
|
557
|
+
if (error < 0)
|
558
|
+
return error;
|
559
|
+
|
560
|
+
error = git_vector_insert(&w->packs, p);
|
561
|
+
if (error < 0) {
|
562
|
+
git_mwindow_put_pack(p);
|
563
|
+
return error;
|
564
|
+
}
|
565
|
+
|
566
|
+
return 0;
|
567
|
+
}
|
568
|
+
|
569
|
+
typedef git_array_t(git_midx_entry) object_entry_array_t;
|
570
|
+
|
571
|
+
struct object_entry_cb_state {
|
572
|
+
uint32_t pack_index;
|
573
|
+
object_entry_array_t *object_entries_array;
|
574
|
+
};
|
575
|
+
|
576
|
+
static int object_entry__cb(const git_oid *oid, off64_t offset, void *data)
|
577
|
+
{
|
578
|
+
struct object_entry_cb_state *state = (struct object_entry_cb_state *)data;
|
579
|
+
|
580
|
+
git_midx_entry *entry = git_array_alloc(*state->object_entries_array);
|
581
|
+
GIT_ERROR_CHECK_ALLOC(entry);
|
582
|
+
|
583
|
+
git_oid_cpy(&entry->sha1, oid);
|
584
|
+
entry->offset = offset;
|
585
|
+
entry->pack_index = state->pack_index;
|
586
|
+
|
587
|
+
return 0;
|
588
|
+
}
|
589
|
+
|
590
|
+
static int object_entry__cmp(const void *a_, const void *b_)
|
591
|
+
{
|
592
|
+
const git_midx_entry *a = (const git_midx_entry *)a_;
|
593
|
+
const git_midx_entry *b = (const git_midx_entry *)b_;
|
594
|
+
|
595
|
+
return git_oid_cmp(&a->sha1, &b->sha1);
|
596
|
+
}
|
597
|
+
|
598
|
+
static int write_offset(off64_t offset, midx_write_cb write_cb, void *cb_data)
|
599
|
+
{
|
600
|
+
int error;
|
601
|
+
uint32_t word;
|
602
|
+
|
603
|
+
word = htonl((uint32_t)((offset >> 32) & 0xffffffffu));
|
604
|
+
error = write_cb((const char *)&word, sizeof(word), cb_data);
|
605
|
+
if (error < 0)
|
606
|
+
return error;
|
607
|
+
word = htonl((uint32_t)((offset >> 0) & 0xffffffffu));
|
608
|
+
error = write_cb((const char *)&word, sizeof(word), cb_data);
|
609
|
+
if (error < 0)
|
610
|
+
return error;
|
611
|
+
|
612
|
+
return 0;
|
613
|
+
}
|
614
|
+
|
615
|
+
static int write_chunk_header(int chunk_id, off64_t offset, midx_write_cb write_cb, void *cb_data)
|
616
|
+
{
|
617
|
+
uint32_t word = htonl(chunk_id);
|
618
|
+
int error = write_cb((const char *)&word, sizeof(word), cb_data);
|
619
|
+
if (error < 0)
|
620
|
+
return error;
|
621
|
+
return write_offset(offset, write_cb, cb_data);
|
622
|
+
|
623
|
+
return 0;
|
624
|
+
}
|
625
|
+
|
626
|
+
static int midx_write_buf(const char *buf, size_t size, void *data)
|
627
|
+
{
|
628
|
+
git_str *b = (git_str *)data;
|
629
|
+
return git_str_put(b, buf, size);
|
630
|
+
}
|
631
|
+
|
632
|
+
struct midx_write_hash_context {
|
633
|
+
midx_write_cb write_cb;
|
634
|
+
void *cb_data;
|
635
|
+
git_hash_ctx *ctx;
|
636
|
+
};
|
637
|
+
|
638
|
+
static int midx_write_hash(const char *buf, size_t size, void *data)
|
639
|
+
{
|
640
|
+
struct midx_write_hash_context *ctx = (struct midx_write_hash_context *)data;
|
641
|
+
int error;
|
642
|
+
|
643
|
+
error = git_hash_update(ctx->ctx, buf, size);
|
644
|
+
if (error < 0)
|
645
|
+
return error;
|
646
|
+
|
647
|
+
return ctx->write_cb(buf, size, ctx->cb_data);
|
648
|
+
}
|
649
|
+
|
650
|
+
static int midx_write(
|
651
|
+
git_midx_writer *w,
|
652
|
+
midx_write_cb write_cb,
|
653
|
+
void *cb_data)
|
654
|
+
{
|
655
|
+
int error = 0;
|
656
|
+
size_t i;
|
657
|
+
struct git_pack_file *p;
|
658
|
+
struct git_midx_header hdr = {0};
|
659
|
+
uint32_t oid_fanout_count;
|
660
|
+
uint32_t object_large_offsets_count;
|
661
|
+
uint32_t oid_fanout[256];
|
662
|
+
off64_t offset;
|
663
|
+
git_str packfile_names = GIT_STR_INIT,
|
664
|
+
oid_lookup = GIT_STR_INIT,
|
665
|
+
object_offsets = GIT_STR_INIT,
|
666
|
+
object_large_offsets = GIT_STR_INIT;
|
667
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
668
|
+
size_t checksum_size;
|
669
|
+
git_midx_entry *entry;
|
670
|
+
object_entry_array_t object_entries_array = GIT_ARRAY_INIT;
|
671
|
+
git_vector object_entries = GIT_VECTOR_INIT;
|
672
|
+
git_hash_ctx ctx;
|
673
|
+
struct midx_write_hash_context hash_cb_data = {0};
|
674
|
+
|
675
|
+
hdr.signature = htonl(MIDX_SIGNATURE);
|
676
|
+
hdr.version = MIDX_VERSION;
|
677
|
+
hdr.object_id_version = MIDX_OBJECT_ID_VERSION;
|
678
|
+
hdr.base_midx_files = 0;
|
679
|
+
|
680
|
+
hash_cb_data.write_cb = write_cb;
|
681
|
+
hash_cb_data.cb_data = cb_data;
|
682
|
+
hash_cb_data.ctx = &ctx;
|
683
|
+
|
684
|
+
checksum_size = GIT_HASH_SHA1_SIZE;
|
685
|
+
error = git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1);
|
686
|
+
if (error < 0)
|
687
|
+
return error;
|
688
|
+
cb_data = &hash_cb_data;
|
689
|
+
write_cb = midx_write_hash;
|
690
|
+
|
691
|
+
git_vector_sort(&w->packs);
|
692
|
+
git_vector_foreach (&w->packs, i, p) {
|
693
|
+
git_str relative_index = GIT_STR_INIT;
|
694
|
+
struct object_entry_cb_state state = {0};
|
695
|
+
size_t path_len;
|
696
|
+
|
697
|
+
state.pack_index = (uint32_t)i;
|
698
|
+
state.object_entries_array = &object_entries_array;
|
699
|
+
|
700
|
+
error = git_str_sets(&relative_index, p->pack_name);
|
701
|
+
if (error < 0)
|
702
|
+
goto cleanup;
|
703
|
+
error = git_fs_path_make_relative(&relative_index, git_str_cstr(&w->pack_dir));
|
704
|
+
if (error < 0) {
|
705
|
+
git_str_dispose(&relative_index);
|
706
|
+
goto cleanup;
|
707
|
+
}
|
708
|
+
path_len = git_str_len(&relative_index);
|
709
|
+
if (path_len <= strlen(".pack") || git__suffixcmp(git_str_cstr(&relative_index), ".pack") != 0) {
|
710
|
+
git_str_dispose(&relative_index);
|
711
|
+
git_error_set(GIT_ERROR_INVALID, "invalid packfile name: '%s'", p->pack_name);
|
712
|
+
error = -1;
|
713
|
+
goto cleanup;
|
714
|
+
}
|
715
|
+
path_len -= strlen(".pack");
|
716
|
+
|
717
|
+
git_str_put(&packfile_names, git_str_cstr(&relative_index), path_len);
|
718
|
+
git_str_puts(&packfile_names, ".idx");
|
719
|
+
git_str_putc(&packfile_names, '\0');
|
720
|
+
git_str_dispose(&relative_index);
|
721
|
+
|
722
|
+
error = git_pack_foreach_entry_offset(p, object_entry__cb, &state);
|
723
|
+
if (error < 0)
|
724
|
+
goto cleanup;
|
725
|
+
}
|
726
|
+
|
727
|
+
/* Sort the object entries. */
|
728
|
+
error = git_vector_init(&object_entries, git_array_size(object_entries_array), object_entry__cmp);
|
729
|
+
if (error < 0)
|
730
|
+
goto cleanup;
|
731
|
+
git_array_foreach (object_entries_array, i, entry) {
|
732
|
+
if ((error = git_vector_set(NULL, &object_entries, i, entry)) < 0)
|
733
|
+
goto cleanup;
|
734
|
+
}
|
735
|
+
git_vector_set_sorted(&object_entries, 0);
|
736
|
+
git_vector_sort(&object_entries);
|
737
|
+
git_vector_uniq(&object_entries, NULL);
|
738
|
+
|
739
|
+
/* Pad the packfile names so it is a multiple of four. */
|
740
|
+
while (git_str_len(&packfile_names) & 3)
|
741
|
+
git_str_putc(&packfile_names, '\0');
|
742
|
+
|
743
|
+
/* Fill the OID Fanout table. */
|
744
|
+
oid_fanout_count = 0;
|
745
|
+
for (i = 0; i < 256; i++) {
|
746
|
+
while (oid_fanout_count < git_vector_length(&object_entries) &&
|
747
|
+
((const git_midx_entry *)git_vector_get(&object_entries, oid_fanout_count))->sha1.id[0] <= i)
|
748
|
+
++oid_fanout_count;
|
749
|
+
oid_fanout[i] = htonl(oid_fanout_count);
|
750
|
+
}
|
751
|
+
|
752
|
+
/* Fill the OID Lookup table. */
|
753
|
+
git_vector_foreach (&object_entries, i, entry) {
|
754
|
+
error = git_str_put(&oid_lookup, (const char *)&entry->sha1, sizeof(entry->sha1));
|
755
|
+
if (error < 0)
|
756
|
+
goto cleanup;
|
757
|
+
}
|
758
|
+
|
759
|
+
/* Fill the Object Offsets and Object Large Offsets tables. */
|
760
|
+
object_large_offsets_count = 0;
|
761
|
+
git_vector_foreach (&object_entries, i, entry) {
|
762
|
+
uint32_t word;
|
763
|
+
|
764
|
+
word = htonl((uint32_t)entry->pack_index);
|
765
|
+
error = git_str_put(&object_offsets, (const char *)&word, sizeof(word));
|
766
|
+
if (error < 0)
|
767
|
+
goto cleanup;
|
768
|
+
if (entry->offset >= 0x80000000l) {
|
769
|
+
word = htonl(0x80000000u | object_large_offsets_count++);
|
770
|
+
if ((error = write_offset(entry->offset, midx_write_buf, &object_large_offsets)) < 0)
|
771
|
+
goto cleanup;
|
772
|
+
} else {
|
773
|
+
word = htonl((uint32_t)entry->offset & 0x7fffffffu);
|
774
|
+
}
|
775
|
+
|
776
|
+
error = git_str_put(&object_offsets, (const char *)&word, sizeof(word));
|
777
|
+
if (error < 0)
|
778
|
+
goto cleanup;
|
779
|
+
}
|
780
|
+
|
781
|
+
/* Write the header. */
|
782
|
+
hdr.packfiles = htonl((uint32_t)git_vector_length(&w->packs));
|
783
|
+
hdr.chunks = 4;
|
784
|
+
if (git_str_len(&object_large_offsets) > 0)
|
785
|
+
hdr.chunks++;
|
786
|
+
error = write_cb((const char *)&hdr, sizeof(hdr), cb_data);
|
787
|
+
if (error < 0)
|
788
|
+
goto cleanup;
|
789
|
+
|
790
|
+
/* Write the chunk headers. */
|
791
|
+
offset = sizeof(hdr) + (hdr.chunks + 1) * 12;
|
792
|
+
error = write_chunk_header(MIDX_PACKFILE_NAMES_ID, offset, write_cb, cb_data);
|
793
|
+
if (error < 0)
|
794
|
+
goto cleanup;
|
795
|
+
offset += git_str_len(&packfile_names);
|
796
|
+
error = write_chunk_header(MIDX_OID_FANOUT_ID, offset, write_cb, cb_data);
|
797
|
+
if (error < 0)
|
798
|
+
goto cleanup;
|
799
|
+
offset += sizeof(oid_fanout);
|
800
|
+
error = write_chunk_header(MIDX_OID_LOOKUP_ID, offset, write_cb, cb_data);
|
801
|
+
if (error < 0)
|
802
|
+
goto cleanup;
|
803
|
+
offset += git_str_len(&oid_lookup);
|
804
|
+
error = write_chunk_header(MIDX_OBJECT_OFFSETS_ID, offset, write_cb, cb_data);
|
805
|
+
if (error < 0)
|
806
|
+
goto cleanup;
|
807
|
+
offset += git_str_len(&object_offsets);
|
808
|
+
if (git_str_len(&object_large_offsets) > 0) {
|
809
|
+
error = write_chunk_header(MIDX_OBJECT_LARGE_OFFSETS_ID, offset, write_cb, cb_data);
|
810
|
+
if (error < 0)
|
811
|
+
goto cleanup;
|
812
|
+
offset += git_str_len(&object_large_offsets);
|
813
|
+
}
|
814
|
+
error = write_chunk_header(0, offset, write_cb, cb_data);
|
815
|
+
if (error < 0)
|
816
|
+
goto cleanup;
|
817
|
+
|
818
|
+
/* Write all the chunks. */
|
819
|
+
error = write_cb(git_str_cstr(&packfile_names), git_str_len(&packfile_names), cb_data);
|
820
|
+
if (error < 0)
|
821
|
+
goto cleanup;
|
822
|
+
error = write_cb((const char *)oid_fanout, sizeof(oid_fanout), cb_data);
|
823
|
+
if (error < 0)
|
824
|
+
goto cleanup;
|
825
|
+
error = write_cb(git_str_cstr(&oid_lookup), git_str_len(&oid_lookup), cb_data);
|
826
|
+
if (error < 0)
|
827
|
+
goto cleanup;
|
828
|
+
error = write_cb(git_str_cstr(&object_offsets), git_str_len(&object_offsets), cb_data);
|
829
|
+
if (error < 0)
|
830
|
+
goto cleanup;
|
831
|
+
error = write_cb(git_str_cstr(&object_large_offsets), git_str_len(&object_large_offsets), cb_data);
|
832
|
+
if (error < 0)
|
833
|
+
goto cleanup;
|
834
|
+
|
835
|
+
/* Finalize the checksum and write the trailer. */
|
836
|
+
error = git_hash_final(checksum, &ctx);
|
837
|
+
if (error < 0)
|
838
|
+
goto cleanup;
|
839
|
+
error = write_cb((char *)checksum, checksum_size, cb_data);
|
840
|
+
if (error < 0)
|
841
|
+
goto cleanup;
|
842
|
+
|
843
|
+
cleanup:
|
844
|
+
git_array_clear(object_entries_array);
|
845
|
+
git_vector_free(&object_entries);
|
846
|
+
git_str_dispose(&packfile_names);
|
847
|
+
git_str_dispose(&oid_lookup);
|
848
|
+
git_str_dispose(&object_offsets);
|
849
|
+
git_str_dispose(&object_large_offsets);
|
850
|
+
git_hash_ctx_cleanup(&ctx);
|
851
|
+
return error;
|
852
|
+
}
|
853
|
+
|
854
|
+
static int midx_write_filebuf(const char *buf, size_t size, void *data)
|
855
|
+
{
|
856
|
+
git_filebuf *f = (git_filebuf *)data;
|
857
|
+
return git_filebuf_write(f, buf, size);
|
858
|
+
}
|
859
|
+
|
860
|
+
int git_midx_writer_commit(
|
861
|
+
git_midx_writer *w)
|
862
|
+
{
|
863
|
+
int error;
|
864
|
+
int filebuf_flags = GIT_FILEBUF_DO_NOT_BUFFER;
|
865
|
+
git_str midx_path = GIT_STR_INIT;
|
866
|
+
git_filebuf output = GIT_FILEBUF_INIT;
|
867
|
+
|
868
|
+
error = git_str_joinpath(&midx_path, git_str_cstr(&w->pack_dir), "multi-pack-index");
|
869
|
+
if (error < 0)
|
870
|
+
return error;
|
871
|
+
|
872
|
+
if (git_repository__fsync_gitdir)
|
873
|
+
filebuf_flags |= GIT_FILEBUF_FSYNC;
|
874
|
+
error = git_filebuf_open(&output, git_str_cstr(&midx_path), filebuf_flags, 0644);
|
875
|
+
git_str_dispose(&midx_path);
|
876
|
+
if (error < 0)
|
877
|
+
return error;
|
878
|
+
|
879
|
+
error = midx_write(w, midx_write_filebuf, &output);
|
880
|
+
if (error < 0) {
|
881
|
+
git_filebuf_cleanup(&output);
|
882
|
+
return error;
|
883
|
+
}
|
884
|
+
|
885
|
+
return git_filebuf_commit(&output);
|
886
|
+
}
|
887
|
+
|
888
|
+
int git_midx_writer_dump(
|
889
|
+
git_buf *midx,
|
890
|
+
git_midx_writer *w)
|
891
|
+
{
|
892
|
+
git_str str = GIT_STR_INIT;
|
893
|
+
int error;
|
894
|
+
|
895
|
+
if ((error = git_buf_tostr(&str, midx)) < 0 ||
|
896
|
+
(error = midx_write(w, midx_write_buf, &str)) == 0)
|
897
|
+
error = git_buf_fromstr(midx, &str);
|
898
|
+
|
899
|
+
git_str_dispose(&str);
|
900
|
+
return error;
|
901
|
+
}
|
data/vendor/libgit2/src/midx.h
CHANGED
@@ -12,8 +12,11 @@
|
|
12
12
|
|
13
13
|
#include <ctype.h>
|
14
14
|
|
15
|
+
#include "git2/sys/midx.h"
|
16
|
+
|
15
17
|
#include "map.h"
|
16
18
|
#include "mwindow.h"
|
19
|
+
#include "odb.h"
|
17
20
|
|
18
21
|
/*
|
19
22
|
* A multi-pack-index file.
|
@@ -48,7 +51,10 @@ typedef struct git_midx_file {
|
|
48
51
|
size_t num_object_large_offsets;
|
49
52
|
|
50
53
|
/* The trailer of the file. Contains the SHA1-checksum of the whole file. */
|
51
|
-
|
54
|
+
unsigned char checksum[GIT_HASH_SHA1_SIZE];
|
55
|
+
|
56
|
+
/* something like ".git/objects/pack/multi-pack-index". */
|
57
|
+
git_str filename;
|
52
58
|
} git_midx_file;
|
53
59
|
|
54
60
|
/*
|
@@ -63,15 +69,36 @@ typedef struct git_midx_entry {
|
|
63
69
|
git_oid sha1;
|
64
70
|
} git_midx_entry;
|
65
71
|
|
72
|
+
/*
|
73
|
+
* A writer for `multi-pack-index` files.
|
74
|
+
*/
|
75
|
+
struct git_midx_writer {
|
76
|
+
/*
|
77
|
+
* The path of the directory where the .pack/.idx files are stored. The
|
78
|
+
* `multi-pack-index` file will be written to the same directory.
|
79
|
+
*/
|
80
|
+
git_str pack_dir;
|
81
|
+
|
82
|
+
/* The list of `git_pack_file`s. */
|
83
|
+
git_vector packs;
|
84
|
+
};
|
85
|
+
|
66
86
|
int git_midx_open(
|
67
87
|
git_midx_file **idx_out,
|
68
88
|
const char *path);
|
89
|
+
bool git_midx_needs_refresh(
|
90
|
+
const git_midx_file *idx,
|
91
|
+
const char *path);
|
69
92
|
int git_midx_entry_find(
|
70
93
|
git_midx_entry *e,
|
71
94
|
git_midx_file *idx,
|
72
95
|
const git_oid *short_oid,
|
73
96
|
size_t len);
|
74
|
-
|
97
|
+
int git_midx_foreach_entry(
|
98
|
+
git_midx_file *idx,
|
99
|
+
git_odb_foreach_cb cb,
|
100
|
+
void *data);
|
101
|
+
int git_midx_close(git_midx_file *idx);
|
75
102
|
void git_midx_free(git_midx_file *idx);
|
76
103
|
|
77
104
|
/* This is exposed for use in the fuzzers. */
|