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/odb.c
CHANGED
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
|
|
24
24
|
#define GIT_ALTERNATES_FILE "info/alternates"
|
|
25
25
|
|
|
26
|
+
#define GIT_ALTERNATES_MAX_DEPTH 5
|
|
27
|
+
|
|
26
28
|
/*
|
|
27
29
|
* We work under the assumption that most objects for long-running
|
|
28
30
|
* operations will be packed
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
#define GIT_ALTERNATES_MAX_DEPTH 5
|
|
32
|
+
int git_odb__loose_priority = GIT_ODB_DEFAULT_LOOSE_PRIORITY;
|
|
33
|
+
int git_odb__packed_priority = GIT_ODB_DEFAULT_PACKED_PRIORITY;
|
|
34
34
|
|
|
35
35
|
bool git_odb__strict_hash_verification = true;
|
|
36
36
|
|
|
@@ -44,8 +44,8 @@ typedef struct
|
|
|
44
44
|
|
|
45
45
|
static git_cache *odb_cache(git_odb *odb)
|
|
46
46
|
{
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
git_repository *owner = GIT_REFCOUNT_OWNER(odb);
|
|
48
|
+
if (owner != NULL) {
|
|
49
49
|
return &owner->objects;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -114,7 +114,8 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj)
|
|
|
114
114
|
size_t hdrlen;
|
|
115
115
|
int error;
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
GIT_ASSERT_ARG(id);
|
|
118
|
+
GIT_ASSERT_ARG(obj);
|
|
118
119
|
|
|
119
120
|
if (!git_object_typeisloose(obj->type)) {
|
|
120
121
|
git_error_set(GIT_ERROR_INVALID, "invalid object type");
|
|
@@ -259,9 +260,7 @@ int git_odb__hashfd_filtered(
|
|
|
259
260
|
if (!(error = git_futils_readbuffer_fd(&raw, fd, size))) {
|
|
260
261
|
git_buf post = GIT_BUF_INIT;
|
|
261
262
|
|
|
262
|
-
error =
|
|
263
|
-
|
|
264
|
-
git_buf_dispose(&raw);
|
|
263
|
+
error = git_filter_list__convert_buf(&post, fl, &raw);
|
|
265
264
|
|
|
266
265
|
if (!error)
|
|
267
266
|
error = git_odb_hash(out, post.ptr, post.size, type);
|
|
@@ -298,14 +297,15 @@ int git_odb__hashlink(git_oid *out, const char *path)
|
|
|
298
297
|
GIT_ERROR_CHECK_ALLOC(link_data);
|
|
299
298
|
|
|
300
299
|
read_len = p_readlink(path, link_data, size);
|
|
301
|
-
|
|
302
|
-
if (read_len != size) {
|
|
300
|
+
if (read_len == -1) {
|
|
303
301
|
git_error_set(GIT_ERROR_OS, "failed to read symlink data for '%s'", path);
|
|
304
302
|
git__free(link_data);
|
|
305
303
|
return -1;
|
|
306
304
|
}
|
|
305
|
+
GIT_ASSERT(read_len <= size);
|
|
306
|
+
link_data[read_len] = '\0';
|
|
307
307
|
|
|
308
|
-
result = git_odb_hash(out, link_data,
|
|
308
|
+
result = git_odb_hash(out, link_data, read_len, GIT_OBJECT_BLOB);
|
|
309
309
|
git__free(link_data);
|
|
310
310
|
} else {
|
|
311
311
|
int fd = git_futils_open_ro(path);
|
|
@@ -346,7 +346,7 @@ int git_odb_hash(git_oid *id, const void *data, size_t len, git_object_t type)
|
|
|
346
346
|
{
|
|
347
347
|
git_rawobj raw;
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
GIT_ASSERT_ARG(id);
|
|
350
350
|
|
|
351
351
|
raw.data = (void *)data;
|
|
352
352
|
raw.len = len;
|
|
@@ -376,7 +376,7 @@ static int fake_wstream__write(git_odb_stream *_stream, const char *data, size_t
|
|
|
376
376
|
{
|
|
377
377
|
fake_wstream *stream = (fake_wstream *)_stream;
|
|
378
378
|
|
|
379
|
-
|
|
379
|
+
GIT_ASSERT(stream->written + len <= stream->size);
|
|
380
380
|
|
|
381
381
|
memcpy(stream->buffer + stream->written, data, len);
|
|
382
382
|
stream->written += len;
|
|
@@ -449,12 +449,18 @@ int git_odb_new(git_odb **out)
|
|
|
449
449
|
git_odb *db = git__calloc(1, sizeof(*db));
|
|
450
450
|
GIT_ERROR_CHECK_ALLOC(db);
|
|
451
451
|
|
|
452
|
+
if (git_mutex_init(&db->lock) < 0) {
|
|
453
|
+
git__free(db);
|
|
454
|
+
return -1;
|
|
455
|
+
}
|
|
452
456
|
if (git_cache_init(&db->own_cache) < 0) {
|
|
457
|
+
git_mutex_free(&db->lock);
|
|
453
458
|
git__free(db);
|
|
454
459
|
return -1;
|
|
455
460
|
}
|
|
456
461
|
if (git_vector_init(&db->backends, 4, backend_sort_cmp) < 0) {
|
|
457
462
|
git_cache_dispose(&db->own_cache);
|
|
463
|
+
git_mutex_free(&db->lock);
|
|
458
464
|
git__free(db);
|
|
459
465
|
return -1;
|
|
460
466
|
}
|
|
@@ -470,12 +476,13 @@ static int add_backend_internal(
|
|
|
470
476
|
{
|
|
471
477
|
backend_internal *internal;
|
|
472
478
|
|
|
473
|
-
|
|
479
|
+
GIT_ASSERT_ARG(odb);
|
|
480
|
+
GIT_ASSERT_ARG(backend);
|
|
474
481
|
|
|
475
482
|
GIT_ERROR_CHECK_VERSION(backend, GIT_ODB_BACKEND_VERSION, "git_odb_backend");
|
|
476
483
|
|
|
477
484
|
/* Check if the backend is already owned by another ODB */
|
|
478
|
-
|
|
485
|
+
GIT_ASSERT(!backend->odb || backend->odb == odb);
|
|
479
486
|
|
|
480
487
|
internal = git__malloc(sizeof(backend_internal));
|
|
481
488
|
GIT_ERROR_CHECK_ALLOC(internal);
|
|
@@ -485,13 +492,18 @@ static int add_backend_internal(
|
|
|
485
492
|
internal->is_alternate = is_alternate;
|
|
486
493
|
internal->disk_inode = disk_inode;
|
|
487
494
|
|
|
495
|
+
if (git_mutex_lock(&odb->lock) < 0) {
|
|
496
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
497
|
+
return -1;
|
|
498
|
+
}
|
|
488
499
|
if (git_vector_insert(&odb->backends, internal) < 0) {
|
|
500
|
+
git_mutex_unlock(&odb->lock);
|
|
489
501
|
git__free(internal);
|
|
490
502
|
return -1;
|
|
491
503
|
}
|
|
492
|
-
|
|
493
504
|
git_vector_sort(&odb->backends);
|
|
494
505
|
internal->backend->odb = odb;
|
|
506
|
+
git_mutex_unlock(&odb->lock);
|
|
495
507
|
return 0;
|
|
496
508
|
}
|
|
497
509
|
|
|
@@ -507,8 +519,19 @@ int git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority)
|
|
|
507
519
|
|
|
508
520
|
size_t git_odb_num_backends(git_odb *odb)
|
|
509
521
|
{
|
|
510
|
-
|
|
511
|
-
|
|
522
|
+
size_t length;
|
|
523
|
+
bool locked = true;
|
|
524
|
+
|
|
525
|
+
GIT_ASSERT_ARG(odb);
|
|
526
|
+
|
|
527
|
+
if (git_mutex_lock(&odb->lock) < 0) {
|
|
528
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
529
|
+
locked = false;
|
|
530
|
+
}
|
|
531
|
+
length = odb->backends.length;
|
|
532
|
+
if (locked)
|
|
533
|
+
git_mutex_unlock(&odb->lock);
|
|
534
|
+
return length;
|
|
512
535
|
}
|
|
513
536
|
|
|
514
537
|
static int git_odb__error_unsupported_in_backend(const char *action)
|
|
@@ -522,24 +545,35 @@ static int git_odb__error_unsupported_in_backend(const char *action)
|
|
|
522
545
|
int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos)
|
|
523
546
|
{
|
|
524
547
|
backend_internal *internal;
|
|
548
|
+
int error;
|
|
549
|
+
|
|
550
|
+
GIT_ASSERT_ARG(out);
|
|
551
|
+
GIT_ASSERT_ARG(odb);
|
|
525
552
|
|
|
526
|
-
|
|
553
|
+
|
|
554
|
+
if ((error = git_mutex_lock(&odb->lock)) < 0) {
|
|
555
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
556
|
+
return error;
|
|
557
|
+
}
|
|
527
558
|
internal = git_vector_get(&odb->backends, pos);
|
|
528
559
|
|
|
529
|
-
if (internal
|
|
530
|
-
|
|
531
|
-
|
|
560
|
+
if (!internal || !internal->backend) {
|
|
561
|
+
git_mutex_unlock(&odb->lock);
|
|
562
|
+
|
|
563
|
+
git_error_set(GIT_ERROR_ODB, "no ODB backend loaded at index %" PRIuZ, pos);
|
|
564
|
+
return GIT_ENOTFOUND;
|
|
532
565
|
}
|
|
566
|
+
*out = internal->backend;
|
|
567
|
+
git_mutex_unlock(&odb->lock);
|
|
533
568
|
|
|
534
|
-
|
|
535
|
-
return GIT_ENOTFOUND;
|
|
569
|
+
return 0;
|
|
536
570
|
}
|
|
537
571
|
|
|
538
572
|
int git_odb__add_default_backends(
|
|
539
573
|
git_odb *db, const char *objects_dir,
|
|
540
574
|
bool as_alternates, int alternate_depth)
|
|
541
575
|
{
|
|
542
|
-
size_t i;
|
|
576
|
+
size_t i = 0;
|
|
543
577
|
struct stat st;
|
|
544
578
|
ino_t inode;
|
|
545
579
|
git_odb_backend *loose, *packed;
|
|
@@ -548,7 +582,7 @@ int git_odb__add_default_backends(
|
|
|
548
582
|
* a cross-platform workaround for this */
|
|
549
583
|
#ifdef GIT_WIN32
|
|
550
584
|
GIT_UNUSED(i);
|
|
551
|
-
GIT_UNUSED(st);
|
|
585
|
+
GIT_UNUSED(&st);
|
|
552
586
|
|
|
553
587
|
inode = 0;
|
|
554
588
|
#else
|
|
@@ -563,23 +597,40 @@ int git_odb__add_default_backends(
|
|
|
563
597
|
|
|
564
598
|
inode = st.st_ino;
|
|
565
599
|
|
|
600
|
+
if (git_mutex_lock(&db->lock) < 0) {
|
|
601
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
602
|
+
return -1;
|
|
603
|
+
}
|
|
566
604
|
for (i = 0; i < db->backends.length; ++i) {
|
|
567
605
|
backend_internal *backend = git_vector_get(&db->backends, i);
|
|
568
|
-
if (backend->disk_inode == inode)
|
|
606
|
+
if (backend->disk_inode == inode) {
|
|
607
|
+
git_mutex_unlock(&db->lock);
|
|
569
608
|
return 0;
|
|
609
|
+
}
|
|
570
610
|
}
|
|
611
|
+
git_mutex_unlock(&db->lock);
|
|
571
612
|
#endif
|
|
572
613
|
|
|
573
614
|
/* add the loose object backend */
|
|
574
615
|
if (git_odb_backend_loose(&loose, objects_dir, -1, db->do_fsync, 0, 0) < 0 ||
|
|
575
|
-
add_backend_internal(db, loose,
|
|
616
|
+
add_backend_internal(db, loose, git_odb__loose_priority, as_alternates, inode) < 0)
|
|
576
617
|
return -1;
|
|
577
618
|
|
|
578
619
|
/* add the packed file backend */
|
|
579
620
|
if (git_odb_backend_pack(&packed, objects_dir) < 0 ||
|
|
580
|
-
add_backend_internal(db, packed,
|
|
621
|
+
add_backend_internal(db, packed, git_odb__packed_priority, as_alternates, inode) < 0)
|
|
581
622
|
return -1;
|
|
582
623
|
|
|
624
|
+
if (git_mutex_lock(&db->lock) < 0) {
|
|
625
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
626
|
+
return -1;
|
|
627
|
+
}
|
|
628
|
+
if (!db->cgraph && git_commit_graph_new(&db->cgraph, objects_dir, false) < 0) {
|
|
629
|
+
git_mutex_unlock(&db->lock);
|
|
630
|
+
return -1;
|
|
631
|
+
}
|
|
632
|
+
git_mutex_unlock(&db->lock);
|
|
633
|
+
|
|
583
634
|
return load_alternates(db, objects_dir, alternate_depth);
|
|
584
635
|
}
|
|
585
636
|
|
|
@@ -641,11 +692,29 @@ int git_odb_add_disk_alternate(git_odb *odb, const char *path)
|
|
|
641
692
|
return git_odb__add_default_backends(odb, path, true, 0);
|
|
642
693
|
}
|
|
643
694
|
|
|
695
|
+
int git_odb_set_commit_graph(git_odb *odb, git_commit_graph *cgraph)
|
|
696
|
+
{
|
|
697
|
+
int error = 0;
|
|
698
|
+
|
|
699
|
+
GIT_ASSERT_ARG(odb);
|
|
700
|
+
|
|
701
|
+
if ((error = git_mutex_lock(&odb->lock)) < 0) {
|
|
702
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the db lock");
|
|
703
|
+
return error;
|
|
704
|
+
}
|
|
705
|
+
git_commit_graph_free(odb->cgraph);
|
|
706
|
+
odb->cgraph = cgraph;
|
|
707
|
+
git_mutex_unlock(&odb->lock);
|
|
708
|
+
|
|
709
|
+
return error;
|
|
710
|
+
}
|
|
711
|
+
|
|
644
712
|
int git_odb_open(git_odb **out, const char *objects_dir)
|
|
645
713
|
{
|
|
646
714
|
git_odb *db;
|
|
647
715
|
|
|
648
|
-
|
|
716
|
+
GIT_ASSERT_ARG(out);
|
|
717
|
+
GIT_ASSERT_ARG(objects_dir);
|
|
649
718
|
|
|
650
719
|
*out = NULL;
|
|
651
720
|
|
|
@@ -664,7 +733,7 @@ int git_odb_open(git_odb **out, const char *objects_dir)
|
|
|
664
733
|
int git_odb__set_caps(git_odb *odb, int caps)
|
|
665
734
|
{
|
|
666
735
|
if (caps == GIT_ODB_CAP_FROM_OWNER) {
|
|
667
|
-
git_repository *repo = odb
|
|
736
|
+
git_repository *repo = GIT_REFCOUNT_OWNER(odb);
|
|
668
737
|
int val;
|
|
669
738
|
|
|
670
739
|
if (!repo) {
|
|
@@ -682,7 +751,12 @@ int git_odb__set_caps(git_odb *odb, int caps)
|
|
|
682
751
|
static void odb_free(git_odb *db)
|
|
683
752
|
{
|
|
684
753
|
size_t i;
|
|
754
|
+
bool locked = true;
|
|
685
755
|
|
|
756
|
+
if (git_mutex_lock(&db->lock) < 0) {
|
|
757
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
758
|
+
locked = false;
|
|
759
|
+
}
|
|
686
760
|
for (i = 0; i < db->backends.length; ++i) {
|
|
687
761
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
688
762
|
git_odb_backend *backend = internal->backend;
|
|
@@ -691,9 +765,13 @@ static void odb_free(git_odb *db)
|
|
|
691
765
|
|
|
692
766
|
git__free(internal);
|
|
693
767
|
}
|
|
768
|
+
if (locked)
|
|
769
|
+
git_mutex_unlock(&db->lock);
|
|
694
770
|
|
|
771
|
+
git_commit_graph_free(db->cgraph);
|
|
695
772
|
git_vector_free(&db->backends);
|
|
696
773
|
git_cache_dispose(&db->own_cache);
|
|
774
|
+
git_mutex_free(&db->lock);
|
|
697
775
|
|
|
698
776
|
git__memzero(db, sizeof(*db));
|
|
699
777
|
git__free(db);
|
|
@@ -714,7 +792,12 @@ static int odb_exists_1(
|
|
|
714
792
|
{
|
|
715
793
|
size_t i;
|
|
716
794
|
bool found = false;
|
|
795
|
+
int error;
|
|
717
796
|
|
|
797
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
798
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
799
|
+
return error;
|
|
800
|
+
}
|
|
718
801
|
for (i = 0; i < db->backends.length && !found; ++i) {
|
|
719
802
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
720
803
|
git_odb_backend *b = internal->backend;
|
|
@@ -725,10 +808,34 @@ static int odb_exists_1(
|
|
|
725
808
|
if (b->exists != NULL)
|
|
726
809
|
found = (bool)b->exists(b, id);
|
|
727
810
|
}
|
|
811
|
+
git_mutex_unlock(&db->lock);
|
|
728
812
|
|
|
729
813
|
return (int)found;
|
|
730
814
|
}
|
|
731
815
|
|
|
816
|
+
int git_odb__get_commit_graph_file(git_commit_graph_file **out, git_odb *db)
|
|
817
|
+
{
|
|
818
|
+
int error = 0;
|
|
819
|
+
git_commit_graph_file *result = NULL;
|
|
820
|
+
|
|
821
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
822
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the db lock");
|
|
823
|
+
return error;
|
|
824
|
+
}
|
|
825
|
+
if (!db->cgraph) {
|
|
826
|
+
error = GIT_ENOTFOUND;
|
|
827
|
+
goto done;
|
|
828
|
+
}
|
|
829
|
+
error = git_commit_graph_get_file(&result, db->cgraph);
|
|
830
|
+
if (error)
|
|
831
|
+
goto done;
|
|
832
|
+
*out = result;
|
|
833
|
+
|
|
834
|
+
done:
|
|
835
|
+
git_mutex_unlock(&db->lock);
|
|
836
|
+
return error;
|
|
837
|
+
}
|
|
838
|
+
|
|
732
839
|
static int odb_freshen_1(
|
|
733
840
|
git_odb *db,
|
|
734
841
|
const git_oid *id,
|
|
@@ -736,7 +843,12 @@ static int odb_freshen_1(
|
|
|
736
843
|
{
|
|
737
844
|
size_t i;
|
|
738
845
|
bool found = false;
|
|
846
|
+
int error;
|
|
739
847
|
|
|
848
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
849
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
850
|
+
return error;
|
|
851
|
+
}
|
|
740
852
|
for (i = 0; i < db->backends.length && !found; ++i) {
|
|
741
853
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
742
854
|
git_odb_backend *b = internal->backend;
|
|
@@ -749,13 +861,15 @@ static int odb_freshen_1(
|
|
|
749
861
|
else if (b->exists != NULL)
|
|
750
862
|
found = b->exists(b, id);
|
|
751
863
|
}
|
|
864
|
+
git_mutex_unlock(&db->lock);
|
|
752
865
|
|
|
753
866
|
return (int)found;
|
|
754
867
|
}
|
|
755
868
|
|
|
756
869
|
int git_odb__freshen(git_odb *db, const git_oid *id)
|
|
757
870
|
{
|
|
758
|
-
|
|
871
|
+
GIT_ASSERT_ARG(db);
|
|
872
|
+
GIT_ASSERT_ARG(id);
|
|
759
873
|
|
|
760
874
|
if (odb_freshen_1(db, id, false))
|
|
761
875
|
return 1;
|
|
@@ -771,7 +885,8 @@ int git_odb_exists(git_odb *db, const git_oid *id)
|
|
|
771
885
|
{
|
|
772
886
|
git_odb_object *object;
|
|
773
887
|
|
|
774
|
-
|
|
888
|
+
GIT_ASSERT_ARG(db);
|
|
889
|
+
GIT_ASSERT_ARG(id);
|
|
775
890
|
|
|
776
891
|
if (git_oid_is_zero(id))
|
|
777
892
|
return 0;
|
|
@@ -798,6 +913,11 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db,
|
|
|
798
913
|
int error = GIT_ENOTFOUND, num_found = 0;
|
|
799
914
|
git_oid last_found = {{0}}, found;
|
|
800
915
|
|
|
916
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
917
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
918
|
+
return error;
|
|
919
|
+
}
|
|
920
|
+
error = GIT_ENOTFOUND;
|
|
801
921
|
for (i = 0; i < db->backends.length; ++i) {
|
|
802
922
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
803
923
|
git_odb_backend *b = internal->backend;
|
|
@@ -811,18 +931,23 @@ static int odb_exists_prefix_1(git_oid *out, git_odb *db,
|
|
|
811
931
|
error = b->exists_prefix(&found, b, key, len);
|
|
812
932
|
if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH)
|
|
813
933
|
continue;
|
|
814
|
-
if (error)
|
|
934
|
+
if (error) {
|
|
935
|
+
git_mutex_unlock(&db->lock);
|
|
815
936
|
return error;
|
|
937
|
+
}
|
|
816
938
|
|
|
817
939
|
/* make sure found item doesn't introduce ambiguity */
|
|
818
940
|
if (num_found) {
|
|
819
|
-
if (git_oid__cmp(&last_found, &found))
|
|
941
|
+
if (git_oid__cmp(&last_found, &found)) {
|
|
942
|
+
git_mutex_unlock(&db->lock);
|
|
820
943
|
return git_odb__error_ambiguous("multiple matches for prefix");
|
|
944
|
+
}
|
|
821
945
|
} else {
|
|
822
946
|
git_oid_cpy(&last_found, &found);
|
|
823
947
|
num_found++;
|
|
824
948
|
}
|
|
825
949
|
}
|
|
950
|
+
git_mutex_unlock(&db->lock);
|
|
826
951
|
|
|
827
952
|
if (!num_found)
|
|
828
953
|
return GIT_ENOTFOUND;
|
|
@@ -839,7 +964,8 @@ int git_odb_exists_prefix(
|
|
|
839
964
|
int error;
|
|
840
965
|
git_oid key = {{0}};
|
|
841
966
|
|
|
842
|
-
|
|
967
|
+
GIT_ASSERT_ARG(db);
|
|
968
|
+
GIT_ASSERT_ARG(short_id);
|
|
843
969
|
|
|
844
970
|
if (len < GIT_OID_MINPREFIXLEN)
|
|
845
971
|
return git_odb__error_ambiguous("prefix length too short");
|
|
@@ -875,7 +1001,8 @@ int git_odb_expand_ids(
|
|
|
875
1001
|
{
|
|
876
1002
|
size_t i;
|
|
877
1003
|
|
|
878
|
-
|
|
1004
|
+
GIT_ASSERT_ARG(db);
|
|
1005
|
+
GIT_ASSERT_ARG(ids);
|
|
879
1006
|
|
|
880
1007
|
for (i = 0; i < count; i++) {
|
|
881
1008
|
git_odb_expand_id *query = &ids[i];
|
|
@@ -962,6 +1089,10 @@ static int odb_read_header_1(
|
|
|
962
1089
|
return 0;
|
|
963
1090
|
}
|
|
964
1091
|
|
|
1092
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1093
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1094
|
+
return error;
|
|
1095
|
+
}
|
|
965
1096
|
for (i = 0; i < db->backends.length; ++i) {
|
|
966
1097
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
967
1098
|
git_odb_backend *b = internal->backend;
|
|
@@ -983,9 +1114,11 @@ static int odb_read_header_1(
|
|
|
983
1114
|
case GIT_ENOTFOUND:
|
|
984
1115
|
break;
|
|
985
1116
|
default:
|
|
1117
|
+
git_mutex_unlock(&db->lock);
|
|
986
1118
|
return error;
|
|
987
1119
|
}
|
|
988
1120
|
}
|
|
1121
|
+
git_mutex_unlock(&db->lock);
|
|
989
1122
|
|
|
990
1123
|
return passthrough ? GIT_PASSTHROUGH : GIT_ENOTFOUND;
|
|
991
1124
|
}
|
|
@@ -997,7 +1130,11 @@ int git_odb__read_header_or_object(
|
|
|
997
1130
|
int error = GIT_ENOTFOUND;
|
|
998
1131
|
git_odb_object *object;
|
|
999
1132
|
|
|
1000
|
-
|
|
1133
|
+
GIT_ASSERT_ARG(db);
|
|
1134
|
+
GIT_ASSERT_ARG(id);
|
|
1135
|
+
GIT_ASSERT_ARG(out);
|
|
1136
|
+
GIT_ASSERT_ARG(len_p);
|
|
1137
|
+
GIT_ASSERT_ARG(type_p);
|
|
1001
1138
|
|
|
1002
1139
|
*out = NULL;
|
|
1003
1140
|
|
|
@@ -1054,6 +1191,10 @@ static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id,
|
|
|
1054
1191
|
return error;
|
|
1055
1192
|
}
|
|
1056
1193
|
|
|
1194
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1195
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1196
|
+
return error;
|
|
1197
|
+
}
|
|
1057
1198
|
for (i = 0; i < db->backends.length && !found; ++i) {
|
|
1058
1199
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1059
1200
|
git_odb_backend *b = internal->backend;
|
|
@@ -1066,12 +1207,15 @@ static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id,
|
|
|
1066
1207
|
if (error == GIT_PASSTHROUGH || error == GIT_ENOTFOUND)
|
|
1067
1208
|
continue;
|
|
1068
1209
|
|
|
1069
|
-
if (error < 0)
|
|
1210
|
+
if (error < 0) {
|
|
1211
|
+
git_mutex_unlock(&db->lock);
|
|
1070
1212
|
return error;
|
|
1213
|
+
}
|
|
1071
1214
|
|
|
1072
1215
|
found = true;
|
|
1073
1216
|
}
|
|
1074
1217
|
}
|
|
1218
|
+
git_mutex_unlock(&db->lock);
|
|
1075
1219
|
|
|
1076
1220
|
if (!found)
|
|
1077
1221
|
return GIT_ENOTFOUND;
|
|
@@ -1104,7 +1248,9 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
|
|
|
1104
1248
|
{
|
|
1105
1249
|
int error;
|
|
1106
1250
|
|
|
1107
|
-
|
|
1251
|
+
GIT_ASSERT_ARG(out);
|
|
1252
|
+
GIT_ASSERT_ARG(db);
|
|
1253
|
+
GIT_ASSERT_ARG(id);
|
|
1108
1254
|
|
|
1109
1255
|
if (git_oid_is_zero(id))
|
|
1110
1256
|
return error_null_oid(GIT_ENOTFOUND, "cannot read object");
|
|
@@ -1162,6 +1308,10 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
|
|
|
1162
1308
|
bool found = false;
|
|
1163
1309
|
git_odb_object *object;
|
|
1164
1310
|
|
|
1311
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1312
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1313
|
+
return error;
|
|
1314
|
+
}
|
|
1165
1315
|
for (i = 0; i < db->backends.length; ++i) {
|
|
1166
1316
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1167
1317
|
git_odb_backend *b = internal->backend;
|
|
@@ -1178,8 +1328,10 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
|
|
|
1178
1328
|
continue;
|
|
1179
1329
|
}
|
|
1180
1330
|
|
|
1181
|
-
if (error)
|
|
1331
|
+
if (error) {
|
|
1332
|
+
git_mutex_unlock(&db->lock);
|
|
1182
1333
|
goto out;
|
|
1334
|
+
}
|
|
1183
1335
|
|
|
1184
1336
|
git__free(data);
|
|
1185
1337
|
data = raw.data;
|
|
@@ -1194,6 +1346,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
|
|
|
1194
1346
|
|
|
1195
1347
|
error = git_odb__error_ambiguous(buf.ptr);
|
|
1196
1348
|
git_buf_dispose(&buf);
|
|
1349
|
+
git_mutex_unlock(&db->lock);
|
|
1197
1350
|
goto out;
|
|
1198
1351
|
}
|
|
1199
1352
|
|
|
@@ -1201,6 +1354,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
|
|
|
1201
1354
|
found = true;
|
|
1202
1355
|
}
|
|
1203
1356
|
}
|
|
1357
|
+
git_mutex_unlock(&db->lock);
|
|
1204
1358
|
|
|
1205
1359
|
if (!found)
|
|
1206
1360
|
return GIT_ENOTFOUND;
|
|
@@ -1237,7 +1391,8 @@ int git_odb_read_prefix(
|
|
|
1237
1391
|
git_oid key = {{0}};
|
|
1238
1392
|
int error;
|
|
1239
1393
|
|
|
1240
|
-
|
|
1394
|
+
GIT_ASSERT_ARG(out);
|
|
1395
|
+
GIT_ASSERT_ARG(db);
|
|
1241
1396
|
|
|
1242
1397
|
if (len < GIT_OID_MINPREFIXLEN)
|
|
1243
1398
|
return git_odb__error_ambiguous("prefix length too short");
|
|
@@ -1267,28 +1422,46 @@ int git_odb_read_prefix(
|
|
|
1267
1422
|
int git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload)
|
|
1268
1423
|
{
|
|
1269
1424
|
unsigned int i;
|
|
1425
|
+
git_vector backends = GIT_VECTOR_INIT;
|
|
1270
1426
|
backend_internal *internal;
|
|
1427
|
+
int error = 0;
|
|
1428
|
+
|
|
1429
|
+
/* Make a copy of the backends vector to invoke the callback without holding the lock. */
|
|
1430
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1431
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1432
|
+
goto cleanup;
|
|
1433
|
+
}
|
|
1434
|
+
error = git_vector_dup(&backends, &db->backends, NULL);
|
|
1435
|
+
git_mutex_unlock(&db->lock);
|
|
1271
1436
|
|
|
1272
|
-
|
|
1437
|
+
if (error < 0)
|
|
1438
|
+
goto cleanup;
|
|
1439
|
+
|
|
1440
|
+
git_vector_foreach(&backends, i, internal) {
|
|
1273
1441
|
git_odb_backend *b = internal->backend;
|
|
1274
|
-
|
|
1442
|
+
error = b->foreach(b, cb, payload);
|
|
1275
1443
|
if (error != 0)
|
|
1276
|
-
|
|
1444
|
+
goto cleanup;
|
|
1277
1445
|
}
|
|
1278
1446
|
|
|
1279
|
-
|
|
1447
|
+
cleanup:
|
|
1448
|
+
git_vector_free(&backends);
|
|
1449
|
+
|
|
1450
|
+
return error;
|
|
1280
1451
|
}
|
|
1281
1452
|
|
|
1282
1453
|
int git_odb_write(
|
|
1283
1454
|
git_oid *oid, git_odb *db, const void *data, size_t len, git_object_t type)
|
|
1284
1455
|
{
|
|
1285
1456
|
size_t i;
|
|
1286
|
-
int error
|
|
1457
|
+
int error;
|
|
1287
1458
|
git_odb_stream *stream;
|
|
1288
1459
|
|
|
1289
|
-
|
|
1460
|
+
GIT_ASSERT_ARG(oid);
|
|
1461
|
+
GIT_ASSERT_ARG(db);
|
|
1290
1462
|
|
|
1291
|
-
git_odb_hash(oid, data, len, type)
|
|
1463
|
+
if ((error = git_odb_hash(oid, data, len, type)) < 0)
|
|
1464
|
+
return error;
|
|
1292
1465
|
|
|
1293
1466
|
if (git_oid_is_zero(oid))
|
|
1294
1467
|
return error_null_oid(GIT_EINVALID, "cannot write object");
|
|
@@ -1296,7 +1469,11 @@ int git_odb_write(
|
|
|
1296
1469
|
if (git_odb__freshen(db, oid))
|
|
1297
1470
|
return 0;
|
|
1298
1471
|
|
|
1299
|
-
|
|
1472
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1473
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1474
|
+
return error;
|
|
1475
|
+
}
|
|
1476
|
+
for (i = 0, error = GIT_ERROR; i < db->backends.length && error < 0; ++i) {
|
|
1300
1477
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1301
1478
|
git_odb_backend *b = internal->backend;
|
|
1302
1479
|
|
|
@@ -1307,6 +1484,7 @@ int git_odb_write(
|
|
|
1307
1484
|
if (b->write != NULL)
|
|
1308
1485
|
error = b->write(b, oid, data, len, type);
|
|
1309
1486
|
}
|
|
1487
|
+
git_mutex_unlock(&db->lock);
|
|
1310
1488
|
|
|
1311
1489
|
if (!error || error == GIT_PASSTHROUGH)
|
|
1312
1490
|
return 0;
|
|
@@ -1345,8 +1523,14 @@ int git_odb_open_wstream(
|
|
|
1345
1523
|
int error = GIT_ERROR;
|
|
1346
1524
|
git_hash_ctx *ctx = NULL;
|
|
1347
1525
|
|
|
1348
|
-
|
|
1526
|
+
GIT_ASSERT_ARG(stream);
|
|
1527
|
+
GIT_ASSERT_ARG(db);
|
|
1349
1528
|
|
|
1529
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1530
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1531
|
+
return error;
|
|
1532
|
+
}
|
|
1533
|
+
error = GIT_ERROR;
|
|
1350
1534
|
for (i = 0; i < db->backends.length && error < 0; ++i) {
|
|
1351
1535
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1352
1536
|
git_odb_backend *b = internal->backend;
|
|
@@ -1363,6 +1547,7 @@ int git_odb_open_wstream(
|
|
|
1363
1547
|
error = init_fake_wstream(stream, b, size, type);
|
|
1364
1548
|
}
|
|
1365
1549
|
}
|
|
1550
|
+
git_mutex_unlock(&db->lock);
|
|
1366
1551
|
|
|
1367
1552
|
if (error < 0) {
|
|
1368
1553
|
if (error == GIT_PASSTHROUGH)
|
|
@@ -1455,8 +1640,14 @@ int git_odb_open_rstream(
|
|
|
1455
1640
|
size_t i, reads = 0;
|
|
1456
1641
|
int error = GIT_ERROR;
|
|
1457
1642
|
|
|
1458
|
-
|
|
1643
|
+
GIT_ASSERT_ARG(stream);
|
|
1644
|
+
GIT_ASSERT_ARG(db);
|
|
1459
1645
|
|
|
1646
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1647
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1648
|
+
return error;
|
|
1649
|
+
}
|
|
1650
|
+
error = GIT_ERROR;
|
|
1460
1651
|
for (i = 0; i < db->backends.length && error < 0; ++i) {
|
|
1461
1652
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1462
1653
|
git_odb_backend *b = internal->backend;
|
|
@@ -1466,6 +1657,7 @@ int git_odb_open_rstream(
|
|
|
1466
1657
|
error = b->readstream(stream, len, type, b, oid);
|
|
1467
1658
|
}
|
|
1468
1659
|
}
|
|
1660
|
+
git_mutex_unlock(&db->lock);
|
|
1469
1661
|
|
|
1470
1662
|
if (error == GIT_PASSTHROUGH)
|
|
1471
1663
|
error = 0;
|
|
@@ -1480,8 +1672,14 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_indexer_
|
|
|
1480
1672
|
size_t i, writes = 0;
|
|
1481
1673
|
int error = GIT_ERROR;
|
|
1482
1674
|
|
|
1483
|
-
|
|
1675
|
+
GIT_ASSERT_ARG(out);
|
|
1676
|
+
GIT_ASSERT_ARG(db);
|
|
1484
1677
|
|
|
1678
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1679
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1680
|
+
return error;
|
|
1681
|
+
}
|
|
1682
|
+
error = GIT_ERROR;
|
|
1485
1683
|
for (i = 0; i < db->backends.length && error < 0; ++i) {
|
|
1486
1684
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1487
1685
|
git_odb_backend *b = internal->backend;
|
|
@@ -1495,6 +1693,7 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_indexer_
|
|
|
1495
1693
|
error = b->writepack(out, b, db, progress_cb, progress_payload);
|
|
1496
1694
|
}
|
|
1497
1695
|
}
|
|
1696
|
+
git_mutex_unlock(&db->lock);
|
|
1498
1697
|
|
|
1499
1698
|
if (error == GIT_PASSTHROUGH)
|
|
1500
1699
|
error = 0;
|
|
@@ -1504,16 +1703,47 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_indexer_
|
|
|
1504
1703
|
return error;
|
|
1505
1704
|
}
|
|
1506
1705
|
|
|
1706
|
+
int git_odb_write_multi_pack_index(git_odb *db)
|
|
1707
|
+
{
|
|
1708
|
+
size_t i, writes = 0;
|
|
1709
|
+
int error = GIT_ERROR;
|
|
1710
|
+
|
|
1711
|
+
GIT_ASSERT_ARG(db);
|
|
1712
|
+
|
|
1713
|
+
for (i = 0; i < db->backends.length && error < 0; ++i) {
|
|
1714
|
+
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1715
|
+
git_odb_backend *b = internal->backend;
|
|
1716
|
+
|
|
1717
|
+
/* we don't write in alternates! */
|
|
1718
|
+
if (internal->is_alternate)
|
|
1719
|
+
continue;
|
|
1720
|
+
|
|
1721
|
+
if (b->writemidx != NULL) {
|
|
1722
|
+
++writes;
|
|
1723
|
+
error = b->writemidx(b);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
if (error == GIT_PASSTHROUGH)
|
|
1728
|
+
error = 0;
|
|
1729
|
+
if (error < 0 && !writes)
|
|
1730
|
+
error = git_odb__error_unsupported_in_backend("write multi-pack-index");
|
|
1731
|
+
|
|
1732
|
+
return error;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1507
1735
|
void *git_odb_backend_data_alloc(git_odb_backend *backend, size_t len)
|
|
1508
1736
|
{
|
|
1509
1737
|
GIT_UNUSED(backend);
|
|
1510
1738
|
return git__malloc(len);
|
|
1511
1739
|
}
|
|
1512
1740
|
|
|
1741
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
1513
1742
|
void *git_odb_backend_malloc(git_odb_backend *backend, size_t len)
|
|
1514
1743
|
{
|
|
1515
1744
|
return git_odb_backend_data_alloc(backend, len);
|
|
1516
1745
|
}
|
|
1746
|
+
#endif
|
|
1517
1747
|
|
|
1518
1748
|
void git_odb_backend_data_free(git_odb_backend *backend, void *data)
|
|
1519
1749
|
{
|
|
@@ -1524,18 +1754,29 @@ void git_odb_backend_data_free(git_odb_backend *backend, void *data)
|
|
|
1524
1754
|
int git_odb_refresh(struct git_odb *db)
|
|
1525
1755
|
{
|
|
1526
1756
|
size_t i;
|
|
1527
|
-
|
|
1757
|
+
int error;
|
|
1758
|
+
|
|
1759
|
+
GIT_ASSERT_ARG(db);
|
|
1528
1760
|
|
|
1761
|
+
if ((error = git_mutex_lock(&db->lock)) < 0) {
|
|
1762
|
+
git_error_set(GIT_ERROR_ODB, "failed to acquire the odb lock");
|
|
1763
|
+
return error;
|
|
1764
|
+
}
|
|
1529
1765
|
for (i = 0; i < db->backends.length; ++i) {
|
|
1530
1766
|
backend_internal *internal = git_vector_get(&db->backends, i);
|
|
1531
1767
|
git_odb_backend *b = internal->backend;
|
|
1532
1768
|
|
|
1533
1769
|
if (b->refresh != NULL) {
|
|
1534
1770
|
int error = b->refresh(b);
|
|
1535
|
-
if (error < 0)
|
|
1771
|
+
if (error < 0) {
|
|
1772
|
+
git_mutex_unlock(&db->lock);
|
|
1536
1773
|
return error;
|
|
1774
|
+
}
|
|
1537
1775
|
}
|
|
1538
1776
|
}
|
|
1777
|
+
if (db->cgraph)
|
|
1778
|
+
git_commit_graph_refresh(db->cgraph);
|
|
1779
|
+
git_mutex_unlock(&db->lock);
|
|
1539
1780
|
|
|
1540
1781
|
return 0;
|
|
1541
1782
|
}
|