rugged 1.3.2 → 1.6.2
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/README.md +34 -2
- data/ext/rugged/extconf.rb +7 -4
- data/ext/rugged/rugged.c +16 -0
- data/ext/rugged/rugged.h +4 -0
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +9 -2
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +28 -10
- data/ext/rugged/rugged_repo.c +7 -9
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_settings.c +5 -0
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +132 -288
- data/vendor/libgit2/COPYING +106 -19
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/AddClarTest.cmake +7 -0
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
- data/vendor/libgit2/cmake/FindPCRE.cmake +12 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
- data/vendor/libgit2/cmake/SelectHashes.cmake +91 -53
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +33 -31
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +3 -1
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/zlib/adler32.c +7 -0
- data/vendor/libgit2/deps/zlib/crc32.c +975 -288
- data/vendor/libgit2/deps/zlib/crc32.h +9441 -436
- data/vendor/libgit2/deps/zlib/deflate.c +83 -31
- data/vendor/libgit2/deps/zlib/deflate.h +12 -15
- data/vendor/libgit2/deps/zlib/gzguts.h +3 -2
- data/vendor/libgit2/deps/zlib/infback.c +2 -1
- data/vendor/libgit2/deps/zlib/inffast.c +14 -14
- data/vendor/libgit2/deps/zlib/inflate.c +39 -8
- data/vendor/libgit2/deps/zlib/inflate.h +3 -2
- data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
- data/vendor/libgit2/deps/zlib/trees.c +27 -48
- data/vendor/libgit2/deps/zlib/zlib.h +126 -100
- data/vendor/libgit2/deps/zlib/zutil.c +2 -2
- data/vendor/libgit2/deps/zlib/zutil.h +12 -9
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +11 -2
- data/vendor/libgit2/include/git2/blame.h +4 -1
- data/vendor/libgit2/include/git2/blob.h +14 -1
- data/vendor/libgit2/include/git2/branch.h +4 -2
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +5 -2
- data/vendor/libgit2/include/git2/clone.h +3 -3
- data/vendor/libgit2/include/git2/commit.h +2 -0
- data/vendor/libgit2/include/git2/common.h +28 -7
- data/vendor/libgit2/include/git2/config.h +25 -9
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +9 -1
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +18 -10
- data/vendor/libgit2/include/git2/email.h +1 -1
- data/vendor/libgit2/include/git2/errors.h +17 -3
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/filter.h +7 -2
- data/vendor/libgit2/include/git2/graph.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +11 -5
- data/vendor/libgit2/include/git2/indexer.h +48 -0
- data/vendor/libgit2/include/git2/merge.h +24 -4
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/object.h +49 -0
- data/vendor/libgit2/include/git2/odb.h +94 -13
- data/vendor/libgit2/include/git2/odb_backend.h +107 -19
- data/vendor/libgit2/include/git2/oid.h +115 -15
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +9 -1
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +2 -2
- data/vendor/libgit2/include/git2/remote.h +184 -37
- data/vendor/libgit2/include/git2/repository.h +34 -10
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +61 -7
- data/vendor/libgit2/include/git2/status.h +14 -5
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/submodule.h +7 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +3 -6
- data/vendor/libgit2/include/git2/sys/remote.h +46 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +46 -39
- data/vendor/libgit2/include/git2/tag.h +1 -0
- data/vendor/libgit2/include/git2/tree.h +4 -3
- data/vendor/libgit2/include/git2/types.h +7 -7
- data/vendor/libgit2/include/git2/version.h +27 -6
- data/vendor/libgit2/include/git2/worktree.h +12 -2
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +177 -419
- data/vendor/libgit2/src/README.md +12 -0
- data/vendor/libgit2/src/cli/CMakeLists.txt +57 -0
- data/vendor/libgit2/src/cli/README.md +26 -0
- data/vendor/libgit2/src/cli/cli.h +20 -0
- data/vendor/libgit2/src/cli/cmd.c +21 -0
- data/vendor/libgit2/src/cli/cmd.h +33 -0
- data/vendor/libgit2/src/cli/cmd_cat_file.c +204 -0
- data/vendor/libgit2/src/cli/cmd_clone.c +176 -0
- data/vendor/libgit2/src/cli/cmd_hash_object.c +154 -0
- data/vendor/libgit2/src/cli/cmd_help.c +86 -0
- data/vendor/libgit2/src/cli/error.h +51 -0
- data/vendor/libgit2/src/cli/main.c +106 -0
- data/vendor/libgit2/src/cli/opt.c +669 -0
- data/vendor/libgit2/src/cli/opt.h +349 -0
- data/vendor/libgit2/src/cli/opt_usage.c +194 -0
- data/vendor/libgit2/src/cli/opt_usage.h +35 -0
- data/vendor/libgit2/src/cli/progress.c +345 -0
- data/vendor/libgit2/src/cli/progress.h +117 -0
- data/vendor/libgit2/src/cli/sighandler.h +20 -0
- data/vendor/libgit2/src/cli/unix/sighandler.c +36 -0
- data/vendor/libgit2/src/cli/win32/precompiled.h +3 -0
- data/vendor/libgit2/src/cli/win32/sighandler.c +37 -0
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +141 -0
- data/vendor/libgit2/src/{annotated_commit.c → libgit2/annotated_commit.c} +1 -1
- data/vendor/libgit2/src/{annotated_commit.h → libgit2/annotated_commit.h} +2 -2
- data/vendor/libgit2/src/{apply.c → libgit2/apply.c} +18 -18
- data/vendor/libgit2/src/{apply.h → libgit2/apply.h} +2 -2
- data/vendor/libgit2/src/{attr.c → libgit2/attr.c} +18 -18
- data/vendor/libgit2/src/{attr_file.c → libgit2/attr_file.c} +18 -18
- data/vendor/libgit2/src/{attr_file.h → libgit2/attr_file.h} +4 -4
- data/vendor/libgit2/src/{attrcache.c → libgit2/attrcache.c} +18 -13
- data/vendor/libgit2/src/{blame.c → libgit2/blame.c} +2 -0
- data/vendor/libgit2/src/{blame_git.c → libgit2/blame_git.c} +1 -1
- data/vendor/libgit2/src/{blob.c → libgit2/blob.c} +38 -29
- data/vendor/libgit2/src/{blob.h → libgit2/blob.h} +3 -3
- data/vendor/libgit2/src/{branch.c → libgit2/branch.c} +164 -118
- data/vendor/libgit2/src/{branch.h → libgit2/branch.h} +15 -3
- data/vendor/libgit2/src/libgit2/buf.c +126 -0
- data/vendor/libgit2/src/libgit2/buf.h +50 -0
- data/vendor/libgit2/src/{checkout.c → libgit2/checkout.c} +74 -68
- data/vendor/libgit2/src/{cherrypick.c → libgit2/cherrypick.c} +13 -13
- data/vendor/libgit2/src/{clone.c → libgit2/clone.c} +96 -67
- data/vendor/libgit2/src/{commit.c → libgit2/commit.c} +178 -73
- data/vendor/libgit2/src/libgit2/commit.h +87 -0
- data/vendor/libgit2/src/{commit_graph.c → libgit2/commit_graph.c} +122 -89
- data/vendor/libgit2/src/{commit_graph.h → libgit2/commit_graph.h} +14 -4
- data/vendor/libgit2/src/{commit_list.c → libgit2/commit_list.c} +7 -4
- data/vendor/libgit2/src/libgit2/common.h +55 -0
- data/vendor/libgit2/src/{config.c → libgit2/config.c} +101 -69
- data/vendor/libgit2/src/{config.h → libgit2/config.h} +15 -2
- data/vendor/libgit2/src/{config_file.c → libgit2/config_file.c} +105 -93
- data/vendor/libgit2/src/{config_mem.c → libgit2/config_mem.c} +9 -9
- data/vendor/libgit2/src/{config_parse.c → libgit2/config_parse.c} +27 -23
- data/vendor/libgit2/src/{crlf.c → libgit2/crlf.c} +24 -21
- data/vendor/libgit2/src/{describe.c → libgit2/describe.c} +35 -27
- data/vendor/libgit2/src/{diff.c → libgit2/diff.c} +30 -9
- data/vendor/libgit2/src/{diff.h → libgit2/diff.h} +2 -4
- data/vendor/libgit2/src/{diff_driver.c → libgit2/diff_driver.c} +34 -36
- data/vendor/libgit2/src/{diff_driver.h → libgit2/diff_driver.h} +3 -3
- data/vendor/libgit2/src/{diff_file.c → libgit2/diff_file.c} +44 -26
- data/vendor/libgit2/src/{diff_generate.c → libgit2/diff_generate.c} +47 -18
- data/vendor/libgit2/src/{diff_generate.h → libgit2/diff_generate.h} +5 -3
- data/vendor/libgit2/src/{diff_print.c → libgit2/diff_print.c} +112 -100
- data/vendor/libgit2/src/{diff_stats.c → libgit2/diff_stats.c} +40 -29
- data/vendor/libgit2/src/libgit2/diff_stats.h +18 -0
- data/vendor/libgit2/src/{diff_tform.c → libgit2/diff_tform.c} +13 -8
- data/vendor/libgit2/src/{diff_xdiff.c → libgit2/diff_xdiff.c} +4 -8
- data/vendor/libgit2/src/{email.c → libgit2/email.c} +55 -39
- data/vendor/libgit2/src/{email.h → libgit2/email.h} +1 -1
- data/vendor/libgit2/src/{errors.c → libgit2/errors.c} +18 -18
- data/vendor/libgit2/src/{errors.h → libgit2/errors.h} +1 -2
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/{fetch.c → libgit2/fetch.c} +72 -27
- data/vendor/libgit2/src/{fetch.h → libgit2/fetch.h} +1 -1
- data/vendor/libgit2/src/{fetchhead.c → libgit2/fetchhead.c} +23 -23
- data/vendor/libgit2/src/{filter.c → libgit2/filter.c} +127 -53
- data/vendor/libgit2/src/{filter.h → libgit2/filter.h} +26 -5
- data/vendor/libgit2/src/{ident.c → libgit2/ident.c} +20 -20
- data/vendor/libgit2/src/{ignore.c → libgit2/ignore.c} +35 -34
- data/vendor/libgit2/src/{ignore.h → libgit2/ignore.h} +2 -2
- data/vendor/libgit2/src/{index.c → libgit2/index.c} +91 -90
- data/vendor/libgit2/src/{index.h → libgit2/index.h} +6 -3
- data/vendor/libgit2/src/{indexer.c → libgit2/indexer.c} +173 -92
- data/vendor/libgit2/src/{iterator.c → libgit2/iterator.c} +71 -61
- data/vendor/libgit2/src/{iterator.h → libgit2/iterator.h} +5 -5
- data/vendor/libgit2/src/{libgit2.c → libgit2/libgit2.c} +46 -11
- data/vendor/libgit2/src/{mailmap.c → libgit2/mailmap.c} +38 -36
- data/vendor/libgit2/src/{merge.c → libgit2/merge.c} +30 -30
- data/vendor/libgit2/src/{merge.h → libgit2/merge.h} +1 -14
- data/vendor/libgit2/src/{merge_driver.c → libgit2/merge_driver.c} +2 -2
- data/vendor/libgit2/src/{merge_file.c → libgit2/merge_file.c} +13 -3
- data/vendor/libgit2/src/{message.c → libgit2/message.c} +21 -10
- data/vendor/libgit2/src/{midx.c → libgit2/midx.c} +112 -92
- data/vendor/libgit2/src/{midx.h → libgit2/midx.h} +5 -4
- data/vendor/libgit2/src/{mwindow.c → libgit2/mwindow.c} +15 -12
- data/vendor/libgit2/src/{mwindow.h → libgit2/mwindow.h} +5 -2
- data/vendor/libgit2/src/{netops.c → libgit2/netops.c} +1 -2
- data/vendor/libgit2/src/{netops.h → libgit2/netops.h} +1 -1
- data/vendor/libgit2/src/{notes.c → libgit2/notes.c} +25 -34
- data/vendor/libgit2/src/{object.c → libgit2/object.c} +135 -30
- data/vendor/libgit2/src/{object.h → libgit2/object.h} +12 -3
- data/vendor/libgit2/src/{odb.c → libgit2/odb.c} +228 -81
- data/vendor/libgit2/src/{odb.h → libgit2/odb.h} +44 -5
- data/vendor/libgit2/src/{odb_loose.c → libgit2/odb_loose.c} +192 -134
- data/vendor/libgit2/src/{odb_mempack.c → libgit2/odb_mempack.c} +18 -5
- data/vendor/libgit2/src/{odb_pack.c → libgit2/odb_pack.c} +137 -85
- data/vendor/libgit2/src/{oid.c → libgit2/oid.c} +136 -90
- data/vendor/libgit2/src/libgit2/oid.h +273 -0
- data/vendor/libgit2/src/{oidmap.c → libgit2/oidmap.c} +1 -1
- data/vendor/libgit2/src/{pack-objects.c → libgit2/pack-objects.c} +56 -30
- data/vendor/libgit2/src/{pack-objects.h → libgit2/pack-objects.h} +11 -6
- data/vendor/libgit2/src/{pack.c → libgit2/pack.c} +114 -84
- data/vendor/libgit2/src/{pack.h → libgit2/pack.h} +31 -16
- data/vendor/libgit2/src/{parse.c → libgit2/parse.c} +4 -3
- data/vendor/libgit2/src/{patch.c → libgit2/patch.c} +3 -3
- data/vendor/libgit2/src/{patch.h → libgit2/patch.h} +1 -0
- data/vendor/libgit2/src/{patch_generate.c → libgit2/patch_generate.c} +27 -11
- data/vendor/libgit2/src/{patch_generate.h → libgit2/patch_generate.h} +5 -5
- data/vendor/libgit2/src/{patch_parse.c → libgit2/patch_parse.c} +29 -29
- data/vendor/libgit2/src/libgit2/path.c +375 -0
- data/vendor/libgit2/src/libgit2/path.h +68 -0
- data/vendor/libgit2/src/{pathspec.c → libgit2/pathspec.c} +6 -6
- data/vendor/libgit2/src/{pathspec.h → libgit2/pathspec.h} +2 -2
- data/vendor/libgit2/src/{proxy.c → libgit2/proxy.c} +4 -1
- data/vendor/libgit2/src/{proxy.h → libgit2/proxy.h} +1 -1
- data/vendor/libgit2/src/{push.c → libgit2/push.c} +43 -38
- data/vendor/libgit2/src/{push.h → libgit2/push.h} +4 -16
- data/vendor/libgit2/src/{reader.c → libgit2/reader.c} +9 -9
- data/vendor/libgit2/src/{reader.h → libgit2/reader.h} +2 -2
- data/vendor/libgit2/src/{rebase.c → libgit2/rebase.c} +119 -107
- data/vendor/libgit2/src/{refdb_fs.c → libgit2/refdb_fs.c} +506 -197
- data/vendor/libgit2/src/{reflog.c → libgit2/reflog.c} +7 -5
- data/vendor/libgit2/src/{reflog.h → libgit2/reflog.h} +1 -2
- data/vendor/libgit2/src/{refs.c → libgit2/refs.c} +34 -32
- data/vendor/libgit2/src/{refs.h → libgit2/refs.h} +2 -2
- data/vendor/libgit2/src/{refspec.c → libgit2/refspec.c} +32 -37
- data/vendor/libgit2/src/{refspec.h → libgit2/refspec.h} +5 -2
- data/vendor/libgit2/src/{remote.c → libgit2/remote.c} +718 -420
- data/vendor/libgit2/src/libgit2/remote.h +100 -0
- data/vendor/libgit2/src/{repository.c → libgit2/repository.c} +629 -386
- data/vendor/libgit2/src/{repository.h → libgit2/repository.h} +20 -9
- data/vendor/libgit2/src/{reset.c → libgit2/reset.c} +8 -5
- data/vendor/libgit2/src/{revert.c → libgit2/revert.c} +14 -14
- data/vendor/libgit2/src/{revparse.c → libgit2/revparse.c} +71 -42
- data/vendor/libgit2/src/{revwalk.c → libgit2/revwalk.c} +12 -8
- data/vendor/libgit2/src/{signature.c → libgit2/signature.c} +12 -6
- data/vendor/libgit2/src/{signature.h → libgit2/signature.h} +1 -1
- data/vendor/libgit2/src/{stash.c → libgit2/stash.c} +235 -61
- data/vendor/libgit2/src/{status.c → libgit2/status.c} +4 -1
- data/vendor/libgit2/src/{strarray.c → libgit2/strarray.c} +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.c +8 -6
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.c +1 -1
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.h +3 -3
- data/vendor/libgit2/src/{streams → libgit2/streams}/socket.c +4 -1
- data/vendor/libgit2/src/{submodule.c → libgit2/submodule.c} +177 -161
- data/vendor/libgit2/src/{submodule.h → libgit2/submodule.h} +1 -1
- data/vendor/libgit2/src/libgit2/sysdir.c +650 -0
- data/vendor/libgit2/src/{sysdir.h → libgit2/sysdir.h} +53 -18
- data/vendor/libgit2/src/{tag.c → libgit2/tag.c} +73 -42
- data/vendor/libgit2/src/{tag.h → libgit2/tag.h} +2 -2
- data/vendor/libgit2/src/{threadstate.c → libgit2/threadstate.c} +3 -3
- data/vendor/libgit2/src/{threadstate.h → libgit2/threadstate.h} +2 -2
- data/vendor/libgit2/src/{trace.c → libgit2/trace.c} +1 -14
- data/vendor/libgit2/src/{trace.h → libgit2/trace.h} +5 -22
- data/vendor/libgit2/src/{trailer.c → libgit2/trailer.c} +1 -1
- data/vendor/libgit2/src/{transaction.c → libgit2/transaction.c} +1 -1
- data/vendor/libgit2/src/{transport.c → libgit2/transport.c} +10 -10
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.c +7 -9
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.h +2 -3
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.c +12 -13
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.c +10 -10
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/{transports → libgit2/transports}/git.c +9 -11
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.c +41 -20
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.h +2 -3
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.c +75 -66
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.h +10 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/local.c +138 -116
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.c +92 -133
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.h +35 -32
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_pkt.c +177 -65
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_protocol.c +97 -49
- data/vendor/libgit2/src/{transports → libgit2/transports}/ssh.c +365 -198
- data/vendor/libgit2/src/{transports → libgit2/transports}/winhttp.c +58 -59
- data/vendor/libgit2/src/{tree-cache.c → libgit2/tree-cache.c} +8 -8
- data/vendor/libgit2/src/{tree-cache.h → libgit2/tree-cache.h} +2 -2
- data/vendor/libgit2/src/{tree.c → libgit2/tree.c} +93 -83
- data/vendor/libgit2/src/{tree.h → libgit2/tree.h} +4 -4
- data/vendor/libgit2/src/{worktree.c → libgit2/worktree.c} +121 -94
- data/vendor/libgit2/src/{worktree.h → libgit2/worktree.h} +1 -1
- data/vendor/libgit2/src/libgit2/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xdiff.h +15 -15
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xdiffi.c +134 -108
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xemit.c +23 -7
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xhistogram.c +87 -78
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xinclude.h +1 -12
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xmerge.c +104 -117
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xpatience.c +6 -17
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xprepare.c +15 -20
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xutils.c +18 -7
- data/vendor/libgit2/src/util/CMakeLists.txt +80 -0
- data/vendor/libgit2/src/{allocators → util/allocators}/failalloc.h +1 -1
- data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.h +1 -1
- data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{array.h → util/array.h} +1 -1
- data/vendor/libgit2/src/{assert_safe.h → util/assert_safe.h} +16 -0
- data/vendor/libgit2/src/{cc-compat.h → util/cc-compat.h} +1 -1
- data/vendor/libgit2/src/{date.c → util/date.c} +14 -20
- data/vendor/libgit2/src/util/date.h +33 -0
- data/vendor/libgit2/src/{filebuf.c → util/filebuf.c} +29 -29
- data/vendor/libgit2/src/{filebuf.h → util/filebuf.h} +2 -2
- data/vendor/libgit2/src/{path.c → util/fs_path.c} +453 -647
- data/vendor/libgit2/src/{path.h → util/fs_path.h} +221 -188
- data/vendor/libgit2/src/{futils.c → util/futils.c} +135 -90
- data/vendor/libgit2/src/{futils.h → util/futils.h} +28 -15
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +15 -1
- data/vendor/libgit2/src/{common.h → util/git2_util.h} +20 -59
- data/vendor/libgit2/src/util/hash/builtin.c +53 -0
- data/vendor/libgit2/src/{hash/sha1/openssl.h → util/hash/builtin.h} +6 -6
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.c +3 -3
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.h +3 -3
- data/vendor/libgit2/src/util/hash/common_crypto.c +112 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/common_crypto.h +11 -3
- data/vendor/libgit2/src/util/hash/mbedtls.c +92 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/mbedtls.h +14 -4
- data/vendor/libgit2/src/util/hash/openssl.c +195 -0
- data/vendor/libgit2/src/util/hash/openssl.h +45 -0
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +243 -0
- data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +601 -0
- data/vendor/libgit2/src/util/hash/sha.h +70 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.c +1 -1
- data/vendor/libgit2/src/util/hash/win32.c +549 -0
- data/vendor/libgit2/src/util/hash/win32.h +60 -0
- data/vendor/libgit2/src/util/hash.c +158 -0
- data/vendor/libgit2/src/util/hash.h +61 -0
- data/vendor/libgit2/src/{khash.h → util/khash.h} +1 -1
- data/vendor/libgit2/src/{map.h → util/map.h} +1 -1
- data/vendor/libgit2/src/util/net.c +1003 -0
- data/vendor/libgit2/src/{net.h → util/net.h} +18 -4
- data/vendor/libgit2/src/{pool.h → util/pool.h} +1 -1
- data/vendor/libgit2/src/{posix.c → util/posix.c} +3 -3
- data/vendor/libgit2/src/{posix.h → util/posix.h} +4 -1
- data/vendor/libgit2/src/{pqueue.h → util/pqueue.h} +2 -2
- data/vendor/libgit2/src/util/rand.c +234 -0
- data/vendor/libgit2/src/util/rand.h +37 -0
- data/vendor/libgit2/src/{regexp.c → util/regexp.c} +4 -4
- data/vendor/libgit2/src/{regexp.h → util/regexp.h} +1 -1
- data/vendor/libgit2/src/{runtime.c → util/runtime.c} +1 -1
- data/vendor/libgit2/src/{runtime.h → util/runtime.h} +1 -1
- data/vendor/libgit2/src/{sortedcache.c → util/sortedcache.c} +1 -1
- data/vendor/libgit2/src/{sortedcache.h → util/sortedcache.h} +2 -2
- data/vendor/libgit2/src/{buffer.c → util/str.c} +157 -151
- data/vendor/libgit2/src/util/str.h +357 -0
- data/vendor/libgit2/src/{strmap.h → util/strmap.h} +1 -1
- data/vendor/libgit2/src/{thread.c → util/thread.c} +1 -1
- data/vendor/libgit2/src/{thread.h → util/thread.h} +23 -22
- data/vendor/libgit2/src/{tsort.c → util/tsort.c} +1 -1
- data/vendor/libgit2/src/{unix → util/unix}/map.c +1 -3
- data/vendor/libgit2/src/{unix → util/unix}/posix.h +1 -4
- data/vendor/libgit2/src/{unix → util/unix}/realpath.c +1 -3
- data/vendor/libgit2/src/{utf8.c → util/utf8.c} +1 -1
- data/vendor/libgit2/src/{utf8.h → util/utf8.h} +1 -1
- data/vendor/libgit2/src/{util.c → util/util.c} +15 -15
- data/vendor/libgit2/src/{util.h → util/util.h} +4 -29
- data/vendor/libgit2/src/{varint.h → util/varint.h} +1 -1
- data/vendor/libgit2/src/{vector.h → util/vector.h} +2 -2
- data/vendor/libgit2/src/{wildmatch.h → util/wildmatch.h} +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/dir.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/error.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/map.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/path_w32.c +140 -9
- data/vendor/libgit2/src/{win32 → util/win32}/path_w32.h +3 -1
- data/vendor/libgit2/src/{win32 → util/win32}/posix.h +1 -2
- data/vendor/libgit2/src/{win32 → util/win32}/posix_w32.c +12 -28
- data/vendor/libgit2/src/util/win32/precompiled.c +1 -0
- data/vendor/libgit2/src/{win32 → util/win32}/precompiled.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/thread.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/utf-conv.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.c +2 -3
- data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.h +3 -4
- data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_util.h +1 -1
- data/vendor/libgit2/src/{zstream.c → util/zstream.c} +5 -5
- data/vendor/libgit2/src/{zstream.h → util/zstream.h} +5 -5
- metadata +402 -356
- data/vendor/libgit2/src/buffer.h +0 -374
- data/vendor/libgit2/src/commit.h +0 -46
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +0 -57
- data/vendor/libgit2/src/hash/sha1/generic.c +0 -300
- data/vendor/libgit2/src/hash/sha1/generic.h +0 -19
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
- data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
- data/vendor/libgit2/src/hash/sha1/win32.c +0 -333
- data/vendor/libgit2/src/hash/sha1/win32.h +0 -128
- data/vendor/libgit2/src/hash/sha1.h +0 -38
- data/vendor/libgit2/src/hash.c +0 -110
- data/vendor/libgit2/src/hash.h +0 -46
- data/vendor/libgit2/src/message.h +0 -17
- data/vendor/libgit2/src/net.c +0 -540
- data/vendor/libgit2/src/oid.h +0 -51
- data/vendor/libgit2/src/remote.h +0 -55
- data/vendor/libgit2/src/sysdir.c +0 -347
- data/vendor/libgit2/src/win32/findfile.c +0 -230
- data/vendor/libgit2/src/win32/findfile.h +0 -19
- /data/vendor/libgit2/src/{win32 → cli/win32}/precompiled.c +0 -0
- /data/vendor/libgit2/src/{attr.h → libgit2/attr.h} +0 -0
- /data/vendor/libgit2/src/{attrcache.h → libgit2/attrcache.h} +0 -0
- /data/vendor/libgit2/src/{blame.h → libgit2/blame.h} +0 -0
- /data/vendor/libgit2/src/{blame_git.h → libgit2/blame_git.h} +0 -0
- /data/vendor/libgit2/src/{cache.c → libgit2/cache.c} +0 -0
- /data/vendor/libgit2/src/{cache.h → libgit2/cache.h} +0 -0
- /data/vendor/libgit2/src/{checkout.h → libgit2/checkout.h} +0 -0
- /data/vendor/libgit2/src/{clone.h → libgit2/clone.h} +0 -0
- /data/vendor/libgit2/src/{commit_list.h → libgit2/commit_list.h} +0 -0
- /data/vendor/libgit2/src/{config_backend.h → libgit2/config_backend.h} +0 -0
- /data/vendor/libgit2/src/{config_cache.c → libgit2/config_cache.c} +0 -0
- /data/vendor/libgit2/src/{config_entries.c → libgit2/config_entries.c} +0 -0
- /data/vendor/libgit2/src/{config_entries.h → libgit2/config_entries.h} +0 -0
- /data/vendor/libgit2/src/{config_parse.h → libgit2/config_parse.h} +0 -0
- /data/vendor/libgit2/src/{config_snapshot.c → libgit2/config_snapshot.c} +0 -0
- /data/vendor/libgit2/src/{delta.c → libgit2/delta.c} +0 -0
- /data/vendor/libgit2/src/{delta.h → libgit2/delta.h} +0 -0
- /data/vendor/libgit2/src/{diff_file.h → libgit2/diff_file.h} +0 -0
- /data/vendor/libgit2/src/{diff_parse.c → libgit2/diff_parse.c} +0 -0
- /data/vendor/libgit2/src/{diff_parse.h → libgit2/diff_parse.h} +0 -0
- /data/vendor/libgit2/src/{diff_tform.h → libgit2/diff_tform.h} +0 -0
- /data/vendor/libgit2/src/{diff_xdiff.h → libgit2/diff_xdiff.h} +0 -0
- /data/vendor/libgit2/src/{fetchhead.h → libgit2/fetchhead.h} +0 -0
- /data/vendor/libgit2/src/{win32 → libgit2}/git2.rc +0 -0
- /data/vendor/libgit2/src/{graph.c → libgit2/graph.c} +0 -0
- /data/vendor/libgit2/src/{hashsig.c → libgit2/hashsig.c} +0 -0
- /data/vendor/libgit2/src/{idxmap.c → libgit2/idxmap.c} +0 -0
- /data/vendor/libgit2/src/{idxmap.h → libgit2/idxmap.h} +0 -0
- /data/vendor/libgit2/src/{indexer.h → libgit2/indexer.h} +0 -0
- /data/vendor/libgit2/src/{libgit2.h → libgit2/libgit2.h} +0 -0
- /data/vendor/libgit2/src/{mailmap.h → libgit2/mailmap.h} +0 -0
- /data/vendor/libgit2/src/{merge_driver.h → libgit2/merge_driver.h} +0 -0
- /data/vendor/libgit2/src/{notes.h → libgit2/notes.h} +0 -0
- /data/vendor/libgit2/src/{object_api.c → libgit2/object_api.c} +0 -0
- /data/vendor/libgit2/src/{offmap.c → libgit2/offmap.c} +0 -0
- /data/vendor/libgit2/src/{offmap.h → libgit2/offmap.h} +0 -0
- /data/vendor/libgit2/src/{oidarray.c → libgit2/oidarray.c} +0 -0
- /data/vendor/libgit2/src/{oidarray.h → libgit2/oidarray.h} +0 -0
- /data/vendor/libgit2/src/{oidmap.h → libgit2/oidmap.h} +0 -0
- /data/vendor/libgit2/src/{parse.h → libgit2/parse.h} +0 -0
- /data/vendor/libgit2/src/{patch_parse.h → libgit2/patch_parse.h} +0 -0
- /data/vendor/libgit2/src/{refdb.c → libgit2/refdb.c} +0 -0
- /data/vendor/libgit2/src/{refdb.h → libgit2/refdb.h} +0 -0
- /data/vendor/libgit2/src/{repo_template.h → libgit2/repo_template.h} +0 -0
- /data/vendor/libgit2/src/{revwalk.h → libgit2/revwalk.h} +0 -0
- /data/vendor/libgit2/src/{settings.h → libgit2/settings.h} +0 -0
- /data/vendor/libgit2/src/{status.h → libgit2/status.h} +0 -0
- /data/vendor/libgit2/src/{stream.h → libgit2/stream.h} +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/socket.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.h +0 -0
- /data/vendor/libgit2/src/{transaction.h → libgit2/transaction.h} +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.h +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/credential.c +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/credential_helpers.c +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/ssh.h +0 -0
- /data/vendor/libgit2/src/{userdiff.h → libgit2/userdiff.h} +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xdiffi.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xemit.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xmacros.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xprepare.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xtypes.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xutils.h +0 -0
- /data/vendor/libgit2/src/{alloc.c → util/alloc.c} +0 -0
- /data/vendor/libgit2/src/{alloc.h → util/alloc.h} +0 -0
- /data/vendor/libgit2/src/{allocators → util/allocators}/failalloc.c +0 -0
- /data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.c +0 -0
- /data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.c +0 -0
- /data/vendor/libgit2/src/{bitvec.h → util/bitvec.h} +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.h +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.c +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.h +0 -0
- /data/vendor/libgit2/src/{integer.h → util/integer.h} +0 -0
- /data/vendor/libgit2/src/{pool.c → util/pool.c} +0 -0
- /data/vendor/libgit2/src/{pqueue.c → util/pqueue.c} +0 -0
- /data/vendor/libgit2/src/{strmap.c → util/strmap.c} +0 -0
- /data/vendor/libgit2/src/{strnlen.h → util/strnlen.h} +0 -0
- /data/vendor/libgit2/src/{unix → util/unix}/pthread.h +0 -0
- /data/vendor/libgit2/src/{varint.c → util/varint.c} +0 -0
- /data/vendor/libgit2/src/{vector.c → util/vector.c} +0 -0
- /data/vendor/libgit2/src/{wildmatch.c → util/wildmatch.c} +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/dir.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/error.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/mingw-compat.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/msvc-compat.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/reparse.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/thread.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/utf-conv.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/version.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/w32_common.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/w32_util.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/win32-compat.h +0 -0
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
#include "remote.h"
|
|
9
9
|
|
|
10
|
-
#include "
|
|
11
|
-
#include "
|
|
12
|
-
#include "git2/oid.h"
|
|
13
|
-
#include "git2/net.h"
|
|
14
|
-
|
|
10
|
+
#include "buf.h"
|
|
11
|
+
#include "branch.h"
|
|
15
12
|
#include "config.h"
|
|
16
13
|
#include "repository.h"
|
|
17
14
|
#include "fetch.h"
|
|
@@ -19,6 +16,13 @@
|
|
|
19
16
|
#include "refspec.h"
|
|
20
17
|
#include "fetchhead.h"
|
|
21
18
|
#include "push.h"
|
|
19
|
+
#include "proxy.h"
|
|
20
|
+
#include "strarray.h"
|
|
21
|
+
|
|
22
|
+
#include "git2/config.h"
|
|
23
|
+
#include "git2/types.h"
|
|
24
|
+
#include "git2/oid.h"
|
|
25
|
+
#include "git2/net.h"
|
|
22
26
|
|
|
23
27
|
#define CONFIG_URL_FMT "remote.%s.url"
|
|
24
28
|
#define CONFIG_PUSHURL_FMT "remote.%s.pushurl"
|
|
@@ -28,7 +32,7 @@
|
|
|
28
32
|
|
|
29
33
|
static int dwim_refspecs(git_vector *out, git_vector *refspecs, git_vector *refs);
|
|
30
34
|
static int lookup_remote_prune_config(git_remote *remote, git_config *config, const char *name);
|
|
31
|
-
|
|
35
|
+
static int apply_insteadof(char **out, git_config *config, const char *url, int direction, bool use_default_if_empty);
|
|
32
36
|
|
|
33
37
|
static int add_refspec_to(git_vector *vector, const char *string, bool is_fetch)
|
|
34
38
|
{
|
|
@@ -60,14 +64,14 @@ static int add_refspec(git_remote *remote, const char *string, bool is_fetch)
|
|
|
60
64
|
static int download_tags_value(git_remote *remote, git_config *cfg)
|
|
61
65
|
{
|
|
62
66
|
git_config_entry *ce;
|
|
63
|
-
|
|
67
|
+
git_str buf = GIT_STR_INIT;
|
|
64
68
|
int error;
|
|
65
69
|
|
|
66
|
-
if (
|
|
70
|
+
if (git_str_printf(&buf, "remote.%s.tagopt", remote->name) < 0)
|
|
67
71
|
return -1;
|
|
68
72
|
|
|
69
|
-
error = git_config__lookup_entry(&ce, cfg,
|
|
70
|
-
|
|
73
|
+
error = git_config__lookup_entry(&ce, cfg, git_str_cstr(&buf), false);
|
|
74
|
+
git_str_dispose(&buf);
|
|
71
75
|
|
|
72
76
|
if (!error && ce && ce->value) {
|
|
73
77
|
if (!strcmp(ce->value, "--no-tags"))
|
|
@@ -99,7 +103,7 @@ static int ensure_remote_name_is_valid(const char *name)
|
|
|
99
103
|
static int write_add_refspec(git_repository *repo, const char *name, const char *refspec, bool fetch)
|
|
100
104
|
{
|
|
101
105
|
git_config *cfg;
|
|
102
|
-
|
|
106
|
+
git_str var = GIT_STR_INIT;
|
|
103
107
|
git_refspec spec;
|
|
104
108
|
const char *fmt;
|
|
105
109
|
int error;
|
|
@@ -117,7 +121,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
|
|
|
117
121
|
|
|
118
122
|
git_refspec__dispose(&spec);
|
|
119
123
|
|
|
120
|
-
if ((error =
|
|
124
|
+
if ((error = git_str_printf(&var, fmt, name)) < 0)
|
|
121
125
|
return error;
|
|
122
126
|
|
|
123
127
|
/*
|
|
@@ -130,11 +134,11 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
|
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
cleanup:
|
|
133
|
-
|
|
137
|
+
git_str_dispose(&var);
|
|
134
138
|
return 0;
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
static int canonicalize_url(
|
|
141
|
+
static int canonicalize_url(git_str *out, const char *in)
|
|
138
142
|
{
|
|
139
143
|
if (in == NULL || strlen(in) == 0) {
|
|
140
144
|
git_error_set(GIT_ERROR_INVALID, "cannot set empty URL");
|
|
@@ -149,18 +153,18 @@ static int canonicalize_url(git_buf *out, const char *in)
|
|
|
149
153
|
(git__isalpha(in[2]) || git__isdigit(in[2]))) {
|
|
150
154
|
const char *c;
|
|
151
155
|
for (c = in; *c; c++)
|
|
152
|
-
|
|
156
|
+
git_str_putc(out, *c == '\\' ? '/' : *c);
|
|
153
157
|
|
|
154
|
-
return
|
|
158
|
+
return git_str_oom(out) ? -1 : 0;
|
|
155
159
|
}
|
|
156
160
|
#endif
|
|
157
161
|
|
|
158
|
-
return
|
|
162
|
+
return git_str_puts(out, in);
|
|
159
163
|
}
|
|
160
164
|
|
|
161
|
-
static int default_fetchspec_for_name(
|
|
165
|
+
static int default_fetchspec_for_name(git_str *buf, const char *name)
|
|
162
166
|
{
|
|
163
|
-
if (
|
|
167
|
+
if (git_str_printf(buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
|
|
164
168
|
return -1;
|
|
165
169
|
|
|
166
170
|
return 0;
|
|
@@ -204,9 +208,9 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
|
|
|
204
208
|
{
|
|
205
209
|
git_remote *remote = NULL;
|
|
206
210
|
git_config *config_ro = NULL, *config_rw;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
211
|
+
git_str canonical_url = GIT_STR_INIT;
|
|
212
|
+
git_str var = GIT_STR_INIT;
|
|
213
|
+
git_str specbuf = GIT_STR_INIT;
|
|
210
214
|
const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
|
|
211
215
|
int error = -1;
|
|
212
216
|
|
|
@@ -243,18 +247,20 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
|
|
|
243
247
|
goto on_error;
|
|
244
248
|
|
|
245
249
|
if (opts->repository && !(opts->flags & GIT_REMOTE_CREATE_SKIP_INSTEADOF)) {
|
|
246
|
-
|
|
250
|
+
if ((error = apply_insteadof(&remote->url, config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH, true)) < 0 ||
|
|
251
|
+
(error = apply_insteadof(&remote->pushurl, config_ro, canonical_url.ptr, GIT_DIRECTION_PUSH, false)) < 0)
|
|
252
|
+
goto on_error;
|
|
247
253
|
} else {
|
|
248
254
|
remote->url = git__strdup(canonical_url.ptr);
|
|
255
|
+
GIT_ERROR_CHECK_ALLOC(remote->url);
|
|
249
256
|
}
|
|
250
|
-
GIT_ERROR_CHECK_ALLOC(remote->url);
|
|
251
257
|
|
|
252
258
|
if (opts->name != NULL) {
|
|
253
259
|
remote->name = git__strdup(opts->name);
|
|
254
260
|
GIT_ERROR_CHECK_ALLOC(remote->name);
|
|
255
261
|
|
|
256
262
|
if (opts->repository &&
|
|
257
|
-
((error =
|
|
263
|
+
((error = git_str_printf(&var, CONFIG_URL_FMT, opts->name)) < 0 ||
|
|
258
264
|
(error = git_repository_config__weakptr(&config_rw, opts->repository)) < 0 ||
|
|
259
265
|
(error = git_config_set_string(config_rw, var.ptr, canonical_url.ptr)) < 0))
|
|
260
266
|
goto on_error;
|
|
@@ -269,7 +275,7 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
|
|
|
269
275
|
if ((error = default_fetchspec_for_name(&specbuf, opts->name)) < 0)
|
|
270
276
|
goto on_error;
|
|
271
277
|
|
|
272
|
-
fetch =
|
|
278
|
+
fetch = git_str_cstr(&specbuf);
|
|
273
279
|
}
|
|
274
280
|
|
|
275
281
|
if ((error = add_refspec(remote, fetch, true)) < 0)
|
|
@@ -293,7 +299,7 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
|
|
|
293
299
|
remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_AUTO;
|
|
294
300
|
|
|
295
301
|
|
|
296
|
-
|
|
302
|
+
git_str_dispose(&var);
|
|
297
303
|
|
|
298
304
|
*out = remote;
|
|
299
305
|
error = 0;
|
|
@@ -303,15 +309,15 @@ on_error:
|
|
|
303
309
|
git_remote_free(remote);
|
|
304
310
|
|
|
305
311
|
git_config_free(config_ro);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
git_str_dispose(&specbuf);
|
|
313
|
+
git_str_dispose(&canonical_url);
|
|
314
|
+
git_str_dispose(&var);
|
|
309
315
|
return error;
|
|
310
316
|
}
|
|
311
317
|
|
|
312
318
|
int git_remote_create(git_remote **out, git_repository *repo, const char *name, const char *url)
|
|
313
319
|
{
|
|
314
|
-
|
|
320
|
+
git_str buf = GIT_STR_INIT;
|
|
315
321
|
int error;
|
|
316
322
|
git_remote_create_options opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
|
|
317
323
|
|
|
@@ -322,14 +328,14 @@ int git_remote_create(git_remote **out, git_repository *repo, const char *name,
|
|
|
322
328
|
if (canonicalize_url(&buf, url) < 0)
|
|
323
329
|
return GIT_ERROR;
|
|
324
330
|
|
|
325
|
-
|
|
331
|
+
git_str_clear(&buf);
|
|
326
332
|
|
|
327
333
|
opts.repository = repo;
|
|
328
334
|
opts.name = name;
|
|
329
335
|
|
|
330
336
|
error = git_remote_create_with_opts(out, url, &opts);
|
|
331
337
|
|
|
332
|
-
|
|
338
|
+
git_str_dispose(&buf);
|
|
333
339
|
|
|
334
340
|
return error;
|
|
335
341
|
}
|
|
@@ -425,13 +431,13 @@ static int refspec_cb(const git_config_entry *entry, void *payload)
|
|
|
425
431
|
}
|
|
426
432
|
|
|
427
433
|
static int get_optional_config(
|
|
428
|
-
bool *found, git_config *config,
|
|
434
|
+
bool *found, git_config *config, git_str *buf,
|
|
429
435
|
git_config_foreach_cb cb, void *payload)
|
|
430
436
|
{
|
|
431
437
|
int error = 0;
|
|
432
|
-
const char *key =
|
|
438
|
+
const char *key = git_str_cstr(buf);
|
|
433
439
|
|
|
434
|
-
if (
|
|
440
|
+
if (git_str_oom(buf))
|
|
435
441
|
return -1;
|
|
436
442
|
|
|
437
443
|
if (cb != NULL)
|
|
@@ -453,7 +459,7 @@ static int get_optional_config(
|
|
|
453
459
|
int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
454
460
|
{
|
|
455
461
|
git_remote *remote = NULL;
|
|
456
|
-
|
|
462
|
+
git_str buf = GIT_STR_INIT;
|
|
457
463
|
const char *val;
|
|
458
464
|
int error = 0;
|
|
459
465
|
git_config *config;
|
|
@@ -484,7 +490,7 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
|
484
490
|
goto cleanup;
|
|
485
491
|
}
|
|
486
492
|
|
|
487
|
-
if ((error =
|
|
493
|
+
if ((error = git_str_printf(&buf, "remote.%s.url", name)) < 0)
|
|
488
494
|
goto cleanup;
|
|
489
495
|
|
|
490
496
|
if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0)
|
|
@@ -496,13 +502,14 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
|
496
502
|
remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_AUTO;
|
|
497
503
|
|
|
498
504
|
if (found && strlen(val) > 0) {
|
|
499
|
-
|
|
500
|
-
|
|
505
|
+
if ((error = apply_insteadof(&remote->url, config, val, GIT_DIRECTION_FETCH, true)) < 0 ||
|
|
506
|
+
(error = apply_insteadof(&remote->pushurl, config, val, GIT_DIRECTION_PUSH, false)) < 0)
|
|
507
|
+
goto cleanup;
|
|
501
508
|
}
|
|
502
509
|
|
|
503
510
|
val = NULL;
|
|
504
|
-
|
|
505
|
-
|
|
511
|
+
git_str_clear(&buf);
|
|
512
|
+
git_str_printf(&buf, "remote.%s.pushurl", name);
|
|
506
513
|
|
|
507
514
|
if ((error = get_optional_config(&found, config, &buf, NULL, (void *)&val)) < 0)
|
|
508
515
|
goto cleanup;
|
|
@@ -516,22 +523,25 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
|
516
523
|
}
|
|
517
524
|
|
|
518
525
|
if (found && strlen(val) > 0) {
|
|
519
|
-
remote->pushurl
|
|
520
|
-
|
|
526
|
+
if (remote->pushurl)
|
|
527
|
+
git__free(remote->pushurl);
|
|
528
|
+
|
|
529
|
+
if ((error = apply_insteadof(&remote->pushurl, config, val, GIT_DIRECTION_FETCH, true)) < 0)
|
|
530
|
+
goto cleanup;
|
|
521
531
|
}
|
|
522
532
|
|
|
523
533
|
data.remote = remote;
|
|
524
534
|
data.fetch = true;
|
|
525
535
|
|
|
526
|
-
|
|
527
|
-
|
|
536
|
+
git_str_clear(&buf);
|
|
537
|
+
git_str_printf(&buf, "remote.%s.fetch", name);
|
|
528
538
|
|
|
529
539
|
if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0)
|
|
530
540
|
goto cleanup;
|
|
531
541
|
|
|
532
542
|
data.fetch = false;
|
|
533
|
-
|
|
534
|
-
|
|
543
|
+
git_str_clear(&buf);
|
|
544
|
+
git_str_printf(&buf, "remote.%s.push", name);
|
|
535
545
|
|
|
536
546
|
if ((error = get_optional_config(NULL, config, &buf, refspec_cb, &data)) < 0)
|
|
537
547
|
goto cleanup;
|
|
@@ -550,7 +560,7 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
|
550
560
|
|
|
551
561
|
cleanup:
|
|
552
562
|
git_config_free(config);
|
|
553
|
-
|
|
563
|
+
git_str_dispose(&buf);
|
|
554
564
|
|
|
555
565
|
if (error < 0)
|
|
556
566
|
git_remote_free(remote);
|
|
@@ -560,12 +570,12 @@ cleanup:
|
|
|
560
570
|
|
|
561
571
|
static int lookup_remote_prune_config(git_remote *remote, git_config *config, const char *name)
|
|
562
572
|
{
|
|
563
|
-
|
|
573
|
+
git_str buf = GIT_STR_INIT;
|
|
564
574
|
int error = 0;
|
|
565
575
|
|
|
566
|
-
|
|
576
|
+
git_str_printf(&buf, "remote.%s.prune", name);
|
|
567
577
|
|
|
568
|
-
if ((error = git_config_get_bool(&remote->prune_refs, config,
|
|
578
|
+
if ((error = git_config_get_bool(&remote->prune_refs, config, git_str_cstr(&buf))) < 0) {
|
|
569
579
|
if (error == GIT_ENOTFOUND) {
|
|
570
580
|
git_error_clear();
|
|
571
581
|
|
|
@@ -578,7 +588,7 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
|
|
|
578
588
|
}
|
|
579
589
|
}
|
|
580
590
|
|
|
581
|
-
|
|
591
|
+
git_str_dispose(&buf);
|
|
582
592
|
return error;
|
|
583
593
|
}
|
|
584
594
|
|
|
@@ -619,7 +629,7 @@ int git_remote_set_instance_url(git_remote *remote, const char *url)
|
|
|
619
629
|
static int set_url(git_repository *repo, const char *remote, const char *pattern, const char *url)
|
|
620
630
|
{
|
|
621
631
|
git_config *cfg;
|
|
622
|
-
|
|
632
|
+
git_str buf = GIT_STR_INIT, canonical_url = GIT_STR_INIT;
|
|
623
633
|
int error;
|
|
624
634
|
|
|
625
635
|
GIT_ASSERT_ARG(repo);
|
|
@@ -631,7 +641,7 @@ static int set_url(git_repository *repo, const char *remote, const char *pattern
|
|
|
631
641
|
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
|
|
632
642
|
return error;
|
|
633
643
|
|
|
634
|
-
if ((error =
|
|
644
|
+
if ((error = git_str_printf(&buf, pattern, remote)) < 0)
|
|
635
645
|
return error;
|
|
636
646
|
|
|
637
647
|
if (url) {
|
|
@@ -644,8 +654,8 @@ static int set_url(git_repository *repo, const char *remote, const char *pattern
|
|
|
644
654
|
}
|
|
645
655
|
|
|
646
656
|
cleanup:
|
|
647
|
-
|
|
648
|
-
|
|
657
|
+
git_str_dispose(&canonical_url);
|
|
658
|
+
git_str_dispose(&buf);
|
|
649
659
|
|
|
650
660
|
return error;
|
|
651
661
|
}
|
|
@@ -683,7 +693,7 @@ int git_remote_set_pushurl(git_repository *repo, const char *remote, const char
|
|
|
683
693
|
}
|
|
684
694
|
|
|
685
695
|
static int resolve_url(
|
|
686
|
-
|
|
696
|
+
git_str *resolved_url,
|
|
687
697
|
const char *url,
|
|
688
698
|
int direction,
|
|
689
699
|
const git_remote_callbacks *callbacks)
|
|
@@ -692,27 +702,28 @@ static int resolve_url(
|
|
|
692
702
|
GIT_UNUSED(direction);
|
|
693
703
|
GIT_UNUSED(callbacks);
|
|
694
704
|
#else
|
|
695
|
-
|
|
705
|
+
git_buf buf = GIT_BUF_INIT;
|
|
706
|
+
int error;
|
|
696
707
|
|
|
697
708
|
if (callbacks && callbacks->resolve_url) {
|
|
698
|
-
|
|
699
|
-
status = callbacks->resolve_url(resolved_url, url, direction, callbacks->payload);
|
|
700
|
-
if (status != GIT_PASSTHROUGH) {
|
|
701
|
-
git_error_set_after_callback_function(status, "git_resolve_url_cb");
|
|
709
|
+
error = callbacks->resolve_url(&buf, url, direction, callbacks->payload);
|
|
702
710
|
|
|
703
|
-
|
|
704
|
-
|
|
711
|
+
if (error != GIT_PASSTHROUGH) {
|
|
712
|
+
git_error_set_after_callback_function(error, "git_resolve_url_cb");
|
|
705
713
|
|
|
706
|
-
|
|
714
|
+
git_str_set(resolved_url, buf.ptr, buf.size);
|
|
715
|
+
git_buf_dispose(&buf);
|
|
716
|
+
|
|
717
|
+
return error;
|
|
707
718
|
}
|
|
708
719
|
}
|
|
709
720
|
#endif
|
|
710
721
|
|
|
711
|
-
return
|
|
722
|
+
return git_str_sets(resolved_url, url);
|
|
712
723
|
}
|
|
713
724
|
|
|
714
725
|
int git_remote__urlfordirection(
|
|
715
|
-
|
|
726
|
+
git_str *url_out,
|
|
716
727
|
struct git_remote *remote,
|
|
717
728
|
int direction,
|
|
718
729
|
const git_remote_callbacks *callbacks)
|
|
@@ -747,54 +758,200 @@ int git_remote__urlfordirection(
|
|
|
747
758
|
return resolve_url(url_out, url, direction, callbacks);
|
|
748
759
|
}
|
|
749
760
|
|
|
750
|
-
|
|
761
|
+
int git_remote_connect_options_init(
|
|
762
|
+
git_remote_connect_options *opts,
|
|
763
|
+
unsigned int version)
|
|
764
|
+
{
|
|
765
|
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
|
766
|
+
opts, version, git_remote_connect_options, GIT_REMOTE_CONNECT_OPTIONS_INIT);
|
|
767
|
+
return 0;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
int git_remote_connect_options_dup(
|
|
771
|
+
git_remote_connect_options *dst,
|
|
772
|
+
const git_remote_connect_options *src)
|
|
773
|
+
{
|
|
774
|
+
memcpy(dst, src, sizeof(git_remote_connect_options));
|
|
775
|
+
|
|
776
|
+
if (git_proxy_options_dup(&dst->proxy_opts, &src->proxy_opts) < 0 ||
|
|
777
|
+
git_strarray_copy(&dst->custom_headers, &src->custom_headers) < 0)
|
|
778
|
+
return -1;
|
|
779
|
+
|
|
780
|
+
return 0;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
void git_remote_connect_options_dispose(git_remote_connect_options *opts)
|
|
784
|
+
{
|
|
785
|
+
if (!opts)
|
|
786
|
+
return;
|
|
787
|
+
|
|
788
|
+
git_strarray_dispose(&opts->custom_headers);
|
|
789
|
+
git_proxy_options_dispose(&opts->proxy_opts);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
static size_t http_header_name_length(const char *http_header)
|
|
793
|
+
{
|
|
794
|
+
const char *colon = strchr(http_header, ':');
|
|
795
|
+
if (!colon)
|
|
796
|
+
return 0;
|
|
797
|
+
return colon - http_header;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
static bool is_malformed_http_header(const char *http_header)
|
|
801
|
+
{
|
|
802
|
+
const char *c;
|
|
803
|
+
size_t name_len;
|
|
804
|
+
|
|
805
|
+
/* Disallow \r and \n */
|
|
806
|
+
if ((c = strchr(http_header, '\r')) != NULL)
|
|
807
|
+
return true;
|
|
808
|
+
if ((c = strchr(http_header, '\n')) != NULL)
|
|
809
|
+
return true;
|
|
810
|
+
|
|
811
|
+
/* Require a header name followed by : */
|
|
812
|
+
if ((name_len = http_header_name_length(http_header)) < 1)
|
|
813
|
+
return true;
|
|
814
|
+
|
|
815
|
+
return false;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
static char *forbidden_custom_headers[] = {
|
|
819
|
+
"User-Agent",
|
|
820
|
+
"Host",
|
|
821
|
+
"Accept",
|
|
822
|
+
"Content-Type",
|
|
823
|
+
"Transfer-Encoding",
|
|
824
|
+
"Content-Length",
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
static bool is_forbidden_custom_header(const char *custom_header)
|
|
828
|
+
{
|
|
829
|
+
unsigned long i;
|
|
830
|
+
size_t name_len = http_header_name_length(custom_header);
|
|
831
|
+
|
|
832
|
+
/* Disallow headers that we set */
|
|
833
|
+
for (i = 0; i < ARRAY_SIZE(forbidden_custom_headers); i++)
|
|
834
|
+
if (strncmp(forbidden_custom_headers[i], custom_header, name_len) == 0)
|
|
835
|
+
return true;
|
|
836
|
+
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
static int validate_custom_headers(const git_strarray *custom_headers)
|
|
751
841
|
{
|
|
752
|
-
|
|
842
|
+
size_t i;
|
|
843
|
+
|
|
844
|
+
if (!custom_headers)
|
|
753
845
|
return 0;
|
|
754
846
|
|
|
755
|
-
|
|
756
|
-
|
|
847
|
+
for (i = 0; i < custom_headers->count; i++) {
|
|
848
|
+
if (is_malformed_http_header(custom_headers->strings[i])) {
|
|
849
|
+
git_error_set(GIT_ERROR_INVALID, "custom HTTP header '%s' is malformed", custom_headers->strings[i]);
|
|
850
|
+
return -1;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
if (is_forbidden_custom_header(custom_headers->strings[i])) {
|
|
854
|
+
git_error_set(GIT_ERROR_INVALID, "custom HTTP header '%s' is already set by libgit2", custom_headers->strings[i]);
|
|
855
|
+
return -1;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
return 0;
|
|
757
860
|
}
|
|
758
861
|
|
|
759
|
-
static int
|
|
862
|
+
static int lookup_redirect_config(
|
|
863
|
+
git_remote_redirect_t *out,
|
|
864
|
+
git_repository *repo)
|
|
760
865
|
{
|
|
761
|
-
|
|
866
|
+
git_config *config;
|
|
867
|
+
const char *value;
|
|
868
|
+
int bool_value, error = 0;
|
|
869
|
+
|
|
870
|
+
if (!repo) {
|
|
871
|
+
*out = GIT_REMOTE_REDIRECT_INITIAL;
|
|
762
872
|
return 0;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
if ((error = git_repository_config_snapshot(&config, repo)) < 0)
|
|
876
|
+
goto done;
|
|
877
|
+
|
|
878
|
+
if ((error = git_config_get_string(&value, config, "http.followRedirects")) < 0) {
|
|
879
|
+
if (error == GIT_ENOTFOUND) {
|
|
880
|
+
*out = GIT_REMOTE_REDIRECT_INITIAL;
|
|
881
|
+
error = 0;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
goto done;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
if (git_config_parse_bool(&bool_value, value) == 0) {
|
|
888
|
+
*out = bool_value ? GIT_REMOTE_REDIRECT_ALL :
|
|
889
|
+
GIT_REMOTE_REDIRECT_NONE;
|
|
890
|
+
} else if (strcasecmp(value, "initial") == 0) {
|
|
891
|
+
*out = GIT_REMOTE_REDIRECT_INITIAL;
|
|
892
|
+
} else {
|
|
893
|
+
git_error_set(GIT_ERROR_CONFIG, "invalid configuration setting '%s' for 'http.followRedirects'", value);
|
|
894
|
+
error = -1;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
done:
|
|
898
|
+
git_config_free(config);
|
|
899
|
+
return error;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
int git_remote_connect_options_normalize(
|
|
903
|
+
git_remote_connect_options *dst,
|
|
904
|
+
git_repository *repo,
|
|
905
|
+
const git_remote_connect_options *src)
|
|
906
|
+
{
|
|
907
|
+
git_remote_connect_options_dispose(dst);
|
|
908
|
+
git_remote_connect_options_init(dst, GIT_REMOTE_CONNECT_OPTIONS_VERSION);
|
|
909
|
+
|
|
910
|
+
if (src) {
|
|
911
|
+
GIT_ERROR_CHECK_VERSION(src, GIT_REMOTE_CONNECT_OPTIONS_VERSION, "git_remote_connect_options");
|
|
912
|
+
GIT_ERROR_CHECK_VERSION(&src->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
|
913
|
+
GIT_ERROR_CHECK_VERSION(&src->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
|
914
|
+
|
|
915
|
+
if (validate_custom_headers(&src->custom_headers) < 0 ||
|
|
916
|
+
git_remote_connect_options_dup(dst, src) < 0)
|
|
917
|
+
return -1;
|
|
918
|
+
}
|
|
763
919
|
|
|
764
|
-
|
|
920
|
+
if (dst->follow_redirects == 0) {
|
|
921
|
+
if (lookup_redirect_config(&dst->follow_redirects, repo) < 0)
|
|
922
|
+
return -1;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
return 0;
|
|
765
926
|
}
|
|
766
927
|
|
|
767
|
-
int
|
|
928
|
+
int git_remote_connect_ext(
|
|
929
|
+
git_remote *remote,
|
|
930
|
+
git_direction direction,
|
|
931
|
+
const git_remote_connect_options *given_opts)
|
|
768
932
|
{
|
|
933
|
+
git_remote_connect_options opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
|
|
934
|
+
git_str url = GIT_STR_INIT;
|
|
769
935
|
git_transport *t;
|
|
770
|
-
git_buf url = GIT_BUF_INIT;
|
|
771
|
-
int flags = GIT_TRANSPORTFLAGS_NONE;
|
|
772
936
|
int error;
|
|
773
|
-
void *payload = NULL;
|
|
774
|
-
git_credential_acquire_cb credentials = NULL;
|
|
775
|
-
git_transport_cb transport = NULL;
|
|
776
937
|
|
|
777
938
|
GIT_ASSERT_ARG(remote);
|
|
778
939
|
|
|
779
|
-
if (
|
|
780
|
-
|
|
781
|
-
credentials = callbacks->credentials;
|
|
782
|
-
transport = callbacks->transport;
|
|
783
|
-
payload = callbacks->payload;
|
|
784
|
-
}
|
|
940
|
+
if (given_opts)
|
|
941
|
+
memcpy(&opts, given_opts, sizeof(git_remote_connect_options));
|
|
785
942
|
|
|
786
|
-
|
|
787
|
-
|
|
943
|
+
GIT_ERROR_CHECK_VERSION(&opts.callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
|
944
|
+
GIT_ERROR_CHECK_VERSION(&opts.proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
|
788
945
|
|
|
789
946
|
t = remote->transport;
|
|
790
947
|
|
|
791
|
-
if ((error = git_remote__urlfordirection(&url, remote, direction, callbacks)) < 0)
|
|
948
|
+
if ((error = git_remote__urlfordirection(&url, remote, direction, &opts.callbacks)) < 0)
|
|
792
949
|
goto on_error;
|
|
793
950
|
|
|
794
951
|
/* If we don't have a transport object yet, and the caller specified a
|
|
795
952
|
* custom transport factory, use that */
|
|
796
|
-
if (!t && transport &&
|
|
797
|
-
|
|
953
|
+
if (!t && opts.callbacks.transport &&
|
|
954
|
+
(error = opts.callbacks.transport(&t, remote, opts.callbacks.payload)) < 0)
|
|
798
955
|
goto on_error;
|
|
799
956
|
|
|
800
957
|
/* If we still don't have a transport, then use the global
|
|
@@ -802,16 +959,12 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
|
|
|
802
959
|
if (!t && (error = git_transport_new(&t, remote, url.ptr)) < 0)
|
|
803
960
|
goto on_error;
|
|
804
961
|
|
|
805
|
-
if ((error =
|
|
806
|
-
goto on_error;
|
|
807
|
-
|
|
808
|
-
if ((error = remote_transport_set_callbacks(t, callbacks)) < 0 ||
|
|
809
|
-
(error = t->connect(t, url.ptr, credentials, payload, conn->proxy, direction, flags)) != 0)
|
|
962
|
+
if ((error = t->connect(t, url.ptr, direction, &opts)) != 0)
|
|
810
963
|
goto on_error;
|
|
811
964
|
|
|
812
965
|
remote->transport = t;
|
|
813
966
|
|
|
814
|
-
|
|
967
|
+
git_str_dispose(&url);
|
|
815
968
|
|
|
816
969
|
return 0;
|
|
817
970
|
|
|
@@ -819,7 +972,7 @@ on_error:
|
|
|
819
972
|
if (t)
|
|
820
973
|
t->free(t);
|
|
821
974
|
|
|
822
|
-
|
|
975
|
+
git_str_dispose(&url);
|
|
823
976
|
|
|
824
977
|
if (t == remote->transport)
|
|
825
978
|
remote->transport = NULL;
|
|
@@ -827,14 +980,25 @@ on_error:
|
|
|
827
980
|
return error;
|
|
828
981
|
}
|
|
829
982
|
|
|
830
|
-
int git_remote_connect(
|
|
983
|
+
int git_remote_connect(
|
|
984
|
+
git_remote *remote,
|
|
985
|
+
git_direction direction,
|
|
986
|
+
const git_remote_callbacks *callbacks,
|
|
987
|
+
const git_proxy_options *proxy,
|
|
988
|
+
const git_strarray *custom_headers)
|
|
831
989
|
{
|
|
832
|
-
|
|
990
|
+
git_remote_connect_options opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
|
|
991
|
+
|
|
992
|
+
if (callbacks)
|
|
993
|
+
memcpy(&opts.callbacks, callbacks, sizeof(git_remote_callbacks));
|
|
994
|
+
|
|
995
|
+
if (proxy)
|
|
996
|
+
memcpy(&opts.proxy_opts, proxy, sizeof(git_proxy_options));
|
|
833
997
|
|
|
834
|
-
|
|
835
|
-
|
|
998
|
+
if (custom_headers)
|
|
999
|
+
memcpy(&opts.custom_headers, custom_headers, sizeof(git_strarray));
|
|
836
1000
|
|
|
837
|
-
return
|
|
1001
|
+
return git_remote_connect_ext(remote, direction, &opts);
|
|
838
1002
|
}
|
|
839
1003
|
|
|
840
1004
|
int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote)
|
|
@@ -849,6 +1013,38 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
|
|
|
849
1013
|
return remote->transport->ls(out, size, remote->transport);
|
|
850
1014
|
}
|
|
851
1015
|
|
|
1016
|
+
int git_remote_capabilities(unsigned int *out, git_remote *remote)
|
|
1017
|
+
{
|
|
1018
|
+
GIT_ASSERT_ARG(remote);
|
|
1019
|
+
|
|
1020
|
+
*out = 0;
|
|
1021
|
+
|
|
1022
|
+
if (!remote->transport) {
|
|
1023
|
+
git_error_set(GIT_ERROR_NET, "this remote has never connected");
|
|
1024
|
+
return -1;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
return remote->transport->capabilities(out, remote->transport);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
int git_remote_oid_type(git_oid_t *out, git_remote *remote)
|
|
1031
|
+
{
|
|
1032
|
+
GIT_ASSERT_ARG(remote);
|
|
1033
|
+
|
|
1034
|
+
if (!remote->transport) {
|
|
1035
|
+
git_error_set(GIT_ERROR_NET, "this remote has never connected");
|
|
1036
|
+
*out = 0;
|
|
1037
|
+
return -1;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
|
1041
|
+
return remote->transport->oid_type(out, remote->transport);
|
|
1042
|
+
#else
|
|
1043
|
+
*out = GIT_OID_SHA1;
|
|
1044
|
+
return 0;
|
|
1045
|
+
#endif
|
|
1046
|
+
}
|
|
1047
|
+
|
|
852
1048
|
static int lookup_config(char **out, git_config *cfg, const char *name)
|
|
853
1049
|
{
|
|
854
1050
|
git_config_entry *ce = NULL;
|
|
@@ -885,7 +1081,7 @@ static void url_config_trim(git_net_url *url)
|
|
|
885
1081
|
static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
|
886
1082
|
{
|
|
887
1083
|
git_config *cfg = NULL;
|
|
888
|
-
|
|
1084
|
+
git_str buf = GIT_STR_INIT;
|
|
889
1085
|
git_net_url lookup_url = GIT_NET_URL_INIT;
|
|
890
1086
|
int error;
|
|
891
1087
|
|
|
@@ -902,19 +1098,19 @@ static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
|
|
902
1098
|
|
|
903
1099
|
/* remote.<name>.proxy config setting */
|
|
904
1100
|
if (remote->name && remote->name[0]) {
|
|
905
|
-
|
|
1101
|
+
git_str_clear(&buf);
|
|
906
1102
|
|
|
907
|
-
if ((error =
|
|
1103
|
+
if ((error = git_str_printf(&buf, "remote.%s.proxy", remote->name)) < 0 ||
|
|
908
1104
|
(error = lookup_config(out, cfg, buf.ptr)) != GIT_ENOTFOUND)
|
|
909
1105
|
goto done;
|
|
910
1106
|
}
|
|
911
1107
|
|
|
912
1108
|
while (true) {
|
|
913
|
-
|
|
1109
|
+
git_str_clear(&buf);
|
|
914
1110
|
|
|
915
|
-
if ((error =
|
|
1111
|
+
if ((error = git_str_puts(&buf, "http.")) < 0 ||
|
|
916
1112
|
(error = git_net_url_fmt(&buf, &lookup_url)) < 0 ||
|
|
917
|
-
(error =
|
|
1113
|
+
(error = git_str_puts(&buf, ".proxy")) < 0 ||
|
|
918
1114
|
(error = lookup_config(out, cfg, buf.ptr)) != GIT_ENOTFOUND)
|
|
919
1115
|
goto done;
|
|
920
1116
|
|
|
@@ -924,20 +1120,20 @@ static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
|
|
924
1120
|
url_config_trim(&lookup_url);
|
|
925
1121
|
}
|
|
926
1122
|
|
|
927
|
-
|
|
1123
|
+
git_str_clear(&buf);
|
|
928
1124
|
|
|
929
1125
|
error = lookup_config(out, cfg, "http.proxy");
|
|
930
1126
|
|
|
931
1127
|
done:
|
|
932
1128
|
git_config_free(cfg);
|
|
933
|
-
|
|
1129
|
+
git_str_dispose(&buf);
|
|
934
1130
|
git_net_url_dispose(&lookup_url);
|
|
935
1131
|
return error;
|
|
936
1132
|
}
|
|
937
1133
|
|
|
938
1134
|
static int http_proxy_env(char **out, git_remote *remote, git_net_url *url)
|
|
939
1135
|
{
|
|
940
|
-
|
|
1136
|
+
git_str proxy_env = GIT_STR_INIT, no_proxy_env = GIT_STR_INIT;
|
|
941
1137
|
bool use_ssl = (strcmp(url->scheme, "https") == 0);
|
|
942
1138
|
int error;
|
|
943
1139
|
|
|
@@ -963,13 +1159,13 @@ static int http_proxy_env(char **out, git_remote *remote, git_net_url *url)
|
|
|
963
1159
|
goto done;
|
|
964
1160
|
|
|
965
1161
|
if (!git_net_url_matches_pattern_list(url, no_proxy_env.ptr))
|
|
966
|
-
*out =
|
|
1162
|
+
*out = git_str_detach(&proxy_env);
|
|
967
1163
|
else
|
|
968
1164
|
error = GIT_ENOTFOUND;
|
|
969
1165
|
|
|
970
1166
|
done:
|
|
971
|
-
|
|
972
|
-
|
|
1167
|
+
git_str_dispose(&proxy_env);
|
|
1168
|
+
git_str_dispose(&no_proxy_env);
|
|
973
1169
|
return error;
|
|
974
1170
|
}
|
|
975
1171
|
|
|
@@ -1048,38 +1244,32 @@ static int ls_to_vector(git_vector *out, git_remote *remote)
|
|
|
1048
1244
|
return 0;
|
|
1049
1245
|
}
|
|
1050
1246
|
|
|
1051
|
-
int
|
|
1247
|
+
static int connect_or_reset_options(
|
|
1248
|
+
git_remote *remote,
|
|
1249
|
+
int direction,
|
|
1250
|
+
git_remote_connect_options *opts)
|
|
1052
1251
|
{
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
const git_strarray *custom_headers = NULL;
|
|
1058
|
-
const git_proxy_options *proxy = NULL;
|
|
1059
|
-
|
|
1060
|
-
GIT_ASSERT_ARG(remote);
|
|
1061
|
-
|
|
1062
|
-
if (!remote->repo) {
|
|
1063
|
-
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
|
1064
|
-
return -1;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
if (opts) {
|
|
1068
|
-
GIT_ERROR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
|
1069
|
-
cbs = &opts->callbacks;
|
|
1070
|
-
custom_headers = &opts->custom_headers;
|
|
1071
|
-
GIT_ERROR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
|
1072
|
-
proxy = &opts->proxy_opts;
|
|
1252
|
+
if (!git_remote_connected(remote)) {
|
|
1253
|
+
return git_remote_connect_ext(remote, direction, opts);
|
|
1254
|
+
} else {
|
|
1255
|
+
return remote->transport->set_connect_opts(remote->transport, opts);
|
|
1073
1256
|
}
|
|
1257
|
+
}
|
|
1074
1258
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1259
|
+
/* Download from an already connected remote. */
|
|
1260
|
+
static int git_remote__download(
|
|
1261
|
+
git_remote *remote,
|
|
1262
|
+
const git_strarray *refspecs,
|
|
1263
|
+
const git_fetch_options *opts)
|
|
1264
|
+
{
|
|
1265
|
+
git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT;
|
|
1266
|
+
size_t i;
|
|
1267
|
+
int error;
|
|
1078
1268
|
|
|
1079
1269
|
if (ls_to_vector(&refs, remote) < 0)
|
|
1080
1270
|
return -1;
|
|
1081
1271
|
|
|
1082
|
-
if ((git_vector_init(&specs, 0, NULL)) < 0)
|
|
1272
|
+
if ((error = git_vector_init(&specs, 0, NULL)) < 0)
|
|
1083
1273
|
goto on_error;
|
|
1084
1274
|
|
|
1085
1275
|
remote->passed_refspecs = 0;
|
|
@@ -1107,7 +1297,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|
|
1107
1297
|
git_vector_free(&specs);
|
|
1108
1298
|
|
|
1109
1299
|
if (error < 0)
|
|
1110
|
-
|
|
1300
|
+
goto on_error;
|
|
1111
1301
|
|
|
1112
1302
|
if (remote->push) {
|
|
1113
1303
|
git_push_free(remote->push);
|
|
@@ -1115,9 +1305,9 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|
|
1115
1305
|
}
|
|
1116
1306
|
|
|
1117
1307
|
if ((error = git_fetch_negotiate(remote, opts)) < 0)
|
|
1118
|
-
|
|
1308
|
+
goto on_error;
|
|
1119
1309
|
|
|
1120
|
-
|
|
1310
|
+
error = git_fetch_download_pack(remote);
|
|
1121
1311
|
|
|
1122
1312
|
on_error:
|
|
1123
1313
|
git_vector_free(&refs);
|
|
@@ -1126,55 +1316,91 @@ on_error:
|
|
|
1126
1316
|
return error;
|
|
1127
1317
|
}
|
|
1128
1318
|
|
|
1319
|
+
int git_remote_download(
|
|
1320
|
+
git_remote *remote,
|
|
1321
|
+
const git_strarray *refspecs,
|
|
1322
|
+
const git_fetch_options *opts)
|
|
1323
|
+
{
|
|
1324
|
+
git_remote_connect_options connect_opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
|
|
1325
|
+
int error;
|
|
1326
|
+
|
|
1327
|
+
GIT_ASSERT_ARG(remote);
|
|
1328
|
+
|
|
1329
|
+
if (!remote->repo) {
|
|
1330
|
+
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
|
1331
|
+
return -1;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
if (git_remote_connect_options__from_fetch_opts(&connect_opts,
|
|
1335
|
+
remote, opts) < 0)
|
|
1336
|
+
return -1;
|
|
1337
|
+
|
|
1338
|
+
if ((error = connect_or_reset_options(remote, GIT_DIRECTION_FETCH, &connect_opts)) < 0)
|
|
1339
|
+
return error;
|
|
1340
|
+
|
|
1341
|
+
return git_remote__download(remote, refspecs, opts);
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1129
1344
|
int git_remote_fetch(
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1345
|
+
git_remote *remote,
|
|
1346
|
+
const git_strarray *refspecs,
|
|
1347
|
+
const git_fetch_options *opts,
|
|
1348
|
+
const char *reflog_message)
|
|
1134
1349
|
{
|
|
1135
1350
|
int error, update_fetchhead = 1;
|
|
1136
1351
|
git_remote_autotag_option_t tagopt = remote->download_tags;
|
|
1137
1352
|
bool prune = false;
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1353
|
+
git_str reflog_msg_buf = GIT_STR_INIT;
|
|
1354
|
+
git_remote_connect_options connect_opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
|
|
1355
|
+
unsigned int capabilities;
|
|
1356
|
+
git_oid_t oid_type;
|
|
1357
|
+
|
|
1358
|
+
GIT_ASSERT_ARG(remote);
|
|
1359
|
+
|
|
1360
|
+
if (!remote->repo) {
|
|
1361
|
+
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
|
1362
|
+
return -1;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
if (git_remote_connect_options__from_fetch_opts(&connect_opts,
|
|
1366
|
+
remote, opts) < 0)
|
|
1367
|
+
return -1;
|
|
1368
|
+
|
|
1369
|
+
if ((error = connect_or_reset_options(remote, GIT_DIRECTION_FETCH, &connect_opts)) < 0)
|
|
1370
|
+
return error;
|
|
1141
1371
|
|
|
1142
1372
|
if (opts) {
|
|
1143
|
-
GIT_ERROR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
|
1144
|
-
cbs = &opts->callbacks;
|
|
1145
|
-
conn.custom_headers = &opts->custom_headers;
|
|
1146
1373
|
update_fetchhead = opts->update_fetchhead;
|
|
1147
1374
|
tagopt = opts->download_tags;
|
|
1148
|
-
GIT_ERROR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
|
1149
|
-
conn.proxy = &opts->proxy_opts;
|
|
1150
1375
|
}
|
|
1151
1376
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1377
|
+
if ((error = git_remote_capabilities(&capabilities, remote)) < 0 ||
|
|
1378
|
+
(error = git_remote_oid_type(&oid_type, remote)) < 0)
|
|
1154
1379
|
return error;
|
|
1155
1380
|
|
|
1156
|
-
|
|
1381
|
+
/* Connect and download everything */
|
|
1382
|
+
error = git_remote__download(remote, refspecs, opts);
|
|
1157
1383
|
|
|
1158
1384
|
/* We don't need to be connected anymore */
|
|
1159
1385
|
git_remote_disconnect(remote);
|
|
1160
1386
|
|
|
1161
1387
|
/* If the download failed, return the error */
|
|
1162
1388
|
if (error != 0)
|
|
1163
|
-
|
|
1389
|
+
goto done;
|
|
1164
1390
|
|
|
1165
1391
|
/* Default reflog message */
|
|
1166
1392
|
if (reflog_message)
|
|
1167
|
-
|
|
1393
|
+
git_str_sets(&reflog_msg_buf, reflog_message);
|
|
1168
1394
|
else {
|
|
1169
|
-
|
|
1395
|
+
git_str_printf(&reflog_msg_buf, "fetch %s",
|
|
1170
1396
|
remote->name ? remote->name : remote->url);
|
|
1171
1397
|
}
|
|
1172
1398
|
|
|
1173
1399
|
/* Create "remote/foo" branches for all remote branches */
|
|
1174
|
-
error = git_remote_update_tips(remote,
|
|
1175
|
-
|
|
1400
|
+
error = git_remote_update_tips(remote, &connect_opts.callbacks, update_fetchhead, tagopt, git_str_cstr(&reflog_msg_buf));
|
|
1401
|
+
git_str_dispose(&reflog_msg_buf);
|
|
1176
1402
|
if (error < 0)
|
|
1177
|
-
|
|
1403
|
+
goto done;
|
|
1178
1404
|
|
|
1179
1405
|
if (opts && opts->prune == GIT_FETCH_PRUNE)
|
|
1180
1406
|
prune = true;
|
|
@@ -1186,8 +1412,10 @@ int git_remote_fetch(
|
|
|
1186
1412
|
prune = remote->prune_refs;
|
|
1187
1413
|
|
|
1188
1414
|
if (prune)
|
|
1189
|
-
error = git_remote_prune(remote,
|
|
1415
|
+
error = git_remote_prune(remote, &connect_opts.callbacks);
|
|
1190
1416
|
|
|
1417
|
+
done:
|
|
1418
|
+
git_remote_connect_options_dispose(&connect_opts);
|
|
1191
1419
|
return error;
|
|
1192
1420
|
}
|
|
1193
1421
|
|
|
@@ -1211,22 +1439,22 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
|
|
|
1211
1439
|
return 0;
|
|
1212
1440
|
}
|
|
1213
1441
|
|
|
1214
|
-
static int ref_to_update(int *update,
|
|
1442
|
+
static int ref_to_update(int *update, git_str *remote_name, git_remote *remote, git_refspec *spec, const char *ref_name)
|
|
1215
1443
|
{
|
|
1216
1444
|
int error = 0;
|
|
1217
1445
|
git_repository *repo;
|
|
1218
|
-
|
|
1219
|
-
|
|
1446
|
+
git_str upstream_remote = GIT_STR_INIT;
|
|
1447
|
+
git_str upstream_name = GIT_STR_INIT;
|
|
1220
1448
|
|
|
1221
1449
|
repo = git_remote_owner(remote);
|
|
1222
1450
|
|
|
1223
1451
|
if ((!git_reference__is_branch(ref_name)) ||
|
|
1224
1452
|
!git_remote_name(remote) ||
|
|
1225
|
-
(error =
|
|
1226
|
-
git__strcmp(git_remote_name(remote),
|
|
1227
|
-
(error =
|
|
1228
|
-
!git_refspec_dst_matches(spec,
|
|
1229
|
-
(error =
|
|
1453
|
+
(error = git_branch__upstream_remote(&upstream_remote, repo, ref_name) < 0) ||
|
|
1454
|
+
git__strcmp(git_remote_name(remote), git_str_cstr(&upstream_remote)) ||
|
|
1455
|
+
(error = git_branch__upstream_name(&upstream_name, repo, ref_name)) < 0 ||
|
|
1456
|
+
!git_refspec_dst_matches(spec, git_str_cstr(&upstream_name)) ||
|
|
1457
|
+
(error = git_refspec__rtransform(remote_name, spec, upstream_name.ptr)) < 0) {
|
|
1230
1458
|
/* Not an error if there is no upstream */
|
|
1231
1459
|
if (error == GIT_ENOTFOUND) {
|
|
1232
1460
|
git_error_clear();
|
|
@@ -1238,15 +1466,15 @@ static int ref_to_update(int *update, git_buf *remote_name, git_remote *remote,
|
|
|
1238
1466
|
*update = 1;
|
|
1239
1467
|
}
|
|
1240
1468
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1469
|
+
git_str_dispose(&upstream_remote);
|
|
1470
|
+
git_str_dispose(&upstream_name);
|
|
1243
1471
|
return error;
|
|
1244
1472
|
}
|
|
1245
1473
|
|
|
1246
1474
|
static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_refspec *spec, git_vector *update_heads, git_reference *ref)
|
|
1247
1475
|
{
|
|
1248
1476
|
git_reference *resolved_ref = NULL;
|
|
1249
|
-
|
|
1477
|
+
git_str remote_name = GIT_STR_INIT;
|
|
1250
1478
|
git_config *config = NULL;
|
|
1251
1479
|
const char *ref_name;
|
|
1252
1480
|
int error = 0, update;
|
|
@@ -1281,10 +1509,10 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
|
|
1281
1509
|
goto cleanup;
|
|
1282
1510
|
|
|
1283
1511
|
if (update)
|
|
1284
|
-
error = remote_head_for_fetchspec_src(out, update_heads,
|
|
1512
|
+
error = remote_head_for_fetchspec_src(out, update_heads, git_str_cstr(&remote_name));
|
|
1285
1513
|
|
|
1286
1514
|
cleanup:
|
|
1287
|
-
|
|
1515
|
+
git_str_dispose(&remote_name);
|
|
1288
1516
|
git_reference_free(resolved_ref);
|
|
1289
1517
|
git_config_free(config);
|
|
1290
1518
|
return error;
|
|
@@ -1403,7 +1631,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
|
|
|
1403
1631
|
const git_refspec *spec;
|
|
1404
1632
|
const char *refname;
|
|
1405
1633
|
int error;
|
|
1406
|
-
git_oid zero_id =
|
|
1634
|
+
git_oid zero_id = GIT_OID_SHA1_ZERO;
|
|
1407
1635
|
|
|
1408
1636
|
if (callbacks)
|
|
1409
1637
|
GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
|
@@ -1422,7 +1650,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
|
|
|
1422
1650
|
*/
|
|
1423
1651
|
git_vector_foreach(&candidates, i, refname) {
|
|
1424
1652
|
git_vector_foreach(&remote->active_refspecs, j, spec) {
|
|
1425
|
-
|
|
1653
|
+
git_str buf = GIT_STR_INIT;
|
|
1426
1654
|
size_t pos;
|
|
1427
1655
|
char *src_name;
|
|
1428
1656
|
git_remote_head key = {0};
|
|
@@ -1430,12 +1658,12 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
|
|
|
1430
1658
|
if (!git_refspec_dst_matches(spec, refname))
|
|
1431
1659
|
continue;
|
|
1432
1660
|
|
|
1433
|
-
if ((error =
|
|
1661
|
+
if ((error = git_refspec__rtransform(&buf, spec, refname)) < 0)
|
|
1434
1662
|
goto cleanup;
|
|
1435
1663
|
|
|
1436
|
-
key.name = (char *)
|
|
1664
|
+
key.name = (char *) git_str_cstr(&buf);
|
|
1437
1665
|
error = git_vector_bsearch(&pos, &remote_refs, &key);
|
|
1438
|
-
|
|
1666
|
+
git_str_dispose(&buf);
|
|
1439
1667
|
|
|
1440
1668
|
if (error < 0 && error != GIT_ENOTFOUND)
|
|
1441
1669
|
goto cleanup;
|
|
@@ -1497,141 +1725,210 @@ cleanup:
|
|
|
1497
1725
|
return error;
|
|
1498
1726
|
}
|
|
1499
1727
|
|
|
1500
|
-
static int
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
git_vector *refs,
|
|
1507
|
-
const char *log_message)
|
|
1728
|
+
static int update_ref(
|
|
1729
|
+
const git_remote *remote,
|
|
1730
|
+
const char *ref_name,
|
|
1731
|
+
git_oid *id,
|
|
1732
|
+
const char *msg,
|
|
1733
|
+
const git_remote_callbacks *callbacks)
|
|
1508
1734
|
{
|
|
1509
|
-
int error = 0, autotag, valid;
|
|
1510
|
-
unsigned int i = 0;
|
|
1511
|
-
git_buf refname = GIT_BUF_INIT;
|
|
1512
|
-
git_oid old;
|
|
1513
|
-
git_odb *odb;
|
|
1514
|
-
git_remote_head *head;
|
|
1515
1735
|
git_reference *ref;
|
|
1516
|
-
|
|
1517
|
-
|
|
1736
|
+
git_oid old_id = GIT_OID_SHA1_ZERO;
|
|
1737
|
+
int error;
|
|
1518
1738
|
|
|
1519
|
-
|
|
1739
|
+
error = git_reference_name_to_id(&old_id, remote->repo, ref_name);
|
|
1520
1740
|
|
|
1521
|
-
if (
|
|
1522
|
-
return
|
|
1741
|
+
if (error < 0 && error != GIT_ENOTFOUND)
|
|
1742
|
+
return error;
|
|
1743
|
+
else if (error == 0 && git_oid_equal(&old_id, id))
|
|
1744
|
+
return 0;
|
|
1523
1745
|
|
|
1524
|
-
|
|
1525
|
-
|
|
1746
|
+
/* If we did find a current reference, make sure we haven't lost a race */
|
|
1747
|
+
if (error)
|
|
1748
|
+
error = git_reference_create(&ref, remote->repo, ref_name, id, true, msg);
|
|
1749
|
+
else
|
|
1750
|
+
error = git_reference_create_matching(&ref, remote->repo, ref_name, id, true, &old_id, msg);
|
|
1526
1751
|
|
|
1527
|
-
|
|
1528
|
-
if (git_vector_init(&update_heads, 16, NULL) < 0)
|
|
1529
|
-
return -1;
|
|
1752
|
+
git_reference_free(ref);
|
|
1530
1753
|
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
autotag = 0;
|
|
1534
|
-
git_buf_clear(&refname);
|
|
1754
|
+
if (error < 0)
|
|
1755
|
+
return error;
|
|
1535
1756
|
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1757
|
+
if (callbacks && callbacks->update_tips &&
|
|
1758
|
+
(error = callbacks->update_tips(ref_name, &old_id, id, callbacks->payload)) < 0)
|
|
1759
|
+
return error;
|
|
1539
1760
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1761
|
+
return 0;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
static int update_one_tip(
|
|
1765
|
+
git_vector *update_heads,
|
|
1766
|
+
git_remote *remote,
|
|
1767
|
+
git_refspec *spec,
|
|
1768
|
+
git_remote_head *head,
|
|
1769
|
+
git_refspec *tagspec,
|
|
1770
|
+
git_remote_autotag_option_t tagopt,
|
|
1771
|
+
const char *log_message,
|
|
1772
|
+
const git_remote_callbacks *callbacks)
|
|
1773
|
+
{
|
|
1774
|
+
git_odb *odb;
|
|
1775
|
+
git_str refname = GIT_STR_INIT;
|
|
1776
|
+
git_reference *ref = NULL;
|
|
1777
|
+
bool autotag = false;
|
|
1778
|
+
git_oid old;
|
|
1779
|
+
int valid;
|
|
1780
|
+
int error;
|
|
1542
1781
|
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
|
|
1782
|
+
if ((error = git_repository_odb__weakptr(&odb, remote->repo)) < 0)
|
|
1783
|
+
goto done;
|
|
1546
1784
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1785
|
+
/* Ignore malformed ref names (which also saves us from tag^{} */
|
|
1786
|
+
if ((error = git_reference_name_is_valid(&valid, head->name)) < 0)
|
|
1787
|
+
goto done;
|
|
1549
1788
|
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
goto on_error;
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1789
|
+
if (!valid)
|
|
1790
|
+
goto done;
|
|
1555
1791
|
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
goto on_error;
|
|
1561
|
-
} else {
|
|
1562
|
-
/*
|
|
1563
|
-
* no rhs mans store it in FETCH_HEAD, even if we don't
|
|
1564
|
-
update anything else.
|
|
1565
|
-
*/
|
|
1566
|
-
if ((error = git_vector_insert(&update_heads, head)) < 0)
|
|
1567
|
-
goto on_error;
|
|
1792
|
+
/* If we have a tag, see if the auto-follow rules say to update it */
|
|
1793
|
+
if (git_refspec_src_matches(tagspec, head->name)) {
|
|
1794
|
+
if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_AUTO)
|
|
1795
|
+
autotag = true;
|
|
1568
1796
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1797
|
+
if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
|
|
1798
|
+
if (git_str_puts(&refname, head->name) < 0)
|
|
1799
|
+
goto done;
|
|
1571
1800
|
}
|
|
1801
|
+
}
|
|
1572
1802
|
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1803
|
+
/* If we didn't want to auto-follow the tag, check if the refspec matches */
|
|
1804
|
+
if (!autotag && git_refspec_src_matches(spec, head->name)) {
|
|
1805
|
+
if (spec->dst) {
|
|
1806
|
+
if ((error = git_refspec__transform(&refname, spec, head->name)) < 0)
|
|
1807
|
+
goto done;
|
|
1808
|
+
} else {
|
|
1809
|
+
/*
|
|
1810
|
+
* no rhs means store it in FETCH_HEAD, even if we don't
|
|
1811
|
+
* update anything else.
|
|
1812
|
+
*/
|
|
1813
|
+
error = git_vector_insert(update_heads, head);
|
|
1814
|
+
goto done;
|
|
1576
1815
|
}
|
|
1816
|
+
}
|
|
1577
1817
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1818
|
+
/* If we still don't have a refname, we don't want it */
|
|
1819
|
+
if (git_str_len(&refname) == 0)
|
|
1820
|
+
goto done;
|
|
1581
1821
|
|
|
1582
|
-
|
|
1583
|
-
|
|
1822
|
+
/* In autotag mode, only create tags for objects already in db */
|
|
1823
|
+
if (autotag && !git_odb_exists(odb, &head->oid))
|
|
1824
|
+
goto done;
|
|
1584
1825
|
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
goto on_error;
|
|
1826
|
+
if (!autotag && (error = git_vector_insert(update_heads, head)) < 0)
|
|
1827
|
+
goto done;
|
|
1588
1828
|
|
|
1589
|
-
|
|
1590
|
-
&& !spec->force
|
|
1591
|
-
&& !git_graph_descendant_of(remote->repo, &head->oid, &old))
|
|
1592
|
-
continue;
|
|
1829
|
+
error = git_reference_name_to_id(&old, remote->repo, refname.ptr);
|
|
1593
1830
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1831
|
+
if (error < 0 && error != GIT_ENOTFOUND)
|
|
1832
|
+
goto done;
|
|
1596
1833
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1834
|
+
if (!(error || error == GIT_ENOTFOUND) &&
|
|
1835
|
+
!spec->force &&
|
|
1836
|
+
!git_graph_descendant_of(remote->repo, &head->oid, &old)) {
|
|
1837
|
+
error = 0;
|
|
1838
|
+
goto done;
|
|
1839
|
+
}
|
|
1600
1840
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1841
|
+
if (error == GIT_ENOTFOUND) {
|
|
1842
|
+
git_oid_clear(&old, GIT_OID_SHA1);
|
|
1843
|
+
error = 0;
|
|
1844
|
+
|
|
1845
|
+
if (autotag && (error = git_vector_insert(update_heads, head)) < 0)
|
|
1846
|
+
goto done;
|
|
1847
|
+
}
|
|
1603
1848
|
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
log_message);
|
|
1849
|
+
if (!git_oid__cmp(&old, &head->oid))
|
|
1850
|
+
goto done;
|
|
1607
1851
|
|
|
1852
|
+
/* In autotag mode, don't overwrite any locally-existing tags */
|
|
1853
|
+
error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag,
|
|
1854
|
+
log_message);
|
|
1855
|
+
|
|
1856
|
+
if (error < 0) {
|
|
1608
1857
|
if (error == GIT_EEXISTS)
|
|
1609
|
-
|
|
1858
|
+
error = 0;
|
|
1610
1859
|
|
|
1611
|
-
|
|
1860
|
+
goto done;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
if (callbacks && callbacks->update_tips != NULL &&
|
|
1864
|
+
(error = callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload)) < 0)
|
|
1865
|
+
git_error_set_after_callback_function(error, "git_remote_fetch");
|
|
1866
|
+
|
|
1867
|
+
done:
|
|
1868
|
+
git_reference_free(ref);
|
|
1869
|
+
git_str_dispose(&refname);
|
|
1870
|
+
return error;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
static int update_tips_for_spec(
|
|
1874
|
+
git_remote *remote,
|
|
1875
|
+
const git_remote_callbacks *callbacks,
|
|
1876
|
+
int update_fetchhead,
|
|
1877
|
+
git_remote_autotag_option_t tagopt,
|
|
1878
|
+
git_refspec *spec,
|
|
1879
|
+
git_vector *refs,
|
|
1880
|
+
const char *log_message)
|
|
1881
|
+
{
|
|
1882
|
+
git_refspec tagspec;
|
|
1883
|
+
git_remote_head *head, oid_head;
|
|
1884
|
+
git_vector update_heads;
|
|
1885
|
+
int error = 0;
|
|
1886
|
+
size_t i;
|
|
1887
|
+
|
|
1888
|
+
GIT_ASSERT_ARG(remote);
|
|
1889
|
+
|
|
1890
|
+
if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0)
|
|
1891
|
+
return -1;
|
|
1892
|
+
|
|
1893
|
+
/* Make a copy of the transport's refs */
|
|
1894
|
+
if (git_vector_init(&update_heads, 16, NULL) < 0)
|
|
1895
|
+
return -1;
|
|
1896
|
+
|
|
1897
|
+
/* Update tips based on the remote heads */
|
|
1898
|
+
git_vector_foreach(refs, i, head) {
|
|
1899
|
+
if (update_one_tip(&update_heads, remote, spec, head, &tagspec, tagopt, log_message, callbacks) < 0)
|
|
1612
1900
|
goto on_error;
|
|
1901
|
+
}
|
|
1613
1902
|
|
|
1614
|
-
|
|
1903
|
+
/* Handle specified oid sources */
|
|
1904
|
+
if (git_oid__is_hexstr(spec->src, GIT_OID_SHA1)) {
|
|
1905
|
+
git_oid id;
|
|
1615
1906
|
|
|
1616
|
-
if (
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1907
|
+
if ((error = git_oid__fromstr(&id, spec->src, GIT_OID_SHA1)) < 0)
|
|
1908
|
+
goto on_error;
|
|
1909
|
+
|
|
1910
|
+
if (spec->dst &&
|
|
1911
|
+
(error = update_ref(remote, spec->dst, &id, log_message, callbacks)) < 0)
|
|
1912
|
+
goto on_error;
|
|
1913
|
+
|
|
1914
|
+
git_oid_cpy(&oid_head.oid, &id);
|
|
1915
|
+
oid_head.name = spec->src;
|
|
1916
|
+
|
|
1917
|
+
if ((error = git_vector_insert(&update_heads, &oid_head)) < 0)
|
|
1918
|
+
goto on_error;
|
|
1620
1919
|
}
|
|
1621
1920
|
|
|
1622
1921
|
if (update_fetchhead &&
|
|
1623
1922
|
(error = git_remote_write_fetchhead(remote, spec, &update_heads)) < 0)
|
|
1624
1923
|
goto on_error;
|
|
1625
1924
|
|
|
1626
|
-
git_vector_free(&update_heads);
|
|
1627
1925
|
git_refspec__dispose(&tagspec);
|
|
1628
|
-
|
|
1926
|
+
git_vector_free(&update_heads);
|
|
1629
1927
|
return 0;
|
|
1630
1928
|
|
|
1631
1929
|
on_error:
|
|
1632
|
-
git_vector_free(&update_heads);
|
|
1633
1930
|
git_refspec__dispose(&tagspec);
|
|
1634
|
-
|
|
1931
|
+
git_vector_free(&update_heads);
|
|
1635
1932
|
return -1;
|
|
1636
1933
|
|
|
1637
1934
|
}
|
|
@@ -1697,20 +1994,22 @@ static int next_head(const git_remote *remote, git_vector *refs,
|
|
|
1697
1994
|
return GIT_ITEROVER;
|
|
1698
1995
|
}
|
|
1699
1996
|
|
|
1700
|
-
static int opportunistic_updates(
|
|
1701
|
-
|
|
1997
|
+
static int opportunistic_updates(
|
|
1998
|
+
const git_remote *remote,
|
|
1999
|
+
const git_remote_callbacks *callbacks,
|
|
2000
|
+
git_vector *refs,
|
|
2001
|
+
const char *msg)
|
|
1702
2002
|
{
|
|
1703
2003
|
size_t i, j, k;
|
|
1704
2004
|
git_refspec *spec;
|
|
1705
2005
|
git_remote_head *head;
|
|
1706
|
-
|
|
1707
|
-
git_buf refname = GIT_BUF_INIT;
|
|
2006
|
+
git_str refname = GIT_STR_INIT;
|
|
1708
2007
|
int error = 0;
|
|
1709
2008
|
|
|
1710
2009
|
i = j = k = 0;
|
|
1711
2010
|
|
|
2011
|
+
/* Handle refspecs matching remote heads */
|
|
1712
2012
|
while ((error = next_head(remote, refs, &spec, &head, &i, &j, &k)) == 0) {
|
|
1713
|
-
git_oid old = {{ 0 }};
|
|
1714
2013
|
/*
|
|
1715
2014
|
* If we got here, there is a refspec which was used
|
|
1716
2015
|
* for fetching which matches the source of one of the
|
|
@@ -1719,50 +2018,32 @@ static int opportunistic_updates(const git_remote *remote, const git_remote_call
|
|
|
1719
2018
|
* FETCH_HEAD
|
|
1720
2019
|
*/
|
|
1721
2020
|
|
|
1722
|
-
|
|
1723
|
-
if ((error =
|
|
2021
|
+
git_str_clear(&refname);
|
|
2022
|
+
if ((error = git_refspec__transform(&refname, spec, head->name)) < 0 ||
|
|
2023
|
+
(error = update_ref(remote, refname.ptr, &head->oid, msg, callbacks)) < 0)
|
|
1724
2024
|
goto cleanup;
|
|
1725
|
-
|
|
1726
|
-
error = git_reference_name_to_id(&old, remote->repo, refname.ptr);
|
|
1727
|
-
if (error < 0 && error != GIT_ENOTFOUND)
|
|
1728
|
-
goto cleanup;
|
|
1729
|
-
|
|
1730
|
-
if (!git_oid_cmp(&old, &head->oid))
|
|
1731
|
-
continue;
|
|
1732
|
-
|
|
1733
|
-
/* If we did find a current reference, make sure we haven't lost a race */
|
|
1734
|
-
if (error)
|
|
1735
|
-
error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, true, msg);
|
|
1736
|
-
else
|
|
1737
|
-
error = git_reference_create_matching(&ref, remote->repo, refname.ptr, &head->oid, true, &old, msg);
|
|
1738
|
-
git_reference_free(ref);
|
|
1739
|
-
if (error < 0)
|
|
1740
|
-
goto cleanup;
|
|
1741
|
-
|
|
1742
|
-
if (callbacks && callbacks->update_tips != NULL) {
|
|
1743
|
-
if (callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload) < 0)
|
|
1744
|
-
goto cleanup;
|
|
1745
|
-
}
|
|
1746
2025
|
}
|
|
1747
2026
|
|
|
1748
|
-
if (error
|
|
1749
|
-
|
|
2027
|
+
if (error != GIT_ITEROVER)
|
|
2028
|
+
goto cleanup;
|
|
2029
|
+
|
|
2030
|
+
error = 0;
|
|
1750
2031
|
|
|
1751
2032
|
cleanup:
|
|
1752
|
-
|
|
2033
|
+
git_str_dispose(&refname);
|
|
1753
2034
|
return error;
|
|
1754
2035
|
}
|
|
1755
2036
|
|
|
1756
2037
|
static int truncate_fetch_head(const char *gitdir)
|
|
1757
2038
|
{
|
|
1758
|
-
|
|
2039
|
+
git_str path = GIT_STR_INIT;
|
|
1759
2040
|
int error;
|
|
1760
2041
|
|
|
1761
|
-
if ((error =
|
|
2042
|
+
if ((error = git_str_joinpath(&path, gitdir, GIT_FETCH_HEAD_FILE)) < 0)
|
|
1762
2043
|
return error;
|
|
1763
2044
|
|
|
1764
2045
|
error = git_futils_truncate(path.ptr, GIT_REFS_FILE_MODE);
|
|
1765
|
-
|
|
2046
|
+
git_str_dispose(&path);
|
|
1766
2047
|
|
|
1767
2048
|
return error;
|
|
1768
2049
|
}
|
|
@@ -1813,7 +2094,7 @@ int git_remote_update_tips(
|
|
|
1813
2094
|
goto out;
|
|
1814
2095
|
}
|
|
1815
2096
|
|
|
1816
|
-
/* Only try to do opportunistic updates if the
|
|
2097
|
+
/* Only try to do opportunistic updates if the refspec lists differ. */
|
|
1817
2098
|
if (remote->passed_refspecs)
|
|
1818
2099
|
error = opportunistic_updates(remote, callbacks, &refs, reflog_message);
|
|
1819
2100
|
|
|
@@ -1854,6 +2135,17 @@ int git_remote_disconnect(git_remote *remote)
|
|
|
1854
2135
|
return 0;
|
|
1855
2136
|
}
|
|
1856
2137
|
|
|
2138
|
+
static void free_heads(git_vector *heads)
|
|
2139
|
+
{
|
|
2140
|
+
git_remote_head *head;
|
|
2141
|
+
size_t i;
|
|
2142
|
+
|
|
2143
|
+
git_vector_foreach(heads, i, head) {
|
|
2144
|
+
git__free(head->name);
|
|
2145
|
+
git__free(head);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
|
|
1857
2149
|
void git_remote_free(git_remote *remote)
|
|
1858
2150
|
{
|
|
1859
2151
|
if (remote == NULL)
|
|
@@ -1877,6 +2169,9 @@ void git_remote_free(git_remote *remote)
|
|
|
1877
2169
|
free_refspecs(&remote->passive_refspecs);
|
|
1878
2170
|
git_vector_free(&remote->passive_refspecs);
|
|
1879
2171
|
|
|
2172
|
+
free_heads(&remote->local_heads);
|
|
2173
|
+
git_vector_free(&remote->local_heads);
|
|
2174
|
+
|
|
1880
2175
|
git_push_free(remote->push);
|
|
1881
2176
|
git__free(remote->url);
|
|
1882
2177
|
git__free(remote->pushurl);
|
|
@@ -1943,7 +2238,7 @@ git_remote_autotag_option_t git_remote_autotag(const git_remote *remote)
|
|
|
1943
2238
|
|
|
1944
2239
|
int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value)
|
|
1945
2240
|
{
|
|
1946
|
-
|
|
2241
|
+
git_str var = GIT_STR_INIT;
|
|
1947
2242
|
git_config *config;
|
|
1948
2243
|
int error;
|
|
1949
2244
|
|
|
@@ -1955,7 +2250,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
|
|
|
1955
2250
|
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
|
|
1956
2251
|
return error;
|
|
1957
2252
|
|
|
1958
|
-
if ((error =
|
|
2253
|
+
if ((error = git_str_printf(&var, CONFIG_TAGOPT_FMT, remote)))
|
|
1959
2254
|
return error;
|
|
1960
2255
|
|
|
1961
2256
|
switch (value) {
|
|
@@ -1975,7 +2270,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
|
|
|
1975
2270
|
error = -1;
|
|
1976
2271
|
}
|
|
1977
2272
|
|
|
1978
|
-
|
|
2273
|
+
git_str_dispose(&var);
|
|
1979
2274
|
return error;
|
|
1980
2275
|
}
|
|
1981
2276
|
|
|
@@ -1989,25 +2284,25 @@ static int rename_remote_config_section(
|
|
|
1989
2284
|
const char *old_name,
|
|
1990
2285
|
const char *new_name)
|
|
1991
2286
|
{
|
|
1992
|
-
|
|
1993
|
-
new_section_name =
|
|
2287
|
+
git_str old_section_name = GIT_STR_INIT,
|
|
2288
|
+
new_section_name = GIT_STR_INIT;
|
|
1994
2289
|
int error = -1;
|
|
1995
2290
|
|
|
1996
|
-
if (
|
|
2291
|
+
if (git_str_printf(&old_section_name, "remote.%s", old_name) < 0)
|
|
1997
2292
|
goto cleanup;
|
|
1998
2293
|
|
|
1999
2294
|
if (new_name &&
|
|
2000
|
-
(
|
|
2295
|
+
(git_str_printf(&new_section_name, "remote.%s", new_name) < 0))
|
|
2001
2296
|
goto cleanup;
|
|
2002
2297
|
|
|
2003
2298
|
error = git_config_rename_section(
|
|
2004
2299
|
repo,
|
|
2005
|
-
|
|
2006
|
-
new_name ?
|
|
2300
|
+
git_str_cstr(&old_section_name),
|
|
2301
|
+
new_name ? git_str_cstr(&new_section_name) : NULL);
|
|
2007
2302
|
|
|
2008
2303
|
cleanup:
|
|
2009
|
-
|
|
2010
|
-
|
|
2304
|
+
git_str_dispose(&old_section_name);
|
|
2305
|
+
git_str_dispose(&new_section_name);
|
|
2011
2306
|
|
|
2012
2307
|
return error;
|
|
2013
2308
|
}
|
|
@@ -2056,27 +2351,27 @@ static int rename_one_remote_reference(
|
|
|
2056
2351
|
{
|
|
2057
2352
|
int error;
|
|
2058
2353
|
git_reference *ref = NULL, *dummy = NULL;
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2354
|
+
git_str namespace = GIT_STR_INIT, old_namespace = GIT_STR_INIT;
|
|
2355
|
+
git_str new_name = GIT_STR_INIT;
|
|
2356
|
+
git_str log_message = GIT_STR_INIT;
|
|
2062
2357
|
size_t pfx_len;
|
|
2063
2358
|
const char *target;
|
|
2064
2359
|
|
|
2065
|
-
if ((error =
|
|
2360
|
+
if ((error = git_str_printf(&namespace, GIT_REFS_REMOTES_DIR "%s/", new_remote_name)) < 0)
|
|
2066
2361
|
return error;
|
|
2067
2362
|
|
|
2068
2363
|
pfx_len = strlen(GIT_REFS_REMOTES_DIR) + strlen(old_remote_name) + 1;
|
|
2069
|
-
|
|
2070
|
-
if ((error =
|
|
2364
|
+
git_str_puts(&new_name, namespace.ptr);
|
|
2365
|
+
if ((error = git_str_puts(&new_name, git_reference_name(reference_in) + pfx_len)) < 0)
|
|
2071
2366
|
goto cleanup;
|
|
2072
2367
|
|
|
2073
|
-
if ((error =
|
|
2368
|
+
if ((error = git_str_printf(&log_message,
|
|
2074
2369
|
"renamed remote %s to %s",
|
|
2075
2370
|
old_remote_name, new_remote_name)) < 0)
|
|
2076
2371
|
goto cleanup;
|
|
2077
2372
|
|
|
2078
|
-
if ((error = git_reference_rename(&ref, reference_in,
|
|
2079
|
-
|
|
2373
|
+
if ((error = git_reference_rename(&ref, reference_in, git_str_cstr(&new_name), 1,
|
|
2374
|
+
git_str_cstr(&log_message))) < 0)
|
|
2080
2375
|
goto cleanup;
|
|
2081
2376
|
|
|
2082
2377
|
if (git_reference_type(ref) != GIT_REFERENCE_SYMBOLIC)
|
|
@@ -2084,29 +2379,29 @@ static int rename_one_remote_reference(
|
|
|
2084
2379
|
|
|
2085
2380
|
/* Handle refs like origin/HEAD -> origin/master */
|
|
2086
2381
|
target = git_reference_symbolic_target(ref);
|
|
2087
|
-
if ((error =
|
|
2382
|
+
if ((error = git_str_printf(&old_namespace, GIT_REFS_REMOTES_DIR "%s/", old_remote_name)) < 0)
|
|
2088
2383
|
goto cleanup;
|
|
2089
2384
|
|
|
2090
2385
|
if (git__prefixcmp(target, old_namespace.ptr))
|
|
2091
2386
|
goto cleanup;
|
|
2092
2387
|
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
if ((error =
|
|
2388
|
+
git_str_clear(&new_name);
|
|
2389
|
+
git_str_puts(&new_name, namespace.ptr);
|
|
2390
|
+
if ((error = git_str_puts(&new_name, target + pfx_len)) < 0)
|
|
2096
2391
|
goto cleanup;
|
|
2097
2392
|
|
|
2098
|
-
error = git_reference_symbolic_set_target(&dummy, ref,
|
|
2099
|
-
|
|
2393
|
+
error = git_reference_symbolic_set_target(&dummy, ref, git_str_cstr(&new_name),
|
|
2394
|
+
git_str_cstr(&log_message));
|
|
2100
2395
|
|
|
2101
2396
|
git_reference_free(dummy);
|
|
2102
2397
|
|
|
2103
2398
|
cleanup:
|
|
2104
2399
|
git_reference_free(reference_in);
|
|
2105
2400
|
git_reference_free(ref);
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2401
|
+
git_str_dispose(&namespace);
|
|
2402
|
+
git_str_dispose(&old_namespace);
|
|
2403
|
+
git_str_dispose(&new_name);
|
|
2404
|
+
git_str_dispose(&log_message);
|
|
2110
2405
|
return error;
|
|
2111
2406
|
}
|
|
2112
2407
|
|
|
@@ -2116,15 +2411,15 @@ static int rename_remote_references(
|
|
|
2116
2411
|
const char *new_name)
|
|
2117
2412
|
{
|
|
2118
2413
|
int error;
|
|
2119
|
-
|
|
2414
|
+
git_str buf = GIT_STR_INIT;
|
|
2120
2415
|
git_reference *ref;
|
|
2121
2416
|
git_reference_iterator *iter;
|
|
2122
2417
|
|
|
2123
|
-
if ((error =
|
|
2418
|
+
if ((error = git_str_printf(&buf, GIT_REFS_REMOTES_DIR "%s/*", old_name)) < 0)
|
|
2124
2419
|
return error;
|
|
2125
2420
|
|
|
2126
|
-
error = git_reference_iterator_glob_new(&iter, repo,
|
|
2127
|
-
|
|
2421
|
+
error = git_reference_iterator_glob_new(&iter, repo, git_str_cstr(&buf));
|
|
2422
|
+
git_str_dispose(&buf);
|
|
2128
2423
|
|
|
2129
2424
|
if (error < 0)
|
|
2130
2425
|
return error;
|
|
@@ -2142,7 +2437,7 @@ static int rename_remote_references(
|
|
|
2142
2437
|
static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const char *new_name)
|
|
2143
2438
|
{
|
|
2144
2439
|
git_config *config;
|
|
2145
|
-
|
|
2440
|
+
git_str base = GIT_STR_INIT, var = GIT_STR_INIT, val = GIT_STR_INIT;
|
|
2146
2441
|
const git_refspec *spec;
|
|
2147
2442
|
size_t i;
|
|
2148
2443
|
int error = 0;
|
|
@@ -2161,7 +2456,7 @@ static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const
|
|
|
2161
2456
|
continue;
|
|
2162
2457
|
|
|
2163
2458
|
/* Does the dst part of the refspec follow the expected format? */
|
|
2164
|
-
if (strcmp(
|
|
2459
|
+
if (strcmp(git_str_cstr(&base), spec->string)) {
|
|
2165
2460
|
char *dup;
|
|
2166
2461
|
|
|
2167
2462
|
dup = git__strdup(spec->string);
|
|
@@ -2175,24 +2470,24 @@ static int rename_fetch_refspecs(git_vector *problems, git_remote *remote, const
|
|
|
2175
2470
|
|
|
2176
2471
|
/* If we do want to move it to the new section */
|
|
2177
2472
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2473
|
+
git_str_clear(&val);
|
|
2474
|
+
git_str_clear(&var);
|
|
2180
2475
|
|
|
2181
2476
|
if (default_fetchspec_for_name(&val, new_name) < 0 ||
|
|
2182
|
-
|
|
2477
|
+
git_str_printf(&var, "remote.%s.fetch", new_name) < 0)
|
|
2183
2478
|
{
|
|
2184
2479
|
error = -1;
|
|
2185
2480
|
break;
|
|
2186
2481
|
}
|
|
2187
2482
|
|
|
2188
2483
|
if ((error = git_config_set_string(
|
|
2189
|
-
config,
|
|
2484
|
+
config, git_str_cstr(&var), git_str_cstr(&val))) < 0)
|
|
2190
2485
|
break;
|
|
2191
2486
|
}
|
|
2192
2487
|
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2488
|
+
git_str_dispose(&base);
|
|
2489
|
+
git_str_dispose(&var);
|
|
2490
|
+
git_str_dispose(&val);
|
|
2196
2491
|
|
|
2197
2492
|
if (error < 0) {
|
|
2198
2493
|
char *str;
|
|
@@ -2247,7 +2542,7 @@ cleanup:
|
|
|
2247
2542
|
|
|
2248
2543
|
int git_remote_name_is_valid(int *valid, const char *remote_name)
|
|
2249
2544
|
{
|
|
2250
|
-
|
|
2545
|
+
git_str buf = GIT_STR_INIT;
|
|
2251
2546
|
git_refspec refspec = {0};
|
|
2252
2547
|
int error;
|
|
2253
2548
|
|
|
@@ -2258,10 +2553,10 @@ int git_remote_name_is_valid(int *valid, const char *remote_name)
|
|
|
2258
2553
|
if (!remote_name || *remote_name == '\0')
|
|
2259
2554
|
return 0;
|
|
2260
2555
|
|
|
2261
|
-
if ((error =
|
|
2556
|
+
if ((error = git_str_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)) < 0)
|
|
2262
2557
|
goto done;
|
|
2263
2558
|
|
|
2264
|
-
error = git_refspec__parse(&refspec,
|
|
2559
|
+
error = git_refspec__parse(&refspec, git_str_cstr(&buf), true);
|
|
2265
2560
|
|
|
2266
2561
|
if (!error)
|
|
2267
2562
|
*valid = 1;
|
|
@@ -2269,7 +2564,7 @@ int git_remote_name_is_valid(int *valid, const char *remote_name)
|
|
|
2269
2564
|
error = 0;
|
|
2270
2565
|
|
|
2271
2566
|
done:
|
|
2272
|
-
|
|
2567
|
+
git_str_dispose(&buf);
|
|
2273
2568
|
git_refspec__dispose(&refspec);
|
|
2274
2569
|
|
|
2275
2570
|
return error;
|
|
@@ -2401,7 +2696,7 @@ static int remove_branch_config_related_entries(
|
|
|
2401
2696
|
git_config *config;
|
|
2402
2697
|
git_config_entry *entry;
|
|
2403
2698
|
git_config_iterator *iter;
|
|
2404
|
-
|
|
2699
|
+
git_str buf = GIT_STR_INIT;
|
|
2405
2700
|
|
|
2406
2701
|
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
|
|
2407
2702
|
return error;
|
|
@@ -2422,21 +2717,21 @@ static int remove_branch_config_related_entries(
|
|
|
2422
2717
|
break;
|
|
2423
2718
|
}
|
|
2424
2719
|
|
|
2425
|
-
|
|
2426
|
-
if ((error =
|
|
2720
|
+
git_str_clear(&buf);
|
|
2721
|
+
if ((error = git_str_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch)) < 0)
|
|
2427
2722
|
break;
|
|
2428
2723
|
|
|
2429
|
-
if ((error = git_config_delete_entry(config,
|
|
2724
|
+
if ((error = git_config_delete_entry(config, git_str_cstr(&buf))) < 0) {
|
|
2430
2725
|
if (error != GIT_ENOTFOUND)
|
|
2431
2726
|
break;
|
|
2432
2727
|
git_error_clear();
|
|
2433
2728
|
}
|
|
2434
2729
|
|
|
2435
|
-
|
|
2436
|
-
if ((error =
|
|
2730
|
+
git_str_clear(&buf);
|
|
2731
|
+
if ((error = git_str_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch)) < 0)
|
|
2437
2732
|
break;
|
|
2438
2733
|
|
|
2439
|
-
if ((error = git_config_delete_entry(config,
|
|
2734
|
+
if ((error = git_config_delete_entry(config, git_str_cstr(&buf))) < 0) {
|
|
2440
2735
|
if (error != GIT_ENOTFOUND)
|
|
2441
2736
|
break;
|
|
2442
2737
|
git_error_clear();
|
|
@@ -2446,7 +2741,7 @@ static int remove_branch_config_related_entries(
|
|
|
2446
2741
|
if (error == GIT_ITEROVER)
|
|
2447
2742
|
error = 0;
|
|
2448
2743
|
|
|
2449
|
-
|
|
2744
|
+
git_str_dispose(&buf);
|
|
2450
2745
|
git_config_iterator_free(iter);
|
|
2451
2746
|
return error;
|
|
2452
2747
|
}
|
|
@@ -2540,12 +2835,17 @@ int git_remote_delete(git_repository *repo, const char *name)
|
|
|
2540
2835
|
}
|
|
2541
2836
|
|
|
2542
2837
|
int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
2838
|
+
{
|
|
2839
|
+
GIT_BUF_WRAP_PRIVATE(out, git_remote__default_branch, remote);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
int git_remote__default_branch(git_str *out, git_remote *remote)
|
|
2543
2843
|
{
|
|
2544
2844
|
const git_remote_head **heads;
|
|
2545
2845
|
const git_remote_head *guess = NULL;
|
|
2546
2846
|
const git_oid *head_id;
|
|
2547
2847
|
size_t heads_len, i;
|
|
2548
|
-
|
|
2848
|
+
git_str local_default = GIT_STR_INIT;
|
|
2549
2849
|
int error;
|
|
2550
2850
|
|
|
2551
2851
|
GIT_ASSERT_ARG(out);
|
|
@@ -2558,12 +2858,9 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
|
2558
2858
|
goto done;
|
|
2559
2859
|
}
|
|
2560
2860
|
|
|
2561
|
-
if ((error = git_buf_sanitize(out)) < 0)
|
|
2562
|
-
return error;
|
|
2563
|
-
|
|
2564
2861
|
/* the first one must be HEAD so if that has the symref info, we're done */
|
|
2565
2862
|
if (heads[0]->symref_target) {
|
|
2566
|
-
error =
|
|
2863
|
+
error = git_str_puts(out, heads[0]->symref_target);
|
|
2567
2864
|
goto done;
|
|
2568
2865
|
}
|
|
2569
2866
|
|
|
@@ -2601,21 +2898,23 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
|
2601
2898
|
goto done;
|
|
2602
2899
|
}
|
|
2603
2900
|
|
|
2604
|
-
error =
|
|
2901
|
+
error = git_str_puts(out, guess->name);
|
|
2605
2902
|
|
|
2606
2903
|
done:
|
|
2607
|
-
|
|
2904
|
+
git_str_dispose(&local_default);
|
|
2608
2905
|
return error;
|
|
2609
2906
|
}
|
|
2610
2907
|
|
|
2611
|
-
int git_remote_upload(
|
|
2908
|
+
int git_remote_upload(
|
|
2909
|
+
git_remote *remote,
|
|
2910
|
+
const git_strarray *refspecs,
|
|
2911
|
+
const git_push_options *opts)
|
|
2612
2912
|
{
|
|
2613
|
-
|
|
2614
|
-
int error;
|
|
2913
|
+
git_remote_connect_options connect_opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
|
|
2615
2914
|
git_push *push;
|
|
2616
2915
|
git_refspec *spec;
|
|
2617
|
-
|
|
2618
|
-
|
|
2916
|
+
size_t i;
|
|
2917
|
+
int error;
|
|
2619
2918
|
|
|
2620
2919
|
GIT_ASSERT_ARG(remote);
|
|
2621
2920
|
|
|
@@ -2624,14 +2923,11 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
|
|
|
2624
2923
|
return -1;
|
|
2625
2924
|
}
|
|
2626
2925
|
|
|
2627
|
-
if (
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
conn.proxy = &opts->proxy_opts;
|
|
2631
|
-
}
|
|
2926
|
+
if ((error = git_remote_connect_options__from_push_opts(
|
|
2927
|
+
&connect_opts, remote, opts)) < 0)
|
|
2928
|
+
goto cleanup;
|
|
2632
2929
|
|
|
2633
|
-
if (
|
|
2634
|
-
(error = git_remote__connect(remote, GIT_DIRECTION_PUSH, cbs, &conn)) < 0)
|
|
2930
|
+
if ((error = connect_or_reset_options(remote, GIT_DIRECTION_PUSH, &connect_opts)) < 0)
|
|
2635
2931
|
goto cleanup;
|
|
2636
2932
|
|
|
2637
2933
|
free_refspecs(&remote->active_refspecs);
|
|
@@ -2643,14 +2939,11 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
|
|
|
2643
2939
|
remote->push = NULL;
|
|
2644
2940
|
}
|
|
2645
2941
|
|
|
2646
|
-
if ((error = git_push_new(&remote->push, remote)) < 0)
|
|
2647
|
-
|
|
2942
|
+
if ((error = git_push_new(&remote->push, remote, opts)) < 0)
|
|
2943
|
+
goto cleanup;
|
|
2648
2944
|
|
|
2649
2945
|
push = remote->push;
|
|
2650
2946
|
|
|
2651
|
-
if (opts && (error = git_push_set_options(push, opts)) < 0)
|
|
2652
|
-
goto cleanup;
|
|
2653
|
-
|
|
2654
2947
|
if (refspecs && refspecs->count > 0) {
|
|
2655
2948
|
for (i = 0; i < refspecs->count; i++) {
|
|
2656
2949
|
if ((error = git_push_add_refspec(push, refspecs->strings[i])) < 0)
|
|
@@ -2665,23 +2958,25 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
|
|
|
2665
2958
|
}
|
|
2666
2959
|
}
|
|
2667
2960
|
|
|
2668
|
-
if ((error = git_push_finish(push
|
|
2961
|
+
if ((error = git_push_finish(push)) < 0)
|
|
2669
2962
|
goto cleanup;
|
|
2670
2963
|
|
|
2671
|
-
if (
|
|
2672
|
-
(error = git_push_status_foreach(push,
|
|
2964
|
+
if (connect_opts.callbacks.push_update_reference &&
|
|
2965
|
+
(error = git_push_status_foreach(push, connect_opts.callbacks.push_update_reference, connect_opts.callbacks.payload)) < 0)
|
|
2673
2966
|
goto cleanup;
|
|
2674
2967
|
|
|
2675
2968
|
cleanup:
|
|
2969
|
+
git_remote_connect_options_dispose(&connect_opts);
|
|
2676
2970
|
return error;
|
|
2677
2971
|
}
|
|
2678
2972
|
|
|
2679
|
-
int git_remote_push(
|
|
2973
|
+
int git_remote_push(
|
|
2974
|
+
git_remote *remote,
|
|
2975
|
+
const git_strarray *refspecs,
|
|
2976
|
+
const git_push_options *opts)
|
|
2680
2977
|
{
|
|
2978
|
+
git_remote_connect_options connect_opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
|
|
2681
2979
|
int error;
|
|
2682
|
-
const git_remote_callbacks *cbs = NULL;
|
|
2683
|
-
const git_strarray *custom_headers = NULL;
|
|
2684
|
-
const git_proxy_options *proxy = NULL;
|
|
2685
2980
|
|
|
2686
2981
|
GIT_ASSERT_ARG(remote);
|
|
2687
2982
|
|
|
@@ -2690,23 +2985,18 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|
|
2690
2985
|
return -1;
|
|
2691
2986
|
}
|
|
2692
2987
|
|
|
2693
|
-
if (
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
custom_headers = &opts->custom_headers;
|
|
2697
|
-
GIT_ERROR_CHECK_VERSION(&opts->proxy_opts, GIT_PROXY_OPTIONS_VERSION, "git_proxy_options");
|
|
2698
|
-
proxy = &opts->proxy_opts;
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
|
|
2702
|
-
return error;
|
|
2988
|
+
if (git_remote_connect_options__from_push_opts(&connect_opts,
|
|
2989
|
+
remote, opts) < 0)
|
|
2990
|
+
return -1;
|
|
2703
2991
|
|
|
2704
2992
|
if ((error = git_remote_upload(remote, refspecs, opts)) < 0)
|
|
2705
|
-
|
|
2993
|
+
goto done;
|
|
2706
2994
|
|
|
2707
|
-
error = git_remote_update_tips(remote,
|
|
2995
|
+
error = git_remote_update_tips(remote, &connect_opts.callbacks, 0, 0, NULL);
|
|
2708
2996
|
|
|
2997
|
+
done:
|
|
2709
2998
|
git_remote_disconnect(remote);
|
|
2999
|
+
git_remote_connect_options_dispose(&connect_opts);
|
|
2710
3000
|
return error;
|
|
2711
3001
|
}
|
|
2712
3002
|
|
|
@@ -2714,19 +3004,20 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|
|
2714
3004
|
#define SUFFIX_FETCH "insteadof"
|
|
2715
3005
|
#define SUFFIX_PUSH "pushinsteadof"
|
|
2716
3006
|
|
|
2717
|
-
|
|
3007
|
+
static int apply_insteadof(char **out, git_config *config, const char *url, int direction, bool use_default_if_empty)
|
|
2718
3008
|
{
|
|
2719
3009
|
size_t match_length, prefix_length, suffix_length;
|
|
2720
3010
|
char *replacement = NULL;
|
|
2721
3011
|
const char *regexp;
|
|
2722
3012
|
|
|
2723
|
-
|
|
3013
|
+
git_str result = GIT_STR_INIT;
|
|
2724
3014
|
git_config_entry *entry;
|
|
2725
3015
|
git_config_iterator *iter;
|
|
2726
3016
|
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
3017
|
+
GIT_ASSERT_ARG(out);
|
|
3018
|
+
GIT_ASSERT_ARG(config);
|
|
3019
|
+
GIT_ASSERT_ARG(url);
|
|
3020
|
+
GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
|
|
2730
3021
|
|
|
2731
3022
|
/* Add 1 to prefix/suffix length due to the additional escaped dot */
|
|
2732
3023
|
prefix_length = strlen(PREFIX) + 1;
|
|
@@ -2739,7 +3030,7 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
|
2739
3030
|
}
|
|
2740
3031
|
|
|
2741
3032
|
if (git_config_iterator_glob_new(&iter, config, regexp) < 0)
|
|
2742
|
-
return
|
|
3033
|
+
return -1;
|
|
2743
3034
|
|
|
2744
3035
|
match_length = 0;
|
|
2745
3036
|
while (git_config_next(&entry, iter) == 0) {
|
|
@@ -2748,6 +3039,7 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
|
2748
3039
|
/* Check if entry value is a prefix of URL */
|
|
2749
3040
|
if (git__prefixcmp(url, entry->value))
|
|
2750
3041
|
continue;
|
|
3042
|
+
|
|
2751
3043
|
/* Check if entry value is longer than previous
|
|
2752
3044
|
* prefixes */
|
|
2753
3045
|
if ((n = strlen(entry->value)) <= match_length)
|
|
@@ -2765,14 +3057,20 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
|
2765
3057
|
|
|
2766
3058
|
git_config_iterator_free(iter);
|
|
2767
3059
|
|
|
2768
|
-
if (match_length == 0)
|
|
2769
|
-
|
|
3060
|
+
if (match_length == 0 && use_default_if_empty) {
|
|
3061
|
+
*out = git__strdup(url);
|
|
3062
|
+
return *out ? 0 : -1;
|
|
3063
|
+
} else if (match_length == 0) {
|
|
3064
|
+
*out = NULL;
|
|
3065
|
+
return 0;
|
|
3066
|
+
}
|
|
2770
3067
|
|
|
2771
|
-
|
|
3068
|
+
git_str_printf(&result, "%s%s", replacement, url + match_length);
|
|
2772
3069
|
|
|
2773
3070
|
git__free(replacement);
|
|
2774
3071
|
|
|
2775
|
-
|
|
3072
|
+
*out = git_str_detach(&result);
|
|
3073
|
+
return 0;
|
|
2776
3074
|
}
|
|
2777
3075
|
|
|
2778
3076
|
/* Deprecated functions */
|