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/refdb.h
CHANGED
@@ -30,6 +30,31 @@ int git_refdb_lookup(
|
|
30
30
|
git_refdb *refdb,
|
31
31
|
const char *ref_name);
|
32
32
|
|
33
|
+
/**
|
34
|
+
* Resolve the reference by following symbolic references.
|
35
|
+
*
|
36
|
+
* Given a reference name, this function will follow any symbolic references up
|
37
|
+
* to `max_nesting` deep and return the resolved direct reference. If any of
|
38
|
+
* the intermediate symbolic references points to a non-existing reference,
|
39
|
+
* then that symbolic reference is returned instead with an error code of `0`.
|
40
|
+
* If the given reference is a direct reference already, it is returned
|
41
|
+
* directly.
|
42
|
+
*
|
43
|
+
* If `max_nesting` is `0`, the reference will not be resolved. If it's
|
44
|
+
* negative, it will be set to the default resolve depth which is `5`.
|
45
|
+
*
|
46
|
+
* @param out Pointer to store the result in.
|
47
|
+
* @param db The refdb to use for resolving the reference.
|
48
|
+
* @param ref_name The reference name to lookup and resolve.
|
49
|
+
* @param max_nesting The maximum nesting depth.
|
50
|
+
* @return `0` on success, a negative error code otherwise.
|
51
|
+
*/
|
52
|
+
int git_refdb_resolve(
|
53
|
+
git_reference **out,
|
54
|
+
git_refdb *db,
|
55
|
+
const char *ref_name,
|
56
|
+
int max_nesting);
|
57
|
+
|
33
58
|
int git_refdb_rename(
|
34
59
|
git_reference **out,
|
35
60
|
git_refdb *db,
|
@@ -50,6 +75,50 @@ int git_refdb_delete(git_refdb *refdb, const char *ref_name, const git_oid *old_
|
|
50
75
|
int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name);
|
51
76
|
int git_refdb_reflog_write(git_reflog *reflog);
|
52
77
|
|
78
|
+
/**
|
79
|
+
* Determine whether a reflog entry should be created for the given reference.
|
80
|
+
*
|
81
|
+
* Whether or not writing to a reference should create a reflog entry is
|
82
|
+
* dependent on a number of things. Most importantly, there's the
|
83
|
+
* "core.logAllRefUpdates" setting that controls in which situations a
|
84
|
+
* reference should get a corresponding reflog entry. The following values for
|
85
|
+
* it are understood:
|
86
|
+
*
|
87
|
+
* - "false": Do not log reference updates.
|
88
|
+
*
|
89
|
+
* - "true": Log normal reference updates. This will write entries for
|
90
|
+
* references in "refs/heads", "refs/remotes", "refs/notes" and
|
91
|
+
* "HEAD" or if the reference already has a log entry.
|
92
|
+
*
|
93
|
+
* - "always": Always create a reflog entry.
|
94
|
+
*
|
95
|
+
* If unset, the value will default to "true" for non-bare repositories and
|
96
|
+
* "false" for bare ones.
|
97
|
+
*
|
98
|
+
* @param out pointer to which the result will be written, `1` means a reflog
|
99
|
+
* entry should be written, `0` means none should be written.
|
100
|
+
* @param db The refdb to decide this for.
|
101
|
+
* @param ref The reference one wants to check.
|
102
|
+
* @return `0` on success, a negative error code otherwise.
|
103
|
+
*/
|
104
|
+
int git_refdb_should_write_reflog(int *out, git_refdb *db, const git_reference *ref);
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Determine whether a reflog entry should be created for HEAD if creating one
|
108
|
+
* for the given reference
|
109
|
+
*
|
110
|
+
* In case the given reference is being pointed to by HEAD, then creating a
|
111
|
+
* reflog entry for this reference also requires us to create a corresponding
|
112
|
+
* reflog entry for HEAD. This function can be used to determine that scenario.
|
113
|
+
*
|
114
|
+
* @param out pointer to which the result will be written, `1` means a reflog
|
115
|
+
* entry should be written, `0` means none should be written.
|
116
|
+
* @param db The refdb to decide this for.
|
117
|
+
* @param ref The reference one wants to check.
|
118
|
+
* @return `0` on success, a negative error code otherwise.
|
119
|
+
*/
|
120
|
+
int git_refdb_should_write_head_reflog(int *out, git_refdb *db, const git_reference *ref);
|
121
|
+
|
53
122
|
int git_refdb_has_log(git_refdb *db, const char *refname);
|
54
123
|
int git_refdb_ensure_log(git_refdb *refdb, const char *refname);
|
55
124
|
|
@@ -5,8 +5,6 @@
|
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
7
|
|
8
|
-
#include "refdb_fs.h"
|
9
|
-
|
10
8
|
#include "refs.h"
|
11
9
|
#include "hash.h"
|
12
10
|
#include "repository.h"
|
@@ -70,6 +68,35 @@ typedef struct refdb_fs_backend {
|
|
70
68
|
|
71
69
|
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
|
72
70
|
|
71
|
+
GIT_INLINE(int) loose_path(
|
72
|
+
git_buf *out,
|
73
|
+
const char *base,
|
74
|
+
const char *refname)
|
75
|
+
{
|
76
|
+
if (git_buf_joinpath(out, base, refname) < 0)
|
77
|
+
return -1;
|
78
|
+
|
79
|
+
return git_path_validate_filesystem_with_suffix(out->ptr, out->size,
|
80
|
+
CONST_STRLEN(".lock"));
|
81
|
+
}
|
82
|
+
|
83
|
+
GIT_INLINE(int) reflog_path(
|
84
|
+
git_buf *out,
|
85
|
+
git_repository *repo,
|
86
|
+
const char *refname)
|
87
|
+
{
|
88
|
+
const char *base;
|
89
|
+
int error;
|
90
|
+
|
91
|
+
base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
|
92
|
+
repo->commondir;
|
93
|
+
|
94
|
+
if ((error = git_buf_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
|
95
|
+
return error;
|
96
|
+
|
97
|
+
return loose_path(out, out->ptr, refname);
|
98
|
+
}
|
99
|
+
|
73
100
|
static int packref_cmp(const void *a_, const void *b_)
|
74
101
|
{
|
75
102
|
const struct packref *a = a_, *b = b_;
|
@@ -95,7 +122,7 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
95
122
|
*/
|
96
123
|
if (error <= 0) {
|
97
124
|
if (error == GIT_ENOTFOUND) {
|
98
|
-
git_sortedcache_clear(backend->refcache, true);
|
125
|
+
GIT_UNUSED(git_sortedcache_clear(backend->refcache, true));
|
99
126
|
git_error_clear();
|
100
127
|
error = 0;
|
101
128
|
}
|
@@ -104,7 +131,7 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
104
131
|
|
105
132
|
/* At this point, refresh the packed refs from the loaded buffer. */
|
106
133
|
|
107
|
-
git_sortedcache_clear(backend->refcache, false);
|
134
|
+
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
|
108
135
|
|
109
136
|
scan = (char *)packedrefs.ptr;
|
110
137
|
eof = scan + packedrefs.size;
|
@@ -192,7 +219,7 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
192
219
|
parse_failed:
|
193
220
|
git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
|
194
221
|
|
195
|
-
git_sortedcache_clear(backend->refcache, false);
|
222
|
+
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
|
196
223
|
git_sortedcache_wunlock(backend->refcache);
|
197
224
|
git_buf_dispose(&packedrefs);
|
198
225
|
|
@@ -225,9 +252,8 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
|
|
225
252
|
{
|
226
253
|
int error;
|
227
254
|
|
228
|
-
|
229
|
-
|
230
|
-
(error = git_futils_readbuffer(buf, buf->ptr)) < 0)
|
255
|
+
if ((error = loose_path(buf, base, path)) < 0 ||
|
256
|
+
(error = git_futils_readbuffer(buf, buf->ptr)) < 0)
|
231
257
|
git_buf_dispose(buf);
|
232
258
|
|
233
259
|
return error;
|
@@ -256,7 +282,8 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
|
256
282
|
if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
|
257
283
|
goto done;
|
258
284
|
|
259
|
-
git_sortedcache_wlock(backend->refcache)
|
285
|
+
if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
|
286
|
+
goto done;
|
260
287
|
|
261
288
|
if (!(error = git_sortedcache_upsert(
|
262
289
|
(void **)&ref, backend->refcache, name))) {
|
@@ -333,11 +360,11 @@ static int refdb_fs_backend__exists(
|
|
333
360
|
git_buf ref_path = GIT_BUF_INIT;
|
334
361
|
int error;
|
335
362
|
|
336
|
-
|
363
|
+
GIT_ASSERT_ARG(backend);
|
337
364
|
|
338
365
|
*exists = 0;
|
339
366
|
|
340
|
-
if ((error =
|
367
|
+
if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
|
341
368
|
goto out;
|
342
369
|
|
343
370
|
if (git_path_isfile(ref_path.ptr)) {
|
@@ -474,7 +501,7 @@ static int refdb_fs_backend__lookup(
|
|
474
501
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
475
502
|
int error;
|
476
503
|
|
477
|
-
|
504
|
+
GIT_ASSERT_ARG(backend);
|
478
505
|
|
479
506
|
if (!(error = loose_lookup(out, backend, ref_name)))
|
480
507
|
return 0;
|
@@ -551,7 +578,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
|
551
578
|
}
|
552
579
|
}
|
553
580
|
|
554
|
-
if ((error =
|
581
|
+
if ((error = git_buf_puts(&path, backend->commonpath)) < 0 ||
|
555
582
|
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
|
556
583
|
git_buf_dispose(&path);
|
557
584
|
return error;
|
@@ -680,12 +707,13 @@ static int refdb_fs_backend__iterator(
|
|
680
707
|
refdb_fs_iter *iter = NULL;
|
681
708
|
int error;
|
682
709
|
|
683
|
-
|
710
|
+
GIT_ASSERT_ARG(backend);
|
684
711
|
|
685
712
|
iter = git__calloc(1, sizeof(refdb_fs_iter));
|
686
713
|
GIT_ERROR_CHECK_ALLOC(iter);
|
687
714
|
|
688
|
-
git_pool_init(&iter->pool, 1)
|
715
|
+
if ((error = git_pool_init(&iter->pool, 1)) < 0)
|
716
|
+
goto out;
|
689
717
|
|
690
718
|
if ((error = git_vector_init(&iter->loose, 8, NULL)) < 0)
|
691
719
|
goto out;
|
@@ -761,7 +789,8 @@ static int reference_path_available(
|
|
761
789
|
}
|
762
790
|
}
|
763
791
|
|
764
|
-
git_sortedcache_rlock(backend->refcache)
|
792
|
+
if ((error = git_sortedcache_rlock(backend->refcache)) < 0)
|
793
|
+
return error;
|
765
794
|
|
766
795
|
for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
|
767
796
|
struct packref *ref = git_sortedcache_entry(backend->refcache, i);
|
@@ -784,9 +813,11 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
784
813
|
git_buf ref_path = GIT_BUF_INIT;
|
785
814
|
const char *basedir;
|
786
815
|
|
787
|
-
|
816
|
+
GIT_ASSERT_ARG(file);
|
817
|
+
GIT_ASSERT_ARG(backend);
|
818
|
+
GIT_ASSERT_ARG(name);
|
788
819
|
|
789
|
-
if (!
|
820
|
+
if (!git_path_validate(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
|
790
821
|
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
|
791
822
|
return GIT_EINVALIDSPEC;
|
792
823
|
}
|
@@ -802,8 +833,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
802
833
|
if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
|
803
834
|
return error;
|
804
835
|
|
805
|
-
if (
|
806
|
-
return
|
836
|
+
if ((error = loose_path(&ref_path, basedir, name)) < 0)
|
837
|
+
return error;
|
807
838
|
|
808
839
|
filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
|
809
840
|
if (backend->fsync)
|
@@ -820,7 +851,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
820
851
|
|
821
852
|
static int loose_commit(git_filebuf *file, const git_reference *ref)
|
822
853
|
{
|
823
|
-
|
854
|
+
GIT_ASSERT_ARG(file);
|
855
|
+
GIT_ASSERT_ARG(ref);
|
824
856
|
|
825
857
|
if (ref->type == GIT_REFERENCE_DIRECT) {
|
826
858
|
char oid[GIT_OID_HEXSZ + 1];
|
@@ -830,7 +862,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
|
|
830
862
|
} else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
|
831
863
|
git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
|
832
864
|
} else {
|
833
|
-
|
865
|
+
GIT_ASSERT(0);
|
834
866
|
}
|
835
867
|
|
836
868
|
return git_filebuf_commit(file);
|
@@ -1067,7 +1099,7 @@ static int packed_write(refdb_fs_backend *backend)
|
|
1067
1099
|
|
1068
1100
|
for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
|
1069
1101
|
struct packref *ref = git_sortedcache_entry(refcache, i);
|
1070
|
-
|
1102
|
+
GIT_ASSERT(ref);
|
1071
1103
|
|
1072
1104
|
if ((error = packed_find_peel(backend, ref)) < 0)
|
1073
1105
|
goto fail;
|
@@ -1129,44 +1161,6 @@ cleanup:
|
|
1129
1161
|
}
|
1130
1162
|
|
1131
1163
|
static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message);
|
1132
|
-
static int has_reflog(git_repository *repo, const char *name);
|
1133
|
-
|
1134
|
-
static int should_write_reflog(int *write, git_repository *repo, const char *name)
|
1135
|
-
{
|
1136
|
-
int error, logall;
|
1137
|
-
|
1138
|
-
error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES);
|
1139
|
-
if (error < 0)
|
1140
|
-
return error;
|
1141
|
-
|
1142
|
-
/* Defaults to the opposite of the repo being bare */
|
1143
|
-
if (logall == GIT_LOGALLREFUPDATES_UNSET)
|
1144
|
-
logall = !git_repository_is_bare(repo);
|
1145
|
-
|
1146
|
-
*write = 0;
|
1147
|
-
switch (logall) {
|
1148
|
-
case GIT_LOGALLREFUPDATES_FALSE:
|
1149
|
-
*write = 0;
|
1150
|
-
break;
|
1151
|
-
|
1152
|
-
case GIT_LOGALLREFUPDATES_TRUE:
|
1153
|
-
/* Only write if it already has a log,
|
1154
|
-
* or if it's under heads/, remotes/ or notes/
|
1155
|
-
*/
|
1156
|
-
*write = has_reflog(repo, name) ||
|
1157
|
-
!git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
|
1158
|
-
!git__strcmp(name, GIT_HEAD_FILE) ||
|
1159
|
-
!git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
|
1160
|
-
!git__prefixcmp(name, GIT_REFS_NOTES_DIR);
|
1161
|
-
break;
|
1162
|
-
|
1163
|
-
case GIT_LOGALLREFUPDATES_ALWAYS:
|
1164
|
-
*write = 1;
|
1165
|
-
break;
|
1166
|
-
}
|
1167
|
-
|
1168
|
-
return 0;
|
1169
|
-
}
|
1170
1164
|
|
1171
1165
|
static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
|
1172
1166
|
const git_oid *old_id, const char *old_target)
|
@@ -1179,8 +1173,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
|
|
1179
1173
|
if (!old_id && !old_target)
|
1180
1174
|
return 0;
|
1181
1175
|
|
1182
|
-
if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0)
|
1176
|
+
if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
|
1177
|
+
if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
|
1178
|
+
return 0;
|
1183
1179
|
goto out;
|
1180
|
+
}
|
1184
1181
|
|
1185
1182
|
/* If the types don't match, there's no way the values do */
|
1186
1183
|
if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
|
@@ -1220,54 +1217,28 @@ out:
|
|
1220
1217
|
*/
|
1221
1218
|
static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message)
|
1222
1219
|
{
|
1223
|
-
|
1220
|
+
git_reference *head = NULL;
|
1221
|
+
git_refdb *refdb = NULL;
|
1222
|
+
int error, write_reflog;
|
1224
1223
|
git_oid old_id;
|
1225
|
-
git_reference *tmp = NULL, *head = NULL, *peeled = NULL;
|
1226
|
-
const char *name;
|
1227
1224
|
|
1228
|
-
if (
|
1229
|
-
|
1225
|
+
if ((error = git_repository_refdb(&refdb, backend->repo)) < 0 ||
|
1226
|
+
(error = git_refdb_should_write_head_reflog(&write_reflog, refdb, ref)) < 0)
|
1227
|
+
goto out;
|
1228
|
+
if (!write_reflog)
|
1229
|
+
goto out;
|
1230
1230
|
|
1231
1231
|
/* if we can't resolve, we use {0}*40 as old id */
|
1232
1232
|
if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0)
|
1233
1233
|
memset(&old_id, 0, sizeof(old_id));
|
1234
1234
|
|
1235
|
-
if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0
|
1236
|
-
|
1237
|
-
|
1238
|
-
if (git_reference_type(head) == GIT_REFERENCE_DIRECT)
|
1239
|
-
goto cleanup;
|
1240
|
-
|
1241
|
-
if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0)
|
1242
|
-
goto cleanup;
|
1243
|
-
|
1244
|
-
/* Go down the symref chain until we find the branch */
|
1245
|
-
while (git_reference_type(tmp) == GIT_REFERENCE_SYMBOLIC) {
|
1246
|
-
error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp));
|
1247
|
-
if (error < 0)
|
1248
|
-
break;
|
1249
|
-
|
1250
|
-
git_reference_free(tmp);
|
1251
|
-
tmp = peeled;
|
1252
|
-
}
|
1253
|
-
|
1254
|
-
if (error == GIT_ENOTFOUND) {
|
1255
|
-
error = 0;
|
1256
|
-
name = git_reference_symbolic_target(tmp);
|
1257
|
-
} else if (error < 0) {
|
1258
|
-
goto cleanup;
|
1259
|
-
} else {
|
1260
|
-
name = git_reference_name(tmp);
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
if (strcmp(name, ref->name))
|
1264
|
-
goto cleanup;
|
1265
|
-
|
1266
|
-
error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message);
|
1235
|
+
if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0 ||
|
1236
|
+
(error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message)) < 0)
|
1237
|
+
goto out;
|
1267
1238
|
|
1268
|
-
|
1269
|
-
git_reference_free(tmp);
|
1239
|
+
out:
|
1270
1240
|
git_reference_free(head);
|
1241
|
+
git_refdb_free(refdb);
|
1271
1242
|
return error;
|
1272
1243
|
}
|
1273
1244
|
|
@@ -1284,7 +1255,7 @@ static int refdb_fs_backend__write(
|
|
1284
1255
|
git_filebuf file = GIT_FILEBUF_INIT;
|
1285
1256
|
int error = 0;
|
1286
1257
|
|
1287
|
-
|
1258
|
+
GIT_ASSERT_ARG(backend);
|
1288
1259
|
|
1289
1260
|
if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
|
1290
1261
|
return error;
|
@@ -1336,7 +1307,10 @@ static int refdb_fs_backend__write_tail(
|
|
1336
1307
|
}
|
1337
1308
|
|
1338
1309
|
if (update_reflog) {
|
1339
|
-
|
1310
|
+
git_refdb *refdb;
|
1311
|
+
|
1312
|
+
if ((error = git_repository_refdb__weakptr(&refdb, backend->repo)) < 0 ||
|
1313
|
+
(error = git_refdb_should_write_reflog(&should_write, refdb, ref)) < 0)
|
1340
1314
|
goto on_error;
|
1341
1315
|
|
1342
1316
|
if (should_write) {
|
@@ -1354,7 +1328,7 @@ on_error:
|
|
1354
1328
|
return error;
|
1355
1329
|
}
|
1356
1330
|
|
1357
|
-
static
|
1331
|
+
static int refdb_fs_backend__prune_refs(
|
1358
1332
|
refdb_fs_backend *backend,
|
1359
1333
|
const char *ref_name,
|
1360
1334
|
const char *prefix)
|
@@ -1362,10 +1336,12 @@ static void refdb_fs_backend__prune_refs(
|
|
1362
1336
|
git_buf relative_path = GIT_BUF_INIT;
|
1363
1337
|
git_buf base_path = GIT_BUF_INIT;
|
1364
1338
|
size_t commonlen;
|
1339
|
+
int error;
|
1365
1340
|
|
1366
|
-
|
1341
|
+
GIT_ASSERT_ARG(backend);
|
1342
|
+
GIT_ASSERT_ARG(ref_name);
|
1367
1343
|
|
1368
|
-
if (git_buf_sets(&relative_path, ref_name) < 0)
|
1344
|
+
if ((error = git_buf_sets(&relative_path, ref_name)) < 0)
|
1369
1345
|
goto cleanup;
|
1370
1346
|
|
1371
1347
|
git_path_squash_slashes(&relative_path);
|
@@ -1375,20 +1351,33 @@ static void refdb_fs_backend__prune_refs(
|
|
1375
1351
|
|
1376
1352
|
git_buf_truncate(&relative_path, commonlen);
|
1377
1353
|
|
1378
|
-
if (prefix)
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1354
|
+
if (prefix)
|
1355
|
+
error = git_buf_join3(&base_path, '/',
|
1356
|
+
backend->commonpath, prefix,
|
1357
|
+
git_buf_cstr(&relative_path));
|
1358
|
+
else
|
1359
|
+
error = git_buf_joinpath(&base_path,
|
1360
|
+
backend->commonpath,
|
1361
|
+
git_buf_cstr(&relative_path));
|
1362
|
+
|
1363
|
+
if (!error)
|
1364
|
+
error = git_path_validate_filesystem(base_path.ptr, base_path.size);
|
1365
|
+
|
1366
|
+
if (error < 0)
|
1367
|
+
goto cleanup;
|
1385
1368
|
|
1386
|
-
git_futils_rmdir_r(ref_name + commonlen,
|
1369
|
+
error = git_futils_rmdir_r(ref_name + commonlen,
|
1370
|
+
git_buf_cstr(&base_path),
|
1371
|
+
GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
|
1372
|
+
|
1373
|
+
if (error == GIT_ENOTFOUND)
|
1374
|
+
error = 0;
|
1387
1375
|
}
|
1388
1376
|
|
1389
1377
|
cleanup:
|
1390
1378
|
git_buf_dispose(&relative_path);
|
1391
1379
|
git_buf_dispose(&base_path);
|
1380
|
+
return error;
|
1392
1381
|
}
|
1393
1382
|
|
1394
1383
|
static int refdb_fs_backend__delete(
|
@@ -1400,7 +1389,8 @@ static int refdb_fs_backend__delete(
|
|
1400
1389
|
git_filebuf file = GIT_FILEBUF_INIT;
|
1401
1390
|
int error = 0;
|
1402
1391
|
|
1403
|
-
|
1392
|
+
GIT_ASSERT_ARG(backend);
|
1393
|
+
GIT_ASSERT_ARG(ref_name);
|
1404
1394
|
|
1405
1395
|
if ((error = loose_lock(&file, backend, ref_name)) < 0)
|
1406
1396
|
return error;
|
@@ -1415,19 +1405,19 @@ static int refdb_fs_backend__delete(
|
|
1415
1405
|
|
1416
1406
|
static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
|
1417
1407
|
{
|
1418
|
-
git_buf
|
1408
|
+
git_buf path = GIT_BUF_INIT;
|
1419
1409
|
int error = 0;
|
1420
1410
|
|
1421
|
-
if (
|
1422
|
-
return
|
1411
|
+
if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
|
1412
|
+
return error;
|
1423
1413
|
|
1424
|
-
error = p_unlink(
|
1414
|
+
error = p_unlink(path.ptr);
|
1425
1415
|
if (error < 0 && errno == ENOENT)
|
1426
1416
|
error = GIT_ENOTFOUND;
|
1427
1417
|
else if (error != 0)
|
1428
1418
|
error = -1;
|
1429
1419
|
|
1430
|
-
git_buf_dispose(&
|
1420
|
+
git_buf_dispose(&path);
|
1431
1421
|
|
1432
1422
|
return error;
|
1433
1423
|
}
|
@@ -1486,7 +1476,7 @@ static int refdb_fs_backend__delete_tail(
|
|
1486
1476
|
cleanup:
|
1487
1477
|
git_filebuf_cleanup(file);
|
1488
1478
|
if (error == 0)
|
1489
|
-
refdb_fs_backend__prune_refs(backend, ref_name, "");
|
1479
|
+
error = refdb_fs_backend__prune_refs(backend, ref_name, "");
|
1490
1480
|
return error;
|
1491
1481
|
}
|
1492
1482
|
|
@@ -1506,7 +1496,7 @@ static int refdb_fs_backend__rename(
|
|
1506
1496
|
git_filebuf file = GIT_FILEBUF_INIT;
|
1507
1497
|
int error;
|
1508
1498
|
|
1509
|
-
|
1499
|
+
GIT_ASSERT_ARG(backend);
|
1510
1500
|
|
1511
1501
|
if ((error = reference_path_available(
|
1512
1502
|
backend, new_name, old_name, force)) < 0 ||
|
@@ -1559,7 +1549,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
|
|
1559
1549
|
int error;
|
1560
1550
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1561
1551
|
|
1562
|
-
|
1552
|
+
GIT_ASSERT_ARG(backend);
|
1563
1553
|
|
1564
1554
|
if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
|
1565
1555
|
(error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
|
@@ -1573,7 +1563,8 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
|
|
1573
1563
|
{
|
1574
1564
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1575
1565
|
|
1576
|
-
|
1566
|
+
if (!backend)
|
1567
|
+
return;
|
1577
1568
|
|
1578
1569
|
git_sortedcache_free(backend->refcache);
|
1579
1570
|
git__free(backend->gitpath);
|
@@ -1618,8 +1609,9 @@ static char *setup_namespace(git_repository *repo, const char *in)
|
|
1618
1609
|
GIT_MKDIR_PATH, NULL) < 0)
|
1619
1610
|
goto done;
|
1620
1611
|
|
1621
|
-
/* Return root of the namespaced gitpath, i.e. without the trailing '
|
1612
|
+
/* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
|
1622
1613
|
git_buf_rtruncate_at_char(&path, '/');
|
1614
|
+
git_buf_putc(&path, '/');
|
1623
1615
|
out = git_buf_detach(&path);
|
1624
1616
|
|
1625
1617
|
done:
|
@@ -1720,13 +1712,6 @@ static int create_new_reflog_file(const char *filepath)
|
|
1720
1712
|
return p_close(fd);
|
1721
1713
|
}
|
1722
1714
|
|
1723
|
-
GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
|
1724
|
-
{
|
1725
|
-
if (strcmp(name, GIT_HEAD_FILE) == 0)
|
1726
|
-
return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
|
1727
|
-
return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
|
1728
|
-
}
|
1729
|
-
|
1730
1715
|
static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
|
1731
1716
|
{
|
1732
1717
|
refdb_fs_backend *backend;
|
@@ -1734,12 +1719,12 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
|
|
1734
1719
|
git_buf path = GIT_BUF_INIT;
|
1735
1720
|
int error;
|
1736
1721
|
|
1737
|
-
|
1722
|
+
GIT_ASSERT_ARG(_backend && name);
|
1738
1723
|
|
1739
1724
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1740
1725
|
repo = backend->repo;
|
1741
1726
|
|
1742
|
-
if ((error =
|
1727
|
+
if ((error = reflog_path(&path, repo, name)) < 0)
|
1743
1728
|
return error;
|
1744
1729
|
|
1745
1730
|
error = create_new_reflog_file(git_buf_cstr(&path));
|
@@ -1753,7 +1738,7 @@ static int has_reflog(git_repository *repo, const char *name)
|
|
1753
1738
|
int ret = 0;
|
1754
1739
|
git_buf path = GIT_BUF_INIT;
|
1755
1740
|
|
1756
|
-
if (
|
1741
|
+
if (reflog_path(&path, repo, name) < 0)
|
1757
1742
|
goto cleanup;
|
1758
1743
|
|
1759
1744
|
ret = git_path_isfile(git_buf_cstr(&path));
|
@@ -1767,7 +1752,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
|
|
1767
1752
|
{
|
1768
1753
|
refdb_fs_backend *backend;
|
1769
1754
|
|
1770
|
-
|
1755
|
+
GIT_ASSERT_ARG(_backend);
|
1756
|
+
GIT_ASSERT_ARG(name);
|
1771
1757
|
|
1772
1758
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1773
1759
|
|
@@ -1783,7 +1769,9 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
|
|
1783
1769
|
git_repository *repo;
|
1784
1770
|
refdb_fs_backend *backend;
|
1785
1771
|
|
1786
|
-
|
1772
|
+
GIT_ASSERT_ARG(out);
|
1773
|
+
GIT_ASSERT_ARG(_backend);
|
1774
|
+
GIT_ASSERT_ARG(name);
|
1787
1775
|
|
1788
1776
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1789
1777
|
repo = backend->repo;
|
@@ -1791,7 +1779,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
|
|
1791
1779
|
if (reflog_alloc(&log, name) < 0)
|
1792
1780
|
return -1;
|
1793
1781
|
|
1794
|
-
if (
|
1782
|
+
if (reflog_path(&log_path, repo, name) < 0)
|
1795
1783
|
goto cleanup;
|
1796
1784
|
|
1797
1785
|
error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
|
@@ -1868,12 +1856,12 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
|
|
1868
1856
|
|
1869
1857
|
repo = backend->repo;
|
1870
1858
|
|
1871
|
-
if (!
|
1859
|
+
if (!git_path_validate(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
|
1872
1860
|
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
|
1873
1861
|
return GIT_EINVALIDSPEC;
|
1874
1862
|
}
|
1875
1863
|
|
1876
|
-
if (
|
1864
|
+
if (reflog_path(&log_path, repo, refname) < 0)
|
1877
1865
|
return -1;
|
1878
1866
|
|
1879
1867
|
if (!git_path_isfile(git_buf_cstr(&log_path))) {
|
@@ -1900,7 +1888,8 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
|
|
1900
1888
|
git_buf log = GIT_BUF_INIT;
|
1901
1889
|
git_filebuf fbuf = GIT_FILEBUF_INIT;
|
1902
1890
|
|
1903
|
-
|
1891
|
+
GIT_ASSERT_ARG(_backend);
|
1892
|
+
GIT_ASSERT_ARG(reflog);
|
1904
1893
|
|
1905
1894
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1906
1895
|
|
@@ -1973,7 +1962,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1973
1962
|
if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
|
1974
1963
|
goto cleanup;
|
1975
1964
|
|
1976
|
-
if ((error =
|
1965
|
+
if ((error = reflog_path(&path, repo, ref->name)) < 0)
|
1977
1966
|
goto cleanup;
|
1978
1967
|
|
1979
1968
|
if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
|
@@ -2022,7 +2011,9 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
2022
2011
|
git_repository *repo;
|
2023
2012
|
refdb_fs_backend *backend;
|
2024
2013
|
|
2025
|
-
|
2014
|
+
GIT_ASSERT_ARG(_backend);
|
2015
|
+
GIT_ASSERT_ARG(old_name);
|
2016
|
+
GIT_ASSERT_ARG(new_name);
|
2026
2017
|
|
2027
2018
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
2028
2019
|
repo = backend->repo;
|
@@ -2034,11 +2025,11 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
2034
2025
|
if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
|
2035
2026
|
return -1;
|
2036
2027
|
|
2037
|
-
if (
|
2038
|
-
return
|
2028
|
+
if ((error = loose_path(&old_path, git_buf_cstr(&temp_path), old_name)) < 0)
|
2029
|
+
return error;
|
2039
2030
|
|
2040
|
-
if (
|
2041
|
-
return
|
2031
|
+
if ((error = loose_path(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized))) < 0)
|
2032
|
+
return error;
|
2042
2033
|
|
2043
2034
|
if (!git_path_exists(git_buf_cstr(&old_path))) {
|
2044
2035
|
error = GIT_ENOTFOUND;
|
@@ -2052,8 +2043,8 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
2052
2043
|
* - a/b -> a/b/c
|
2053
2044
|
* - a/b/c/d -> a/b/c
|
2054
2045
|
*/
|
2055
|
-
if (
|
2056
|
-
return
|
2046
|
+
if ((error = loose_path(&temp_path, git_buf_cstr(&temp_path), "temp_reflog")) < 0)
|
2047
|
+
return error;
|
2057
2048
|
|
2058
2049
|
if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
|
2059
2050
|
error = -1;
|
@@ -2099,9 +2090,10 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
|
|
2099
2090
|
git_buf path = GIT_BUF_INIT;
|
2100
2091
|
int error;
|
2101
2092
|
|
2102
|
-
|
2093
|
+
GIT_ASSERT_ARG(_backend);
|
2094
|
+
GIT_ASSERT_ARG(name);
|
2103
2095
|
|
2104
|
-
if ((error =
|
2096
|
+
if ((error = reflog_path(&path, backend->repo, name)) < 0)
|
2105
2097
|
goto out;
|
2106
2098
|
|
2107
2099
|
if (!git_path_exists(path.ptr))
|
@@ -2110,7 +2102,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
|
|
2110
2102
|
if ((error = p_unlink(path.ptr)) < 0)
|
2111
2103
|
goto out;
|
2112
2104
|
|
2113
|
-
refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
|
2105
|
+
error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
|
2114
2106
|
|
2115
2107
|
out:
|
2116
2108
|
git_buf_dispose(&path);
|