rugged 1.0.0 → 1.2.0
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 +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/merge.h
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#include "merge_driver.h"
|
9
9
|
|
10
10
|
#include "vector.h"
|
11
|
-
#include "
|
11
|
+
#include "runtime.h"
|
12
12
|
#include "merge.h"
|
13
13
|
#include "git2/merge.h"
|
14
14
|
#include "git2/sys/merge.h"
|
@@ -32,33 +32,38 @@ static struct merge_driver_registry merge_driver_registry;
|
|
32
32
|
|
33
33
|
static void git_merge_driver_global_shutdown(void);
|
34
34
|
|
35
|
-
git_repository*
|
35
|
+
git_repository *git_merge_driver_source_repo(
|
36
|
+
const git_merge_driver_source *src)
|
36
37
|
{
|
37
|
-
|
38
|
+
GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
|
38
39
|
return src->repo;
|
39
40
|
}
|
40
41
|
|
41
|
-
const git_index_entry*
|
42
|
+
const git_index_entry *git_merge_driver_source_ancestor(
|
43
|
+
const git_merge_driver_source *src)
|
42
44
|
{
|
43
|
-
|
45
|
+
GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
|
44
46
|
return src->ancestor;
|
45
47
|
}
|
46
48
|
|
47
|
-
const git_index_entry*
|
49
|
+
const git_index_entry *git_merge_driver_source_ours(
|
50
|
+
const git_merge_driver_source *src)
|
48
51
|
{
|
49
|
-
|
52
|
+
GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
|
50
53
|
return src->ours;
|
51
54
|
}
|
52
55
|
|
53
|
-
const git_index_entry*
|
56
|
+
const git_index_entry *git_merge_driver_source_theirs(
|
57
|
+
const git_merge_driver_source *src)
|
54
58
|
{
|
55
|
-
|
59
|
+
GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
|
56
60
|
return src->theirs;
|
57
61
|
}
|
58
62
|
|
59
|
-
const git_merge_file_options*
|
63
|
+
const git_merge_file_options *git_merge_driver_source_file_options(
|
64
|
+
const git_merge_driver_source *src)
|
60
65
|
{
|
61
|
-
|
66
|
+
GIT_ASSERT_ARG_WITH_RETVAL(src, NULL);
|
62
67
|
return src->file_opts;
|
63
68
|
}
|
64
69
|
|
@@ -209,7 +214,7 @@ int git_merge_driver_global_init(void)
|
|
209
214
|
merge_driver_name__binary, &git_merge_driver__binary)) < 0)
|
210
215
|
goto done;
|
211
216
|
|
212
|
-
|
217
|
+
error = git_runtime_shutdown_register(git_merge_driver_global_shutdown);
|
213
218
|
|
214
219
|
done:
|
215
220
|
if (error < 0)
|
@@ -262,7 +267,8 @@ int git_merge_driver_register(const char *name, git_merge_driver *driver)
|
|
262
267
|
{
|
263
268
|
int error;
|
264
269
|
|
265
|
-
|
270
|
+
GIT_ASSERT_ARG(name);
|
271
|
+
GIT_ASSERT_ARG(driver);
|
266
272
|
|
267
273
|
if (git_rwlock_wrlock(&merge_driver_registry.lock) < 0) {
|
268
274
|
git_error_set(GIT_ERROR_OS, "failed to lock merge driver registry");
|
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
#define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0)
|
30
30
|
|
31
|
-
int
|
31
|
+
static int merge_file_input_from_index(
|
32
32
|
git_merge_file_input *input_out,
|
33
33
|
git_odb_object **odb_object_out,
|
34
34
|
git_odb *odb,
|
@@ -36,7 +36,10 @@ int git_merge_file__input_from_index(
|
|
36
36
|
{
|
37
37
|
int error = 0;
|
38
38
|
|
39
|
-
|
39
|
+
GIT_ASSERT_ARG(input_out);
|
40
|
+
GIT_ASSERT_ARG(odb_object_out);
|
41
|
+
GIT_ASSERT_ARG(odb);
|
42
|
+
GIT_ASSERT_ARG(entry);
|
40
43
|
|
41
44
|
if ((error = git_odb_read(odb_object_out, odb, &entry->id)) < 0)
|
42
45
|
goto done;
|
@@ -241,7 +244,9 @@ int git_merge_file(
|
|
241
244
|
{
|
242
245
|
git_merge_file_input inputs[3] = { {0} };
|
243
246
|
|
244
|
-
|
247
|
+
GIT_ASSERT_ARG(out);
|
248
|
+
GIT_ASSERT_ARG(ours);
|
249
|
+
GIT_ASSERT_ARG(theirs);
|
245
250
|
|
246
251
|
memset(out, 0x0, sizeof(git_merge_file_result));
|
247
252
|
|
@@ -268,7 +273,10 @@ int git_merge_file_from_index(
|
|
268
273
|
git_odb_object *odb_object[3] = { 0 };
|
269
274
|
int error = 0;
|
270
275
|
|
271
|
-
|
276
|
+
GIT_ASSERT_ARG(out);
|
277
|
+
GIT_ASSERT_ARG(repo);
|
278
|
+
GIT_ASSERT_ARG(ours);
|
279
|
+
GIT_ASSERT_ARG(theirs);
|
272
280
|
|
273
281
|
memset(out, 0x0, sizeof(git_merge_file_result));
|
274
282
|
|
@@ -276,17 +284,15 @@ int git_merge_file_from_index(
|
|
276
284
|
goto done;
|
277
285
|
|
278
286
|
if (ancestor) {
|
279
|
-
if ((error =
|
287
|
+
if ((error = merge_file_input_from_index(
|
280
288
|
&ancestor_input, &odb_object[0], odb, ancestor)) < 0)
|
281
289
|
goto done;
|
282
290
|
|
283
291
|
ancestor_ptr = &ancestor_input;
|
284
292
|
}
|
285
293
|
|
286
|
-
if ((error =
|
287
|
-
|
288
|
-
(error = git_merge_file__input_from_index(
|
289
|
-
&their_input, &odb_object[2], odb, theirs)) < 0)
|
294
|
+
if ((error = merge_file_input_from_index(&our_input, &odb_object[1], odb, ours)) < 0 ||
|
295
|
+
(error = merge_file_input_from_index(&their_input, &odb_object[2], odb, theirs)) < 0)
|
290
296
|
goto done;
|
291
297
|
|
292
298
|
error = merge_file__from_inputs(out,
|
@@ -28,8 +28,10 @@ int git_message_prettify(git_buf *message_out, const char *message, int strip_co
|
|
28
28
|
int consecutive_empty_lines = 0;
|
29
29
|
size_t i, line_length, rtrimmed_line_length;
|
30
30
|
char *next_newline;
|
31
|
+
int error;
|
31
32
|
|
32
|
-
git_buf_sanitize(message_out)
|
33
|
+
if ((error = git_buf_sanitize(message_out)) < 0)
|
34
|
+
return error;
|
33
35
|
|
34
36
|
for (i = 0; i < strlen(message); i += line_length) {
|
35
37
|
next_newline = memchr(message + i, '\n', message_len - i);
|
@@ -0,0 +1,879 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "midx.h"
|
9
|
+
|
10
|
+
#include "array.h"
|
11
|
+
#include "buffer.h"
|
12
|
+
#include "filebuf.h"
|
13
|
+
#include "futils.h"
|
14
|
+
#include "hash.h"
|
15
|
+
#include "odb.h"
|
16
|
+
#include "pack.h"
|
17
|
+
#include "path.h"
|
18
|
+
#include "repository.h"
|
19
|
+
|
20
|
+
#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
|
21
|
+
#define MIDX_VERSION 1
|
22
|
+
#define MIDX_OBJECT_ID_VERSION 1
|
23
|
+
struct git_midx_header {
|
24
|
+
uint32_t signature;
|
25
|
+
uint8_t version;
|
26
|
+
uint8_t object_id_version;
|
27
|
+
uint8_t chunks;
|
28
|
+
uint8_t base_midx_files;
|
29
|
+
uint32_t packfiles;
|
30
|
+
};
|
31
|
+
|
32
|
+
#define MIDX_PACKFILE_NAMES_ID 0x504e414d /* "PNAM" */
|
33
|
+
#define MIDX_OID_FANOUT_ID 0x4f494446 /* "OIDF" */
|
34
|
+
#define MIDX_OID_LOOKUP_ID 0x4f49444c /* "OIDL" */
|
35
|
+
#define MIDX_OBJECT_OFFSETS_ID 0x4f4f4646 /* "OOFF" */
|
36
|
+
#define MIDX_OBJECT_LARGE_OFFSETS_ID 0x4c4f4646 /* "LOFF" */
|
37
|
+
|
38
|
+
struct git_midx_chunk {
|
39
|
+
off64_t offset;
|
40
|
+
size_t length;
|
41
|
+
};
|
42
|
+
|
43
|
+
typedef int (*midx_write_cb)(const char *buf, size_t size, void *cb_data);
|
44
|
+
|
45
|
+
static int midx_error(const char *message)
|
46
|
+
{
|
47
|
+
git_error_set(GIT_ERROR_ODB, "invalid multi-pack-index file - %s", message);
|
48
|
+
return -1;
|
49
|
+
}
|
50
|
+
|
51
|
+
static int midx_parse_packfile_names(
|
52
|
+
git_midx_file *idx,
|
53
|
+
const unsigned char *data,
|
54
|
+
uint32_t packfiles,
|
55
|
+
struct git_midx_chunk *chunk)
|
56
|
+
{
|
57
|
+
int error;
|
58
|
+
uint32_t i;
|
59
|
+
char *packfile_name = (char *)(data + chunk->offset);
|
60
|
+
size_t chunk_size = chunk->length, len;
|
61
|
+
if (chunk->offset == 0)
|
62
|
+
return midx_error("missing Packfile Names chunk");
|
63
|
+
if (chunk->length == 0)
|
64
|
+
return midx_error("empty Packfile Names chunk");
|
65
|
+
if ((error = git_vector_init(&idx->packfile_names, packfiles, git__strcmp_cb)) < 0)
|
66
|
+
return error;
|
67
|
+
for (i = 0; i < packfiles; ++i) {
|
68
|
+
len = p_strnlen(packfile_name, chunk_size);
|
69
|
+
if (len == 0)
|
70
|
+
return midx_error("empty packfile name");
|
71
|
+
if (len + 1 > chunk_size)
|
72
|
+
return midx_error("unterminated packfile name");
|
73
|
+
git_vector_insert(&idx->packfile_names, packfile_name);
|
74
|
+
if (i && strcmp(git_vector_get(&idx->packfile_names, i - 1), packfile_name) >= 0)
|
75
|
+
return midx_error("packfile names are not sorted");
|
76
|
+
if (strlen(packfile_name) <= strlen(".idx") || git__suffixcmp(packfile_name, ".idx") != 0)
|
77
|
+
return midx_error("non-.idx packfile name");
|
78
|
+
if (strchr(packfile_name, '/') != NULL || strchr(packfile_name, '\\') != NULL)
|
79
|
+
return midx_error("non-local packfile");
|
80
|
+
packfile_name += len + 1;
|
81
|
+
chunk_size -= len + 1;
|
82
|
+
}
|
83
|
+
return 0;
|
84
|
+
}
|
85
|
+
|
86
|
+
static int midx_parse_oid_fanout(
|
87
|
+
git_midx_file *idx,
|
88
|
+
const unsigned char *data,
|
89
|
+
struct git_midx_chunk *chunk_oid_fanout)
|
90
|
+
{
|
91
|
+
uint32_t i, nr;
|
92
|
+
if (chunk_oid_fanout->offset == 0)
|
93
|
+
return midx_error("missing OID Fanout chunk");
|
94
|
+
if (chunk_oid_fanout->length == 0)
|
95
|
+
return midx_error("empty OID Fanout chunk");
|
96
|
+
if (chunk_oid_fanout->length != 256 * 4)
|
97
|
+
return midx_error("OID Fanout chunk has wrong length");
|
98
|
+
|
99
|
+
idx->oid_fanout = (const uint32_t *)(data + chunk_oid_fanout->offset);
|
100
|
+
nr = 0;
|
101
|
+
for (i = 0; i < 256; ++i) {
|
102
|
+
uint32_t n = ntohl(idx->oid_fanout[i]);
|
103
|
+
if (n < nr)
|
104
|
+
return midx_error("index is non-monotonic");
|
105
|
+
nr = n;
|
106
|
+
}
|
107
|
+
idx->num_objects = nr;
|
108
|
+
return 0;
|
109
|
+
}
|
110
|
+
|
111
|
+
static int midx_parse_oid_lookup(
|
112
|
+
git_midx_file *idx,
|
113
|
+
const unsigned char *data,
|
114
|
+
struct git_midx_chunk *chunk_oid_lookup)
|
115
|
+
{
|
116
|
+
uint32_t i;
|
117
|
+
git_oid *oid, *prev_oid, zero_oid = {{0}};
|
118
|
+
|
119
|
+
if (chunk_oid_lookup->offset == 0)
|
120
|
+
return midx_error("missing OID Lookup chunk");
|
121
|
+
if (chunk_oid_lookup->length == 0)
|
122
|
+
return midx_error("empty OID Lookup chunk");
|
123
|
+
if (chunk_oid_lookup->length != idx->num_objects * GIT_OID_RAWSZ)
|
124
|
+
return midx_error("OID Lookup chunk has wrong length");
|
125
|
+
|
126
|
+
idx->oid_lookup = oid = (git_oid *)(data + chunk_oid_lookup->offset);
|
127
|
+
prev_oid = &zero_oid;
|
128
|
+
for (i = 0; i < idx->num_objects; ++i, ++oid) {
|
129
|
+
if (git_oid_cmp(prev_oid, oid) >= 0)
|
130
|
+
return midx_error("OID Lookup index is non-monotonic");
|
131
|
+
prev_oid = oid;
|
132
|
+
}
|
133
|
+
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
static int midx_parse_object_offsets(
|
138
|
+
git_midx_file *idx,
|
139
|
+
const unsigned char *data,
|
140
|
+
struct git_midx_chunk *chunk_object_offsets)
|
141
|
+
{
|
142
|
+
if (chunk_object_offsets->offset == 0)
|
143
|
+
return midx_error("missing Object Offsets chunk");
|
144
|
+
if (chunk_object_offsets->length == 0)
|
145
|
+
return midx_error("empty Object Offsets chunk");
|
146
|
+
if (chunk_object_offsets->length != idx->num_objects * 8)
|
147
|
+
return midx_error("Object Offsets chunk has wrong length");
|
148
|
+
|
149
|
+
idx->object_offsets = data + chunk_object_offsets->offset;
|
150
|
+
|
151
|
+
return 0;
|
152
|
+
}
|
153
|
+
|
154
|
+
static int midx_parse_object_large_offsets(
|
155
|
+
git_midx_file *idx,
|
156
|
+
const unsigned char *data,
|
157
|
+
struct git_midx_chunk *chunk_object_large_offsets)
|
158
|
+
{
|
159
|
+
if (chunk_object_large_offsets->length == 0)
|
160
|
+
return 0;
|
161
|
+
if (chunk_object_large_offsets->length % 8 != 0)
|
162
|
+
return midx_error("malformed Object Large Offsets chunk");
|
163
|
+
|
164
|
+
idx->object_large_offsets = data + chunk_object_large_offsets->offset;
|
165
|
+
idx->num_object_large_offsets = chunk_object_large_offsets->length / 8;
|
166
|
+
|
167
|
+
return 0;
|
168
|
+
}
|
169
|
+
|
170
|
+
int git_midx_parse(
|
171
|
+
git_midx_file *idx,
|
172
|
+
const unsigned char *data,
|
173
|
+
size_t size)
|
174
|
+
{
|
175
|
+
struct git_midx_header *hdr;
|
176
|
+
const unsigned char *chunk_hdr;
|
177
|
+
struct git_midx_chunk *last_chunk;
|
178
|
+
uint32_t i;
|
179
|
+
off64_t last_chunk_offset, chunk_offset, trailer_offset;
|
180
|
+
git_oid idx_checksum = {{0}};
|
181
|
+
int error;
|
182
|
+
struct git_midx_chunk chunk_packfile_names = {0},
|
183
|
+
chunk_oid_fanout = {0},
|
184
|
+
chunk_oid_lookup = {0},
|
185
|
+
chunk_object_offsets = {0},
|
186
|
+
chunk_object_large_offsets = {0};
|
187
|
+
|
188
|
+
GIT_ASSERT_ARG(idx);
|
189
|
+
|
190
|
+
if (size < sizeof(struct git_midx_header) + GIT_OID_RAWSZ)
|
191
|
+
return midx_error("multi-pack index is too short");
|
192
|
+
|
193
|
+
hdr = ((struct git_midx_header *)data);
|
194
|
+
|
195
|
+
if (hdr->signature != htonl(MIDX_SIGNATURE) ||
|
196
|
+
hdr->version != MIDX_VERSION ||
|
197
|
+
hdr->object_id_version != MIDX_OBJECT_ID_VERSION) {
|
198
|
+
return midx_error("unsupported multi-pack index version");
|
199
|
+
}
|
200
|
+
if (hdr->chunks == 0)
|
201
|
+
return midx_error("no chunks in multi-pack index");
|
202
|
+
|
203
|
+
/*
|
204
|
+
* The very first chunk's offset should be after the header, all the chunk
|
205
|
+
* headers, and a special zero chunk.
|
206
|
+
*/
|
207
|
+
last_chunk_offset =
|
208
|
+
sizeof(struct git_midx_header) +
|
209
|
+
(1 + hdr->chunks) * 12;
|
210
|
+
trailer_offset = size - GIT_OID_RAWSZ;
|
211
|
+
if (trailer_offset < last_chunk_offset)
|
212
|
+
return midx_error("wrong index size");
|
213
|
+
git_oid_cpy(&idx->checksum, (git_oid *)(data + trailer_offset));
|
214
|
+
|
215
|
+
if (git_hash_buf(&idx_checksum, data, (size_t)trailer_offset) < 0)
|
216
|
+
return midx_error("could not calculate signature");
|
217
|
+
if (!git_oid_equal(&idx_checksum, &idx->checksum))
|
218
|
+
return midx_error("index signature mismatch");
|
219
|
+
|
220
|
+
chunk_hdr = data + sizeof(struct git_midx_header);
|
221
|
+
last_chunk = NULL;
|
222
|
+
for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
|
223
|
+
chunk_offset = ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32 |
|
224
|
+
((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 8))));
|
225
|
+
if (chunk_offset < last_chunk_offset)
|
226
|
+
return midx_error("chunks are non-monotonic");
|
227
|
+
if (chunk_offset >= trailer_offset)
|
228
|
+
return midx_error("chunks extend beyond the trailer");
|
229
|
+
if (last_chunk != NULL)
|
230
|
+
last_chunk->length = (size_t)(chunk_offset - last_chunk_offset);
|
231
|
+
last_chunk_offset = chunk_offset;
|
232
|
+
|
233
|
+
switch (ntohl(*((uint32_t *)(chunk_hdr + 0)))) {
|
234
|
+
case MIDX_PACKFILE_NAMES_ID:
|
235
|
+
chunk_packfile_names.offset = last_chunk_offset;
|
236
|
+
last_chunk = &chunk_packfile_names;
|
237
|
+
break;
|
238
|
+
|
239
|
+
case MIDX_OID_FANOUT_ID:
|
240
|
+
chunk_oid_fanout.offset = last_chunk_offset;
|
241
|
+
last_chunk = &chunk_oid_fanout;
|
242
|
+
break;
|
243
|
+
|
244
|
+
case MIDX_OID_LOOKUP_ID:
|
245
|
+
chunk_oid_lookup.offset = last_chunk_offset;
|
246
|
+
last_chunk = &chunk_oid_lookup;
|
247
|
+
break;
|
248
|
+
|
249
|
+
case MIDX_OBJECT_OFFSETS_ID:
|
250
|
+
chunk_object_offsets.offset = last_chunk_offset;
|
251
|
+
last_chunk = &chunk_object_offsets;
|
252
|
+
break;
|
253
|
+
|
254
|
+
case MIDX_OBJECT_LARGE_OFFSETS_ID:
|
255
|
+
chunk_object_large_offsets.offset = last_chunk_offset;
|
256
|
+
last_chunk = &chunk_object_large_offsets;
|
257
|
+
break;
|
258
|
+
|
259
|
+
default:
|
260
|
+
return midx_error("unrecognized chunk ID");
|
261
|
+
}
|
262
|
+
}
|
263
|
+
last_chunk->length = (size_t)(trailer_offset - last_chunk_offset);
|
264
|
+
|
265
|
+
error = midx_parse_packfile_names(
|
266
|
+
idx, data, ntohl(hdr->packfiles), &chunk_packfile_names);
|
267
|
+
if (error < 0)
|
268
|
+
return error;
|
269
|
+
error = midx_parse_oid_fanout(idx, data, &chunk_oid_fanout);
|
270
|
+
if (error < 0)
|
271
|
+
return error;
|
272
|
+
error = midx_parse_oid_lookup(idx, data, &chunk_oid_lookup);
|
273
|
+
if (error < 0)
|
274
|
+
return error;
|
275
|
+
error = midx_parse_object_offsets(idx, data, &chunk_object_offsets);
|
276
|
+
if (error < 0)
|
277
|
+
return error;
|
278
|
+
error = midx_parse_object_large_offsets(idx, data, &chunk_object_large_offsets);
|
279
|
+
if (error < 0)
|
280
|
+
return error;
|
281
|
+
|
282
|
+
return 0;
|
283
|
+
}
|
284
|
+
|
285
|
+
int git_midx_open(
|
286
|
+
git_midx_file **idx_out,
|
287
|
+
const char *path)
|
288
|
+
{
|
289
|
+
git_midx_file *idx;
|
290
|
+
git_file fd = -1;
|
291
|
+
size_t idx_size;
|
292
|
+
struct stat st;
|
293
|
+
int error;
|
294
|
+
|
295
|
+
/* TODO: properly open the file without access time using O_NOATIME */
|
296
|
+
fd = git_futils_open_ro(path);
|
297
|
+
if (fd < 0)
|
298
|
+
return fd;
|
299
|
+
|
300
|
+
if (p_fstat(fd, &st) < 0) {
|
301
|
+
p_close(fd);
|
302
|
+
git_error_set(GIT_ERROR_ODB, "multi-pack-index file not found - '%s'", path);
|
303
|
+
return -1;
|
304
|
+
}
|
305
|
+
|
306
|
+
if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)) {
|
307
|
+
p_close(fd);
|
308
|
+
git_error_set(GIT_ERROR_ODB, "invalid pack index '%s'", path);
|
309
|
+
return -1;
|
310
|
+
}
|
311
|
+
idx_size = (size_t)st.st_size;
|
312
|
+
|
313
|
+
idx = git__calloc(1, sizeof(git_midx_file));
|
314
|
+
GIT_ERROR_CHECK_ALLOC(idx);
|
315
|
+
|
316
|
+
error = git_buf_sets(&idx->filename, path);
|
317
|
+
if (error < 0)
|
318
|
+
return error;
|
319
|
+
|
320
|
+
error = git_futils_mmap_ro(&idx->index_map, fd, 0, idx_size);
|
321
|
+
p_close(fd);
|
322
|
+
if (error < 0) {
|
323
|
+
git_midx_free(idx);
|
324
|
+
return error;
|
325
|
+
}
|
326
|
+
|
327
|
+
if ((error = git_midx_parse(idx, idx->index_map.data, idx_size)) < 0) {
|
328
|
+
git_midx_free(idx);
|
329
|
+
return error;
|
330
|
+
}
|
331
|
+
|
332
|
+
*idx_out = idx;
|
333
|
+
return 0;
|
334
|
+
}
|
335
|
+
|
336
|
+
bool git_midx_needs_refresh(
|
337
|
+
const git_midx_file *idx,
|
338
|
+
const char *path)
|
339
|
+
{
|
340
|
+
git_file fd = -1;
|
341
|
+
struct stat st;
|
342
|
+
ssize_t bytes_read;
|
343
|
+
git_oid idx_checksum = {{0}};
|
344
|
+
|
345
|
+
/* TODO: properly open the file without access time using O_NOATIME */
|
346
|
+
fd = git_futils_open_ro(path);
|
347
|
+
if (fd < 0)
|
348
|
+
return true;
|
349
|
+
|
350
|
+
if (p_fstat(fd, &st) < 0) {
|
351
|
+
p_close(fd);
|
352
|
+
return true;
|
353
|
+
}
|
354
|
+
|
355
|
+
if (!S_ISREG(st.st_mode) ||
|
356
|
+
!git__is_sizet(st.st_size) ||
|
357
|
+
(size_t)st.st_size != idx->index_map.len) {
|
358
|
+
p_close(fd);
|
359
|
+
return true;
|
360
|
+
}
|
361
|
+
|
362
|
+
bytes_read = p_pread(fd, &idx_checksum, GIT_OID_RAWSZ, st.st_size - GIT_OID_RAWSZ);
|
363
|
+
p_close(fd);
|
364
|
+
|
365
|
+
if (bytes_read != GIT_OID_RAWSZ)
|
366
|
+
return true;
|
367
|
+
|
368
|
+
return !git_oid_equal(&idx_checksum, &idx->checksum);
|
369
|
+
}
|
370
|
+
|
371
|
+
int git_midx_entry_find(
|
372
|
+
git_midx_entry *e,
|
373
|
+
git_midx_file *idx,
|
374
|
+
const git_oid *short_oid,
|
375
|
+
size_t len)
|
376
|
+
{
|
377
|
+
int pos, found = 0;
|
378
|
+
size_t pack_index;
|
379
|
+
uint32_t hi, lo;
|
380
|
+
const git_oid *current = NULL;
|
381
|
+
const unsigned char *object_offset;
|
382
|
+
off64_t offset;
|
383
|
+
|
384
|
+
GIT_ASSERT_ARG(idx);
|
385
|
+
|
386
|
+
hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]);
|
387
|
+
lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
|
388
|
+
|
389
|
+
pos = git_pack__lookup_sha1(idx->oid_lookup, GIT_OID_RAWSZ, lo, hi, short_oid->id);
|
390
|
+
|
391
|
+
if (pos >= 0) {
|
392
|
+
/* An object matching exactly the oid was found */
|
393
|
+
found = 1;
|
394
|
+
current = idx->oid_lookup + pos;
|
395
|
+
} else {
|
396
|
+
/* No object was found */
|
397
|
+
/* pos refers to the object with the "closest" oid to short_oid */
|
398
|
+
pos = -1 - pos;
|
399
|
+
if (pos < (int)idx->num_objects) {
|
400
|
+
current = idx->oid_lookup + pos;
|
401
|
+
|
402
|
+
if (!git_oid_ncmp(short_oid, current, len))
|
403
|
+
found = 1;
|
404
|
+
}
|
405
|
+
}
|
406
|
+
|
407
|
+
if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) {
|
408
|
+
/* Check for ambiguousity */
|
409
|
+
const git_oid *next = current + 1;
|
410
|
+
|
411
|
+
if (!git_oid_ncmp(short_oid, next, len)) {
|
412
|
+
found = 2;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
if (!found)
|
417
|
+
return git_odb__error_notfound("failed to find offset for multi-pack index entry", short_oid, len);
|
418
|
+
if (found > 1)
|
419
|
+
return git_odb__error_ambiguous("found multiple offsets for multi-pack index entry");
|
420
|
+
|
421
|
+
object_offset = idx->object_offsets + pos * 8;
|
422
|
+
offset = ntohl(*((uint32_t *)(object_offset + 4)));
|
423
|
+
if (offset & 0x80000000) {
|
424
|
+
uint32_t object_large_offsets_pos = offset & 0x7fffffff;
|
425
|
+
const unsigned char *object_large_offsets_index = idx->object_large_offsets;
|
426
|
+
|
427
|
+
/* Make sure we're not being sent out of bounds */
|
428
|
+
if (object_large_offsets_pos >= idx->num_object_large_offsets)
|
429
|
+
return git_odb__error_notfound("invalid index into the object large offsets table", short_oid, len);
|
430
|
+
|
431
|
+
object_large_offsets_index += 8 * object_large_offsets_pos;
|
432
|
+
|
433
|
+
offset = (((uint64_t)ntohl(*((uint32_t *)(object_large_offsets_index + 0)))) << 32) |
|
434
|
+
ntohl(*((uint32_t *)(object_large_offsets_index + 4)));
|
435
|
+
}
|
436
|
+
pack_index = ntohl(*((uint32_t *)(object_offset + 0)));
|
437
|
+
if (pack_index >= git_vector_length(&idx->packfile_names))
|
438
|
+
return midx_error("invalid index into the packfile names table");
|
439
|
+
e->pack_index = pack_index;
|
440
|
+
e->offset = offset;
|
441
|
+
git_oid_cpy(&e->sha1, current);
|
442
|
+
return 0;
|
443
|
+
}
|
444
|
+
|
445
|
+
int git_midx_foreach_entry(
|
446
|
+
git_midx_file *idx,
|
447
|
+
git_odb_foreach_cb cb,
|
448
|
+
void *data)
|
449
|
+
{
|
450
|
+
size_t i;
|
451
|
+
int error;
|
452
|
+
|
453
|
+
GIT_ASSERT_ARG(idx);
|
454
|
+
|
455
|
+
for (i = 0; i < idx->num_objects; ++i) {
|
456
|
+
if ((error = cb(&idx->oid_lookup[i], data)) != 0)
|
457
|
+
return git_error_set_after_callback(error);
|
458
|
+
}
|
459
|
+
|
460
|
+
return error;
|
461
|
+
}
|
462
|
+
|
463
|
+
int git_midx_close(git_midx_file *idx)
|
464
|
+
{
|
465
|
+
GIT_ASSERT_ARG(idx);
|
466
|
+
|
467
|
+
if (idx->index_map.data)
|
468
|
+
git_futils_mmap_free(&idx->index_map);
|
469
|
+
|
470
|
+
git_vector_free(&idx->packfile_names);
|
471
|
+
|
472
|
+
return 0;
|
473
|
+
}
|
474
|
+
|
475
|
+
void git_midx_free(git_midx_file *idx)
|
476
|
+
{
|
477
|
+
if (!idx)
|
478
|
+
return;
|
479
|
+
|
480
|
+
git_buf_dispose(&idx->filename);
|
481
|
+
git_midx_close(idx);
|
482
|
+
git__free(idx);
|
483
|
+
}
|
484
|
+
|
485
|
+
static int packfile__cmp(const void *a_, const void *b_)
|
486
|
+
{
|
487
|
+
const struct git_pack_file *a = a_;
|
488
|
+
const struct git_pack_file *b = b_;
|
489
|
+
|
490
|
+
return strcmp(a->pack_name, b->pack_name);
|
491
|
+
}
|
492
|
+
|
493
|
+
int git_midx_writer_new(
|
494
|
+
git_midx_writer **out,
|
495
|
+
const char *pack_dir)
|
496
|
+
{
|
497
|
+
git_midx_writer *w = git__calloc(1, sizeof(git_midx_writer));
|
498
|
+
GIT_ERROR_CHECK_ALLOC(w);
|
499
|
+
|
500
|
+
if (git_buf_sets(&w->pack_dir, pack_dir) < 0) {
|
501
|
+
git__free(w);
|
502
|
+
return -1;
|
503
|
+
}
|
504
|
+
git_path_squash_slashes(&w->pack_dir);
|
505
|
+
|
506
|
+
if (git_vector_init(&w->packs, 0, packfile__cmp) < 0) {
|
507
|
+
git_buf_dispose(&w->pack_dir);
|
508
|
+
git__free(w);
|
509
|
+
return -1;
|
510
|
+
}
|
511
|
+
|
512
|
+
*out = w;
|
513
|
+
return 0;
|
514
|
+
}
|
515
|
+
|
516
|
+
void git_midx_writer_free(git_midx_writer *w)
|
517
|
+
{
|
518
|
+
struct git_pack_file *p;
|
519
|
+
size_t i;
|
520
|
+
|
521
|
+
if (!w)
|
522
|
+
return;
|
523
|
+
|
524
|
+
git_vector_foreach (&w->packs, i, p)
|
525
|
+
git_mwindow_put_pack(p);
|
526
|
+
git_vector_free(&w->packs);
|
527
|
+
git_buf_dispose(&w->pack_dir);
|
528
|
+
git__free(w);
|
529
|
+
}
|
530
|
+
|
531
|
+
int git_midx_writer_add(
|
532
|
+
git_midx_writer *w,
|
533
|
+
const char *idx_path)
|
534
|
+
{
|
535
|
+
git_buf idx_path_buf = GIT_BUF_INIT;
|
536
|
+
int error;
|
537
|
+
struct git_pack_file *p;
|
538
|
+
|
539
|
+
error = git_path_prettify(&idx_path_buf, idx_path, git_buf_cstr(&w->pack_dir));
|
540
|
+
if (error < 0)
|
541
|
+
return error;
|
542
|
+
|
543
|
+
error = git_mwindow_get_pack(&p, git_buf_cstr(&idx_path_buf));
|
544
|
+
git_buf_dispose(&idx_path_buf);
|
545
|
+
if (error < 0)
|
546
|
+
return error;
|
547
|
+
|
548
|
+
error = git_vector_insert(&w->packs, p);
|
549
|
+
if (error < 0) {
|
550
|
+
git_mwindow_put_pack(p);
|
551
|
+
return error;
|
552
|
+
}
|
553
|
+
|
554
|
+
return 0;
|
555
|
+
}
|
556
|
+
|
557
|
+
typedef git_array_t(git_midx_entry) object_entry_array_t;
|
558
|
+
|
559
|
+
struct object_entry_cb_state {
|
560
|
+
uint32_t pack_index;
|
561
|
+
object_entry_array_t *object_entries_array;
|
562
|
+
};
|
563
|
+
|
564
|
+
static int object_entry__cb(const git_oid *oid, off64_t offset, void *data)
|
565
|
+
{
|
566
|
+
struct object_entry_cb_state *state = (struct object_entry_cb_state *)data;
|
567
|
+
|
568
|
+
git_midx_entry *entry = git_array_alloc(*state->object_entries_array);
|
569
|
+
GIT_ERROR_CHECK_ALLOC(entry);
|
570
|
+
|
571
|
+
git_oid_cpy(&entry->sha1, oid);
|
572
|
+
entry->offset = offset;
|
573
|
+
entry->pack_index = state->pack_index;
|
574
|
+
|
575
|
+
return 0;
|
576
|
+
}
|
577
|
+
|
578
|
+
static int object_entry__cmp(const void *a_, const void *b_)
|
579
|
+
{
|
580
|
+
const git_midx_entry *a = (const git_midx_entry *)a_;
|
581
|
+
const git_midx_entry *b = (const git_midx_entry *)b_;
|
582
|
+
|
583
|
+
return git_oid_cmp(&a->sha1, &b->sha1);
|
584
|
+
}
|
585
|
+
|
586
|
+
static int write_offset(off64_t offset, midx_write_cb write_cb, void *cb_data)
|
587
|
+
{
|
588
|
+
int error;
|
589
|
+
uint32_t word;
|
590
|
+
|
591
|
+
word = htonl((uint32_t)((offset >> 32) & 0xffffffffu));
|
592
|
+
error = write_cb((const char *)&word, sizeof(word), cb_data);
|
593
|
+
if (error < 0)
|
594
|
+
return error;
|
595
|
+
word = htonl((uint32_t)((offset >> 0) & 0xffffffffu));
|
596
|
+
error = write_cb((const char *)&word, sizeof(word), cb_data);
|
597
|
+
if (error < 0)
|
598
|
+
return error;
|
599
|
+
|
600
|
+
return 0;
|
601
|
+
}
|
602
|
+
|
603
|
+
static int write_chunk_header(int chunk_id, off64_t offset, midx_write_cb write_cb, void *cb_data)
|
604
|
+
{
|
605
|
+
uint32_t word = htonl(chunk_id);
|
606
|
+
int error = write_cb((const char *)&word, sizeof(word), cb_data);
|
607
|
+
if (error < 0)
|
608
|
+
return error;
|
609
|
+
return write_offset(offset, write_cb, cb_data);
|
610
|
+
|
611
|
+
return 0;
|
612
|
+
}
|
613
|
+
|
614
|
+
static int midx_write_buf(const char *buf, size_t size, void *data)
|
615
|
+
{
|
616
|
+
git_buf *b = (git_buf *)data;
|
617
|
+
return git_buf_put(b, buf, size);
|
618
|
+
}
|
619
|
+
|
620
|
+
struct midx_write_hash_context {
|
621
|
+
midx_write_cb write_cb;
|
622
|
+
void *cb_data;
|
623
|
+
git_hash_ctx *ctx;
|
624
|
+
};
|
625
|
+
|
626
|
+
static int midx_write_hash(const char *buf, size_t size, void *data)
|
627
|
+
{
|
628
|
+
struct midx_write_hash_context *ctx = (struct midx_write_hash_context *)data;
|
629
|
+
int error;
|
630
|
+
|
631
|
+
error = git_hash_update(ctx->ctx, buf, size);
|
632
|
+
if (error < 0)
|
633
|
+
return error;
|
634
|
+
|
635
|
+
return ctx->write_cb(buf, size, ctx->cb_data);
|
636
|
+
}
|
637
|
+
|
638
|
+
static int midx_write(
|
639
|
+
git_midx_writer *w,
|
640
|
+
midx_write_cb write_cb,
|
641
|
+
void *cb_data)
|
642
|
+
{
|
643
|
+
int error = 0;
|
644
|
+
size_t i;
|
645
|
+
struct git_pack_file *p;
|
646
|
+
struct git_midx_header hdr = {0};
|
647
|
+
uint32_t oid_fanout_count;
|
648
|
+
uint32_t object_large_offsets_count;
|
649
|
+
uint32_t oid_fanout[256];
|
650
|
+
off64_t offset;
|
651
|
+
git_buf packfile_names = GIT_BUF_INIT,
|
652
|
+
oid_lookup = GIT_BUF_INIT,
|
653
|
+
object_offsets = GIT_BUF_INIT,
|
654
|
+
object_large_offsets = GIT_BUF_INIT;
|
655
|
+
git_oid idx_checksum = {{0}};
|
656
|
+
git_midx_entry *entry;
|
657
|
+
object_entry_array_t object_entries_array = GIT_ARRAY_INIT;
|
658
|
+
git_vector object_entries = GIT_VECTOR_INIT;
|
659
|
+
git_hash_ctx ctx;
|
660
|
+
struct midx_write_hash_context hash_cb_data = {0};
|
661
|
+
|
662
|
+
hdr.signature = htonl(MIDX_SIGNATURE);
|
663
|
+
hdr.version = MIDX_VERSION;
|
664
|
+
hdr.object_id_version = MIDX_OBJECT_ID_VERSION;
|
665
|
+
hdr.base_midx_files = 0;
|
666
|
+
|
667
|
+
hash_cb_data.write_cb = write_cb;
|
668
|
+
hash_cb_data.cb_data = cb_data;
|
669
|
+
hash_cb_data.ctx = &ctx;
|
670
|
+
|
671
|
+
error = git_hash_ctx_init(&ctx);
|
672
|
+
if (error < 0)
|
673
|
+
return error;
|
674
|
+
cb_data = &hash_cb_data;
|
675
|
+
write_cb = midx_write_hash;
|
676
|
+
|
677
|
+
git_vector_sort(&w->packs);
|
678
|
+
git_vector_foreach (&w->packs, i, p) {
|
679
|
+
git_buf relative_index = GIT_BUF_INIT;
|
680
|
+
struct object_entry_cb_state state = {0};
|
681
|
+
size_t path_len;
|
682
|
+
|
683
|
+
state.pack_index = (uint32_t)i;
|
684
|
+
state.object_entries_array = &object_entries_array;
|
685
|
+
|
686
|
+
error = git_buf_sets(&relative_index, p->pack_name);
|
687
|
+
if (error < 0)
|
688
|
+
goto cleanup;
|
689
|
+
error = git_path_make_relative(&relative_index, git_buf_cstr(&w->pack_dir));
|
690
|
+
if (error < 0) {
|
691
|
+
git_buf_dispose(&relative_index);
|
692
|
+
goto cleanup;
|
693
|
+
}
|
694
|
+
path_len = git_buf_len(&relative_index);
|
695
|
+
if (path_len <= strlen(".pack") || git__suffixcmp(git_buf_cstr(&relative_index), ".pack") != 0) {
|
696
|
+
git_buf_dispose(&relative_index);
|
697
|
+
git_error_set(GIT_ERROR_INVALID, "invalid packfile name: '%s'", p->pack_name);
|
698
|
+
error = -1;
|
699
|
+
goto cleanup;
|
700
|
+
}
|
701
|
+
path_len -= strlen(".pack");
|
702
|
+
|
703
|
+
git_buf_put(&packfile_names, git_buf_cstr(&relative_index), path_len);
|
704
|
+
git_buf_puts(&packfile_names, ".idx");
|
705
|
+
git_buf_putc(&packfile_names, '\0');
|
706
|
+
git_buf_dispose(&relative_index);
|
707
|
+
|
708
|
+
error = git_pack_foreach_entry_offset(p, object_entry__cb, &state);
|
709
|
+
if (error < 0)
|
710
|
+
goto cleanup;
|
711
|
+
}
|
712
|
+
|
713
|
+
/* Sort the object entries. */
|
714
|
+
error = git_vector_init(&object_entries, git_array_size(object_entries_array), object_entry__cmp);
|
715
|
+
if (error < 0)
|
716
|
+
goto cleanup;
|
717
|
+
git_array_foreach (object_entries_array, i, entry) {
|
718
|
+
if ((error = git_vector_set(NULL, &object_entries, i, entry)) < 0)
|
719
|
+
goto cleanup;
|
720
|
+
}
|
721
|
+
git_vector_set_sorted(&object_entries, 0);
|
722
|
+
git_vector_sort(&object_entries);
|
723
|
+
git_vector_uniq(&object_entries, NULL);
|
724
|
+
|
725
|
+
/* Pad the packfile names so it is a multiple of four. */
|
726
|
+
while (git_buf_len(&packfile_names) & 3)
|
727
|
+
git_buf_putc(&packfile_names, '\0');
|
728
|
+
|
729
|
+
/* Fill the OID Fanout table. */
|
730
|
+
oid_fanout_count = 0;
|
731
|
+
for (i = 0; i < 256; i++) {
|
732
|
+
while (oid_fanout_count < git_vector_length(&object_entries) &&
|
733
|
+
((const git_midx_entry *)git_vector_get(&object_entries, oid_fanout_count))->sha1.id[0] <= i)
|
734
|
+
++oid_fanout_count;
|
735
|
+
oid_fanout[i] = htonl(oid_fanout_count);
|
736
|
+
}
|
737
|
+
|
738
|
+
/* Fill the OID Lookup table. */
|
739
|
+
git_vector_foreach (&object_entries, i, entry) {
|
740
|
+
error = git_buf_put(&oid_lookup, (const char *)&entry->sha1, sizeof(entry->sha1));
|
741
|
+
if (error < 0)
|
742
|
+
goto cleanup;
|
743
|
+
}
|
744
|
+
|
745
|
+
/* Fill the Object Offsets and Object Large Offsets tables. */
|
746
|
+
object_large_offsets_count = 0;
|
747
|
+
git_vector_foreach (&object_entries, i, entry) {
|
748
|
+
uint32_t word;
|
749
|
+
|
750
|
+
word = htonl((uint32_t)entry->pack_index);
|
751
|
+
error = git_buf_put(&object_offsets, (const char *)&word, sizeof(word));
|
752
|
+
if (error < 0)
|
753
|
+
goto cleanup;
|
754
|
+
if (entry->offset >= 0x80000000l) {
|
755
|
+
word = htonl(0x80000000u | object_large_offsets_count++);
|
756
|
+
if ((error = write_offset(entry->offset, midx_write_buf, &object_large_offsets)) < 0)
|
757
|
+
goto cleanup;
|
758
|
+
} else {
|
759
|
+
word = htonl((uint32_t)entry->offset & 0x7fffffffu);
|
760
|
+
}
|
761
|
+
|
762
|
+
error = git_buf_put(&object_offsets, (const char *)&word, sizeof(word));
|
763
|
+
if (error < 0)
|
764
|
+
goto cleanup;
|
765
|
+
}
|
766
|
+
|
767
|
+
/* Write the header. */
|
768
|
+
hdr.packfiles = htonl((uint32_t)git_vector_length(&w->packs));
|
769
|
+
hdr.chunks = 4;
|
770
|
+
if (git_buf_len(&object_large_offsets) > 0)
|
771
|
+
hdr.chunks++;
|
772
|
+
error = write_cb((const char *)&hdr, sizeof(hdr), cb_data);
|
773
|
+
if (error < 0)
|
774
|
+
goto cleanup;
|
775
|
+
|
776
|
+
/* Write the chunk headers. */
|
777
|
+
offset = sizeof(hdr) + (hdr.chunks + 1) * 12;
|
778
|
+
error = write_chunk_header(MIDX_PACKFILE_NAMES_ID, offset, write_cb, cb_data);
|
779
|
+
if (error < 0)
|
780
|
+
goto cleanup;
|
781
|
+
offset += git_buf_len(&packfile_names);
|
782
|
+
error = write_chunk_header(MIDX_OID_FANOUT_ID, offset, write_cb, cb_data);
|
783
|
+
if (error < 0)
|
784
|
+
goto cleanup;
|
785
|
+
offset += sizeof(oid_fanout);
|
786
|
+
error = write_chunk_header(MIDX_OID_LOOKUP_ID, offset, write_cb, cb_data);
|
787
|
+
if (error < 0)
|
788
|
+
goto cleanup;
|
789
|
+
offset += git_buf_len(&oid_lookup);
|
790
|
+
error = write_chunk_header(MIDX_OBJECT_OFFSETS_ID, offset, write_cb, cb_data);
|
791
|
+
if (error < 0)
|
792
|
+
goto cleanup;
|
793
|
+
offset += git_buf_len(&object_offsets);
|
794
|
+
if (git_buf_len(&object_large_offsets) > 0) {
|
795
|
+
error = write_chunk_header(MIDX_OBJECT_LARGE_OFFSETS_ID, offset, write_cb, cb_data);
|
796
|
+
if (error < 0)
|
797
|
+
goto cleanup;
|
798
|
+
offset += git_buf_len(&object_large_offsets);
|
799
|
+
}
|
800
|
+
error = write_chunk_header(0, offset, write_cb, cb_data);
|
801
|
+
if (error < 0)
|
802
|
+
goto cleanup;
|
803
|
+
|
804
|
+
/* Write all the chunks. */
|
805
|
+
error = write_cb(git_buf_cstr(&packfile_names), git_buf_len(&packfile_names), cb_data);
|
806
|
+
if (error < 0)
|
807
|
+
goto cleanup;
|
808
|
+
error = write_cb((const char *)oid_fanout, sizeof(oid_fanout), cb_data);
|
809
|
+
if (error < 0)
|
810
|
+
goto cleanup;
|
811
|
+
error = write_cb(git_buf_cstr(&oid_lookup), git_buf_len(&oid_lookup), cb_data);
|
812
|
+
if (error < 0)
|
813
|
+
goto cleanup;
|
814
|
+
error = write_cb(git_buf_cstr(&object_offsets), git_buf_len(&object_offsets), cb_data);
|
815
|
+
if (error < 0)
|
816
|
+
goto cleanup;
|
817
|
+
error = write_cb(git_buf_cstr(&object_large_offsets), git_buf_len(&object_large_offsets), cb_data);
|
818
|
+
if (error < 0)
|
819
|
+
goto cleanup;
|
820
|
+
|
821
|
+
/* Finalize the checksum and write the trailer. */
|
822
|
+
error = git_hash_final(&idx_checksum, &ctx);
|
823
|
+
if (error < 0)
|
824
|
+
goto cleanup;
|
825
|
+
error = write_cb((const char *)&idx_checksum, sizeof(idx_checksum), cb_data);
|
826
|
+
if (error < 0)
|
827
|
+
goto cleanup;
|
828
|
+
|
829
|
+
cleanup:
|
830
|
+
git_array_clear(object_entries_array);
|
831
|
+
git_vector_free(&object_entries);
|
832
|
+
git_buf_dispose(&packfile_names);
|
833
|
+
git_buf_dispose(&oid_lookup);
|
834
|
+
git_buf_dispose(&object_offsets);
|
835
|
+
git_buf_dispose(&object_large_offsets);
|
836
|
+
git_hash_ctx_cleanup(&ctx);
|
837
|
+
return error;
|
838
|
+
}
|
839
|
+
|
840
|
+
static int midx_write_filebuf(const char *buf, size_t size, void *data)
|
841
|
+
{
|
842
|
+
git_filebuf *f = (git_filebuf *)data;
|
843
|
+
return git_filebuf_write(f, buf, size);
|
844
|
+
}
|
845
|
+
|
846
|
+
int git_midx_writer_commit(
|
847
|
+
git_midx_writer *w)
|
848
|
+
{
|
849
|
+
int error;
|
850
|
+
int filebuf_flags = GIT_FILEBUF_DO_NOT_BUFFER;
|
851
|
+
git_buf midx_path = GIT_BUF_INIT;
|
852
|
+
git_filebuf output = GIT_FILEBUF_INIT;
|
853
|
+
|
854
|
+
error = git_buf_joinpath(&midx_path, git_buf_cstr(&w->pack_dir), "multi-pack-index");
|
855
|
+
if (error < 0)
|
856
|
+
return error;
|
857
|
+
|
858
|
+
if (git_repository__fsync_gitdir)
|
859
|
+
filebuf_flags |= GIT_FILEBUF_FSYNC;
|
860
|
+
error = git_filebuf_open(&output, git_buf_cstr(&midx_path), filebuf_flags, 0644);
|
861
|
+
git_buf_dispose(&midx_path);
|
862
|
+
if (error < 0)
|
863
|
+
return error;
|
864
|
+
|
865
|
+
error = midx_write(w, midx_write_filebuf, &output);
|
866
|
+
if (error < 0) {
|
867
|
+
git_filebuf_cleanup(&output);
|
868
|
+
return error;
|
869
|
+
}
|
870
|
+
|
871
|
+
return git_filebuf_commit(&output);
|
872
|
+
}
|
873
|
+
|
874
|
+
int git_midx_writer_dump(
|
875
|
+
git_buf *midx,
|
876
|
+
git_midx_writer *w)
|
877
|
+
{
|
878
|
+
return midx_write(w, midx_write_buf, midx);
|
879
|
+
}
|