rugged 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +3 -3
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_commit.c +1 -1
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_remote.c +32 -2
- data/ext/rugged/rugged_repo.c +13 -3
- data/lib/rugged/commit.rb +17 -4
- data/lib/rugged/repository.rb +7 -8
- data/lib/rugged/submodule_collection.rb +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +41 -74
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
- data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
- data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/deps/pcre/LICENCE +93 -0
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
- data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/apply.h +2 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +95 -42
- data/vendor/libgit2/include/git2/blob.h +31 -3
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +33 -6
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +248 -8
- data/vendor/libgit2/include/git2/diff.h +35 -20
- data/vendor/libgit2/include/git2/errors.h +8 -7
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +4 -5
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/pack.h +1 -1
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/strarray.h +6 -10
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +77 -44
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +21 -8
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +92 -42
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +44 -40
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +28 -15
- data/vendor/libgit2/src/blame_git.c +6 -3
- data/vendor/libgit2/src/blob.c +46 -24
- data/vendor/libgit2/src/branch.c +87 -37
- data/vendor/libgit2/src/buffer.c +339 -27
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +3 -24
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +97 -98
- data/vendor/libgit2/src/cherrypick.c +8 -2
- data/vendor/libgit2/src/clone.c +104 -29
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +26 -2
- data/vendor/libgit2/src/config.c +40 -22
- data/vendor/libgit2/src/config_cache.c +9 -4
- data/vendor/libgit2/src/config_entries.c +35 -27
- data/vendor/libgit2/src/config_file.c +25 -8
- data/vendor/libgit2/src/config_parse.c +5 -7
- data/vendor/libgit2/src/config_snapshot.c +2 -1
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +11 -4
- data/vendor/libgit2/src/diff.c +23 -19
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +5 -7
- data/vendor/libgit2/src/diff_generate.c +56 -28
- data/vendor/libgit2/src/diff_parse.c +2 -3
- data/vendor/libgit2/src/diff_print.c +81 -65
- data/vendor/libgit2/src/diff_stats.c +19 -16
- data/vendor/libgit2/src/diff_tform.c +13 -13
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +26 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +7 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +209 -113
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +8 -8
- data/vendor/libgit2/src/futils.h +4 -4
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/idxmap.c +0 -22
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +126 -84
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +60 -36
- data/vendor/libgit2/src/integer.h +79 -2
- data/vendor/libgit2/src/iterator.c +40 -28
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +125 -49
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +108 -46
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +15 -9
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +879 -0
- data/vendor/libgit2/src/midx.h +110 -0
- data/vendor/libgit2/src/mwindow.c +214 -95
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +133 -4
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +24 -15
- data/vendor/libgit2/src/odb.c +298 -57
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +31 -21
- data/vendor/libgit2/src/odb_mempack.c +3 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +7 -4
- data/vendor/libgit2/src/pack-objects.c +83 -69
- data/vendor/libgit2/src/pack.c +383 -150
- data/vendor/libgit2/src/pack.h +44 -9
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +3 -5
- data/vendor/libgit2/src/patch_parse.c +6 -3
- data/vendor/libgit2/src/path.c +102 -57
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +12 -11
- data/vendor/libgit2/src/pool.c +34 -22
- data/vendor/libgit2/src/pool.h +9 -1
- data/vendor/libgit2/src/posix.c +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- data/vendor/libgit2/src/proxy.c +2 -0
- data/vendor/libgit2/src/push.c +2 -0
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +95 -49
- data/vendor/libgit2/src/refdb.c +165 -13
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +144 -152
- data/vendor/libgit2/src/reflog.c +21 -20
- data/vendor/libgit2/src/refs.c +151 -231
- data/vendor/libgit2/src/refs.h +2 -20
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/regexp.c +2 -2
- data/vendor/libgit2/src/remote.c +312 -121
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +351 -189
- data/vendor/libgit2/src/repository.h +23 -29
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +8 -2
- data/vendor/libgit2/src/revparse.c +19 -13
- data/vendor/libgit2/src/revwalk.c +35 -20
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.c +2 -3
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +7 -3
- data/vendor/libgit2/src/status.c +9 -4
- data/vendor/libgit2/src/strarray.c +64 -0
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +113 -207
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +10 -9
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +134 -66
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +8 -26
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +49 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +21 -9
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +17 -7
- data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +84 -42
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +5 -5
- data/vendor/libgit2/src/transports/smart.c +14 -9
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +156 -88
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/posix.h +16 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +74 -183
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/git2.rc +18 -3
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +23 -25
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +77 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +37 -15
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +56 -38
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -361
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -246
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
data/vendor/libgit2/src/reflog.c
CHANGED
|
@@ -12,12 +12,8 @@
|
|
|
12
12
|
#include "signature.h"
|
|
13
13
|
#include "refdb.h"
|
|
14
14
|
|
|
15
|
-
#include
|
|
16
|
-
|
|
17
|
-
git_reflog_entry *git_reflog_entry__alloc(void)
|
|
18
|
-
{
|
|
19
|
-
return git__calloc(1, sizeof(git_reflog_entry));
|
|
20
|
-
}
|
|
15
|
+
#include "git2/sys/refdb_backend.h"
|
|
16
|
+
#include "git2/sys/reflog.h"
|
|
21
17
|
|
|
22
18
|
void git_reflog_entry__free(git_reflog_entry *entry)
|
|
23
19
|
{
|
|
@@ -54,7 +50,9 @@ int git_reflog_read(git_reflog **reflog, git_repository *repo, const char *name
|
|
|
54
50
|
git_refdb *refdb;
|
|
55
51
|
int error;
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
GIT_ASSERT_ARG(reflog);
|
|
54
|
+
GIT_ASSERT_ARG(repo);
|
|
55
|
+
GIT_ASSERT_ARG(name);
|
|
58
56
|
|
|
59
57
|
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
|
|
60
58
|
return error;
|
|
@@ -66,7 +64,8 @@ int git_reflog_write(git_reflog *reflog)
|
|
|
66
64
|
{
|
|
67
65
|
git_refdb *db;
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
GIT_ASSERT_ARG(reflog);
|
|
68
|
+
GIT_ASSERT_ARG(reflog->db);
|
|
70
69
|
|
|
71
70
|
db = reflog->db;
|
|
72
71
|
return db->backend->reflog_write(db->backend, reflog);
|
|
@@ -77,7 +76,9 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign
|
|
|
77
76
|
const git_reflog_entry *previous;
|
|
78
77
|
git_reflog_entry *entry;
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
GIT_ASSERT_ARG(reflog);
|
|
80
|
+
GIT_ASSERT_ARG(new_oid);
|
|
81
|
+
GIT_ASSERT_ARG(committer);
|
|
81
82
|
|
|
82
83
|
entry = git__calloc(1, sizeof(git_reflog_entry));
|
|
83
84
|
GIT_ERROR_CHECK_ALLOC(entry);
|
|
@@ -143,13 +144,13 @@ int git_reflog_delete(git_repository *repo, const char *name)
|
|
|
143
144
|
|
|
144
145
|
size_t git_reflog_entrycount(git_reflog *reflog)
|
|
145
146
|
{
|
|
146
|
-
|
|
147
|
+
GIT_ASSERT_ARG_WITH_RETVAL(reflog, 0);
|
|
147
148
|
return reflog->entries.length;
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
const git_reflog_entry *
|
|
151
|
+
const git_reflog_entry *git_reflog_entry_byindex(const git_reflog *reflog, size_t idx)
|
|
151
152
|
{
|
|
152
|
-
|
|
153
|
+
GIT_ASSERT_ARG_WITH_RETVAL(reflog, NULL);
|
|
153
154
|
|
|
154
155
|
if (idx >= reflog->entries.length)
|
|
155
156
|
return NULL;
|
|
@@ -158,27 +159,27 @@ const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size
|
|
|
158
159
|
&reflog->entries, reflog_inverse_index(idx, reflog->entries.length));
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
const git_oid *
|
|
162
|
+
const git_oid *git_reflog_entry_id_old(const git_reflog_entry *entry)
|
|
162
163
|
{
|
|
163
|
-
|
|
164
|
+
GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
|
|
164
165
|
return &entry->oid_old;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
const git_oid *
|
|
168
|
+
const git_oid *git_reflog_entry_id_new(const git_reflog_entry *entry)
|
|
168
169
|
{
|
|
169
|
-
|
|
170
|
+
GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
|
|
170
171
|
return &entry->oid_cur;
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
const git_signature *
|
|
174
|
+
const git_signature *git_reflog_entry_committer(const git_reflog_entry *entry)
|
|
174
175
|
{
|
|
175
|
-
|
|
176
|
+
GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
|
|
176
177
|
return entry->committer;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
const char *
|
|
180
|
+
const char *git_reflog_entry_message(const git_reflog_entry *entry)
|
|
180
181
|
{
|
|
181
|
-
|
|
182
|
+
GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
|
|
182
183
|
return entry->msg;
|
|
183
184
|
}
|
|
184
185
|
|
data/vendor/libgit2/src/refs.c
CHANGED
|
@@ -27,9 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
bool git_reference__enable_symbolic_ref_target_validation = true;
|
|
29
29
|
|
|
30
|
-
#define DEFAULT_NESTING_LEVEL 5
|
|
31
|
-
#define MAX_NESTING_LEVEL 10
|
|
32
|
-
|
|
33
30
|
enum {
|
|
34
31
|
GIT_PACKREF_HAS_PEEL = 1,
|
|
35
32
|
GIT_PACKREF_WAS_LOOSE = 2
|
|
@@ -53,7 +50,8 @@ git_reference *git_reference__alloc_symbolic(
|
|
|
53
50
|
{
|
|
54
51
|
git_reference *ref;
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
|
|
54
|
+
GIT_ASSERT_ARG_WITH_RETVAL(target, NULL);
|
|
57
55
|
|
|
58
56
|
ref = alloc_ref(name);
|
|
59
57
|
if (!ref)
|
|
@@ -76,7 +74,8 @@ git_reference *git_reference__alloc(
|
|
|
76
74
|
{
|
|
77
75
|
git_reference *ref;
|
|
78
76
|
|
|
79
|
-
|
|
77
|
+
GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
|
|
78
|
+
GIT_ASSERT_ARG_WITH_RETVAL(oid, NULL);
|
|
80
79
|
|
|
81
80
|
ref = alloc_ref(name);
|
|
82
81
|
if (!ref)
|
|
@@ -97,7 +96,8 @@ git_reference *git_reference__realloc(
|
|
|
97
96
|
size_t namelen, reflen;
|
|
98
97
|
git_reference *rewrite = NULL;
|
|
99
98
|
|
|
100
|
-
|
|
99
|
+
GIT_ASSERT_ARG_WITH_RETVAL(ptr_to_ref, NULL);
|
|
100
|
+
GIT_ASSERT_ARG_WITH_RETVAL(name, NULL);
|
|
101
101
|
|
|
102
102
|
namelen = strlen(name);
|
|
103
103
|
|
|
@@ -214,92 +214,37 @@ int git_reference_lookup_resolved(
|
|
|
214
214
|
const char *name,
|
|
215
215
|
int max_nesting)
|
|
216
216
|
{
|
|
217
|
-
git_refname_t
|
|
218
|
-
git_reference_t scan_type;
|
|
219
|
-
int error = 0, nesting;
|
|
220
|
-
git_reference *ref = NULL;
|
|
217
|
+
git_refname_t normalized;
|
|
221
218
|
git_refdb *refdb;
|
|
219
|
+
int error = 0;
|
|
222
220
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (max_nesting > MAX_NESTING_LEVEL)
|
|
228
|
-
max_nesting = MAX_NESTING_LEVEL;
|
|
229
|
-
else if (max_nesting < 0)
|
|
230
|
-
max_nesting = DEFAULT_NESTING_LEVEL;
|
|
231
|
-
|
|
232
|
-
scan_type = GIT_REFERENCE_SYMBOLIC;
|
|
233
|
-
|
|
234
|
-
if ((error = reference_normalize_for_repo(scan_name, repo, name, true)) < 0)
|
|
235
|
-
return error;
|
|
221
|
+
GIT_ASSERT_ARG(ref_out);
|
|
222
|
+
GIT_ASSERT_ARG(repo);
|
|
223
|
+
GIT_ASSERT_ARG(name);
|
|
236
224
|
|
|
237
|
-
if ((error =
|
|
225
|
+
if ((error = reference_normalize_for_repo(normalized, repo, name, true)) < 0 ||
|
|
226
|
+
(error = git_repository_refdb__weakptr(&refdb, repo)) < 0 ||
|
|
227
|
+
(error = git_refdb_resolve(ref_out, refdb, normalized, max_nesting)) < 0)
|
|
238
228
|
return error;
|
|
239
229
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return error;
|
|
251
|
-
|
|
252
|
-
scan_type = ref->type;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (scan_type != GIT_REFERENCE_DIRECT && max_nesting != 0) {
|
|
256
|
-
git_error_set(GIT_ERROR_REFERENCE,
|
|
257
|
-
"cannot resolve reference (>%u levels deep)", max_nesting);
|
|
258
|
-
git_reference_free(ref);
|
|
259
|
-
return -1;
|
|
230
|
+
/*
|
|
231
|
+
* The resolved reference may be a symbolic reference in case its
|
|
232
|
+
* target doesn't exist. If the user asked us to resolve (e.g.
|
|
233
|
+
* `max_nesting != 0`), then we need to return an error in case we got
|
|
234
|
+
* a symbolic reference back.
|
|
235
|
+
*/
|
|
236
|
+
if (max_nesting && git_reference_type(*ref_out) == GIT_REFERENCE_SYMBOLIC) {
|
|
237
|
+
git_reference_free(*ref_out);
|
|
238
|
+
*ref_out = NULL;
|
|
239
|
+
return GIT_ENOTFOUND;
|
|
260
240
|
}
|
|
261
241
|
|
|
262
|
-
*ref_out = ref;
|
|
263
242
|
return 0;
|
|
264
243
|
}
|
|
265
244
|
|
|
266
|
-
int git_reference__read_head(
|
|
267
|
-
git_reference **out,
|
|
268
|
-
git_repository *repo,
|
|
269
|
-
const char *path)
|
|
270
|
-
{
|
|
271
|
-
git_buf reference = GIT_BUF_INIT;
|
|
272
|
-
char *name = NULL;
|
|
273
|
-
int error;
|
|
274
|
-
|
|
275
|
-
if ((error = git_futils_readbuffer(&reference, path)) < 0)
|
|
276
|
-
goto out;
|
|
277
|
-
git_buf_rtrim(&reference);
|
|
278
|
-
|
|
279
|
-
if (git__strncmp(reference.ptr, GIT_SYMREF, strlen(GIT_SYMREF)) == 0) {
|
|
280
|
-
git_buf_consume(&reference, reference.ptr + strlen(GIT_SYMREF));
|
|
281
|
-
|
|
282
|
-
name = git_path_basename(path);
|
|
283
|
-
|
|
284
|
-
if ((*out = git_reference__alloc_symbolic(name, reference.ptr)) == NULL) {
|
|
285
|
-
error = -1;
|
|
286
|
-
goto out;
|
|
287
|
-
}
|
|
288
|
-
} else {
|
|
289
|
-
if ((error = git_reference_lookup(out, repo, reference.ptr)) < 0)
|
|
290
|
-
goto out;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
out:
|
|
294
|
-
git__free(name);
|
|
295
|
-
git_buf_dispose(&reference);
|
|
296
|
-
|
|
297
|
-
return error;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
245
|
int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname)
|
|
301
246
|
{
|
|
302
|
-
int error = 0, i;
|
|
247
|
+
int error = 0, i, valid;
|
|
303
248
|
bool fallbackmode = true, foundvalid = false;
|
|
304
249
|
git_reference *ref;
|
|
305
250
|
git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
|
|
@@ -325,10 +270,11 @@ int git_reference_dwim(git_reference **out, git_repository *repo, const char *re
|
|
|
325
270
|
|
|
326
271
|
git_buf_clear(&refnamebuf);
|
|
327
272
|
|
|
328
|
-
if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0
|
|
273
|
+
if ((error = git_buf_printf(&refnamebuf, formatters[i], git_buf_cstr(&name))) < 0 ||
|
|
274
|
+
(error = git_reference_name_is_valid(&valid, git_buf_cstr(&refnamebuf))) < 0)
|
|
329
275
|
goto cleanup;
|
|
330
276
|
|
|
331
|
-
if (!
|
|
277
|
+
if (!valid) {
|
|
332
278
|
error = GIT_EINVALIDSPEC;
|
|
333
279
|
continue;
|
|
334
280
|
}
|
|
@@ -366,25 +312,25 @@ cleanup:
|
|
|
366
312
|
*/
|
|
367
313
|
git_reference_t git_reference_type(const git_reference *ref)
|
|
368
314
|
{
|
|
369
|
-
|
|
315
|
+
GIT_ASSERT_ARG(ref);
|
|
370
316
|
return ref->type;
|
|
371
317
|
}
|
|
372
318
|
|
|
373
319
|
const char *git_reference_name(const git_reference *ref)
|
|
374
320
|
{
|
|
375
|
-
|
|
321
|
+
GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
|
|
376
322
|
return ref->name;
|
|
377
323
|
}
|
|
378
324
|
|
|
379
325
|
git_repository *git_reference_owner(const git_reference *ref)
|
|
380
326
|
{
|
|
381
|
-
|
|
327
|
+
GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
|
|
382
328
|
return ref->db->repo;
|
|
383
329
|
}
|
|
384
330
|
|
|
385
331
|
const git_oid *git_reference_target(const git_reference *ref)
|
|
386
332
|
{
|
|
387
|
-
|
|
333
|
+
GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
|
|
388
334
|
|
|
389
335
|
if (ref->type != GIT_REFERENCE_DIRECT)
|
|
390
336
|
return NULL;
|
|
@@ -394,7 +340,7 @@ const git_oid *git_reference_target(const git_reference *ref)
|
|
|
394
340
|
|
|
395
341
|
const git_oid *git_reference_target_peel(const git_reference *ref)
|
|
396
342
|
{
|
|
397
|
-
|
|
343
|
+
GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
|
|
398
344
|
|
|
399
345
|
if (ref->type != GIT_REFERENCE_DIRECT || git_oid_is_zero(&ref->peel))
|
|
400
346
|
return NULL;
|
|
@@ -404,7 +350,7 @@ const git_oid *git_reference_target_peel(const git_reference *ref)
|
|
|
404
350
|
|
|
405
351
|
const char *git_reference_symbolic_target(const git_reference *ref)
|
|
406
352
|
{
|
|
407
|
-
|
|
353
|
+
GIT_ASSERT_ARG_WITH_RETVAL(ref, NULL);
|
|
408
354
|
|
|
409
355
|
if (ref->type != GIT_REFERENCE_SYMBOLIC)
|
|
410
356
|
return NULL;
|
|
@@ -429,8 +375,9 @@ static int reference__create(
|
|
|
429
375
|
git_reference *ref = NULL;
|
|
430
376
|
int error = 0;
|
|
431
377
|
|
|
432
|
-
|
|
433
|
-
|
|
378
|
+
GIT_ASSERT_ARG(repo);
|
|
379
|
+
GIT_ASSERT_ARG(name);
|
|
380
|
+
GIT_ASSERT_ARG(symbolic || signature);
|
|
434
381
|
|
|
435
382
|
if (ref_out)
|
|
436
383
|
*ref_out = NULL;
|
|
@@ -444,7 +391,7 @@ static int reference__create(
|
|
|
444
391
|
return error;
|
|
445
392
|
|
|
446
393
|
if (oid != NULL) {
|
|
447
|
-
|
|
394
|
+
GIT_ASSERT(symbolic == NULL);
|
|
448
395
|
|
|
449
396
|
if (!git_object__is_valid(repo, oid, GIT_OBJECT_ANY)) {
|
|
450
397
|
git_error_set(GIT_ERROR_REFERENCE,
|
|
@@ -480,7 +427,7 @@ static int reference__create(
|
|
|
480
427
|
return 0;
|
|
481
428
|
}
|
|
482
429
|
|
|
483
|
-
int
|
|
430
|
+
static int refs_configured_ident(git_signature **out, const git_repository *repo)
|
|
484
431
|
{
|
|
485
432
|
if (repo->ident_name && repo->ident_email)
|
|
486
433
|
return git_signature_now(out, repo->ident_name, repo->ident_email);
|
|
@@ -494,7 +441,7 @@ int git_reference__log_signature(git_signature **out, git_repository *repo)
|
|
|
494
441
|
int error;
|
|
495
442
|
git_signature *who;
|
|
496
443
|
|
|
497
|
-
if(((error =
|
|
444
|
+
if(((error = refs_configured_ident(&who, repo)) < 0) &&
|
|
498
445
|
((error = git_signature_default(&who, repo)) < 0) &&
|
|
499
446
|
((error = git_signature_now(&who, "unknown", "unknown")) < 0))
|
|
500
447
|
return error;
|
|
@@ -516,7 +463,7 @@ int git_reference_create_matching(
|
|
|
516
463
|
int error;
|
|
517
464
|
git_signature *who = NULL;
|
|
518
465
|
|
|
519
|
-
|
|
466
|
+
GIT_ASSERT_ARG(id);
|
|
520
467
|
|
|
521
468
|
if ((error = git_reference__log_signature(&who, repo)) < 0)
|
|
522
469
|
return error;
|
|
@@ -551,7 +498,7 @@ int git_reference_symbolic_create_matching(
|
|
|
551
498
|
int error;
|
|
552
499
|
git_signature *who = NULL;
|
|
553
500
|
|
|
554
|
-
|
|
501
|
+
GIT_ASSERT_ARG(target);
|
|
555
502
|
|
|
556
503
|
if ((error = git_reference__log_signature(&who, repo)) < 0)
|
|
557
504
|
return error;
|
|
@@ -592,7 +539,9 @@ int git_reference_set_target(
|
|
|
592
539
|
int error;
|
|
593
540
|
git_repository *repo;
|
|
594
541
|
|
|
595
|
-
|
|
542
|
+
GIT_ASSERT_ARG(out);
|
|
543
|
+
GIT_ASSERT_ARG(ref);
|
|
544
|
+
GIT_ASSERT_ARG(id);
|
|
596
545
|
|
|
597
546
|
repo = ref->db->repo;
|
|
598
547
|
|
|
@@ -619,7 +568,9 @@ int git_reference_symbolic_set_target(
|
|
|
619
568
|
{
|
|
620
569
|
int error;
|
|
621
570
|
|
|
622
|
-
|
|
571
|
+
GIT_ASSERT_ARG(out);
|
|
572
|
+
GIT_ASSERT_ARG(ref);
|
|
573
|
+
GIT_ASSERT_ARG(target);
|
|
623
574
|
|
|
624
575
|
if ((error = ensure_is_an_updatable_symbolic_reference(ref)) < 0)
|
|
625
576
|
return error;
|
|
@@ -631,84 +582,33 @@ int git_reference_symbolic_set_target(
|
|
|
631
582
|
typedef struct {
|
|
632
583
|
const char *old_name;
|
|
633
584
|
git_refname_t new_name;
|
|
634
|
-
}
|
|
585
|
+
} refs_update_head_payload;
|
|
635
586
|
|
|
636
|
-
static int
|
|
587
|
+
static int refs_update_head(git_repository *worktree, void *_payload)
|
|
637
588
|
{
|
|
638
|
-
|
|
639
|
-
git_reference *head = NULL;
|
|
640
|
-
char *gitdir = NULL;
|
|
589
|
+
refs_update_head_payload *payload = (refs_update_head_payload *)_payload;
|
|
590
|
+
git_reference *head = NULL, *updated = NULL;
|
|
641
591
|
int error;
|
|
642
592
|
|
|
643
|
-
if ((error =
|
|
644
|
-
git_error_set(GIT_ERROR_REFERENCE, "could not read HEAD when renaming references");
|
|
645
|
-
goto out;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
if ((gitdir = git_path_dirname(path)) == NULL) {
|
|
649
|
-
error = -1;
|
|
593
|
+
if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0)
|
|
650
594
|
goto out;
|
|
651
|
-
}
|
|
652
595
|
|
|
653
596
|
if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC ||
|
|
654
|
-
git__strcmp(head
|
|
655
|
-
error = 0;
|
|
597
|
+
git__strcmp(git_reference_symbolic_target(head), payload->old_name) != 0)
|
|
656
598
|
goto out;
|
|
657
|
-
}
|
|
658
599
|
|
|
659
|
-
/* Update HEAD it was pointing to the reference being renamed */
|
|
660
|
-
if ((error =
|
|
600
|
+
/* Update HEAD if it was pointing to the reference being renamed */
|
|
601
|
+
if ((error = git_reference_symbolic_set_target(&updated, head, payload->new_name, NULL)) < 0) {
|
|
661
602
|
git_error_set(GIT_ERROR_REFERENCE, "failed to update HEAD after renaming reference");
|
|
662
603
|
goto out;
|
|
663
604
|
}
|
|
664
605
|
|
|
665
606
|
out:
|
|
607
|
+
git_reference_free(updated);
|
|
666
608
|
git_reference_free(head);
|
|
667
|
-
git__free(gitdir);
|
|
668
|
-
|
|
669
609
|
return error;
|
|
670
610
|
}
|
|
671
611
|
|
|
672
|
-
static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force,
|
|
673
|
-
const git_signature *signature, const char *message)
|
|
674
|
-
{
|
|
675
|
-
git_repository *repo;
|
|
676
|
-
git_refname_t normalized;
|
|
677
|
-
bool should_head_be_updated = false;
|
|
678
|
-
int error = 0;
|
|
679
|
-
|
|
680
|
-
assert(ref && new_name && signature);
|
|
681
|
-
|
|
682
|
-
repo = git_reference_owner(ref);
|
|
683
|
-
|
|
684
|
-
if ((error = reference_normalize_for_repo(
|
|
685
|
-
normalized, repo, new_name, true)) < 0)
|
|
686
|
-
return error;
|
|
687
|
-
|
|
688
|
-
/* Check if we have to update HEAD. */
|
|
689
|
-
if ((error = git_branch_is_head(ref)) < 0)
|
|
690
|
-
return error;
|
|
691
|
-
|
|
692
|
-
should_head_be_updated = (error > 0);
|
|
693
|
-
|
|
694
|
-
if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0)
|
|
695
|
-
return error;
|
|
696
|
-
|
|
697
|
-
/* Update HEAD if it was pointing to the reference being renamed */
|
|
698
|
-
if (should_head_be_updated) {
|
|
699
|
-
error = git_repository_set_head(ref->db->repo, normalized);
|
|
700
|
-
} else {
|
|
701
|
-
rename_cb_data payload;
|
|
702
|
-
payload.old_name = ref->name;
|
|
703
|
-
memcpy(&payload.new_name, &normalized, sizeof(normalized));
|
|
704
|
-
|
|
705
|
-
error = git_repository_foreach_head(repo, update_wt_heads, 0, &payload);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return error;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
|
|
712
612
|
int git_reference_rename(
|
|
713
613
|
git_reference **out,
|
|
714
614
|
git_reference *ref,
|
|
@@ -716,17 +616,29 @@ int git_reference_rename(
|
|
|
716
616
|
int force,
|
|
717
617
|
const char *log_message)
|
|
718
618
|
{
|
|
719
|
-
|
|
619
|
+
refs_update_head_payload payload;
|
|
620
|
+
git_signature *signature = NULL;
|
|
621
|
+
git_repository *repo;
|
|
720
622
|
int error;
|
|
721
623
|
|
|
722
|
-
|
|
624
|
+
GIT_ASSERT_ARG(out);
|
|
625
|
+
GIT_ASSERT_ARG(ref);
|
|
723
626
|
|
|
724
|
-
|
|
725
|
-
return error;
|
|
627
|
+
repo = git_reference_owner(ref);
|
|
726
628
|
|
|
727
|
-
error =
|
|
728
|
-
|
|
629
|
+
if ((error = git_reference__log_signature(&signature, repo)) < 0 ||
|
|
630
|
+
(error = reference_normalize_for_repo(payload.new_name, repo, new_name, true)) < 0 ||
|
|
631
|
+
(error = git_refdb_rename(out, ref->db, ref->name, payload.new_name, force, signature, log_message)) < 0)
|
|
632
|
+
goto out;
|
|
729
633
|
|
|
634
|
+
payload.old_name = ref->name;
|
|
635
|
+
|
|
636
|
+
/* We may have to update any HEAD that was pointing to the renamed reference. */
|
|
637
|
+
if ((error = git_repository_foreach_worktree(repo, refs_update_head, &payload)) < 0)
|
|
638
|
+
goto out;
|
|
639
|
+
|
|
640
|
+
out:
|
|
641
|
+
git_signature_free(signature);
|
|
730
642
|
return error;
|
|
731
643
|
}
|
|
732
644
|
|
|
@@ -876,7 +788,8 @@ int git_reference_list(
|
|
|
876
788
|
{
|
|
877
789
|
git_vector ref_list;
|
|
878
790
|
|
|
879
|
-
|
|
791
|
+
GIT_ASSERT_ARG(array);
|
|
792
|
+
GIT_ASSERT_ARG(repo);
|
|
880
793
|
|
|
881
794
|
array->strings = NULL;
|
|
882
795
|
array->count = 0;
|
|
@@ -960,7 +873,8 @@ static bool is_all_caps_and_underscore(const char *name, size_t len)
|
|
|
960
873
|
size_t i;
|
|
961
874
|
char c;
|
|
962
875
|
|
|
963
|
-
|
|
876
|
+
GIT_ASSERT_ARG(name);
|
|
877
|
+
GIT_ASSERT_ARG(len > 0);
|
|
964
878
|
|
|
965
879
|
for (i = 0; i < len; i++)
|
|
966
880
|
{
|
|
@@ -991,7 +905,7 @@ int git_reference__normalize_name(
|
|
|
991
905
|
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
|
|
992
906
|
#endif
|
|
993
907
|
|
|
994
|
-
|
|
908
|
+
GIT_ASSERT_ARG(name);
|
|
995
909
|
|
|
996
910
|
process_flags = flags;
|
|
997
911
|
current = (char *)name;
|
|
@@ -1123,7 +1037,8 @@ int git_reference_normalize_name(
|
|
|
1123
1037
|
goto cleanup;
|
|
1124
1038
|
}
|
|
1125
1039
|
|
|
1126
|
-
git_buf_copy_cstr(buffer_out, buffer_size, &buf)
|
|
1040
|
+
if ((error = git_buf_copy_cstr(buffer_out, buffer_size, &buf)) < 0)
|
|
1041
|
+
goto cleanup;
|
|
1127
1042
|
|
|
1128
1043
|
error = 0;
|
|
1129
1044
|
|
|
@@ -1139,7 +1054,9 @@ int git_reference_cmp(
|
|
|
1139
1054
|
const git_reference *ref2)
|
|
1140
1055
|
{
|
|
1141
1056
|
git_reference_t type1, type2;
|
|
1142
|
-
|
|
1057
|
+
|
|
1058
|
+
GIT_ASSERT_ARG(ref1);
|
|
1059
|
+
GIT_ASSERT_ARG(ref2);
|
|
1143
1060
|
|
|
1144
1061
|
type1 = git_reference_type(ref1);
|
|
1145
1062
|
type2 = git_reference_type(ref2);
|
|
@@ -1154,40 +1071,6 @@ int git_reference_cmp(
|
|
|
1154
1071
|
return git_oid__cmp(&ref1->target.oid, &ref2->target.oid);
|
|
1155
1072
|
}
|
|
1156
1073
|
|
|
1157
|
-
/**
|
|
1158
|
-
* Get the end of a chain of references. If the final one is not
|
|
1159
|
-
* found, we return the reference just before that.
|
|
1160
|
-
*/
|
|
1161
|
-
static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting)
|
|
1162
|
-
{
|
|
1163
|
-
git_reference *ref;
|
|
1164
|
-
int error = 0;
|
|
1165
|
-
|
|
1166
|
-
if (nesting > MAX_NESTING_LEVEL) {
|
|
1167
|
-
git_error_set(GIT_ERROR_REFERENCE, "reference chain too deep (%d)", nesting);
|
|
1168
|
-
return GIT_ENOTFOUND;
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
/* set to NULL to let the caller know that they're at the end of the chain */
|
|
1172
|
-
if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) {
|
|
1173
|
-
*out = NULL;
|
|
1174
|
-
return error;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
if (git_reference_type(ref) == GIT_REFERENCE_DIRECT) {
|
|
1178
|
-
*out = ref;
|
|
1179
|
-
error = 0;
|
|
1180
|
-
} else {
|
|
1181
|
-
error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1);
|
|
1182
|
-
if (error == GIT_ENOTFOUND && !*out)
|
|
1183
|
-
*out = ref;
|
|
1184
|
-
else
|
|
1185
|
-
git_reference_free(ref);
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
return error;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
1074
|
/*
|
|
1192
1075
|
* Starting with the reference given by `ref_name`, follows symbolic
|
|
1193
1076
|
* references until a direct reference is found and updated the OID
|
|
@@ -1202,31 +1085,37 @@ int git_reference__update_terminal(
|
|
|
1202
1085
|
{
|
|
1203
1086
|
git_reference *ref = NULL, *ref2 = NULL;
|
|
1204
1087
|
git_signature *who = NULL;
|
|
1088
|
+
git_refdb *refdb = NULL;
|
|
1205
1089
|
const git_signature *to_use;
|
|
1206
1090
|
int error = 0;
|
|
1207
1091
|
|
|
1208
1092
|
if (!sig && (error = git_reference__log_signature(&who, repo)) < 0)
|
|
1209
|
-
|
|
1093
|
+
goto out;
|
|
1210
1094
|
|
|
1211
1095
|
to_use = sig ? sig : who;
|
|
1212
|
-
error = get_terminal(&ref, repo, ref_name, 0);
|
|
1213
1096
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1097
|
+
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
|
|
1098
|
+
goto out;
|
|
1099
|
+
|
|
1100
|
+
if ((error = git_refdb_resolve(&ref, refdb, ref_name, -1)) < 0) {
|
|
1101
|
+
if (error == GIT_ENOTFOUND) {
|
|
1102
|
+
git_error_clear();
|
|
1103
|
+
error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
|
|
1104
|
+
log_message, NULL, NULL);
|
|
1105
|
+
}
|
|
1106
|
+
goto out;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/* In case the resolved reference is symbolic, then it's a dangling symref. */
|
|
1110
|
+
if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
|
|
1218
1111
|
error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use,
|
|
1219
1112
|
log_message, NULL, NULL);
|
|
1220
|
-
} else
|
|
1221
|
-
git_error_clear();
|
|
1222
|
-
error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
|
|
1223
|
-
log_message, NULL, NULL);
|
|
1224
|
-
} else if (error == 0) {
|
|
1225
|
-
assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT);
|
|
1113
|
+
} else {
|
|
1226
1114
|
error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use,
|
|
1227
1115
|
log_message, &ref->target.oid, NULL);
|
|
1228
1116
|
}
|
|
1229
1117
|
|
|
1118
|
+
out:
|
|
1230
1119
|
git_reference_free(ref2);
|
|
1231
1120
|
git_reference_free(ref);
|
|
1232
1121
|
git_signature_free(who);
|
|
@@ -1290,7 +1179,8 @@ int git_reference_has_log(git_repository *repo, const char *refname)
|
|
|
1290
1179
|
int error;
|
|
1291
1180
|
git_refdb *refdb;
|
|
1292
1181
|
|
|
1293
|
-
|
|
1182
|
+
GIT_ASSERT_ARG(repo);
|
|
1183
|
+
GIT_ASSERT_ARG(refname);
|
|
1294
1184
|
|
|
1295
1185
|
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
|
|
1296
1186
|
return error;
|
|
@@ -1303,7 +1193,8 @@ int git_reference_ensure_log(git_repository *repo, const char *refname)
|
|
|
1303
1193
|
int error;
|
|
1304
1194
|
git_refdb *refdb;
|
|
1305
1195
|
|
|
1306
|
-
|
|
1196
|
+
GIT_ASSERT_ARG(repo);
|
|
1197
|
+
GIT_ASSERT_ARG(refname);
|
|
1307
1198
|
|
|
1308
1199
|
if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
|
|
1309
1200
|
return error;
|
|
@@ -1318,7 +1209,7 @@ int git_reference__is_branch(const char *ref_name)
|
|
|
1318
1209
|
|
|
1319
1210
|
int git_reference_is_branch(const git_reference *ref)
|
|
1320
1211
|
{
|
|
1321
|
-
|
|
1212
|
+
GIT_ASSERT_ARG(ref);
|
|
1322
1213
|
return git_reference__is_branch(ref->name);
|
|
1323
1214
|
}
|
|
1324
1215
|
|
|
@@ -1329,7 +1220,7 @@ int git_reference__is_remote(const char *ref_name)
|
|
|
1329
1220
|
|
|
1330
1221
|
int git_reference_is_remote(const git_reference *ref)
|
|
1331
1222
|
{
|
|
1332
|
-
|
|
1223
|
+
GIT_ASSERT_ARG(ref);
|
|
1333
1224
|
return git_reference__is_remote(ref->name);
|
|
1334
1225
|
}
|
|
1335
1226
|
|
|
@@ -1340,7 +1231,7 @@ int git_reference__is_tag(const char *ref_name)
|
|
|
1340
1231
|
|
|
1341
1232
|
int git_reference_is_tag(const git_reference *ref)
|
|
1342
1233
|
{
|
|
1343
|
-
|
|
1234
|
+
GIT_ASSERT_ARG(ref);
|
|
1344
1235
|
return git_reference__is_tag(ref->name);
|
|
1345
1236
|
}
|
|
1346
1237
|
|
|
@@ -1351,7 +1242,7 @@ int git_reference__is_note(const char *ref_name)
|
|
|
1351
1242
|
|
|
1352
1243
|
int git_reference_is_note(const git_reference *ref)
|
|
1353
1244
|
{
|
|
1354
|
-
|
|
1245
|
+
GIT_ASSERT_ARG(ref);
|
|
1355
1246
|
return git_reference__is_note(ref->name);
|
|
1356
1247
|
}
|
|
1357
1248
|
|
|
@@ -1373,7 +1264,7 @@ int git_reference_peel(
|
|
|
1373
1264
|
git_object *target = NULL;
|
|
1374
1265
|
int error;
|
|
1375
1266
|
|
|
1376
|
-
|
|
1267
|
+
GIT_ASSERT_ARG(ref);
|
|
1377
1268
|
|
|
1378
1269
|
if (ref->type == GIT_REFERENCE_DIRECT) {
|
|
1379
1270
|
resolved = ref;
|
|
@@ -1415,19 +1306,30 @@ cleanup:
|
|
|
1415
1306
|
return error;
|
|
1416
1307
|
}
|
|
1417
1308
|
|
|
1418
|
-
int
|
|
1309
|
+
int git_reference__name_is_valid(
|
|
1310
|
+
int *valid,
|
|
1311
|
+
const char *refname,
|
|
1312
|
+
unsigned int flags)
|
|
1419
1313
|
{
|
|
1420
|
-
|
|
1421
|
-
git_error_clear();
|
|
1422
|
-
return false;
|
|
1423
|
-
}
|
|
1314
|
+
int error;
|
|
1424
1315
|
|
|
1425
|
-
|
|
1316
|
+
GIT_ASSERT(valid && refname);
|
|
1317
|
+
|
|
1318
|
+
*valid = 0;
|
|
1319
|
+
|
|
1320
|
+
error = git_reference__normalize_name(NULL, refname, flags);
|
|
1321
|
+
|
|
1322
|
+
if (!error)
|
|
1323
|
+
*valid = 1;
|
|
1324
|
+
else if (error == GIT_EINVALIDSPEC)
|
|
1325
|
+
error = 0;
|
|
1326
|
+
|
|
1327
|
+
return error;
|
|
1426
1328
|
}
|
|
1427
1329
|
|
|
1428
|
-
int
|
|
1330
|
+
int git_reference_name_is_valid(int *valid, const char *refname)
|
|
1429
1331
|
{
|
|
1430
|
-
return
|
|
1332
|
+
return git_reference__name_is_valid(valid, refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
|
|
1431
1333
|
}
|
|
1432
1334
|
|
|
1433
1335
|
const char *git_reference__shorthand(const char *name)
|
|
@@ -1441,7 +1343,7 @@ const char *git_reference__shorthand(const char *name)
|
|
|
1441
1343
|
else if (!git__prefixcmp(name, GIT_REFS_DIR))
|
|
1442
1344
|
return name + strlen(GIT_REFS_DIR);
|
|
1443
1345
|
|
|
1444
|
-
/* No shorthands are
|
|
1346
|
+
/* No shorthands are available, so just return the name. */
|
|
1445
1347
|
return name;
|
|
1446
1348
|
}
|
|
1447
1349
|
|
|
@@ -1454,7 +1356,10 @@ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_re
|
|
|
1454
1356
|
{
|
|
1455
1357
|
int error;
|
|
1456
1358
|
git_reference *tmp_ref;
|
|
1457
|
-
|
|
1359
|
+
|
|
1360
|
+
GIT_ASSERT_ARG(unborn);
|
|
1361
|
+
GIT_ASSERT_ARG(ref);
|
|
1362
|
+
GIT_ASSERT_ARG(repo);
|
|
1458
1363
|
|
|
1459
1364
|
if (ref->type == GIT_REFERENCE_DIRECT) {
|
|
1460
1365
|
*unborn = 0;
|
|
@@ -1473,3 +1378,18 @@ int git_reference__is_unborn_head(bool *unborn, const git_reference *ref, git_re
|
|
|
1473
1378
|
|
|
1474
1379
|
return 0;
|
|
1475
1380
|
}
|
|
1381
|
+
|
|
1382
|
+
/* Deprecated functions */
|
|
1383
|
+
|
|
1384
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
1385
|
+
|
|
1386
|
+
int git_reference_is_valid_name(const char *refname)
|
|
1387
|
+
{
|
|
1388
|
+
int valid = 0;
|
|
1389
|
+
|
|
1390
|
+
git_reference__name_is_valid(&valid, refname, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL);
|
|
1391
|
+
|
|
1392
|
+
return valid;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
#endif
|