rugged 1.0.1 → 1.3.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 +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_commit.c +1 -1
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/commit.rb +16 -2
- data/lib/rugged/repository.rb +2 -2
- 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/FindLibSSH2.cmake +13 -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 +95 -0
- data/vendor/libgit2/include/git2/blame.h +95 -42
- data/vendor/libgit2/include/git2/blob.h +37 -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/clone.h +1 -1
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +51 -6
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +368 -8
- data/vendor/libgit2/include/git2/diff.h +34 -113
- data/vendor/libgit2/include/git2/email.h +127 -0
- data/vendor/libgit2/include/git2/errors.h +8 -7
- data/vendor/libgit2/include/git2/filter.h +63 -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/notes.h +2 -2
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/oidarray.h +5 -8
- 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 +62 -9
- data/vendor/libgit2/include/git2/repository.h +107 -62
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/stash.h +1 -1
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/stdint.h +3 -3
- 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/email.h +45 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +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 +4 -4
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +84 -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 +192 -70
- data/vendor/libgit2/src/attr_file.c +99 -41
- 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 +32 -19
- data/vendor/libgit2/src/blame_git.c +7 -4
- data/vendor/libgit2/src/blob.c +60 -32
- data/vendor/libgit2/src/branch.c +87 -37
- data/vendor/libgit2/src/buffer.c +349 -29
- data/vendor/libgit2/src/buffer.h +154 -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 -8
- data/vendor/libgit2/src/checkout.c +103 -105
- data/vendor/libgit2/src/cherrypick.c +8 -2
- data/vendor/libgit2/src/clone.c +105 -30
- 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 +41 -23
- 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 +17 -9
- data/vendor/libgit2/src/config_parse.c +6 -8
- 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 +12 -5
- data/vendor/libgit2/src/diff.c +55 -183
- 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/email.c +299 -0
- data/vendor/libgit2/src/email.h +25 -0
- 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 +215 -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 +8 -10
- 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 +33 -17
- data/vendor/libgit2/src/index.c +124 -82
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +95 -37
- 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} +148 -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 +95 -43
- 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 +40 -40
- 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/oidarray.c +10 -1
- 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 +103 -58
- data/vendor/libgit2/src/path.h +80 -7
- 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 +145 -153
- data/vendor/libgit2/src/reflog.c +21 -20
- data/vendor/libgit2/src/refs.c +153 -233
- data/vendor/libgit2/src/refs.h +2 -20
- data/vendor/libgit2/src/refspec.c +81 -45
- data/vendor/libgit2/src/regexp.c +2 -2
- data/vendor/libgit2/src/remote.c +320 -122
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +476 -203
- data/vendor/libgit2/src/repository.h +27 -29
- data/vendor/libgit2/src/reset.c +8 -7
- data/vendor/libgit2/src/revert.c +8 -2
- data/vendor/libgit2/src/revparse.c +23 -17
- 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 +6 -2
- 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 +84 -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/trailer.c +1 -1
- 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 +68 -38
- 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 +55 -21
- data/vendor/libgit2/src/transports/winhttp.c +157 -89
- 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 +75 -184
- data/vendor/libgit2/src/util.h +34 -40
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +5 -3
- 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.h +6 -6
- data/vendor/libgit2/src/win32/posix_w32.c +86 -7
- 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 +36 -14
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +65 -42
- 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/remote.c
CHANGED
@@ -82,9 +82,11 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
|
|
82
82
|
|
83
83
|
static int ensure_remote_name_is_valid(const char *name)
|
84
84
|
{
|
85
|
-
int error
|
85
|
+
int valid, error;
|
86
|
+
|
87
|
+
error = git_remote_name_is_valid(&valid, name);
|
86
88
|
|
87
|
-
if (!
|
89
|
+
if (!error && !valid) {
|
88
90
|
git_error_set(
|
89
91
|
GIT_ERROR_CONFIG,
|
90
92
|
"'%s' is not a valid remote name.", name ? name : "(null)");
|
@@ -110,12 +112,8 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
|
|
110
112
|
if ((error = ensure_remote_name_is_valid(name)) < 0)
|
111
113
|
return error;
|
112
114
|
|
113
|
-
if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0)
|
114
|
-
if (git_error_last()->klass != GIT_ERROR_NOMEMORY)
|
115
|
-
error = GIT_EINVALIDSPEC;
|
116
|
-
|
115
|
+
if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0)
|
117
116
|
return error;
|
118
|
-
}
|
119
117
|
|
120
118
|
git_refspec__dispose(&spec);
|
121
119
|
|
@@ -123,7 +121,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
|
|
123
121
|
return error;
|
124
122
|
|
125
123
|
/*
|
126
|
-
* "$^" is
|
124
|
+
* "$^" is an unmatchable regexp: it will not match anything at all, so
|
127
125
|
* all values will be considered new and we will not replace any
|
128
126
|
* present value.
|
129
127
|
*/
|
@@ -195,10 +193,12 @@ int git_remote_create_options_init(git_remote_create_options *opts, unsigned int
|
|
195
193
|
return 0;
|
196
194
|
}
|
197
195
|
|
196
|
+
#ifndef GIT_DEPRECATE_HARD
|
198
197
|
int git_remote_create_init_options(git_remote_create_options *opts, unsigned int version)
|
199
198
|
{
|
200
199
|
return git_remote_create_options_init(opts, version);
|
201
200
|
}
|
201
|
+
#endif
|
202
202
|
|
203
203
|
int git_remote_create_with_opts(git_remote **out, const char *url, const git_remote_create_options *opts)
|
204
204
|
{
|
@@ -210,7 +210,8 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
|
|
210
210
|
const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
|
211
211
|
int error = -1;
|
212
212
|
|
213
|
-
|
213
|
+
GIT_ASSERT_ARG(out);
|
214
|
+
GIT_ASSERT_ARG(url);
|
214
215
|
|
215
216
|
if (!opts) {
|
216
217
|
opts = &dummy_opts;
|
@@ -459,7 +460,9 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
459
460
|
struct refspec_cb_data data = { NULL };
|
460
461
|
bool optional_setting_found = false, found;
|
461
462
|
|
462
|
-
|
463
|
+
GIT_ASSERT_ARG(out);
|
464
|
+
GIT_ASSERT_ARG(repo);
|
465
|
+
GIT_ASSERT_ARG(name);
|
463
466
|
|
464
467
|
if ((error = ensure_remote_name_is_valid(name)) < 0)
|
465
468
|
return error;
|
@@ -581,29 +584,46 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
|
|
581
584
|
|
582
585
|
const char *git_remote_name(const git_remote *remote)
|
583
586
|
{
|
584
|
-
|
587
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
585
588
|
return remote->name;
|
586
589
|
}
|
587
590
|
|
588
591
|
git_repository *git_remote_owner(const git_remote *remote)
|
589
592
|
{
|
590
|
-
|
593
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
591
594
|
return remote->repo;
|
592
595
|
}
|
593
596
|
|
594
597
|
const char *git_remote_url(const git_remote *remote)
|
595
598
|
{
|
596
|
-
|
599
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
597
600
|
return remote->url;
|
598
601
|
}
|
599
602
|
|
603
|
+
int git_remote_set_instance_url(git_remote *remote, const char *url)
|
604
|
+
{
|
605
|
+
char *tmp;
|
606
|
+
|
607
|
+
GIT_ASSERT_ARG(remote);
|
608
|
+
GIT_ASSERT_ARG(url);
|
609
|
+
|
610
|
+
if ((tmp = git__strdup(url)) == NULL)
|
611
|
+
return -1;
|
612
|
+
|
613
|
+
git__free(remote->url);
|
614
|
+
remote->url = tmp;
|
615
|
+
|
616
|
+
return 0;
|
617
|
+
}
|
618
|
+
|
600
619
|
static int set_url(git_repository *repo, const char *remote, const char *pattern, const char *url)
|
601
620
|
{
|
602
621
|
git_config *cfg;
|
603
622
|
git_buf buf = GIT_BUF_INIT, canonical_url = GIT_BUF_INIT;
|
604
623
|
int error;
|
605
624
|
|
606
|
-
|
625
|
+
GIT_ASSERT_ARG(repo);
|
626
|
+
GIT_ASSERT_ARG(remote);
|
607
627
|
|
608
628
|
if ((error = ensure_remote_name_is_valid(remote)) < 0)
|
609
629
|
return error;
|
@@ -637,44 +657,84 @@ int git_remote_set_url(git_repository *repo, const char *remote, const char *url
|
|
637
657
|
|
638
658
|
const char *git_remote_pushurl(const git_remote *remote)
|
639
659
|
{
|
640
|
-
|
660
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
641
661
|
return remote->pushurl;
|
642
662
|
}
|
643
663
|
|
644
|
-
int
|
664
|
+
int git_remote_set_instance_pushurl(git_remote *remote, const char *url)
|
665
|
+
{
|
666
|
+
char *tmp;
|
667
|
+
|
668
|
+
GIT_ASSERT_ARG(remote);
|
669
|
+
GIT_ASSERT_ARG(url);
|
670
|
+
|
671
|
+
if ((tmp = git__strdup(url)) == NULL)
|
672
|
+
return -1;
|
673
|
+
|
674
|
+
git__free(remote->pushurl);
|
675
|
+
remote->pushurl = tmp;
|
676
|
+
|
677
|
+
return 0;
|
678
|
+
}
|
679
|
+
|
680
|
+
int git_remote_set_pushurl(git_repository *repo, const char *remote, const char *url)
|
645
681
|
{
|
646
682
|
return set_url(repo, remote, CONFIG_PUSHURL_FMT, url);
|
647
683
|
}
|
648
684
|
|
649
|
-
static int resolve_url(
|
685
|
+
static int resolve_url(
|
686
|
+
git_buf *resolved_url,
|
687
|
+
const char *url,
|
688
|
+
int direction,
|
689
|
+
const git_remote_callbacks *callbacks)
|
650
690
|
{
|
651
|
-
|
691
|
+
#ifdef GIT_DEPRECATE_HARD
|
692
|
+
GIT_UNUSED(direction);
|
693
|
+
GIT_UNUSED(callbacks);
|
694
|
+
#else
|
695
|
+
int status, error;
|
652
696
|
|
653
697
|
if (callbacks && callbacks->resolve_url) {
|
654
698
|
git_buf_clear(resolved_url);
|
655
699
|
status = callbacks->resolve_url(resolved_url, url, direction, callbacks->payload);
|
656
700
|
if (status != GIT_PASSTHROUGH) {
|
657
701
|
git_error_set_after_callback_function(status, "git_resolve_url_cb");
|
658
|
-
|
702
|
+
|
703
|
+
if ((error = git_buf_sanitize(resolved_url)) < 0)
|
704
|
+
return error;
|
705
|
+
|
659
706
|
return status;
|
660
707
|
}
|
661
708
|
}
|
709
|
+
#endif
|
662
710
|
|
663
711
|
return git_buf_sets(resolved_url, url);
|
664
712
|
}
|
665
713
|
|
666
|
-
int git_remote__urlfordirection(
|
714
|
+
int git_remote__urlfordirection(
|
715
|
+
git_buf *url_out,
|
716
|
+
struct git_remote *remote,
|
717
|
+
int direction,
|
718
|
+
const git_remote_callbacks *callbacks)
|
667
719
|
{
|
668
720
|
const char *url = NULL;
|
669
721
|
|
670
|
-
|
671
|
-
|
722
|
+
GIT_ASSERT_ARG(remote);
|
723
|
+
GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
|
672
724
|
|
673
|
-
if (
|
725
|
+
if (callbacks && callbacks->remote_ready) {
|
726
|
+
int status = callbacks->remote_ready(remote, direction, callbacks->payload);
|
727
|
+
|
728
|
+
if (status != 0 && status != GIT_PASSTHROUGH) {
|
729
|
+
git_error_set_after_callback_function(status, "git_remote_ready_cb");
|
730
|
+
return status;
|
731
|
+
}
|
732
|
+
}
|
733
|
+
|
734
|
+
if (direction == GIT_DIRECTION_FETCH)
|
674
735
|
url = remote->url;
|
675
|
-
|
736
|
+
else if (direction == GIT_DIRECTION_PUSH)
|
676
737
|
url = remote->pushurl ? remote->pushurl : remote->url;
|
677
|
-
}
|
678
738
|
|
679
739
|
if (!url) {
|
680
740
|
git_error_set(GIT_ERROR_INVALID,
|
@@ -683,10 +743,11 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
|
|
683
743
|
direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
|
684
744
|
return GIT_EINVALID;
|
685
745
|
}
|
746
|
+
|
686
747
|
return resolve_url(url_out, url, direction, callbacks);
|
687
748
|
}
|
688
749
|
|
689
|
-
int
|
750
|
+
static int remote_transport_set_callbacks(git_transport *t, const git_remote_callbacks *cbs)
|
690
751
|
{
|
691
752
|
if (!t->set_callbacks || !cbs)
|
692
753
|
return 0;
|
@@ -713,7 +774,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
|
|
713
774
|
git_credential_acquire_cb credentials = NULL;
|
714
775
|
git_transport_cb transport = NULL;
|
715
776
|
|
716
|
-
|
777
|
+
GIT_ASSERT_ARG(remote);
|
717
778
|
|
718
779
|
if (callbacks) {
|
719
780
|
GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
@@ -744,7 +805,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
|
|
744
805
|
if ((error = set_transport_custom_headers(t, conn->custom_headers)) != 0)
|
745
806
|
goto on_error;
|
746
807
|
|
747
|
-
if ((error =
|
808
|
+
if ((error = remote_transport_set_callbacks(t, callbacks)) < 0 ||
|
748
809
|
(error = t->connect(t, url.ptr, credentials, payload, conn->proxy, direction, flags)) != 0)
|
749
810
|
goto on_error;
|
750
811
|
|
@@ -778,7 +839,7 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
|
|
778
839
|
|
779
840
|
int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote)
|
780
841
|
{
|
781
|
-
|
842
|
+
GIT_ASSERT_ARG(remote);
|
782
843
|
|
783
844
|
if (!remote->transport) {
|
784
845
|
git_error_set(GIT_ERROR_NET, "this remote has never connected");
|
@@ -788,75 +849,147 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
|
|
788
849
|
return remote->transport->ls(out, size, remote->transport);
|
789
850
|
}
|
790
851
|
|
791
|
-
int
|
852
|
+
static int lookup_config(char **out, git_config *cfg, const char *name)
|
792
853
|
{
|
793
|
-
git_config *cfg;
|
794
854
|
git_config_entry *ce = NULL;
|
795
|
-
git_buf val = GIT_BUF_INIT;
|
796
855
|
int error;
|
797
856
|
|
798
|
-
|
857
|
+
if ((error = git_config__lookup_entry(&ce, cfg, name, false)) < 0)
|
858
|
+
return error;
|
859
|
+
|
860
|
+
if (ce && ce->value) {
|
861
|
+
*out = git__strdup(ce->value);
|
862
|
+
GIT_ERROR_CHECK_ALLOC(*out);
|
863
|
+
} else {
|
864
|
+
error = GIT_ENOTFOUND;
|
865
|
+
}
|
799
866
|
|
800
|
-
|
801
|
-
|
867
|
+
git_config_entry_free(ce);
|
868
|
+
return error;
|
869
|
+
}
|
802
870
|
|
803
|
-
|
871
|
+
static void url_config_trim(git_net_url *url)
|
872
|
+
{
|
873
|
+
size_t len = strlen(url->path);
|
804
874
|
|
805
|
-
if (
|
806
|
-
|
875
|
+
if (url->path[len - 1] == '/') {
|
876
|
+
len--;
|
877
|
+
} else {
|
878
|
+
while (len && url->path[len - 1] != '/')
|
879
|
+
len--;
|
880
|
+
}
|
881
|
+
|
882
|
+
url->path[len] = '\0';
|
883
|
+
}
|
884
|
+
|
885
|
+
static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
886
|
+
{
|
887
|
+
git_config *cfg = NULL;
|
888
|
+
git_buf buf = GIT_BUF_INIT;
|
889
|
+
git_net_url lookup_url = GIT_NET_URL_INIT;
|
890
|
+
int error;
|
807
891
|
|
808
|
-
|
809
|
-
|
892
|
+
if ((error = git_net_url_dup(&lookup_url, url)) < 0)
|
893
|
+
goto done;
|
894
|
+
|
895
|
+
if (remote->repo) {
|
896
|
+
if ((error = git_repository_config(&cfg, remote->repo)) < 0)
|
897
|
+
goto done;
|
898
|
+
} else {
|
899
|
+
if ((error = git_config_open_default(&cfg)) < 0)
|
900
|
+
goto done;
|
901
|
+
}
|
810
902
|
|
811
903
|
/* remote.<name>.proxy config setting */
|
812
904
|
if (remote->name && remote->name[0]) {
|
813
|
-
|
905
|
+
git_buf_clear(&buf);
|
814
906
|
|
815
|
-
if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0
|
816
|
-
|
907
|
+
if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0 ||
|
908
|
+
(error = lookup_config(out, cfg, buf.ptr)) != GIT_ENOTFOUND)
|
909
|
+
goto done;
|
910
|
+
}
|
817
911
|
|
818
|
-
|
819
|
-
|
912
|
+
while (true) {
|
913
|
+
git_buf_clear(&buf);
|
820
914
|
|
821
|
-
if (error < 0
|
822
|
-
|
915
|
+
if ((error = git_buf_puts(&buf, "http.")) < 0 ||
|
916
|
+
(error = git_net_url_fmt(&buf, &lookup_url)) < 0 ||
|
917
|
+
(error = git_buf_puts(&buf, ".proxy")) < 0 ||
|
918
|
+
(error = lookup_config(out, cfg, buf.ptr)) != GIT_ENOTFOUND)
|
919
|
+
goto done;
|
823
920
|
|
824
|
-
if (
|
825
|
-
|
826
|
-
|
827
|
-
|
921
|
+
if (! lookup_url.path[0])
|
922
|
+
break;
|
923
|
+
|
924
|
+
url_config_trim(&lookup_url);
|
828
925
|
}
|
829
926
|
|
830
|
-
|
831
|
-
if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0)
|
832
|
-
return error;
|
927
|
+
git_buf_clear(&buf);
|
833
928
|
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
929
|
+
error = lookup_config(out, cfg, "http.proxy");
|
930
|
+
|
931
|
+
done:
|
932
|
+
git_config_free(cfg);
|
933
|
+
git_buf_dispose(&buf);
|
934
|
+
git_net_url_dispose(&lookup_url);
|
935
|
+
return error;
|
936
|
+
}
|
937
|
+
|
938
|
+
static int http_proxy_env(char **out, git_remote *remote, git_net_url *url)
|
939
|
+
{
|
940
|
+
git_buf proxy_env = GIT_BUF_INIT, no_proxy_env = GIT_BUF_INIT;
|
941
|
+
bool use_ssl = (strcmp(url->scheme, "https") == 0);
|
942
|
+
int error;
|
943
|
+
|
944
|
+
GIT_UNUSED(remote);
|
838
945
|
|
839
946
|
/* http_proxy / https_proxy environment variables */
|
840
|
-
error = git__getenv(&
|
947
|
+
error = git__getenv(&proxy_env, use_ssl ? "https_proxy" : "http_proxy");
|
841
948
|
|
842
949
|
/* try uppercase environment variables */
|
843
950
|
if (error == GIT_ENOTFOUND)
|
844
|
-
error = git__getenv(&
|
951
|
+
error = git__getenv(&proxy_env, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
|
845
952
|
|
846
|
-
if (error
|
847
|
-
|
848
|
-
git_error_clear();
|
849
|
-
error = 0;
|
850
|
-
}
|
953
|
+
if (error)
|
954
|
+
goto done;
|
851
955
|
|
852
|
-
|
853
|
-
|
956
|
+
/* no_proxy/NO_PROXY environment variables */
|
957
|
+
error = git__getenv(&no_proxy_env, "no_proxy");
|
854
958
|
|
855
|
-
|
959
|
+
if (error == GIT_ENOTFOUND)
|
960
|
+
error = git__getenv(&no_proxy_env, "NO_PROXY");
|
856
961
|
|
857
|
-
|
858
|
-
|
859
|
-
|
962
|
+
if (error && error != GIT_ENOTFOUND)
|
963
|
+
goto done;
|
964
|
+
|
965
|
+
if (!git_net_url_matches_pattern_list(url, no_proxy_env.ptr))
|
966
|
+
*out = git_buf_detach(&proxy_env);
|
967
|
+
else
|
968
|
+
error = GIT_ENOTFOUND;
|
969
|
+
|
970
|
+
done:
|
971
|
+
git_buf_dispose(&proxy_env);
|
972
|
+
git_buf_dispose(&no_proxy_env);
|
973
|
+
return error;
|
974
|
+
}
|
975
|
+
|
976
|
+
int git_remote__http_proxy(char **out, git_remote *remote, git_net_url *url)
|
977
|
+
{
|
978
|
+
int error;
|
979
|
+
|
980
|
+
GIT_ASSERT_ARG(out);
|
981
|
+
GIT_ASSERT_ARG(remote);
|
982
|
+
|
983
|
+
*out = NULL;
|
984
|
+
|
985
|
+
/*
|
986
|
+
* Go through the possible sources for proxy configuration,
|
987
|
+
* Examine the various git config options first, then
|
988
|
+
* consult environment variables.
|
989
|
+
*/
|
990
|
+
if ((error = http_proxy_config(out, remote, url)) != GIT_ENOTFOUND ||
|
991
|
+
(error = http_proxy_env(out, remote, url)) != GIT_ENOTFOUND)
|
992
|
+
return error;
|
860
993
|
|
861
994
|
return 0;
|
862
995
|
}
|
@@ -924,7 +1057,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|
924
1057
|
const git_strarray *custom_headers = NULL;
|
925
1058
|
const git_proxy_options *proxy = NULL;
|
926
1059
|
|
927
|
-
|
1060
|
+
GIT_ASSERT_ARG(remote);
|
928
1061
|
|
929
1062
|
if (!remote->repo) {
|
930
1063
|
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
@@ -1063,7 +1196,8 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
|
|
1063
1196
|
unsigned int i;
|
1064
1197
|
git_remote_head *remote_ref;
|
1065
1198
|
|
1066
|
-
|
1199
|
+
GIT_ASSERT_ARG(update_heads);
|
1200
|
+
GIT_ASSERT_ARG(fetchspec_src);
|
1067
1201
|
|
1068
1202
|
*out = NULL;
|
1069
1203
|
|
@@ -1117,7 +1251,9 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
|
1117
1251
|
const char *ref_name;
|
1118
1252
|
int error = 0, update;
|
1119
1253
|
|
1120
|
-
|
1254
|
+
GIT_ASSERT_ARG(out);
|
1255
|
+
GIT_ASSERT_ARG(spec);
|
1256
|
+
GIT_ASSERT_ARG(ref);
|
1121
1257
|
|
1122
1258
|
*out = NULL;
|
1123
1259
|
|
@@ -1131,6 +1267,16 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
|
1131
1267
|
ref_name = git_reference_name(resolved_ref);
|
1132
1268
|
}
|
1133
1269
|
|
1270
|
+
/*
|
1271
|
+
* The ref name may be unresolvable - perhaps it's pointing to
|
1272
|
+
* something invalid. In this case, there is no remote head for
|
1273
|
+
* this ref.
|
1274
|
+
*/
|
1275
|
+
if (!ref_name) {
|
1276
|
+
error = 0;
|
1277
|
+
goto cleanup;
|
1278
|
+
}
|
1279
|
+
|
1134
1280
|
if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0)
|
1135
1281
|
goto cleanup;
|
1136
1282
|
|
@@ -1154,7 +1300,7 @@ static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git
|
|
1154
1300
|
unsigned int i = 0;
|
1155
1301
|
int error = 0;
|
1156
1302
|
|
1157
|
-
|
1303
|
+
GIT_ASSERT_ARG(remote);
|
1158
1304
|
|
1159
1305
|
/* no heads, nothing to do */
|
1160
1306
|
if (update_heads->length == 0)
|
@@ -1237,7 +1383,7 @@ static int prune_candidates(git_vector *candidates, git_remote *remote)
|
|
1237
1383
|
}
|
1238
1384
|
|
1239
1385
|
out:
|
1240
|
-
|
1386
|
+
git_strarray_dispose(&arr);
|
1241
1387
|
return error;
|
1242
1388
|
}
|
1243
1389
|
|
@@ -1297,7 +1443,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
|
|
1297
1443
|
if (error == GIT_ENOTFOUND)
|
1298
1444
|
continue;
|
1299
1445
|
|
1300
|
-
/*
|
1446
|
+
/* If we did find a source, remove it from the candidates. */
|
1301
1447
|
if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0)
|
1302
1448
|
goto cleanup;
|
1303
1449
|
|
@@ -1360,7 +1506,7 @@ static int update_tips_for_spec(
|
|
1360
1506
|
git_vector *refs,
|
1361
1507
|
const char *log_message)
|
1362
1508
|
{
|
1363
|
-
int error = 0, autotag;
|
1509
|
+
int error = 0, autotag, valid;
|
1364
1510
|
unsigned int i = 0;
|
1365
1511
|
git_buf refname = GIT_BUF_INIT;
|
1366
1512
|
git_oid old;
|
@@ -1370,7 +1516,7 @@ static int update_tips_for_spec(
|
|
1370
1516
|
git_refspec tagspec;
|
1371
1517
|
git_vector update_heads;
|
1372
1518
|
|
1373
|
-
|
1519
|
+
GIT_ASSERT_ARG(remote);
|
1374
1520
|
|
1375
1521
|
if (git_repository_odb__weakptr(&odb, remote->repo) < 0)
|
1376
1522
|
return -1;
|
@@ -1388,7 +1534,10 @@ static int update_tips_for_spec(
|
|
1388
1534
|
git_buf_clear(&refname);
|
1389
1535
|
|
1390
1536
|
/* Ignore malformed ref names (which also saves us from tag^{} */
|
1391
|
-
if (
|
1537
|
+
if (git_reference_name_is_valid(&valid, head->name) < 0)
|
1538
|
+
goto on_error;
|
1539
|
+
|
1540
|
+
if (!valid)
|
1392
1541
|
continue;
|
1393
1542
|
|
1394
1543
|
/* If we have a tag, see if the auto-follow rules say to update it */
|
@@ -1437,6 +1586,11 @@ static int update_tips_for_spec(
|
|
1437
1586
|
if (error < 0 && error != GIT_ENOTFOUND)
|
1438
1587
|
goto on_error;
|
1439
1588
|
|
1589
|
+
if (!(error || error == GIT_ENOTFOUND)
|
1590
|
+
&& !spec->force
|
1591
|
+
&& !git_graph_descendant_of(remote->repo, &head->oid, &old))
|
1592
|
+
continue;
|
1593
|
+
|
1440
1594
|
if (error == GIT_ENOTFOUND) {
|
1441
1595
|
memset(&old, 0, GIT_OID_RAWSZ);
|
1442
1596
|
|
@@ -1497,6 +1651,7 @@ static int next_head(const git_remote *remote, git_vector *refs,
|
|
1497
1651
|
git_remote_head *head;
|
1498
1652
|
git_refspec *spec, *passive_spec;
|
1499
1653
|
size_t i, j, k;
|
1654
|
+
int valid;
|
1500
1655
|
|
1501
1656
|
active = &remote->active_refspecs;
|
1502
1657
|
passive = &remote->passive_refspecs;
|
@@ -1508,7 +1663,10 @@ static int next_head(const git_remote *remote, git_vector *refs,
|
|
1508
1663
|
for (; i < refs->length; i++) {
|
1509
1664
|
head = git_vector_get(refs, i);
|
1510
1665
|
|
1511
|
-
if (
|
1666
|
+
if (git_reference_name_is_valid(&valid, head->name) < 0)
|
1667
|
+
return -1;
|
1668
|
+
|
1669
|
+
if (!valid)
|
1512
1670
|
continue;
|
1513
1671
|
|
1514
1672
|
for (; j < active->length; j++) {
|
@@ -1655,7 +1813,7 @@ int git_remote_update_tips(
|
|
1655
1813
|
goto out;
|
1656
1814
|
}
|
1657
1815
|
|
1658
|
-
/*
|
1816
|
+
/* Only try to do opportunistic updates if the refpec lists differ. */
|
1659
1817
|
if (remote->passed_refspecs)
|
1660
1818
|
error = opportunistic_updates(remote, callbacks, &refs, reflog_message);
|
1661
1819
|
|
@@ -1667,7 +1825,7 @@ out:
|
|
1667
1825
|
|
1668
1826
|
int git_remote_connected(const git_remote *remote)
|
1669
1827
|
{
|
1670
|
-
|
1828
|
+
GIT_ASSERT_ARG(remote);
|
1671
1829
|
|
1672
1830
|
if (!remote->transport || !remote->transport->is_connected)
|
1673
1831
|
return 0;
|
@@ -1678,7 +1836,7 @@ int git_remote_connected(const git_remote *remote)
|
|
1678
1836
|
|
1679
1837
|
int git_remote_stop(git_remote *remote)
|
1680
1838
|
{
|
1681
|
-
|
1839
|
+
GIT_ASSERT_ARG(remote);
|
1682
1840
|
|
1683
1841
|
if (remote->transport && remote->transport->cancel)
|
1684
1842
|
remote->transport->cancel(remote->transport);
|
@@ -1688,7 +1846,7 @@ int git_remote_stop(git_remote *remote)
|
|
1688
1846
|
|
1689
1847
|
int git_remote_disconnect(git_remote *remote)
|
1690
1848
|
{
|
1691
|
-
|
1849
|
+
GIT_ASSERT_ARG(remote);
|
1692
1850
|
|
1693
1851
|
if (git_remote_connected(remote))
|
1694
1852
|
remote->transport->close(remote->transport);
|
@@ -1774,7 +1932,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
|
|
1774
1932
|
|
1775
1933
|
const git_indexer_progress *git_remote_stats(git_remote *remote)
|
1776
1934
|
{
|
1777
|
-
|
1935
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
1778
1936
|
return &remote->stats;
|
1779
1937
|
}
|
1780
1938
|
|
@@ -1789,7 +1947,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
|
|
1789
1947
|
git_config *config;
|
1790
1948
|
int error;
|
1791
1949
|
|
1792
|
-
|
1950
|
+
GIT_ASSERT_ARG(repo && remote);
|
1793
1951
|
|
1794
1952
|
if ((error = ensure_remote_name_is_valid(remote)) < 0)
|
1795
1953
|
return error;
|
@@ -2053,7 +2211,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name,
|
|
2053
2211
|
git_vector problem_refspecs = GIT_VECTOR_INIT;
|
2054
2212
|
git_remote *remote = NULL;
|
2055
2213
|
|
2056
|
-
|
2214
|
+
GIT_ASSERT_ARG(out && repo && name && new_name);
|
2057
2215
|
|
2058
2216
|
if ((error = git_remote_lookup(&remote, repo, name)) < 0)
|
2059
2217
|
return error;
|
@@ -2087,24 +2245,34 @@ cleanup:
|
|
2087
2245
|
return error;
|
2088
2246
|
}
|
2089
2247
|
|
2090
|
-
int
|
2091
|
-
const char *remote_name)
|
2248
|
+
int git_remote_name_is_valid(int *valid, const char *remote_name)
|
2092
2249
|
{
|
2093
2250
|
git_buf buf = GIT_BUF_INIT;
|
2094
|
-
git_refspec refspec;
|
2095
|
-
int error
|
2251
|
+
git_refspec refspec = {0};
|
2252
|
+
int error;
|
2253
|
+
|
2254
|
+
GIT_ASSERT(valid);
|
2255
|
+
|
2256
|
+
*valid = 0;
|
2096
2257
|
|
2097
2258
|
if (!remote_name || *remote_name == '\0')
|
2098
2259
|
return 0;
|
2099
2260
|
|
2100
|
-
git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)
|
2261
|
+
if ((error = git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)) < 0)
|
2262
|
+
goto done;
|
2263
|
+
|
2101
2264
|
error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true);
|
2102
2265
|
|
2266
|
+
if (!error)
|
2267
|
+
*valid = 1;
|
2268
|
+
else if (error == GIT_EINVALIDSPEC)
|
2269
|
+
error = 0;
|
2270
|
+
|
2271
|
+
done:
|
2103
2272
|
git_buf_dispose(&buf);
|
2104
2273
|
git_refspec__dispose(&refspec);
|
2105
2274
|
|
2106
|
-
|
2107
|
-
return error == 0;
|
2275
|
+
return error;
|
2108
2276
|
}
|
2109
2277
|
|
2110
2278
|
git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname)
|
@@ -2219,7 +2387,7 @@ static const char *name_offset(size_t *len_out, const char *name)
|
|
2219
2387
|
prefix_len = strlen("remote.");
|
2220
2388
|
dot = strchr(name + prefix_len, '.');
|
2221
2389
|
|
2222
|
-
|
2390
|
+
GIT_ASSERT_ARG_WITH_RETVAL(dot, NULL);
|
2223
2391
|
|
2224
2392
|
*len_out = dot - name - prefix_len;
|
2225
2393
|
return name + prefix_len;
|
@@ -2249,10 +2417,13 @@ static int remove_branch_config_related_entries(
|
|
2249
2417
|
if (strcmp(remote_name, entry->value))
|
2250
2418
|
continue;
|
2251
2419
|
|
2252
|
-
branch = name_offset(&branch_len, entry->name)
|
2420
|
+
if ((branch = name_offset(&branch_len, entry->name)) == NULL) {
|
2421
|
+
error = -1;
|
2422
|
+
break;
|
2423
|
+
}
|
2253
2424
|
|
2254
2425
|
git_buf_clear(&buf);
|
2255
|
-
if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
|
2426
|
+
if ((error = git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch)) < 0)
|
2256
2427
|
break;
|
2257
2428
|
|
2258
2429
|
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
|
@@ -2262,7 +2433,7 @@ static int remove_branch_config_related_entries(
|
|
2262
2433
|
}
|
2263
2434
|
|
2264
2435
|
git_buf_clear(&buf);
|
2265
|
-
if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
|
2436
|
+
if ((error = git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch)) < 0)
|
2266
2437
|
break;
|
2267
2438
|
|
2268
2439
|
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
|
@@ -2357,7 +2528,8 @@ int git_remote_delete(git_repository *repo, const char *name)
|
|
2357
2528
|
{
|
2358
2529
|
int error;
|
2359
2530
|
|
2360
|
-
|
2531
|
+
GIT_ASSERT_ARG(repo);
|
2532
|
+
GIT_ASSERT_ARG(name);
|
2361
2533
|
|
2362
2534
|
if ((error = remove_branch_config_related_entries(repo, name)) < 0 ||
|
2363
2535
|
(error = remove_remote_tracking(repo, name)) < 0 ||
|
@@ -2373,29 +2545,37 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
2373
2545
|
const git_remote_head *guess = NULL;
|
2374
2546
|
const git_oid *head_id;
|
2375
2547
|
size_t heads_len, i;
|
2548
|
+
git_buf local_default = GIT_BUF_INIT;
|
2376
2549
|
int error;
|
2377
2550
|
|
2378
|
-
|
2551
|
+
GIT_ASSERT_ARG(out);
|
2379
2552
|
|
2380
2553
|
if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
|
2381
|
-
|
2554
|
+
goto done;
|
2382
2555
|
|
2383
|
-
if (heads_len == 0)
|
2384
|
-
|
2556
|
+
if (heads_len == 0 || strcmp(heads[0]->name, GIT_HEAD_FILE)) {
|
2557
|
+
error = GIT_ENOTFOUND;
|
2558
|
+
goto done;
|
2559
|
+
}
|
2385
2560
|
|
2386
|
-
if (
|
2387
|
-
return
|
2561
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
2562
|
+
return error;
|
2388
2563
|
|
2389
|
-
git_buf_sanitize(out);
|
2390
2564
|
/* the first one must be HEAD so if that has the symref info, we're done */
|
2391
|
-
if (heads[0]->symref_target)
|
2392
|
-
|
2565
|
+
if (heads[0]->symref_target) {
|
2566
|
+
error = git_buf_puts(out, heads[0]->symref_target);
|
2567
|
+
goto done;
|
2568
|
+
}
|
2393
2569
|
|
2394
2570
|
/*
|
2395
2571
|
* If there's no symref information, we have to look over them
|
2396
|
-
* and guess. We return the first match unless the
|
2397
|
-
* branch is a candidate. Then we return the
|
2572
|
+
* and guess. We return the first match unless the default
|
2573
|
+
* branch is a candidate. Then we return the default branch.
|
2398
2574
|
*/
|
2575
|
+
|
2576
|
+
if ((error = git_repository_initialbranch(&local_default, remote->repo)) < 0)
|
2577
|
+
goto done;
|
2578
|
+
|
2399
2579
|
head_id = &heads[0]->oid;
|
2400
2580
|
|
2401
2581
|
for (i = 1; i < heads_len; i++) {
|
@@ -2410,16 +2590,22 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
2410
2590
|
continue;
|
2411
2591
|
}
|
2412
2592
|
|
2413
|
-
if (!git__strcmp(
|
2593
|
+
if (!git__strcmp(local_default.ptr, heads[i]->name)) {
|
2414
2594
|
guess = heads[i];
|
2415
2595
|
break;
|
2416
2596
|
}
|
2417
2597
|
}
|
2418
2598
|
|
2419
|
-
if (!guess)
|
2420
|
-
|
2599
|
+
if (!guess) {
|
2600
|
+
error = GIT_ENOTFOUND;
|
2601
|
+
goto done;
|
2602
|
+
}
|
2421
2603
|
|
2422
|
-
|
2604
|
+
error = git_buf_puts(out, guess->name);
|
2605
|
+
|
2606
|
+
done:
|
2607
|
+
git_buf_dispose(&local_default);
|
2608
|
+
return error;
|
2423
2609
|
}
|
2424
2610
|
|
2425
2611
|
int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts)
|
@@ -2431,7 +2617,7 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
|
|
2431
2617
|
const git_remote_callbacks *cbs = NULL;
|
2432
2618
|
git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT;
|
2433
2619
|
|
2434
|
-
|
2620
|
+
GIT_ASSERT_ARG(remote);
|
2435
2621
|
|
2436
2622
|
if (!remote->repo) {
|
2437
2623
|
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
@@ -2497,7 +2683,7 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|
2497
2683
|
const git_strarray *custom_headers = NULL;
|
2498
2684
|
const git_proxy_options *proxy = NULL;
|
2499
2685
|
|
2500
|
-
|
2686
|
+
GIT_ASSERT_ARG(remote);
|
2501
2687
|
|
2502
2688
|
if (!remote->repo) {
|
2503
2689
|
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
@@ -2512,8 +2698,6 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|
2512
2698
|
proxy = &opts->proxy_opts;
|
2513
2699
|
}
|
2514
2700
|
|
2515
|
-
assert(remote);
|
2516
|
-
|
2517
2701
|
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
|
2518
2702
|
return error;
|
2519
2703
|
|
@@ -2540,9 +2724,9 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
2540
2724
|
git_config_entry *entry;
|
2541
2725
|
git_config_iterator *iter;
|
2542
2726
|
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2727
|
+
GIT_ASSERT_ARG_WITH_RETVAL(config, NULL);
|
2728
|
+
GIT_ASSERT_ARG_WITH_RETVAL(url, NULL);
|
2729
|
+
GIT_ASSERT_ARG_WITH_RETVAL(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH, NULL);
|
2546
2730
|
|
2547
2731
|
/* Add 1 to prefix/suffix length due to the additional escaped dot */
|
2548
2732
|
prefix_length = strlen(PREFIX) + 1;
|
@@ -2590,3 +2774,17 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
2590
2774
|
|
2591
2775
|
return result.ptr;
|
2592
2776
|
}
|
2777
|
+
|
2778
|
+
/* Deprecated functions */
|
2779
|
+
|
2780
|
+
#ifndef GIT_DEPRECATE_HARD
|
2781
|
+
|
2782
|
+
int git_remote_is_valid_name(const char *remote_name)
|
2783
|
+
{
|
2784
|
+
int valid = 0;
|
2785
|
+
|
2786
|
+
git_remote_name_is_valid(&valid, remote_name);
|
2787
|
+
return valid;
|
2788
|
+
}
|
2789
|
+
|
2790
|
+
#endif
|