rugged 1.1.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/extconf.rb +2 -2
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_config.c +7 -2
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_remote.c +17 -0
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +103 -271
- data/vendor/libgit2/COPYING +149 -24
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
- data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
- data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +154 -122
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +106 -2
- data/vendor/libgit2/include/git2/blame.h +97 -43
- data/vendor/libgit2/include/git2/blob.h +33 -2
- data/vendor/libgit2/include/git2/branch.h +27 -0
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +43 -6
- data/vendor/libgit2/include/git2/checkout.h +32 -13
- data/vendor/libgit2/include/git2/clone.h +4 -4
- data/vendor/libgit2/include/git2/commit.h +37 -19
- data/vendor/libgit2/include/git2/common.h +46 -5
- data/vendor/libgit2/include/git2/config.h +19 -3
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +326 -6
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +50 -121
- data/vendor/libgit2/include/git2/email.h +127 -0
- data/vendor/libgit2/include/git2/errors.h +7 -6
- data/vendor/libgit2/include/git2/filter.h +69 -18
- data/vendor/libgit2/include/git2/graph.h +21 -2
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +13 -7
- data/vendor/libgit2/include/git2/indexer.h +19 -0
- data/vendor/libgit2/include/git2/merge.h +23 -3
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/notes.h +2 -2
- data/vendor/libgit2/include/git2/object.h +23 -0
- data/vendor/libgit2/include/git2/odb.h +65 -6
- data/vendor/libgit2/include/git2/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/oidarray.h +5 -8
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +16 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +34 -2
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +8 -4
- data/vendor/libgit2/include/git2/remote.h +246 -46
- data/vendor/libgit2/include/git2/repository.h +25 -18
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +4 -4
- data/vendor/libgit2/include/git2/status.h +124 -62
- data/vendor/libgit2/include/git2/stdint.h +3 -3
- data/vendor/libgit2/include/git2/submodule.h +16 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/email.h +45 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +9 -5
- data/vendor/libgit2/include/git2/sys/remote.h +31 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +26 -34
- data/vendor/libgit2/include/git2/tag.h +13 -0
- data/vendor/libgit2/include/git2/tree.h +4 -17
- data/vendor/libgit2/include/git2/types.h +16 -7
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +13 -2
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +192 -290
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/annotated_commit.h +1 -1
- data/vendor/libgit2/src/apply.c +34 -25
- data/vendor/libgit2/src/apply.h +2 -2
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +204 -82
- data/vendor/libgit2/src/attr_file.c +105 -52
- data/vendor/libgit2/src/attr_file.h +36 -15
- data/vendor/libgit2/src/attrcache.c +55 -45
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +15 -9
- data/vendor/libgit2/src/blame_git.c +2 -2
- data/vendor/libgit2/src/blob.c +76 -52
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +203 -110
- data/vendor/libgit2/src/branch.h +15 -3
- data/vendor/libgit2/src/buf.c +126 -0
- data/vendor/libgit2/src/buf.h +50 -0
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +11 -9
- data/vendor/libgit2/src/checkout.c +118 -91
- data/vendor/libgit2/src/cherrypick.c +16 -12
- data/vendor/libgit2/src/clone.c +97 -103
- data/vendor/libgit2/src/commit.c +167 -84
- data/vendor/libgit2/src/commit.h +24 -1
- data/vendor/libgit2/src/commit_graph.c +1224 -0
- data/vendor/libgit2/src/commit_graph.h +169 -0
- data/vendor/libgit2/src/commit_list.c +48 -3
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +35 -5
- data/vendor/libgit2/src/config.c +119 -64
- data/vendor/libgit2/src/config.h +15 -2
- data/vendor/libgit2/src/config_cache.c +5 -3
- data/vendor/libgit2/src/config_file.c +120 -100
- data/vendor/libgit2/src/config_mem.c +9 -9
- data/vendor/libgit2/src/config_parse.c +29 -27
- data/vendor/libgit2/src/crlf.c +36 -23
- data/vendor/libgit2/src/date.c +13 -19
- data/vendor/libgit2/src/date.h +33 -0
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +32 -21
- data/vendor/libgit2/src/diff.c +71 -183
- data/vendor/libgit2/src/diff.h +2 -4
- data/vendor/libgit2/src/diff_driver.c +53 -51
- data/vendor/libgit2/src/diff_driver.h +3 -3
- data/vendor/libgit2/src/diff_file.c +31 -26
- data/vendor/libgit2/src/diff_generate.c +76 -23
- data/vendor/libgit2/src/diff_generate.h +5 -3
- data/vendor/libgit2/src/diff_print.c +120 -95
- data/vendor/libgit2/src/diff_stats.c +47 -34
- data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
- data/vendor/libgit2/src/diff_tform.c +18 -16
- data/vendor/libgit2/src/diff_xdiff.c +7 -10
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/email.c +315 -0
- data/vendor/libgit2/src/email.h +25 -0
- data/vendor/libgit2/src/errors.c +37 -32
- data/vendor/libgit2/src/features.h.in +11 -2
- data/vendor/libgit2/src/fetch.c +77 -26
- data/vendor/libgit2/src/fetch.h +1 -1
- data/vendor/libgit2/src/fetchhead.c +27 -23
- data/vendor/libgit2/src/filebuf.c +36 -34
- data/vendor/libgit2/src/filebuf.h +1 -1
- data/vendor/libgit2/src/filter.c +278 -132
- data/vendor/libgit2/src/filter.h +46 -6
- data/vendor/libgit2/src/fs_path.c +2071 -0
- data/vendor/libgit2/src/fs_path.h +772 -0
- data/vendor/libgit2/src/futils.c +96 -90
- data/vendor/libgit2/src/futils.h +27 -15
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
- data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
- data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
- data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
- data/vendor/libgit2/src/hash/sha1.h +3 -1
- data/vendor/libgit2/src/hash.c +71 -36
- data/vendor/libgit2/src/hash.h +13 -13
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +30 -20
- data/vendor/libgit2/src/ignore.c +63 -46
- data/vendor/libgit2/src/ignore.h +2 -2
- data/vendor/libgit2/src/index.c +184 -149
- data/vendor/libgit2/src/index.h +7 -4
- data/vendor/libgit2/src/indexer.c +143 -89
- data/vendor/libgit2/src/integer.h +64 -2
- data/vendor/libgit2/src/iterator.c +93 -73
- data/vendor/libgit2/src/iterator.h +6 -6
- data/vendor/libgit2/src/khash.h +3 -12
- data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +60 -45
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +104 -61
- data/vendor/libgit2/src/merge.h +3 -15
- data/vendor/libgit2/src/merge_driver.c +21 -15
- data/vendor/libgit2/src/merge_file.c +24 -6
- data/vendor/libgit2/src/message.c +21 -8
- data/vendor/libgit2/src/midx.c +501 -18
- data/vendor/libgit2/src/midx.h +29 -2
- data/vendor/libgit2/src/mwindow.c +103 -59
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +405 -71
- data/vendor/libgit2/src/net.h +26 -5
- data/vendor/libgit2/src/netops.c +7 -5
- data/vendor/libgit2/src/netops.h +3 -3
- data/vendor/libgit2/src/notes.c +40 -49
- data/vendor/libgit2/src/object.c +68 -20
- data/vendor/libgit2/src/object.h +1 -1
- data/vendor/libgit2/src/odb.c +320 -80
- data/vendor/libgit2/src/odb.h +17 -3
- data/vendor/libgit2/src/odb_loose.c +96 -86
- data/vendor/libgit2/src/odb_mempack.c +19 -6
- data/vendor/libgit2/src/odb_pack.c +402 -125
- data/vendor/libgit2/src/oid.c +16 -8
- data/vendor/libgit2/src/oid.h +15 -0
- data/vendor/libgit2/src/oidarray.c +10 -1
- data/vendor/libgit2/src/pack-objects.c +90 -69
- data/vendor/libgit2/src/pack-objects.h +11 -6
- data/vendor/libgit2/src/pack.c +337 -127
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +17 -10
- data/vendor/libgit2/src/patch.h +1 -0
- data/vendor/libgit2/src/patch_generate.c +29 -13
- data/vendor/libgit2/src/patch_generate.h +5 -5
- data/vendor/libgit2/src/patch_parse.c +26 -25
- data/vendor/libgit2/src/path.c +86 -1768
- data/vendor/libgit2/src/path.h +39 -635
- data/vendor/libgit2/src/pathspec.c +12 -12
- data/vendor/libgit2/src/pathspec.h +2 -2
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +14 -6
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/pqueue.h +1 -1
- data/vendor/libgit2/src/proxy.c +4 -1
- data/vendor/libgit2/src/proxy.h +1 -1
- data/vendor/libgit2/src/push.c +30 -35
- data/vendor/libgit2/src/push.h +4 -16
- data/vendor/libgit2/src/rand.c +226 -0
- data/vendor/libgit2/src/rand.h +37 -0
- data/vendor/libgit2/src/reader.c +18 -14
- data/vendor/libgit2/src/reader.h +2 -2
- data/vendor/libgit2/src/rebase.c +177 -132
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +548 -222
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +107 -72
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +53 -38
- data/vendor/libgit2/src/refspec.h +5 -2
- data/vendor/libgit2/src/regexp.c +1 -1
- data/vendor/libgit2/src/remote.c +960 -486
- data/vendor/libgit2/src/remote.h +16 -10
- data/vendor/libgit2/src/repository.c +702 -422
- data/vendor/libgit2/src/repository.h +26 -8
- data/vendor/libgit2/src/reset.c +16 -12
- data/vendor/libgit2/src/revert.c +16 -12
- data/vendor/libgit2/src/revparse.c +66 -48
- data/vendor/libgit2/src/revwalk.c +39 -22
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +18 -11
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +1 -1
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +39 -38
- data/vendor/libgit2/src/status.c +11 -5
- data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
- data/vendor/libgit2/src/str.h +357 -0
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +22 -23
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +290 -212
- data/vendor/libgit2/src/submodule.h +10 -10
- data/vendor/libgit2/src/sysdir.c +70 -56
- data/vendor/libgit2/src/sysdir.h +15 -10
- data/vendor/libgit2/src/tag.c +72 -34
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +84 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +3 -16
- data/vendor/libgit2/src/trace.h +17 -30
- data/vendor/libgit2/src/trailer.c +2 -2
- data/vendor/libgit2/src/transaction.c +20 -9
- data/vendor/libgit2/src/transport.c +13 -13
- data/vendor/libgit2/src/transports/auth.c +8 -10
- data/vendor/libgit2/src/transports/auth.h +2 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
- data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +10 -14
- data/vendor/libgit2/src/transports/http.c +56 -34
- data/vendor/libgit2/src/transports/http.h +3 -3
- data/vendor/libgit2/src/transports/httpclient.c +106 -79
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +127 -119
- data/vendor/libgit2/src/transports/smart.c +61 -144
- data/vendor/libgit2/src/transports/smart.h +26 -32
- data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
- data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
- data/vendor/libgit2/src/transports/ssh.c +100 -131
- data/vendor/libgit2/src/transports/winhttp.c +86 -82
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree-cache.h +2 -2
- data/vendor/libgit2/src/tree.c +150 -116
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -3
- data/vendor/libgit2/src/unix/posix.h +1 -4
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/unix/realpath.c +0 -2
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +68 -144
- data/vendor/libgit2/src/util.h +36 -68
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +5 -3
- data/vendor/libgit2/src/win32/findfile.c +172 -114
- data/vendor/libgit2/src/win32/findfile.h +7 -4
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +162 -33
- data/vendor/libgit2/src/win32/path_w32.h +2 -1
- data/vendor/libgit2/src/win32/posix.h +6 -7
- data/vendor/libgit2/src/win32/posix_w32.c +26 -33
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +5 -6
- data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +138 -105
- data/vendor/libgit2/src/worktree.h +1 -1
- data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
- data/vendor/libgit2/src/xdiff/xemit.c +23 -7
- data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
- data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
- data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
- data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
- data/vendor/libgit2/src/xdiff/xutils.c +18 -7
- data/vendor/libgit2/src/zstream.c +6 -6
- data/vendor/libgit2/src/zstream.h +4 -4
- metadata +60 -24
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/buffer.h +0 -222
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -369
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -18,6 +18,7 @@
|
|
18
18
|
#include "sortedcache.h"
|
19
19
|
#include "signature.h"
|
20
20
|
#include "wildmatch.h"
|
21
|
+
#include "path.h"
|
21
22
|
|
22
23
|
#include <git2/tag.h>
|
23
24
|
#include <git2/object.h>
|
@@ -34,7 +35,7 @@ enum {
|
|
34
35
|
PACKREF_HAS_PEEL = 1,
|
35
36
|
PACKREF_WAS_LOOSE = 2,
|
36
37
|
PACKREF_CANNOT_PEEL = 4,
|
37
|
-
PACKREF_SHADOWED = 8
|
38
|
+
PACKREF_SHADOWED = 8
|
38
39
|
};
|
39
40
|
|
40
41
|
enum {
|
@@ -64,9 +65,43 @@ typedef struct refdb_fs_backend {
|
|
64
65
|
git_iterator_flag_t iterator_flags;
|
65
66
|
uint32_t direach_flags;
|
66
67
|
int fsync;
|
68
|
+
git_map packed_refs_map;
|
69
|
+
git_mutex prlock; /* protect packed_refs_map */
|
70
|
+
git_futils_filestamp packed_refs_stamp;
|
71
|
+
bool sorted;
|
67
72
|
} refdb_fs_backend;
|
68
73
|
|
69
74
|
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
|
75
|
+
static char *packed_set_peeling_mode(char *data, size_t data_sz, refdb_fs_backend *backend);
|
76
|
+
|
77
|
+
GIT_INLINE(int) loose_path(
|
78
|
+
git_str *out,
|
79
|
+
const char *base,
|
80
|
+
const char *refname)
|
81
|
+
{
|
82
|
+
if (git_str_joinpath(out, base, refname) < 0)
|
83
|
+
return -1;
|
84
|
+
|
85
|
+
return git_fs_path_validate_str_length_with_suffix(out,
|
86
|
+
CONST_STRLEN(".lock"));
|
87
|
+
}
|
88
|
+
|
89
|
+
GIT_INLINE(int) reflog_path(
|
90
|
+
git_str *out,
|
91
|
+
git_repository *repo,
|
92
|
+
const char *refname)
|
93
|
+
{
|
94
|
+
const char *base;
|
95
|
+
int error;
|
96
|
+
|
97
|
+
base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
|
98
|
+
repo->commondir;
|
99
|
+
|
100
|
+
if ((error = git_str_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
|
101
|
+
return error;
|
102
|
+
|
103
|
+
return loose_path(out, out->ptr, refname);
|
104
|
+
}
|
70
105
|
|
71
106
|
static int packref_cmp(const void *a_, const void *b_)
|
72
107
|
{
|
@@ -77,7 +112,7 @@ static int packref_cmp(const void *a_, const void *b_)
|
|
77
112
|
static int packed_reload(refdb_fs_backend *backend)
|
78
113
|
{
|
79
114
|
int error;
|
80
|
-
|
115
|
+
git_str packedrefs = GIT_STR_INIT;
|
81
116
|
char *scan, *eof, *eol;
|
82
117
|
|
83
118
|
if (!backend->gitpath)
|
@@ -93,7 +128,7 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
93
128
|
*/
|
94
129
|
if (error <= 0) {
|
95
130
|
if (error == GIT_ENOTFOUND) {
|
96
|
-
git_sortedcache_clear(backend->refcache, true);
|
131
|
+
GIT_UNUSED(git_sortedcache_clear(backend->refcache, true));
|
97
132
|
git_error_clear();
|
98
133
|
error = 0;
|
99
134
|
}
|
@@ -102,33 +137,14 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
102
137
|
|
103
138
|
/* At this point, refresh the packed refs from the loaded buffer. */
|
104
139
|
|
105
|
-
git_sortedcache_clear(backend->refcache, false);
|
140
|
+
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
|
106
141
|
|
107
|
-
scan =
|
142
|
+
scan = packedrefs.ptr;
|
108
143
|
eof = scan + packedrefs.size;
|
109
144
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
static const char *traits_header = "# pack-refs with: ";
|
114
|
-
|
115
|
-
if (git__prefixcmp(scan, traits_header) == 0) {
|
116
|
-
scan += strlen(traits_header);
|
117
|
-
eol = strchr(scan, '\n');
|
118
|
-
|
119
|
-
if (!eol)
|
120
|
-
goto parse_failed;
|
121
|
-
*eol = '\0';
|
122
|
-
|
123
|
-
if (strstr(scan, " fully-peeled ") != NULL) {
|
124
|
-
backend->peeling_mode = PEELING_FULL;
|
125
|
-
} else if (strstr(scan, " peeled ") != NULL) {
|
126
|
-
backend->peeling_mode = PEELING_STANDARD;
|
127
|
-
}
|
128
|
-
|
129
|
-
scan = eol + 1;
|
130
|
-
}
|
131
|
-
}
|
145
|
+
scan = packed_set_peeling_mode(scan, packedrefs.size, backend);
|
146
|
+
if (!scan)
|
147
|
+
goto parse_failed;
|
132
148
|
|
133
149
|
while (scan < eof && *scan == '#') {
|
134
150
|
if (!(eol = strchr(scan, '\n')))
|
@@ -183,26 +199,26 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
183
199
|
}
|
184
200
|
|
185
201
|
git_sortedcache_wunlock(backend->refcache);
|
186
|
-
|
202
|
+
git_str_dispose(&packedrefs);
|
187
203
|
|
188
204
|
return 0;
|
189
205
|
|
190
206
|
parse_failed:
|
191
207
|
git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
|
192
208
|
|
193
|
-
git_sortedcache_clear(backend->refcache, false);
|
209
|
+
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
|
194
210
|
git_sortedcache_wunlock(backend->refcache);
|
195
|
-
|
211
|
+
git_str_dispose(&packedrefs);
|
196
212
|
|
197
213
|
return -1;
|
198
214
|
}
|
199
215
|
|
200
216
|
static int loose_parse_oid(
|
201
|
-
git_oid *oid, const char *filename,
|
217
|
+
git_oid *oid, const char *filename, git_str *file_content)
|
202
218
|
{
|
203
|
-
const char *str =
|
219
|
+
const char *str = git_str_cstr(file_content);
|
204
220
|
|
205
|
-
if (
|
221
|
+
if (git_str_len(file_content) < GIT_OID_HEXSZ)
|
206
222
|
goto corrupted;
|
207
223
|
|
208
224
|
/* we need to get 40 OID characters from the file */
|
@@ -219,14 +235,13 @@ corrupted:
|
|
219
235
|
return -1;
|
220
236
|
}
|
221
237
|
|
222
|
-
static int loose_readbuffer(
|
238
|
+
static int loose_readbuffer(git_str *buf, const char *base, const char *path)
|
223
239
|
{
|
224
240
|
int error;
|
225
241
|
|
226
|
-
|
227
|
-
|
228
|
-
(
|
229
|
-
git_buf_dispose(buf);
|
242
|
+
if ((error = loose_path(buf, base, path)) < 0 ||
|
243
|
+
(error = git_futils_readbuffer(buf, buf->ptr)) < 0)
|
244
|
+
git_str_dispose(buf);
|
230
245
|
|
231
246
|
return error;
|
232
247
|
}
|
@@ -234,7 +249,7 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
|
|
234
249
|
static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
235
250
|
{
|
236
251
|
int error = 0;
|
237
|
-
|
252
|
+
git_str ref_file = GIT_STR_INIT;
|
238
253
|
struct packref *ref = NULL;
|
239
254
|
git_oid oid;
|
240
255
|
|
@@ -247,7 +262,7 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
|
247
262
|
}
|
248
263
|
|
249
264
|
/* skip symbolic refs */
|
250
|
-
if (!git__prefixcmp(
|
265
|
+
if (!git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF))
|
251
266
|
goto done;
|
252
267
|
|
253
268
|
/* parse OID from file */
|
@@ -267,11 +282,11 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
|
267
282
|
git_sortedcache_wunlock(backend->refcache);
|
268
283
|
|
269
284
|
done:
|
270
|
-
|
285
|
+
git_str_dispose(&ref_file);
|
271
286
|
return error;
|
272
287
|
}
|
273
288
|
|
274
|
-
static int _dirent_loose_load(void *payload,
|
289
|
+
static int _dirent_loose_load(void *payload, git_str *full_path)
|
275
290
|
{
|
276
291
|
refdb_fs_backend *backend = payload;
|
277
292
|
const char *file_path;
|
@@ -279,8 +294,8 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
|
|
279
294
|
if (git__suffixcmp(full_path->ptr, ".lock") == 0)
|
280
295
|
return 0;
|
281
296
|
|
282
|
-
if (
|
283
|
-
int error =
|
297
|
+
if (git_fs_path_isdir(full_path->ptr)) {
|
298
|
+
int error = git_fs_path_direach(
|
284
299
|
full_path, backend->direach_flags, _dirent_loose_load, backend);
|
285
300
|
/* Race with the filesystem, ignore it */
|
286
301
|
if (error == GIT_ENOTFOUND) {
|
@@ -305,9 +320,9 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
|
|
305
320
|
static int packed_loadloose(refdb_fs_backend *backend)
|
306
321
|
{
|
307
322
|
int error;
|
308
|
-
|
323
|
+
git_str refs_path = GIT_STR_INIT;
|
309
324
|
|
310
|
-
if (
|
325
|
+
if (git_str_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
|
311
326
|
return -1;
|
312
327
|
|
313
328
|
/*
|
@@ -315,10 +330,10 @@ static int packed_loadloose(refdb_fs_backend *backend)
|
|
315
330
|
* This will overwrite any old packed entries with their
|
316
331
|
* updated loose versions
|
317
332
|
*/
|
318
|
-
error =
|
333
|
+
error = git_fs_path_direach(
|
319
334
|
&refs_path, backend->direach_flags, _dirent_loose_load, backend);
|
320
335
|
|
321
|
-
|
336
|
+
git_str_dispose(&refs_path);
|
322
337
|
|
323
338
|
return error;
|
324
339
|
}
|
@@ -329,17 +344,17 @@ static int refdb_fs_backend__exists(
|
|
329
344
|
const char *ref_name)
|
330
345
|
{
|
331
346
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
332
|
-
|
347
|
+
git_str ref_path = GIT_STR_INIT;
|
333
348
|
int error;
|
334
349
|
|
335
|
-
|
350
|
+
GIT_ASSERT_ARG(backend);
|
336
351
|
|
337
352
|
*exists = 0;
|
338
353
|
|
339
|
-
if ((error =
|
354
|
+
if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
|
340
355
|
goto out;
|
341
356
|
|
342
|
-
if (
|
357
|
+
if (git_fs_path_isfile(ref_path.ptr)) {
|
343
358
|
*exists = 1;
|
344
359
|
goto out;
|
345
360
|
}
|
@@ -353,18 +368,18 @@ static int refdb_fs_backend__exists(
|
|
353
368
|
}
|
354
369
|
|
355
370
|
out:
|
356
|
-
|
371
|
+
git_str_dispose(&ref_path);
|
357
372
|
return error;
|
358
373
|
}
|
359
374
|
|
360
|
-
static const char *loose_parse_symbolic(
|
375
|
+
static const char *loose_parse_symbolic(git_str *file_content)
|
361
376
|
{
|
362
377
|
const unsigned int header_len = (unsigned int)strlen(GIT_SYMREF);
|
363
378
|
const char *refname_start;
|
364
379
|
|
365
380
|
refname_start = (const char *)file_content->ptr;
|
366
381
|
|
367
|
-
if (
|
382
|
+
if (git_str_len(file_content) < header_len + 1) {
|
368
383
|
git_error_set(GIT_ERROR_REFERENCE, "corrupted loose reference file");
|
369
384
|
return NULL;
|
370
385
|
}
|
@@ -396,7 +411,7 @@ static int loose_lookup(
|
|
396
411
|
refdb_fs_backend *backend,
|
397
412
|
const char *ref_name)
|
398
413
|
{
|
399
|
-
|
414
|
+
git_str ref_file = GIT_STR_INIT;
|
400
415
|
int error = 0;
|
401
416
|
const char *ref_dir;
|
402
417
|
|
@@ -410,10 +425,10 @@ static int loose_lookup(
|
|
410
425
|
|
411
426
|
if ((error = loose_readbuffer(&ref_file, ref_dir, ref_name)) < 0)
|
412
427
|
/* cannot read loose ref file - gah */;
|
413
|
-
else if (git__prefixcmp(
|
428
|
+
else if (git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF) == 0) {
|
414
429
|
const char *target;
|
415
430
|
|
416
|
-
|
431
|
+
git_str_rtrim(&ref_file);
|
417
432
|
|
418
433
|
if (!(target = loose_parse_symbolic(&ref_file)))
|
419
434
|
error = -1;
|
@@ -427,7 +442,7 @@ static int loose_lookup(
|
|
427
442
|
*out = git_reference__alloc(ref_name, &oid, NULL);
|
428
443
|
}
|
429
444
|
|
430
|
-
|
445
|
+
git_str_dispose(&ref_file);
|
431
446
|
return error;
|
432
447
|
}
|
433
448
|
|
@@ -437,10 +452,198 @@ static int ref_error_notfound(const char *name)
|
|
437
452
|
return GIT_ENOTFOUND;
|
438
453
|
}
|
439
454
|
|
440
|
-
static
|
441
|
-
|
442
|
-
|
443
|
-
|
455
|
+
static char *packed_set_peeling_mode(
|
456
|
+
char *data,
|
457
|
+
size_t data_sz,
|
458
|
+
refdb_fs_backend *backend)
|
459
|
+
{
|
460
|
+
static const char *traits_header = "# pack-refs with:";
|
461
|
+
char *eol;
|
462
|
+
backend->peeling_mode = PEELING_NONE;
|
463
|
+
|
464
|
+
if (git__prefixncmp(data, data_sz, traits_header) == 0) {
|
465
|
+
size_t hdr_sz = strlen(traits_header);
|
466
|
+
const char *sorted = " sorted ";
|
467
|
+
const char *peeled = " peeled ";
|
468
|
+
const char *fully_peeled = " fully-peeled ";
|
469
|
+
data += hdr_sz;
|
470
|
+
data_sz -= hdr_sz;
|
471
|
+
|
472
|
+
eol = memchr(data, '\n', data_sz);
|
473
|
+
|
474
|
+
if (!eol)
|
475
|
+
return NULL;
|
476
|
+
|
477
|
+
if (git__memmem(data, eol - data, fully_peeled, strlen(fully_peeled)))
|
478
|
+
backend->peeling_mode = PEELING_FULL;
|
479
|
+
else if (git__memmem(data, eol - data, peeled, strlen(peeled)))
|
480
|
+
backend->peeling_mode = PEELING_STANDARD;
|
481
|
+
|
482
|
+
backend->sorted = NULL != git__memmem(data, eol - data, sorted, strlen(sorted));
|
483
|
+
|
484
|
+
return eol + 1;
|
485
|
+
}
|
486
|
+
return data;
|
487
|
+
}
|
488
|
+
|
489
|
+
static void packed_map_free(refdb_fs_backend *backend)
|
490
|
+
{
|
491
|
+
if (backend->packed_refs_map.data) {
|
492
|
+
#ifdef GIT_WIN32
|
493
|
+
git__free(backend->packed_refs_map.data);
|
494
|
+
#else
|
495
|
+
git_futils_mmap_free(&backend->packed_refs_map);
|
496
|
+
#endif
|
497
|
+
backend->packed_refs_map.data = NULL;
|
498
|
+
backend->packed_refs_map.len = 0;
|
499
|
+
git_futils_filestamp_set(&backend->packed_refs_stamp, NULL);
|
500
|
+
}
|
501
|
+
}
|
502
|
+
|
503
|
+
static int packed_map_check(refdb_fs_backend *backend)
|
504
|
+
{
|
505
|
+
int error = 0;
|
506
|
+
git_file fd = -1;
|
507
|
+
struct stat st;
|
508
|
+
|
509
|
+
if ((error = git_mutex_lock(&backend->prlock)) < 0)
|
510
|
+
return error;
|
511
|
+
|
512
|
+
if (backend->packed_refs_map.data &&
|
513
|
+
!git_futils_filestamp_check(
|
514
|
+
&backend->packed_refs_stamp, backend->refcache->path)) {
|
515
|
+
git_mutex_unlock(&backend->prlock);
|
516
|
+
return error;
|
517
|
+
}
|
518
|
+
packed_map_free(backend);
|
519
|
+
|
520
|
+
fd = git_futils_open_ro(backend->refcache->path);
|
521
|
+
if (fd < 0) {
|
522
|
+
git_mutex_unlock(&backend->prlock);
|
523
|
+
if (fd == GIT_ENOTFOUND) {
|
524
|
+
git_error_clear();
|
525
|
+
return 0;
|
526
|
+
}
|
527
|
+
return fd;
|
528
|
+
}
|
529
|
+
|
530
|
+
if (p_fstat(fd, &st) < 0) {
|
531
|
+
p_close(fd);
|
532
|
+
git_mutex_unlock(&backend->prlock);
|
533
|
+
git_error_set(GIT_ERROR_OS, "unable to stat packed-refs '%s'", backend->refcache->path);
|
534
|
+
return -1;
|
535
|
+
}
|
536
|
+
|
537
|
+
if (st.st_size == 0) {
|
538
|
+
p_close(fd);
|
539
|
+
git_mutex_unlock(&backend->prlock);
|
540
|
+
return 0;
|
541
|
+
}
|
542
|
+
|
543
|
+
git_futils_filestamp_set_from_stat(&backend->packed_refs_stamp, &st);
|
544
|
+
|
545
|
+
#ifdef GIT_WIN32
|
546
|
+
/* on windows, we copy the entire file into memory rather than using
|
547
|
+
* mmap() because using mmap() on windows also locks the file and this
|
548
|
+
* map is long-lived. */
|
549
|
+
backend->packed_refs_map.len = (size_t)st.st_size;
|
550
|
+
backend->packed_refs_map.data =
|
551
|
+
git__malloc(backend->packed_refs_map.len);
|
552
|
+
GIT_ERROR_CHECK_ALLOC(backend->packed_refs_map.data);
|
553
|
+
{
|
554
|
+
ssize_t bytesread =
|
555
|
+
p_read(fd, backend->packed_refs_map.data,
|
556
|
+
backend->packed_refs_map.len);
|
557
|
+
error = (bytesread == (ssize_t)backend->packed_refs_map.len) ? 0 : -1;
|
558
|
+
}
|
559
|
+
#else
|
560
|
+
error = git_futils_mmap_ro(&backend->packed_refs_map, fd, 0, (size_t)st.st_size);
|
561
|
+
#endif
|
562
|
+
p_close(fd);
|
563
|
+
if (error < 0) {
|
564
|
+
git_mutex_unlock(&backend->prlock);
|
565
|
+
return error;
|
566
|
+
}
|
567
|
+
|
568
|
+
packed_set_peeling_mode(
|
569
|
+
backend->packed_refs_map.data, backend->packed_refs_map.len,
|
570
|
+
backend);
|
571
|
+
|
572
|
+
git_mutex_unlock(&backend->prlock);
|
573
|
+
return error;
|
574
|
+
}
|
575
|
+
|
576
|
+
/*
|
577
|
+
* Find beginning of packed-ref record pointed to by p.
|
578
|
+
* buf - a lower-bound pointer to some memory buffer
|
579
|
+
* p - an upper-bound pointer to the same memory buffer
|
580
|
+
*/
|
581
|
+
static const char *start_of_record(const char *buf, const char *p)
|
582
|
+
{
|
583
|
+
const char *nl = p;
|
584
|
+
while (true) {
|
585
|
+
nl = git__memrchr(buf, '\n', nl - buf);
|
586
|
+
if (!nl)
|
587
|
+
return buf;
|
588
|
+
|
589
|
+
if (nl[1] == '^' && nl > buf)
|
590
|
+
--nl;
|
591
|
+
else
|
592
|
+
break;
|
593
|
+
};
|
594
|
+
return nl + 1;
|
595
|
+
}
|
596
|
+
|
597
|
+
/*
|
598
|
+
* Find end of packed-ref record pointed to by p.
|
599
|
+
* end - an upper-bound pointer to some memory buffer
|
600
|
+
* p - a lower-bound pointer to the same memory buffer
|
601
|
+
*/
|
602
|
+
static const char *end_of_record(const char *p, const char *end)
|
603
|
+
{
|
604
|
+
while (1) {
|
605
|
+
size_t sz = end - p;
|
606
|
+
p = memchr(p, '\n', sz);
|
607
|
+
if (!p)
|
608
|
+
return end;
|
609
|
+
++p;
|
610
|
+
if (p < end && p[0] == '^')
|
611
|
+
++p;
|
612
|
+
else
|
613
|
+
break;
|
614
|
+
}
|
615
|
+
return p;
|
616
|
+
}
|
617
|
+
|
618
|
+
static int
|
619
|
+
cmp_record_to_refname(const char *rec, size_t data_end, const char *ref_name)
|
620
|
+
{
|
621
|
+
const size_t ref_len = strlen(ref_name);
|
622
|
+
int cmp_val;
|
623
|
+
const char *end;
|
624
|
+
|
625
|
+
rec += GIT_OID_HEXSZ + 1; /* <oid> + space */
|
626
|
+
if (data_end < GIT_OID_HEXSZ + 3) {
|
627
|
+
/* an incomplete (corrupt) record is treated as less than ref_name */
|
628
|
+
return -1;
|
629
|
+
}
|
630
|
+
data_end -= GIT_OID_HEXSZ + 1;
|
631
|
+
|
632
|
+
end = memchr(rec, '\n', data_end);
|
633
|
+
if (end)
|
634
|
+
data_end = end - rec;
|
635
|
+
|
636
|
+
cmp_val = memcmp(rec, ref_name, min(ref_len, data_end));
|
637
|
+
|
638
|
+
if (cmp_val == 0 && data_end != ref_len)
|
639
|
+
return (data_end > ref_len) ? 1 : -1;
|
640
|
+
return cmp_val;
|
641
|
+
}
|
642
|
+
|
643
|
+
static int packed_unsorted_lookup(
|
644
|
+
git_reference **out,
|
645
|
+
refdb_fs_backend *backend,
|
646
|
+
const char *ref_name)
|
444
647
|
{
|
445
648
|
int error = 0;
|
446
649
|
struct packref *entry;
|
@@ -465,6 +668,85 @@ static int packed_lookup(
|
|
465
668
|
return error;
|
466
669
|
}
|
467
670
|
|
671
|
+
static int packed_lookup(
|
672
|
+
git_reference **out,
|
673
|
+
refdb_fs_backend *backend,
|
674
|
+
const char *ref_name)
|
675
|
+
{
|
676
|
+
int error = 0;
|
677
|
+
const char *left, *right, *data_end;
|
678
|
+
|
679
|
+
if ((error = packed_map_check(backend)) < 0)
|
680
|
+
return error;
|
681
|
+
|
682
|
+
if (!backend->sorted)
|
683
|
+
return packed_unsorted_lookup(out, backend, ref_name);
|
684
|
+
|
685
|
+
left = backend->packed_refs_map.data;
|
686
|
+
right = data_end = (const char *) backend->packed_refs_map.data +
|
687
|
+
backend->packed_refs_map.len;
|
688
|
+
|
689
|
+
while (left < right && *left == '#') {
|
690
|
+
if (!(left = memchr(left, '\n', data_end - left)))
|
691
|
+
goto parse_failed;
|
692
|
+
left++;
|
693
|
+
}
|
694
|
+
|
695
|
+
while (left < right) {
|
696
|
+
const char *mid, *rec;
|
697
|
+
int compare;
|
698
|
+
|
699
|
+
mid = left + (right - left) / 2;
|
700
|
+
rec = start_of_record(left, mid);
|
701
|
+
compare = cmp_record_to_refname(rec, data_end - rec, ref_name);
|
702
|
+
|
703
|
+
if (compare < 0) {
|
704
|
+
left = end_of_record(mid, right);
|
705
|
+
} else if (compare > 0) {
|
706
|
+
right = rec;
|
707
|
+
} else {
|
708
|
+
const char *eol;
|
709
|
+
git_oid oid, peel, *peel_ptr = NULL;
|
710
|
+
|
711
|
+
if (data_end - rec < GIT_OID_HEXSZ ||
|
712
|
+
git_oid_fromstr(&oid, rec) < 0) {
|
713
|
+
goto parse_failed;
|
714
|
+
}
|
715
|
+
rec += GIT_OID_HEXSZ + 1;
|
716
|
+
if (!(eol = memchr(rec, '\n', data_end - rec))) {
|
717
|
+
goto parse_failed;
|
718
|
+
}
|
719
|
+
|
720
|
+
/* look for optional "^<OID>\n" */
|
721
|
+
|
722
|
+
if (eol + 1 < data_end) {
|
723
|
+
rec = eol + 1;
|
724
|
+
|
725
|
+
if (*rec == '^') {
|
726
|
+
rec++;
|
727
|
+
if (data_end - rec < GIT_OID_HEXSZ ||
|
728
|
+
git_oid_fromstr(&peel, rec) < 0) {
|
729
|
+
goto parse_failed;
|
730
|
+
}
|
731
|
+
peel_ptr = &peel;
|
732
|
+
}
|
733
|
+
}
|
734
|
+
|
735
|
+
*out = git_reference__alloc(ref_name, &oid, peel_ptr);
|
736
|
+
if (!*out) {
|
737
|
+
return -1;
|
738
|
+
}
|
739
|
+
|
740
|
+
return 0;
|
741
|
+
}
|
742
|
+
}
|
743
|
+
return GIT_ENOTFOUND;
|
744
|
+
|
745
|
+
parse_failed:
|
746
|
+
git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
|
747
|
+
return -1;
|
748
|
+
}
|
749
|
+
|
468
750
|
static int refdb_fs_backend__lookup(
|
469
751
|
git_reference **out,
|
470
752
|
git_refdb_backend *_backend,
|
@@ -473,7 +755,7 @@ static int refdb_fs_backend__lookup(
|
|
473
755
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
474
756
|
int error;
|
475
757
|
|
476
|
-
|
758
|
+
GIT_ASSERT_ARG(backend);
|
477
759
|
|
478
760
|
if (!(error = loose_lookup(out, backend, ref_name)))
|
479
761
|
return 0;
|
@@ -484,7 +766,6 @@ static int refdb_fs_backend__lookup(
|
|
484
766
|
git_error_clear();
|
485
767
|
error = packed_lookup(out, backend, ref_name);
|
486
768
|
}
|
487
|
-
|
488
769
|
return error;
|
489
770
|
}
|
490
771
|
|
@@ -514,7 +795,7 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
|
|
514
795
|
static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
515
796
|
{
|
516
797
|
int error = 0;
|
517
|
-
|
798
|
+
git_str path = GIT_STR_INIT;
|
518
799
|
git_iterator *fsit = NULL;
|
519
800
|
git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
|
520
801
|
const git_index_entry *entry = NULL;
|
@@ -550,26 +831,26 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
|
550
831
|
}
|
551
832
|
}
|
552
833
|
|
553
|
-
if ((error =
|
554
|
-
(error =
|
555
|
-
|
834
|
+
if ((error = git_str_puts(&path, backend->commonpath)) < 0 ||
|
835
|
+
(error = git_str_put(&path, ref_prefix, ref_prefix_len)) < 0) {
|
836
|
+
git_str_dispose(&path);
|
556
837
|
return error;
|
557
838
|
}
|
558
839
|
|
559
840
|
if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
|
560
|
-
|
841
|
+
git_str_dispose(&path);
|
561
842
|
return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
|
562
843
|
}
|
563
844
|
|
564
|
-
error =
|
845
|
+
error = git_str_sets(&path, ref_prefix);
|
565
846
|
|
566
847
|
while (!error && !git_iterator_advance(&entry, fsit)) {
|
567
848
|
const char *ref_name;
|
568
849
|
char *ref_dup;
|
569
850
|
|
570
|
-
|
571
|
-
|
572
|
-
ref_name =
|
851
|
+
git_str_truncate(&path, ref_prefix_len);
|
852
|
+
git_str_puts(&path, entry->path);
|
853
|
+
ref_name = git_str_cstr(&path);
|
573
854
|
|
574
855
|
if (git__suffixcmp(ref_name, ".lock") == 0 ||
|
575
856
|
(iter->glob && wildmatch(iter->glob, ref_name, 0) != 0))
|
@@ -583,7 +864,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
|
583
864
|
}
|
584
865
|
|
585
866
|
git_iterator_free(fsit);
|
586
|
-
|
867
|
+
git_str_dispose(&path);
|
587
868
|
|
588
869
|
return error;
|
589
870
|
}
|
@@ -679,7 +960,7 @@ static int refdb_fs_backend__iterator(
|
|
679
960
|
refdb_fs_iter *iter = NULL;
|
680
961
|
int error;
|
681
962
|
|
682
|
-
|
963
|
+
GIT_ASSERT_ARG(backend);
|
683
964
|
|
684
965
|
iter = git__calloc(1, sizeof(refdb_fs_iter));
|
685
966
|
GIT_ERROR_CHECK_ALLOC(iter);
|
@@ -736,7 +1017,7 @@ static bool ref_is_available(
|
|
736
1017
|
static int reference_path_available(
|
737
1018
|
refdb_fs_backend *backend,
|
738
1019
|
const char *new_ref,
|
739
|
-
const char*
|
1020
|
+
const char *old_ref,
|
740
1021
|
int force)
|
741
1022
|
{
|
742
1023
|
size_t i;
|
@@ -782,12 +1063,14 @@ static int reference_path_available(
|
|
782
1063
|
static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *name)
|
783
1064
|
{
|
784
1065
|
int error, filebuf_flags;
|
785
|
-
|
1066
|
+
git_str ref_path = GIT_STR_INIT;
|
786
1067
|
const char *basedir;
|
787
1068
|
|
788
|
-
|
1069
|
+
GIT_ASSERT_ARG(file);
|
1070
|
+
GIT_ASSERT_ARG(backend);
|
1071
|
+
GIT_ASSERT_ARG(name);
|
789
1072
|
|
790
|
-
if (!
|
1073
|
+
if (!git_path_is_valid(backend->repo, name, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
|
791
1074
|
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
|
792
1075
|
return GIT_EINVALIDSPEC;
|
793
1076
|
}
|
@@ -803,8 +1086,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
803
1086
|
if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
|
804
1087
|
return error;
|
805
1088
|
|
806
|
-
if (
|
807
|
-
return
|
1089
|
+
if ((error = loose_path(&ref_path, basedir, name)) < 0)
|
1090
|
+
return error;
|
808
1091
|
|
809
1092
|
filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
|
810
1093
|
if (backend->fsync)
|
@@ -815,13 +1098,14 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
815
1098
|
if (error == GIT_EDIRECTORY)
|
816
1099
|
git_error_set(GIT_ERROR_REFERENCE, "cannot lock ref '%s', there are refs beneath that folder", name);
|
817
1100
|
|
818
|
-
|
1101
|
+
git_str_dispose(&ref_path);
|
819
1102
|
return error;
|
820
1103
|
}
|
821
1104
|
|
822
1105
|
static int loose_commit(git_filebuf *file, const git_reference *ref)
|
823
1106
|
{
|
824
|
-
|
1107
|
+
GIT_ASSERT_ARG(file);
|
1108
|
+
GIT_ASSERT_ARG(ref);
|
825
1109
|
|
826
1110
|
if (ref->type == GIT_REFERENCE_DIRECT) {
|
827
1111
|
char oid[GIT_OID_HEXSZ + 1];
|
@@ -831,7 +1115,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
|
|
831
1115
|
} else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
|
832
1116
|
git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
|
833
1117
|
} else {
|
834
|
-
|
1118
|
+
GIT_ASSERT(0);
|
835
1119
|
}
|
836
1120
|
|
837
1121
|
return git_filebuf_commit(file);
|
@@ -982,7 +1266,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
982
1266
|
{
|
983
1267
|
size_t i;
|
984
1268
|
git_filebuf lock = GIT_FILEBUF_INIT;
|
985
|
-
|
1269
|
+
git_str ref_content = GIT_STR_INIT;
|
986
1270
|
int error = 0;
|
987
1271
|
|
988
1272
|
/* backend->refcache is already locked when this is called */
|
@@ -1003,7 +1287,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
1003
1287
|
continue;
|
1004
1288
|
|
1005
1289
|
if (error < 0) {
|
1006
|
-
|
1290
|
+
git_str_dispose(&ref_content);
|
1007
1291
|
git_error_set(GIT_ERROR_REFERENCE, "failed to lock loose reference '%s'", ref->name);
|
1008
1292
|
return error;
|
1009
1293
|
}
|
@@ -1034,7 +1318,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
1034
1318
|
p_unlink(lock.path_original);
|
1035
1319
|
}
|
1036
1320
|
|
1037
|
-
|
1321
|
+
git_str_dispose(&ref_content);
|
1038
1322
|
git_filebuf_cleanup(&lock);
|
1039
1323
|
return 0;
|
1040
1324
|
}
|
@@ -1049,6 +1333,15 @@ static int packed_write(refdb_fs_backend *backend)
|
|
1049
1333
|
int error, open_flags = 0;
|
1050
1334
|
size_t i;
|
1051
1335
|
|
1336
|
+
/* take lock and close up packed-refs mmap if open */
|
1337
|
+
if ((error = git_mutex_lock(&backend->prlock)) < 0) {
|
1338
|
+
return error;
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
packed_map_free(backend);
|
1342
|
+
|
1343
|
+
git_mutex_unlock(&backend->prlock);
|
1344
|
+
|
1052
1345
|
/* lock the cache to updates while we do this */
|
1053
1346
|
if ((error = git_sortedcache_wlock(refcache)) < 0)
|
1054
1347
|
return error;
|
@@ -1068,7 +1361,7 @@ static int packed_write(refdb_fs_backend *backend)
|
|
1068
1361
|
|
1069
1362
|
for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
|
1070
1363
|
struct packref *ref = git_sortedcache_entry(refcache, i);
|
1071
|
-
|
1364
|
+
GIT_ASSERT(ref);
|
1072
1365
|
|
1073
1366
|
if ((error = packed_find_peel(backend, ref)) < 0)
|
1074
1367
|
goto fail;
|
@@ -1142,8 +1435,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
|
|
1142
1435
|
if (!old_id && !old_target)
|
1143
1436
|
return 0;
|
1144
1437
|
|
1145
|
-
if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0)
|
1438
|
+
if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
|
1439
|
+
if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
|
1440
|
+
return 0;
|
1146
1441
|
goto out;
|
1442
|
+
}
|
1147
1443
|
|
1148
1444
|
/* If the types don't match, there's no way the values do */
|
1149
1445
|
if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
|
@@ -1221,7 +1517,7 @@ static int refdb_fs_backend__write(
|
|
1221
1517
|
git_filebuf file = GIT_FILEBUF_INIT;
|
1222
1518
|
int error = 0;
|
1223
1519
|
|
1224
|
-
|
1520
|
+
GIT_ASSERT_ARG(backend);
|
1225
1521
|
|
1226
1522
|
if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
|
1227
1523
|
return error;
|
@@ -1294,41 +1590,56 @@ on_error:
|
|
1294
1590
|
return error;
|
1295
1591
|
}
|
1296
1592
|
|
1297
|
-
static
|
1593
|
+
static int refdb_fs_backend__prune_refs(
|
1298
1594
|
refdb_fs_backend *backend,
|
1299
1595
|
const char *ref_name,
|
1300
1596
|
const char *prefix)
|
1301
1597
|
{
|
1302
|
-
|
1303
|
-
|
1598
|
+
git_str relative_path = GIT_STR_INIT;
|
1599
|
+
git_str base_path = GIT_STR_INIT;
|
1304
1600
|
size_t commonlen;
|
1601
|
+
int error;
|
1305
1602
|
|
1306
|
-
|
1603
|
+
GIT_ASSERT_ARG(backend);
|
1604
|
+
GIT_ASSERT_ARG(ref_name);
|
1307
1605
|
|
1308
|
-
if (
|
1606
|
+
if ((error = git_str_sets(&relative_path, ref_name)) < 0)
|
1309
1607
|
goto cleanup;
|
1310
1608
|
|
1311
|
-
|
1312
|
-
if ((commonlen =
|
1313
|
-
(commonlen =
|
1314
|
-
(commonlen =
|
1609
|
+
git_fs_path_squash_slashes(&relative_path);
|
1610
|
+
if ((commonlen = git_fs_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
|
1611
|
+
(commonlen = git_fs_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
|
1612
|
+
(commonlen = git_fs_path_common_dirlen("refs/remotes/", git_str_cstr(&relative_path))) == strlen("refs/remotes/")) {
|
1315
1613
|
|
1316
|
-
|
1614
|
+
git_str_truncate(&relative_path, commonlen);
|
1317
1615
|
|
1318
|
-
if (prefix)
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1616
|
+
if (prefix)
|
1617
|
+
error = git_str_join3(&base_path, '/',
|
1618
|
+
backend->commonpath, prefix,
|
1619
|
+
git_str_cstr(&relative_path));
|
1620
|
+
else
|
1621
|
+
error = git_str_joinpath(&base_path,
|
1622
|
+
backend->commonpath,
|
1623
|
+
git_str_cstr(&relative_path));
|
1624
|
+
|
1625
|
+
if (!error)
|
1626
|
+
error = git_path_validate_str_length(NULL, &base_path);
|
1627
|
+
|
1628
|
+
if (error < 0)
|
1629
|
+
goto cleanup;
|
1325
1630
|
|
1326
|
-
git_futils_rmdir_r(ref_name + commonlen,
|
1631
|
+
error = git_futils_rmdir_r(ref_name + commonlen,
|
1632
|
+
git_str_cstr(&base_path),
|
1633
|
+
GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
|
1634
|
+
|
1635
|
+
if (error == GIT_ENOTFOUND)
|
1636
|
+
error = 0;
|
1327
1637
|
}
|
1328
1638
|
|
1329
1639
|
cleanup:
|
1330
|
-
|
1331
|
-
|
1640
|
+
git_str_dispose(&relative_path);
|
1641
|
+
git_str_dispose(&base_path);
|
1642
|
+
return error;
|
1332
1643
|
}
|
1333
1644
|
|
1334
1645
|
static int refdb_fs_backend__delete(
|
@@ -1340,7 +1651,8 @@ static int refdb_fs_backend__delete(
|
|
1340
1651
|
git_filebuf file = GIT_FILEBUF_INIT;
|
1341
1652
|
int error = 0;
|
1342
1653
|
|
1343
|
-
|
1654
|
+
GIT_ASSERT_ARG(backend);
|
1655
|
+
GIT_ASSERT_ARG(ref_name);
|
1344
1656
|
|
1345
1657
|
if ((error = loose_lock(&file, backend, ref_name)) < 0)
|
1346
1658
|
return error;
|
@@ -1355,19 +1667,19 @@ static int refdb_fs_backend__delete(
|
|
1355
1667
|
|
1356
1668
|
static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
|
1357
1669
|
{
|
1358
|
-
|
1670
|
+
git_str path = GIT_STR_INIT;
|
1359
1671
|
int error = 0;
|
1360
1672
|
|
1361
|
-
if (
|
1362
|
-
return
|
1673
|
+
if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
|
1674
|
+
return error;
|
1363
1675
|
|
1364
|
-
error = p_unlink(
|
1676
|
+
error = p_unlink(path.ptr);
|
1365
1677
|
if (error < 0 && errno == ENOENT)
|
1366
1678
|
error = GIT_ENOTFOUND;
|
1367
1679
|
else if (error != 0)
|
1368
1680
|
error = -1;
|
1369
1681
|
|
1370
|
-
|
1682
|
+
git_str_dispose(&path);
|
1371
1683
|
|
1372
1684
|
return error;
|
1373
1685
|
}
|
@@ -1426,7 +1738,7 @@ static int refdb_fs_backend__delete_tail(
|
|
1426
1738
|
cleanup:
|
1427
1739
|
git_filebuf_cleanup(file);
|
1428
1740
|
if (error == 0)
|
1429
|
-
refdb_fs_backend__prune_refs(backend, ref_name, "");
|
1741
|
+
error = refdb_fs_backend__prune_refs(backend, ref_name, "");
|
1430
1742
|
return error;
|
1431
1743
|
}
|
1432
1744
|
|
@@ -1446,7 +1758,7 @@ static int refdb_fs_backend__rename(
|
|
1446
1758
|
git_filebuf file = GIT_FILEBUF_INIT;
|
1447
1759
|
int error;
|
1448
1760
|
|
1449
|
-
|
1761
|
+
GIT_ASSERT_ARG(backend);
|
1450
1762
|
|
1451
1763
|
if ((error = reference_path_available(
|
1452
1764
|
backend, new_name, old_name, force)) < 0 ||
|
@@ -1499,7 +1811,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
|
|
1499
1811
|
int error;
|
1500
1812
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1501
1813
|
|
1502
|
-
|
1814
|
+
GIT_ASSERT_ARG(backend);
|
1503
1815
|
|
1504
1816
|
if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
|
1505
1817
|
(error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
|
@@ -1513,9 +1825,16 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
|
|
1513
1825
|
{
|
1514
1826
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1515
1827
|
|
1516
|
-
|
1828
|
+
if (!backend)
|
1829
|
+
return;
|
1517
1830
|
|
1518
1831
|
git_sortedcache_free(backend->refcache);
|
1832
|
+
|
1833
|
+
git_mutex_lock(&backend->prlock);
|
1834
|
+
packed_map_free(backend);
|
1835
|
+
git_mutex_unlock(&backend->prlock);
|
1836
|
+
git_mutex_free(&backend->prlock);
|
1837
|
+
|
1519
1838
|
git__free(backend->gitpath);
|
1520
1839
|
git__free(backend->commonpath);
|
1521
1840
|
git__free(backend);
|
@@ -1523,17 +1842,17 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
|
|
1523
1842
|
|
1524
1843
|
static char *setup_namespace(git_repository *repo, const char *in)
|
1525
1844
|
{
|
1526
|
-
|
1845
|
+
git_str path = GIT_STR_INIT;
|
1527
1846
|
char *parts, *start, *end, *out = NULL;
|
1528
1847
|
|
1529
1848
|
if (!in)
|
1530
1849
|
goto done;
|
1531
1850
|
|
1532
|
-
|
1851
|
+
git_str_puts(&path, in);
|
1533
1852
|
|
1534
1853
|
/* if the repo is not namespaced, nothing else to do */
|
1535
1854
|
if (repo->namespace == NULL) {
|
1536
|
-
out =
|
1855
|
+
out = git_str_detach(&path);
|
1537
1856
|
goto done;
|
1538
1857
|
}
|
1539
1858
|
|
@@ -1548,22 +1867,23 @@ static char *setup_namespace(git_repository *repo, const char *in)
|
|
1548
1867
|
* refs under refs/namespaces/foo/refs/namespaces/bar/
|
1549
1868
|
*/
|
1550
1869
|
while ((start = git__strsep(&end, "/")) != NULL)
|
1551
|
-
|
1870
|
+
git_str_printf(&path, "refs/namespaces/%s/", start);
|
1552
1871
|
|
1553
|
-
|
1872
|
+
git_str_printf(&path, "refs/namespaces/%s/refs", end);
|
1554
1873
|
git__free(parts);
|
1555
1874
|
|
1556
1875
|
/* Make sure that the folder with the namespace exists */
|
1557
|
-
if (git_futils_mkdir_relative(
|
1876
|
+
if (git_futils_mkdir_relative(git_str_cstr(&path), in, 0777,
|
1558
1877
|
GIT_MKDIR_PATH, NULL) < 0)
|
1559
1878
|
goto done;
|
1560
1879
|
|
1561
|
-
/* Return root of the namespaced gitpath, i.e. without the trailing '
|
1562
|
-
|
1563
|
-
|
1880
|
+
/* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
|
1881
|
+
git_str_rtruncate_at_char(&path, '/');
|
1882
|
+
git_str_putc(&path, '/');
|
1883
|
+
out = git_str_detach(&path);
|
1564
1884
|
|
1565
1885
|
done:
|
1566
|
-
|
1886
|
+
git_str_dispose(&path);
|
1567
1887
|
return out;
|
1568
1888
|
}
|
1569
1889
|
|
@@ -1660,30 +1980,23 @@ static int create_new_reflog_file(const char *filepath)
|
|
1660
1980
|
return p_close(fd);
|
1661
1981
|
}
|
1662
1982
|
|
1663
|
-
GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
|
1664
|
-
{
|
1665
|
-
if (strcmp(name, GIT_HEAD_FILE) == 0)
|
1666
|
-
return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
|
1667
|
-
return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
|
1668
|
-
}
|
1669
|
-
|
1670
1983
|
static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
|
1671
1984
|
{
|
1672
1985
|
refdb_fs_backend *backend;
|
1673
1986
|
git_repository *repo;
|
1674
|
-
|
1987
|
+
git_str path = GIT_STR_INIT;
|
1675
1988
|
int error;
|
1676
1989
|
|
1677
|
-
|
1990
|
+
GIT_ASSERT_ARG(_backend && name);
|
1678
1991
|
|
1679
1992
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1680
1993
|
repo = backend->repo;
|
1681
1994
|
|
1682
|
-
if ((error =
|
1995
|
+
if ((error = reflog_path(&path, repo, name)) < 0)
|
1683
1996
|
return error;
|
1684
1997
|
|
1685
|
-
error = create_new_reflog_file(
|
1686
|
-
|
1998
|
+
error = create_new_reflog_file(git_str_cstr(&path));
|
1999
|
+
git_str_dispose(&path);
|
1687
2000
|
|
1688
2001
|
return error;
|
1689
2002
|
}
|
@@ -1691,15 +2004,15 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
|
|
1691
2004
|
static int has_reflog(git_repository *repo, const char *name)
|
1692
2005
|
{
|
1693
2006
|
int ret = 0;
|
1694
|
-
|
2007
|
+
git_str path = GIT_STR_INIT;
|
1695
2008
|
|
1696
|
-
if (
|
2009
|
+
if (reflog_path(&path, repo, name) < 0)
|
1697
2010
|
goto cleanup;
|
1698
2011
|
|
1699
|
-
ret =
|
2012
|
+
ret = git_fs_path_isfile(git_str_cstr(&path));
|
1700
2013
|
|
1701
2014
|
cleanup:
|
1702
|
-
|
2015
|
+
git_str_dispose(&path);
|
1703
2016
|
return ret;
|
1704
2017
|
}
|
1705
2018
|
|
@@ -1707,7 +2020,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
|
|
1707
2020
|
{
|
1708
2021
|
refdb_fs_backend *backend;
|
1709
2022
|
|
1710
|
-
|
2023
|
+
GIT_ASSERT_ARG(_backend);
|
2024
|
+
GIT_ASSERT_ARG(name);
|
1711
2025
|
|
1712
2026
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1713
2027
|
|
@@ -1717,13 +2031,15 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
|
|
1717
2031
|
static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend, const char *name)
|
1718
2032
|
{
|
1719
2033
|
int error = -1;
|
1720
|
-
|
1721
|
-
|
2034
|
+
git_str log_path = GIT_STR_INIT;
|
2035
|
+
git_str log_file = GIT_STR_INIT;
|
1722
2036
|
git_reflog *log = NULL;
|
1723
2037
|
git_repository *repo;
|
1724
2038
|
refdb_fs_backend *backend;
|
1725
2039
|
|
1726
|
-
|
2040
|
+
GIT_ASSERT_ARG(out);
|
2041
|
+
GIT_ASSERT_ARG(_backend);
|
2042
|
+
GIT_ASSERT_ARG(name);
|
1727
2043
|
|
1728
2044
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1729
2045
|
repo = backend->repo;
|
@@ -1731,19 +2047,19 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
|
|
1731
2047
|
if (reflog_alloc(&log, name) < 0)
|
1732
2048
|
return -1;
|
1733
2049
|
|
1734
|
-
if (
|
2050
|
+
if (reflog_path(&log_path, repo, name) < 0)
|
1735
2051
|
goto cleanup;
|
1736
2052
|
|
1737
|
-
error = git_futils_readbuffer(&log_file,
|
2053
|
+
error = git_futils_readbuffer(&log_file, git_str_cstr(&log_path));
|
1738
2054
|
if (error < 0 && error != GIT_ENOTFOUND)
|
1739
2055
|
goto cleanup;
|
1740
2056
|
|
1741
2057
|
if ((error == GIT_ENOTFOUND) &&
|
1742
|
-
((error = create_new_reflog_file(
|
2058
|
+
((error = create_new_reflog_file(git_str_cstr(&log_path))) < 0))
|
1743
2059
|
goto cleanup;
|
1744
2060
|
|
1745
2061
|
if ((error = reflog_parse(log,
|
1746
|
-
|
2062
|
+
git_str_cstr(&log_file), git_str_len(&log_file))) < 0)
|
1747
2063
|
goto cleanup;
|
1748
2064
|
|
1749
2065
|
*out = log;
|
@@ -1753,14 +2069,14 @@ cleanup:
|
|
1753
2069
|
git_reflog_free(log);
|
1754
2070
|
|
1755
2071
|
success:
|
1756
|
-
|
1757
|
-
|
2072
|
+
git_str_dispose(&log_file);
|
2073
|
+
git_str_dispose(&log_path);
|
1758
2074
|
|
1759
2075
|
return error;
|
1760
2076
|
}
|
1761
2077
|
|
1762
2078
|
static int serialize_reflog_entry(
|
1763
|
-
|
2079
|
+
git_str *buf,
|
1764
2080
|
const git_oid *oid_old,
|
1765
2081
|
const git_oid *oid_new,
|
1766
2082
|
const git_signature *committer,
|
@@ -1772,61 +2088,61 @@ static int serialize_reflog_entry(
|
|
1772
2088
|
git_oid_tostr(raw_old, GIT_OID_HEXSZ+1, oid_old);
|
1773
2089
|
git_oid_tostr(raw_new, GIT_OID_HEXSZ+1, oid_new);
|
1774
2090
|
|
1775
|
-
|
2091
|
+
git_str_clear(buf);
|
1776
2092
|
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
2093
|
+
git_str_puts(buf, raw_old);
|
2094
|
+
git_str_putc(buf, ' ');
|
2095
|
+
git_str_puts(buf, raw_new);
|
1780
2096
|
|
1781
2097
|
git_signature__writebuf(buf, " ", committer);
|
1782
2098
|
|
1783
2099
|
/* drop trailing LF */
|
1784
|
-
|
2100
|
+
git_str_rtrim(buf);
|
1785
2101
|
|
1786
2102
|
if (msg) {
|
1787
2103
|
size_t i;
|
1788
2104
|
|
1789
|
-
|
1790
|
-
|
2105
|
+
git_str_putc(buf, '\t');
|
2106
|
+
git_str_puts(buf, msg);
|
1791
2107
|
|
1792
2108
|
for (i = 0; i < buf->size - 2; i++)
|
1793
2109
|
if (buf->ptr[i] == '\n')
|
1794
2110
|
buf->ptr[i] = ' ';
|
1795
|
-
|
2111
|
+
git_str_rtrim(buf);
|
1796
2112
|
}
|
1797
2113
|
|
1798
|
-
|
2114
|
+
git_str_putc(buf, '\n');
|
1799
2115
|
|
1800
|
-
return
|
2116
|
+
return git_str_oom(buf);
|
1801
2117
|
}
|
1802
2118
|
|
1803
2119
|
static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char *refname)
|
1804
2120
|
{
|
1805
2121
|
git_repository *repo;
|
1806
|
-
|
2122
|
+
git_str log_path = GIT_STR_INIT;
|
1807
2123
|
int error;
|
1808
2124
|
|
1809
2125
|
repo = backend->repo;
|
1810
2126
|
|
1811
|
-
if (!
|
2127
|
+
if (!git_path_is_valid(backend->repo, refname, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
|
1812
2128
|
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
|
1813
2129
|
return GIT_EINVALIDSPEC;
|
1814
2130
|
}
|
1815
2131
|
|
1816
|
-
if (
|
2132
|
+
if (reflog_path(&log_path, repo, refname) < 0)
|
1817
2133
|
return -1;
|
1818
2134
|
|
1819
|
-
if (!
|
2135
|
+
if (!git_fs_path_isfile(git_str_cstr(&log_path))) {
|
1820
2136
|
git_error_set(GIT_ERROR_INVALID,
|
1821
2137
|
"log file for reference '%s' doesn't exist", refname);
|
1822
2138
|
error = -1;
|
1823
2139
|
goto cleanup;
|
1824
2140
|
}
|
1825
2141
|
|
1826
|
-
error = git_filebuf_open(file,
|
2142
|
+
error = git_filebuf_open(file, git_str_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE);
|
1827
2143
|
|
1828
2144
|
cleanup:
|
1829
|
-
|
2145
|
+
git_str_dispose(&log_path);
|
1830
2146
|
|
1831
2147
|
return error;
|
1832
2148
|
}
|
@@ -1837,10 +2153,11 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
|
|
1837
2153
|
unsigned int i;
|
1838
2154
|
git_reflog_entry *entry;
|
1839
2155
|
refdb_fs_backend *backend;
|
1840
|
-
|
2156
|
+
git_str log = GIT_STR_INIT;
|
1841
2157
|
git_filebuf fbuf = GIT_FILEBUF_INIT;
|
1842
2158
|
|
1843
|
-
|
2159
|
+
GIT_ASSERT_ARG(_backend);
|
2160
|
+
GIT_ASSERT_ARG(reflog);
|
1844
2161
|
|
1845
2162
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1846
2163
|
|
@@ -1862,7 +2179,7 @@ cleanup:
|
|
1862
2179
|
git_filebuf_cleanup(&fbuf);
|
1863
2180
|
|
1864
2181
|
success:
|
1865
|
-
|
2182
|
+
git_str_dispose(&log);
|
1866
2183
|
|
1867
2184
|
return error;
|
1868
2185
|
}
|
@@ -1872,7 +2189,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1872
2189
|
{
|
1873
2190
|
int error, is_symbolic, open_flags;
|
1874
2191
|
git_oid old_id = {{0}}, new_id = {{0}};
|
1875
|
-
|
2192
|
+
git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
|
1876
2193
|
git_repository *repo = backend->repo;
|
1877
2194
|
|
1878
2195
|
is_symbolic = ref->type == GIT_REFERENCE_SYMBOLIC;
|
@@ -1913,10 +2230,10 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1913
2230
|
if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
|
1914
2231
|
goto cleanup;
|
1915
2232
|
|
1916
|
-
if ((error =
|
2233
|
+
if ((error = reflog_path(&path, repo, ref->name)) < 0)
|
1917
2234
|
goto cleanup;
|
1918
2235
|
|
1919
|
-
if (((error = git_futils_mkpath2file(
|
2236
|
+
if (((error = git_futils_mkpath2file(git_str_cstr(&path), 0777)) < 0) &&
|
1920
2237
|
(error != GIT_EEXISTS)) {
|
1921
2238
|
goto cleanup;
|
1922
2239
|
}
|
@@ -1924,11 +2241,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1924
2241
|
/* If the new branch matches part of the namespace of a previously deleted branch,
|
1925
2242
|
* there maybe an obsolete/unused directory (or directory hierarchy) in the way.
|
1926
2243
|
*/
|
1927
|
-
if (
|
1928
|
-
if ((error = git_futils_rmdir_r(
|
2244
|
+
if (git_fs_path_isdir(git_str_cstr(&path))) {
|
2245
|
+
if ((error = git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
|
1929
2246
|
if (error == GIT_ENOTFOUND)
|
1930
2247
|
error = 0;
|
1931
|
-
} else if (
|
2248
|
+
} else if (git_fs_path_isdir(git_str_cstr(&path))) {
|
1932
2249
|
git_error_set(GIT_ERROR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
|
1933
2250
|
ref->name);
|
1934
2251
|
error = GIT_EDIRECTORY;
|
@@ -1943,11 +2260,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1943
2260
|
if (backend->fsync)
|
1944
2261
|
open_flags |= O_FSYNC;
|
1945
2262
|
|
1946
|
-
error = git_futils_writebuffer(&buf,
|
2263
|
+
error = git_futils_writebuffer(&buf, git_str_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
|
1947
2264
|
|
1948
2265
|
cleanup:
|
1949
|
-
|
1950
|
-
|
2266
|
+
git_str_dispose(&buf);
|
2267
|
+
git_str_dispose(&path);
|
1951
2268
|
|
1952
2269
|
return error;
|
1953
2270
|
}
|
@@ -1955,14 +2272,16 @@ cleanup:
|
|
1955
2272
|
static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name)
|
1956
2273
|
{
|
1957
2274
|
int error = 0, fd;
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
2275
|
+
git_str old_path = GIT_STR_INIT;
|
2276
|
+
git_str new_path = GIT_STR_INIT;
|
2277
|
+
git_str temp_path = GIT_STR_INIT;
|
2278
|
+
git_str normalized = GIT_STR_INIT;
|
1962
2279
|
git_repository *repo;
|
1963
2280
|
refdb_fs_backend *backend;
|
1964
2281
|
|
1965
|
-
|
2282
|
+
GIT_ASSERT_ARG(_backend);
|
2283
|
+
GIT_ASSERT_ARG(old_name);
|
2284
|
+
GIT_ASSERT_ARG(new_name);
|
1966
2285
|
|
1967
2286
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1968
2287
|
repo = backend->repo;
|
@@ -1971,16 +2290,16 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
1971
2290
|
&normalized, new_name, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL)) < 0)
|
1972
2291
|
return error;
|
1973
2292
|
|
1974
|
-
if (
|
2293
|
+
if (git_str_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
|
1975
2294
|
return -1;
|
1976
2295
|
|
1977
|
-
if (
|
1978
|
-
return
|
2296
|
+
if ((error = loose_path(&old_path, git_str_cstr(&temp_path), old_name)) < 0)
|
2297
|
+
return error;
|
1979
2298
|
|
1980
|
-
if (
|
1981
|
-
return
|
2299
|
+
if ((error = loose_path(&new_path, git_str_cstr(&temp_path), git_str_cstr(&normalized))) < 0)
|
2300
|
+
return error;
|
1982
2301
|
|
1983
|
-
if (!
|
2302
|
+
if (!git_fs_path_exists(git_str_cstr(&old_path))) {
|
1984
2303
|
error = GIT_ENOTFOUND;
|
1985
2304
|
goto cleanup;
|
1986
2305
|
}
|
@@ -1992,43 +2311,43 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
1992
2311
|
* - a/b -> a/b/c
|
1993
2312
|
* - a/b/c/d -> a/b/c
|
1994
2313
|
*/
|
1995
|
-
if (
|
1996
|
-
return
|
2314
|
+
if ((error = loose_path(&temp_path, git_str_cstr(&temp_path), "temp_reflog")) < 0)
|
2315
|
+
return error;
|
1997
2316
|
|
1998
|
-
if ((fd = git_futils_mktmp(&temp_path,
|
2317
|
+
if ((fd = git_futils_mktmp(&temp_path, git_str_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
|
1999
2318
|
error = -1;
|
2000
2319
|
goto cleanup;
|
2001
2320
|
}
|
2002
2321
|
|
2003
2322
|
p_close(fd);
|
2004
2323
|
|
2005
|
-
if (p_rename(
|
2324
|
+
if (p_rename(git_str_cstr(&old_path), git_str_cstr(&temp_path)) < 0) {
|
2006
2325
|
git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
|
2007
2326
|
error = -1;
|
2008
2327
|
goto cleanup;
|
2009
2328
|
}
|
2010
2329
|
|
2011
|
-
if (
|
2012
|
-
(git_futils_rmdir_r(
|
2330
|
+
if (git_fs_path_isdir(git_str_cstr(&new_path)) &&
|
2331
|
+
(git_futils_rmdir_r(git_str_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
|
2013
2332
|
error = -1;
|
2014
2333
|
goto cleanup;
|
2015
2334
|
}
|
2016
2335
|
|
2017
|
-
if (git_futils_mkpath2file(
|
2336
|
+
if (git_futils_mkpath2file(git_str_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
|
2018
2337
|
error = -1;
|
2019
2338
|
goto cleanup;
|
2020
2339
|
}
|
2021
2340
|
|
2022
|
-
if (p_rename(
|
2341
|
+
if (p_rename(git_str_cstr(&temp_path), git_str_cstr(&new_path)) < 0) {
|
2023
2342
|
git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
|
2024
2343
|
error = -1;
|
2025
2344
|
}
|
2026
2345
|
|
2027
2346
|
cleanup:
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2347
|
+
git_str_dispose(&temp_path);
|
2348
|
+
git_str_dispose(&old_path);
|
2349
|
+
git_str_dispose(&new_path);
|
2350
|
+
git_str_dispose(&normalized);
|
2032
2351
|
|
2033
2352
|
return error;
|
2034
2353
|
}
|
@@ -2036,24 +2355,25 @@ cleanup:
|
|
2036
2355
|
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
|
2037
2356
|
{
|
2038
2357
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
2039
|
-
|
2358
|
+
git_str path = GIT_STR_INIT;
|
2040
2359
|
int error;
|
2041
2360
|
|
2042
|
-
|
2361
|
+
GIT_ASSERT_ARG(_backend);
|
2362
|
+
GIT_ASSERT_ARG(name);
|
2043
2363
|
|
2044
|
-
if ((error =
|
2364
|
+
if ((error = reflog_path(&path, backend->repo, name)) < 0)
|
2045
2365
|
goto out;
|
2046
2366
|
|
2047
|
-
if (!
|
2367
|
+
if (!git_fs_path_exists(path.ptr))
|
2048
2368
|
goto out;
|
2049
2369
|
|
2050
2370
|
if ((error = p_unlink(path.ptr)) < 0)
|
2051
2371
|
goto out;
|
2052
2372
|
|
2053
|
-
refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
|
2373
|
+
error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
|
2054
2374
|
|
2055
2375
|
out:
|
2056
|
-
|
2376
|
+
git_str_dispose(&path);
|
2057
2377
|
|
2058
2378
|
return error;
|
2059
2379
|
}
|
@@ -2063,11 +2383,16 @@ int git_refdb_backend_fs(
|
|
2063
2383
|
git_repository *repository)
|
2064
2384
|
{
|
2065
2385
|
int t = 0;
|
2066
|
-
|
2386
|
+
git_str gitpath = GIT_STR_INIT;
|
2067
2387
|
refdb_fs_backend *backend;
|
2068
2388
|
|
2069
2389
|
backend = git__calloc(1, sizeof(refdb_fs_backend));
|
2070
2390
|
GIT_ERROR_CHECK_ALLOC(backend);
|
2391
|
+
if (git_mutex_init(&backend->prlock) < 0) {
|
2392
|
+
git__free(backend);
|
2393
|
+
return -1;
|
2394
|
+
}
|
2395
|
+
|
2071
2396
|
|
2072
2397
|
if (git_refdb_init_backend(&backend->parent, GIT_REFDB_BACKEND_VERSION) < 0)
|
2073
2398
|
goto fail;
|
@@ -2088,21 +2413,21 @@ int git_refdb_backend_fs(
|
|
2088
2413
|
goto fail;
|
2089
2414
|
}
|
2090
2415
|
|
2091
|
-
if (
|
2416
|
+
if (git_str_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
|
2092
2417
|
git_sortedcache_new(
|
2093
2418
|
&backend->refcache, offsetof(struct packref, name),
|
2094
|
-
NULL, NULL, packref_cmp,
|
2419
|
+
NULL, NULL, packref_cmp, git_str_cstr(&gitpath)) < 0)
|
2095
2420
|
goto fail;
|
2096
2421
|
|
2097
|
-
|
2422
|
+
git_str_dispose(&gitpath);
|
2098
2423
|
|
2099
2424
|
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
|
2100
2425
|
backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
|
2101
|
-
backend->direach_flags |=
|
2426
|
+
backend->direach_flags |= GIT_FS_PATH_DIR_IGNORE_CASE;
|
2102
2427
|
}
|
2103
2428
|
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
|
2104
2429
|
backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
|
2105
|
-
backend->direach_flags |=
|
2430
|
+
backend->direach_flags |= GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE;
|
2106
2431
|
}
|
2107
2432
|
if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
|
2108
2433
|
git_repository__fsync_gitdir)
|
@@ -2130,7 +2455,8 @@ int git_refdb_backend_fs(
|
|
2130
2455
|
return 0;
|
2131
2456
|
|
2132
2457
|
fail:
|
2133
|
-
|
2458
|
+
git_mutex_free(&backend->prlock);
|
2459
|
+
git_str_dispose(&gitpath);
|
2134
2460
|
git__free(backend->gitpath);
|
2135
2461
|
git__free(backend->commonpath);
|
2136
2462
|
git__free(backend);
|