rugged 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -6
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +18 -5
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -34
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +156 -124
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/include/git2/apply.h +2 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +93 -42
- data/vendor/libgit2/include/git2/blob.h +31 -3
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +19 -4
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +35 -20
- data/vendor/libgit2/include/git2/errors.h +6 -6
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +3 -3
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +25 -4
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +16 -7
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +84 -39
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +42 -37
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +26 -15
- data/vendor/libgit2/src/blob.c +44 -24
- data/vendor/libgit2/src/branch.c +69 -17
- data/vendor/libgit2/src/buffer.c +334 -25
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +48 -26
- data/vendor/libgit2/src/cherrypick.c +6 -2
- data/vendor/libgit2/src/clone.c +26 -11
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +25 -2
- data/vendor/libgit2/src/config.c +37 -15
- data/vendor/libgit2/src/config_cache.c +9 -4
- data/vendor/libgit2/src/config_file.c +16 -8
- data/vendor/libgit2/src/config_parse.c +4 -6
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +6 -3
- data/vendor/libgit2/src/diff.c +11 -8
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +2 -6
- data/vendor/libgit2/src/diff_generate.c +46 -17
- data/vendor/libgit2/src/diff_print.c +19 -6
- data/vendor/libgit2/src/diff_stats.c +7 -5
- data/vendor/libgit2/src/diff_tform.c +11 -10
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +24 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +5 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +206 -110
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +5 -5
- data/vendor/libgit2/src/futils.h +1 -1
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +112 -75
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +50 -32
- data/vendor/libgit2/src/integer.h +79 -2
- data/vendor/libgit2/src/iterator.c +36 -24
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +75 -32
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +11 -3
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +471 -10
- data/vendor/libgit2/src/midx.h +28 -1
- data/vendor/libgit2/src/mwindow.c +106 -60
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +127 -3
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +22 -14
- data/vendor/libgit2/src/odb.c +289 -51
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +28 -18
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +5 -4
- data/vendor/libgit2/src/pack-objects.c +54 -48
- data/vendor/libgit2/src/pack.c +339 -125
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +2 -1
- data/vendor/libgit2/src/path.c +98 -53
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +8 -8
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +93 -49
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +125 -71
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +91 -43
- data/vendor/libgit2/src/refs.h +1 -1
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/remote.c +281 -105
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +191 -118
- data/vendor/libgit2/src/repository.h +13 -2
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +6 -2
- data/vendor/libgit2/src/revparse.c +14 -9
- data/vendor/libgit2/src/revwalk.c +32 -15
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +3 -1
- data/vendor/libgit2/src/status.c +7 -4
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +128 -62
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +4 -6
- data/vendor/libgit2/src/tag.c +47 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +19 -8
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +62 -30
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +3 -3
- data/vendor/libgit2/src/transports/smart.c +12 -7
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +138 -81
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/posix.h +3 -0
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +53 -129
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +22 -24
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +77 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +32 -14
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +32 -16
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -364
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
data/vendor/libgit2/src/remote.c
CHANGED
@@ -82,9 +82,11 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
|
|
82
82
|
|
83
83
|
static int ensure_remote_name_is_valid(const char *name)
|
84
84
|
{
|
85
|
-
int error
|
85
|
+
int valid, error;
|
86
|
+
|
87
|
+
error = git_remote_name_is_valid(&valid, name);
|
86
88
|
|
87
|
-
if (!
|
89
|
+
if (!error && !valid) {
|
88
90
|
git_error_set(
|
89
91
|
GIT_ERROR_CONFIG,
|
90
92
|
"'%s' is not a valid remote name.", name ? name : "(null)");
|
@@ -110,12 +112,8 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
|
|
110
112
|
if ((error = ensure_remote_name_is_valid(name)) < 0)
|
111
113
|
return error;
|
112
114
|
|
113
|
-
if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0)
|
114
|
-
if (git_error_last()->klass != GIT_ERROR_NOMEMORY)
|
115
|
-
error = GIT_EINVALIDSPEC;
|
116
|
-
|
115
|
+
if ((error = git_refspec__parse(&spec, refspec, fetch)) < 0)
|
117
116
|
return error;
|
118
|
-
}
|
119
117
|
|
120
118
|
git_refspec__dispose(&spec);
|
121
119
|
|
@@ -123,7 +121,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
|
|
123
121
|
return error;
|
124
122
|
|
125
123
|
/*
|
126
|
-
* "$^" is
|
124
|
+
* "$^" is an unmatchable regexp: it will not match anything at all, so
|
127
125
|
* all values will be considered new and we will not replace any
|
128
126
|
* present value.
|
129
127
|
*/
|
@@ -212,7 +210,8 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
|
|
212
210
|
const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
|
213
211
|
int error = -1;
|
214
212
|
|
215
|
-
|
213
|
+
GIT_ASSERT_ARG(out);
|
214
|
+
GIT_ASSERT_ARG(url);
|
216
215
|
|
217
216
|
if (!opts) {
|
218
217
|
opts = &dummy_opts;
|
@@ -461,7 +460,9 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
|
|
461
460
|
struct refspec_cb_data data = { NULL };
|
462
461
|
bool optional_setting_found = false, found;
|
463
462
|
|
464
|
-
|
463
|
+
GIT_ASSERT_ARG(out);
|
464
|
+
GIT_ASSERT_ARG(repo);
|
465
|
+
GIT_ASSERT_ARG(name);
|
465
466
|
|
466
467
|
if ((error = ensure_remote_name_is_valid(name)) < 0)
|
467
468
|
return error;
|
@@ -583,29 +584,46 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
|
|
583
584
|
|
584
585
|
const char *git_remote_name(const git_remote *remote)
|
585
586
|
{
|
586
|
-
|
587
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
587
588
|
return remote->name;
|
588
589
|
}
|
589
590
|
|
590
591
|
git_repository *git_remote_owner(const git_remote *remote)
|
591
592
|
{
|
592
|
-
|
593
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
593
594
|
return remote->repo;
|
594
595
|
}
|
595
596
|
|
596
597
|
const char *git_remote_url(const git_remote *remote)
|
597
598
|
{
|
598
|
-
|
599
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
599
600
|
return remote->url;
|
600
601
|
}
|
601
602
|
|
603
|
+
int git_remote_set_instance_url(git_remote *remote, const char *url)
|
604
|
+
{
|
605
|
+
char *tmp;
|
606
|
+
|
607
|
+
GIT_ASSERT_ARG(remote);
|
608
|
+
GIT_ASSERT_ARG(url);
|
609
|
+
|
610
|
+
if ((tmp = git__strdup(url)) == NULL)
|
611
|
+
return -1;
|
612
|
+
|
613
|
+
git__free(remote->url);
|
614
|
+
remote->url = tmp;
|
615
|
+
|
616
|
+
return 0;
|
617
|
+
}
|
618
|
+
|
602
619
|
static int set_url(git_repository *repo, const char *remote, const char *pattern, const char *url)
|
603
620
|
{
|
604
621
|
git_config *cfg;
|
605
622
|
git_buf buf = GIT_BUF_INIT, canonical_url = GIT_BUF_INIT;
|
606
623
|
int error;
|
607
624
|
|
608
|
-
|
625
|
+
GIT_ASSERT_ARG(repo);
|
626
|
+
GIT_ASSERT_ARG(remote);
|
609
627
|
|
610
628
|
if ((error = ensure_remote_name_is_valid(remote)) < 0)
|
611
629
|
return error;
|
@@ -639,44 +657,84 @@ int git_remote_set_url(git_repository *repo, const char *remote, const char *url
|
|
639
657
|
|
640
658
|
const char *git_remote_pushurl(const git_remote *remote)
|
641
659
|
{
|
642
|
-
|
660
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
643
661
|
return remote->pushurl;
|
644
662
|
}
|
645
663
|
|
664
|
+
int git_remote_set_instance_pushurl(git_remote *remote, const char *url)
|
665
|
+
{
|
666
|
+
char *tmp;
|
667
|
+
|
668
|
+
GIT_ASSERT_ARG(remote);
|
669
|
+
GIT_ASSERT_ARG(url);
|
670
|
+
|
671
|
+
if ((tmp = git__strdup(url)) == NULL)
|
672
|
+
return -1;
|
673
|
+
|
674
|
+
git__free(remote->pushurl);
|
675
|
+
remote->pushurl = tmp;
|
676
|
+
|
677
|
+
return 0;
|
678
|
+
}
|
679
|
+
|
646
680
|
int git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url)
|
647
681
|
{
|
648
682
|
return set_url(repo, remote, CONFIG_PUSHURL_FMT, url);
|
649
683
|
}
|
650
684
|
|
651
|
-
static int resolve_url(
|
685
|
+
static int resolve_url(
|
686
|
+
git_buf *resolved_url,
|
687
|
+
const char *url,
|
688
|
+
int direction,
|
689
|
+
const git_remote_callbacks *callbacks)
|
652
690
|
{
|
653
|
-
|
691
|
+
#ifdef GIT_DEPRECATE_HARD
|
692
|
+
GIT_UNUSED(direction);
|
693
|
+
GIT_UNUSED(callbacks);
|
694
|
+
#else
|
695
|
+
int status, error;
|
654
696
|
|
655
697
|
if (callbacks && callbacks->resolve_url) {
|
656
698
|
git_buf_clear(resolved_url);
|
657
699
|
status = callbacks->resolve_url(resolved_url, url, direction, callbacks->payload);
|
658
700
|
if (status != GIT_PASSTHROUGH) {
|
659
701
|
git_error_set_after_callback_function(status, "git_resolve_url_cb");
|
660
|
-
|
702
|
+
|
703
|
+
if ((error = git_buf_sanitize(resolved_url)) < 0)
|
704
|
+
return error;
|
705
|
+
|
661
706
|
return status;
|
662
707
|
}
|
663
708
|
}
|
709
|
+
#endif
|
664
710
|
|
665
711
|
return git_buf_sets(resolved_url, url);
|
666
712
|
}
|
667
713
|
|
668
|
-
int git_remote__urlfordirection(
|
714
|
+
int git_remote__urlfordirection(
|
715
|
+
git_buf *url_out,
|
716
|
+
struct git_remote *remote,
|
717
|
+
int direction,
|
718
|
+
const git_remote_callbacks *callbacks)
|
669
719
|
{
|
670
720
|
const char *url = NULL;
|
671
721
|
|
672
|
-
|
673
|
-
|
722
|
+
GIT_ASSERT_ARG(remote);
|
723
|
+
GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
|
674
724
|
|
675
|
-
if (
|
725
|
+
if (callbacks && callbacks->remote_ready) {
|
726
|
+
int status = callbacks->remote_ready(remote, direction, callbacks->payload);
|
727
|
+
|
728
|
+
if (status != 0 && status != GIT_PASSTHROUGH) {
|
729
|
+
git_error_set_after_callback_function(status, "git_remote_ready_cb");
|
730
|
+
return status;
|
731
|
+
}
|
732
|
+
}
|
733
|
+
|
734
|
+
if (direction == GIT_DIRECTION_FETCH)
|
676
735
|
url = remote->url;
|
677
|
-
|
736
|
+
else if (direction == GIT_DIRECTION_PUSH)
|
678
737
|
url = remote->pushurl ? remote->pushurl : remote->url;
|
679
|
-
}
|
680
738
|
|
681
739
|
if (!url) {
|
682
740
|
git_error_set(GIT_ERROR_INVALID,
|
@@ -685,6 +743,7 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
|
|
685
743
|
direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
|
686
744
|
return GIT_EINVALID;
|
687
745
|
}
|
746
|
+
|
688
747
|
return resolve_url(url_out, url, direction, callbacks);
|
689
748
|
}
|
690
749
|
|
@@ -715,7 +774,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
|
|
715
774
|
git_credential_acquire_cb credentials = NULL;
|
716
775
|
git_transport_cb transport = NULL;
|
717
776
|
|
718
|
-
|
777
|
+
GIT_ASSERT_ARG(remote);
|
719
778
|
|
720
779
|
if (callbacks) {
|
721
780
|
GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
@@ -780,7 +839,7 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
|
|
780
839
|
|
781
840
|
int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote)
|
782
841
|
{
|
783
|
-
|
842
|
+
GIT_ASSERT_ARG(remote);
|
784
843
|
|
785
844
|
if (!remote->transport) {
|
786
845
|
git_error_set(GIT_ERROR_NET, "this remote has never connected");
|
@@ -790,75 +849,140 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
|
|
790
849
|
return remote->transport->ls(out, size, remote->transport);
|
791
850
|
}
|
792
851
|
|
793
|
-
int
|
852
|
+
static int lookup_config(char **out, git_config *cfg, const char *name)
|
794
853
|
{
|
795
|
-
git_config *cfg;
|
796
854
|
git_config_entry *ce = NULL;
|
797
|
-
git_buf val = GIT_BUF_INIT;
|
798
855
|
int error;
|
799
856
|
|
800
|
-
|
857
|
+
if ((error = git_config__lookup_entry(&ce, cfg, name, false)) < 0)
|
858
|
+
return error;
|
801
859
|
|
802
|
-
if (
|
803
|
-
|
860
|
+
if (ce && ce->value) {
|
861
|
+
*out = git__strdup(ce->value);
|
862
|
+
GIT_ERROR_CHECK_ALLOC(*out);
|
863
|
+
} else {
|
864
|
+
error = GIT_ENOTFOUND;
|
865
|
+
}
|
804
866
|
|
805
|
-
|
867
|
+
git_config_entry_free(ce);
|
868
|
+
return error;
|
869
|
+
}
|
806
870
|
|
807
|
-
|
808
|
-
|
871
|
+
static void url_config_trim(git_net_url *url)
|
872
|
+
{
|
873
|
+
size_t len = strlen(url->path);
|
874
|
+
|
875
|
+
if (url->path[len - 1] == '/') {
|
876
|
+
len--;
|
877
|
+
} else {
|
878
|
+
while (len && url->path[len - 1] != '/')
|
879
|
+
len--;
|
880
|
+
}
|
881
|
+
|
882
|
+
url->path[len] = '\0';
|
883
|
+
}
|
884
|
+
|
885
|
+
static int http_proxy_config(char **out, git_remote *remote, git_net_url *url)
|
886
|
+
{
|
887
|
+
git_config *cfg;
|
888
|
+
git_buf buf = GIT_BUF_INIT;
|
889
|
+
git_net_url lookup_url = GIT_NET_URL_INIT;
|
890
|
+
int error;
|
809
891
|
|
810
|
-
|
811
|
-
|
892
|
+
if ((error = git_net_url_dup(&lookup_url, url)) < 0 ||
|
893
|
+
(error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
|
894
|
+
goto done;
|
812
895
|
|
813
896
|
/* remote.<name>.proxy config setting */
|
814
897
|
if (remote->name && remote->name[0]) {
|
815
|
-
|
898
|
+
git_buf_clear(&buf);
|
816
899
|
|
817
|
-
if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0
|
818
|
-
|
900
|
+
if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0 ||
|
901
|
+
(error = lookup_config(out, cfg, buf.ptr)) != GIT_ENOTFOUND)
|
902
|
+
goto done;
|
903
|
+
}
|
819
904
|
|
820
|
-
|
821
|
-
|
905
|
+
while (true) {
|
906
|
+
git_buf_clear(&buf);
|
822
907
|
|
823
|
-
if (error < 0
|
824
|
-
|
908
|
+
if ((error = git_buf_puts(&buf, "http.")) < 0 ||
|
909
|
+
(error = git_net_url_fmt(&buf, &lookup_url)) < 0 ||
|
910
|
+
(error = git_buf_puts(&buf, ".proxy")) < 0 ||
|
911
|
+
(error = lookup_config(out, cfg, buf.ptr)) != GIT_ENOTFOUND)
|
912
|
+
goto done;
|
825
913
|
|
826
|
-
if (
|
827
|
-
|
828
|
-
|
829
|
-
|
914
|
+
if (! lookup_url.path[0])
|
915
|
+
break;
|
916
|
+
|
917
|
+
url_config_trim(&lookup_url);
|
830
918
|
}
|
831
919
|
|
832
|
-
|
833
|
-
if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0)
|
834
|
-
return error;
|
920
|
+
git_buf_clear(&buf);
|
835
921
|
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
922
|
+
error = lookup_config(out, cfg, "http.proxy");
|
923
|
+
|
924
|
+
done:
|
925
|
+
git_buf_dispose(&buf);
|
926
|
+
git_net_url_dispose(&lookup_url);
|
927
|
+
return error;
|
928
|
+
}
|
929
|
+
|
930
|
+
static int http_proxy_env(char **out, git_remote *remote, git_net_url *url)
|
931
|
+
{
|
932
|
+
git_buf proxy_env = GIT_BUF_INIT, no_proxy_env = GIT_BUF_INIT;
|
933
|
+
bool use_ssl = (strcmp(url->scheme, "https") == 0);
|
934
|
+
int error;
|
935
|
+
|
936
|
+
GIT_UNUSED(remote);
|
840
937
|
|
841
938
|
/* http_proxy / https_proxy environment variables */
|
842
|
-
error = git__getenv(&
|
939
|
+
error = git__getenv(&proxy_env, use_ssl ? "https_proxy" : "http_proxy");
|
843
940
|
|
844
941
|
/* try uppercase environment variables */
|
845
942
|
if (error == GIT_ENOTFOUND)
|
846
|
-
error = git__getenv(&
|
943
|
+
error = git__getenv(&proxy_env, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
|
847
944
|
|
848
|
-
if (error
|
849
|
-
|
850
|
-
git_error_clear();
|
851
|
-
error = 0;
|
852
|
-
}
|
945
|
+
if (error)
|
946
|
+
goto done;
|
853
947
|
|
854
|
-
|
855
|
-
|
948
|
+
/* no_proxy/NO_PROXY environment variables */
|
949
|
+
error = git__getenv(&no_proxy_env, "no_proxy");
|
856
950
|
|
857
|
-
|
951
|
+
if (error == GIT_ENOTFOUND)
|
952
|
+
error = git__getenv(&no_proxy_env, "NO_PROXY");
|
858
953
|
|
859
|
-
|
860
|
-
|
861
|
-
|
954
|
+
if (error && error != GIT_ENOTFOUND)
|
955
|
+
goto done;
|
956
|
+
|
957
|
+
if (!git_net_url_matches_pattern_list(url, no_proxy_env.ptr))
|
958
|
+
*out = git_buf_detach(&proxy_env);
|
959
|
+
else
|
960
|
+
error = GIT_ENOTFOUND;
|
961
|
+
|
962
|
+
done:
|
963
|
+
git_buf_dispose(&proxy_env);
|
964
|
+
git_buf_dispose(&no_proxy_env);
|
965
|
+
return error;
|
966
|
+
}
|
967
|
+
|
968
|
+
int git_remote__http_proxy(char **out, git_remote *remote, git_net_url *url)
|
969
|
+
{
|
970
|
+
int error;
|
971
|
+
|
972
|
+
GIT_ASSERT_ARG(out);
|
973
|
+
GIT_ASSERT_ARG(remote);
|
974
|
+
GIT_ASSERT_ARG(remote->repo);
|
975
|
+
|
976
|
+
*out = NULL;
|
977
|
+
|
978
|
+
/*
|
979
|
+
* Go through the possible sources for proxy configuration,
|
980
|
+
* Examine the various git config options first, then
|
981
|
+
* consult environment variables.
|
982
|
+
*/
|
983
|
+
if ((error = http_proxy_config(out, remote, url)) != GIT_ENOTFOUND ||
|
984
|
+
(error = http_proxy_env(out, remote, url)) != GIT_ENOTFOUND)
|
985
|
+
return error;
|
862
986
|
|
863
987
|
return 0;
|
864
988
|
}
|
@@ -926,7 +1050,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|
926
1050
|
const git_strarray *custom_headers = NULL;
|
927
1051
|
const git_proxy_options *proxy = NULL;
|
928
1052
|
|
929
|
-
|
1053
|
+
GIT_ASSERT_ARG(remote);
|
930
1054
|
|
931
1055
|
if (!remote->repo) {
|
932
1056
|
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
@@ -1065,7 +1189,8 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
|
|
1065
1189
|
unsigned int i;
|
1066
1190
|
git_remote_head *remote_ref;
|
1067
1191
|
|
1068
|
-
|
1192
|
+
GIT_ASSERT_ARG(update_heads);
|
1193
|
+
GIT_ASSERT_ARG(fetchspec_src);
|
1069
1194
|
|
1070
1195
|
*out = NULL;
|
1071
1196
|
|
@@ -1119,7 +1244,9 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
|
1119
1244
|
const char *ref_name;
|
1120
1245
|
int error = 0, update;
|
1121
1246
|
|
1122
|
-
|
1247
|
+
GIT_ASSERT_ARG(out);
|
1248
|
+
GIT_ASSERT_ARG(spec);
|
1249
|
+
GIT_ASSERT_ARG(ref);
|
1123
1250
|
|
1124
1251
|
*out = NULL;
|
1125
1252
|
|
@@ -1133,6 +1260,16 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
|
|
1133
1260
|
ref_name = git_reference_name(resolved_ref);
|
1134
1261
|
}
|
1135
1262
|
|
1263
|
+
/*
|
1264
|
+
* The ref name may be unresolvable - perhaps it's pointing to
|
1265
|
+
* something invalid. In this case, there is no remote head for
|
1266
|
+
* this ref.
|
1267
|
+
*/
|
1268
|
+
if (!ref_name) {
|
1269
|
+
error = 0;
|
1270
|
+
goto cleanup;
|
1271
|
+
}
|
1272
|
+
|
1136
1273
|
if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0)
|
1137
1274
|
goto cleanup;
|
1138
1275
|
|
@@ -1156,7 +1293,7 @@ static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git
|
|
1156
1293
|
unsigned int i = 0;
|
1157
1294
|
int error = 0;
|
1158
1295
|
|
1159
|
-
|
1296
|
+
GIT_ASSERT_ARG(remote);
|
1160
1297
|
|
1161
1298
|
/* no heads, nothing to do */
|
1162
1299
|
if (update_heads->length == 0)
|
@@ -1299,7 +1436,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
|
|
1299
1436
|
if (error == GIT_ENOTFOUND)
|
1300
1437
|
continue;
|
1301
1438
|
|
1302
|
-
/*
|
1439
|
+
/* If we did find a source, remove it from the candidates. */
|
1303
1440
|
if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0)
|
1304
1441
|
goto cleanup;
|
1305
1442
|
|
@@ -1362,7 +1499,7 @@ static int update_tips_for_spec(
|
|
1362
1499
|
git_vector *refs,
|
1363
1500
|
const char *log_message)
|
1364
1501
|
{
|
1365
|
-
int error = 0, autotag;
|
1502
|
+
int error = 0, autotag, valid;
|
1366
1503
|
unsigned int i = 0;
|
1367
1504
|
git_buf refname = GIT_BUF_INIT;
|
1368
1505
|
git_oid old;
|
@@ -1372,7 +1509,7 @@ static int update_tips_for_spec(
|
|
1372
1509
|
git_refspec tagspec;
|
1373
1510
|
git_vector update_heads;
|
1374
1511
|
|
1375
|
-
|
1512
|
+
GIT_ASSERT_ARG(remote);
|
1376
1513
|
|
1377
1514
|
if (git_repository_odb__weakptr(&odb, remote->repo) < 0)
|
1378
1515
|
return -1;
|
@@ -1390,7 +1527,10 @@ static int update_tips_for_spec(
|
|
1390
1527
|
git_buf_clear(&refname);
|
1391
1528
|
|
1392
1529
|
/* Ignore malformed ref names (which also saves us from tag^{} */
|
1393
|
-
if (
|
1530
|
+
if (git_reference_name_is_valid(&valid, head->name) < 0)
|
1531
|
+
goto on_error;
|
1532
|
+
|
1533
|
+
if (!valid)
|
1394
1534
|
continue;
|
1395
1535
|
|
1396
1536
|
/* If we have a tag, see if the auto-follow rules say to update it */
|
@@ -1439,6 +1579,11 @@ static int update_tips_for_spec(
|
|
1439
1579
|
if (error < 0 && error != GIT_ENOTFOUND)
|
1440
1580
|
goto on_error;
|
1441
1581
|
|
1582
|
+
if (!(error || error == GIT_ENOTFOUND)
|
1583
|
+
&& !spec->force
|
1584
|
+
&& !git_graph_descendant_of(remote->repo, &head->oid, &old))
|
1585
|
+
continue;
|
1586
|
+
|
1442
1587
|
if (error == GIT_ENOTFOUND) {
|
1443
1588
|
memset(&old, 0, GIT_OID_RAWSZ);
|
1444
1589
|
|
@@ -1499,6 +1644,7 @@ static int next_head(const git_remote *remote, git_vector *refs,
|
|
1499
1644
|
git_remote_head *head;
|
1500
1645
|
git_refspec *spec, *passive_spec;
|
1501
1646
|
size_t i, j, k;
|
1647
|
+
int valid;
|
1502
1648
|
|
1503
1649
|
active = &remote->active_refspecs;
|
1504
1650
|
passive = &remote->passive_refspecs;
|
@@ -1510,7 +1656,10 @@ static int next_head(const git_remote *remote, git_vector *refs,
|
|
1510
1656
|
for (; i < refs->length; i++) {
|
1511
1657
|
head = git_vector_get(refs, i);
|
1512
1658
|
|
1513
|
-
if (
|
1659
|
+
if (git_reference_name_is_valid(&valid, head->name) < 0)
|
1660
|
+
return -1;
|
1661
|
+
|
1662
|
+
if (!valid)
|
1514
1663
|
continue;
|
1515
1664
|
|
1516
1665
|
for (; j < active->length; j++) {
|
@@ -1657,7 +1806,7 @@ int git_remote_update_tips(
|
|
1657
1806
|
goto out;
|
1658
1807
|
}
|
1659
1808
|
|
1660
|
-
/*
|
1809
|
+
/* Only try to do opportunistic updates if the refpec lists differ. */
|
1661
1810
|
if (remote->passed_refspecs)
|
1662
1811
|
error = opportunistic_updates(remote, callbacks, &refs, reflog_message);
|
1663
1812
|
|
@@ -1669,7 +1818,7 @@ out:
|
|
1669
1818
|
|
1670
1819
|
int git_remote_connected(const git_remote *remote)
|
1671
1820
|
{
|
1672
|
-
|
1821
|
+
GIT_ASSERT_ARG(remote);
|
1673
1822
|
|
1674
1823
|
if (!remote->transport || !remote->transport->is_connected)
|
1675
1824
|
return 0;
|
@@ -1680,7 +1829,7 @@ int git_remote_connected(const git_remote *remote)
|
|
1680
1829
|
|
1681
1830
|
int git_remote_stop(git_remote *remote)
|
1682
1831
|
{
|
1683
|
-
|
1832
|
+
GIT_ASSERT_ARG(remote);
|
1684
1833
|
|
1685
1834
|
if (remote->transport && remote->transport->cancel)
|
1686
1835
|
remote->transport->cancel(remote->transport);
|
@@ -1690,7 +1839,7 @@ int git_remote_stop(git_remote *remote)
|
|
1690
1839
|
|
1691
1840
|
int git_remote_disconnect(git_remote *remote)
|
1692
1841
|
{
|
1693
|
-
|
1842
|
+
GIT_ASSERT_ARG(remote);
|
1694
1843
|
|
1695
1844
|
if (git_remote_connected(remote))
|
1696
1845
|
remote->transport->close(remote->transport);
|
@@ -1776,7 +1925,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
|
|
1776
1925
|
|
1777
1926
|
const git_indexer_progress *git_remote_stats(git_remote *remote)
|
1778
1927
|
{
|
1779
|
-
|
1928
|
+
GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
|
1780
1929
|
return &remote->stats;
|
1781
1930
|
}
|
1782
1931
|
|
@@ -1791,7 +1940,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
|
|
1791
1940
|
git_config *config;
|
1792
1941
|
int error;
|
1793
1942
|
|
1794
|
-
|
1943
|
+
GIT_ASSERT_ARG(repo && remote);
|
1795
1944
|
|
1796
1945
|
if ((error = ensure_remote_name_is_valid(remote)) < 0)
|
1797
1946
|
return error;
|
@@ -2055,7 +2204,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name,
|
|
2055
2204
|
git_vector problem_refspecs = GIT_VECTOR_INIT;
|
2056
2205
|
git_remote *remote = NULL;
|
2057
2206
|
|
2058
|
-
|
2207
|
+
GIT_ASSERT_ARG(out && repo && name && new_name);
|
2059
2208
|
|
2060
2209
|
if ((error = git_remote_lookup(&remote, repo, name)) < 0)
|
2061
2210
|
return error;
|
@@ -2089,24 +2238,34 @@ cleanup:
|
|
2089
2238
|
return error;
|
2090
2239
|
}
|
2091
2240
|
|
2092
|
-
int
|
2093
|
-
const char *remote_name)
|
2241
|
+
int git_remote_name_is_valid(int *valid, const char *remote_name)
|
2094
2242
|
{
|
2095
2243
|
git_buf buf = GIT_BUF_INIT;
|
2096
|
-
git_refspec refspec;
|
2097
|
-
int error
|
2244
|
+
git_refspec refspec = {0};
|
2245
|
+
int error;
|
2246
|
+
|
2247
|
+
GIT_ASSERT(valid);
|
2248
|
+
|
2249
|
+
*valid = 0;
|
2098
2250
|
|
2099
2251
|
if (!remote_name || *remote_name == '\0')
|
2100
2252
|
return 0;
|
2101
2253
|
|
2102
|
-
git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)
|
2254
|
+
if ((error = git_buf_printf(&buf, "refs/heads/test:refs/remotes/%s/test", remote_name)) < 0)
|
2255
|
+
goto done;
|
2256
|
+
|
2103
2257
|
error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true);
|
2104
2258
|
|
2259
|
+
if (!error)
|
2260
|
+
*valid = 1;
|
2261
|
+
else if (error == GIT_EINVALIDSPEC)
|
2262
|
+
error = 0;
|
2263
|
+
|
2264
|
+
done:
|
2105
2265
|
git_buf_dispose(&buf);
|
2106
2266
|
git_refspec__dispose(&refspec);
|
2107
2267
|
|
2108
|
-
|
2109
|
-
return error == 0;
|
2268
|
+
return error;
|
2110
2269
|
}
|
2111
2270
|
|
2112
2271
|
git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname)
|
@@ -2221,7 +2380,7 @@ static const char *name_offset(size_t *len_out, const char *name)
|
|
2221
2380
|
prefix_len = strlen("remote.");
|
2222
2381
|
dot = strchr(name + prefix_len, '.');
|
2223
2382
|
|
2224
|
-
|
2383
|
+
GIT_ASSERT_ARG_WITH_RETVAL(dot, NULL);
|
2225
2384
|
|
2226
2385
|
*len_out = dot - name - prefix_len;
|
2227
2386
|
return name + prefix_len;
|
@@ -2251,10 +2410,13 @@ static int remove_branch_config_related_entries(
|
|
2251
2410
|
if (strcmp(remote_name, entry->value))
|
2252
2411
|
continue;
|
2253
2412
|
|
2254
|
-
branch = name_offset(&branch_len, entry->name)
|
2413
|
+
if ((branch = name_offset(&branch_len, entry->name)) == NULL) {
|
2414
|
+
error = -1;
|
2415
|
+
break;
|
2416
|
+
}
|
2255
2417
|
|
2256
2418
|
git_buf_clear(&buf);
|
2257
|
-
if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
|
2419
|
+
if ((error = git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch)) < 0)
|
2258
2420
|
break;
|
2259
2421
|
|
2260
2422
|
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
|
@@ -2264,7 +2426,7 @@ static int remove_branch_config_related_entries(
|
|
2264
2426
|
}
|
2265
2427
|
|
2266
2428
|
git_buf_clear(&buf);
|
2267
|
-
if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
|
2429
|
+
if ((error = git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch)) < 0)
|
2268
2430
|
break;
|
2269
2431
|
|
2270
2432
|
if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
|
@@ -2359,7 +2521,8 @@ int git_remote_delete(git_repository *repo, const char *name)
|
|
2359
2521
|
{
|
2360
2522
|
int error;
|
2361
2523
|
|
2362
|
-
|
2524
|
+
GIT_ASSERT_ARG(repo);
|
2525
|
+
GIT_ASSERT_ARG(name);
|
2363
2526
|
|
2364
2527
|
if ((error = remove_branch_config_related_entries(repo, name)) < 0 ||
|
2365
2528
|
(error = remove_remote_tracking(repo, name)) < 0 ||
|
@@ -2378,7 +2541,7 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
2378
2541
|
git_buf local_default = GIT_BUF_INIT;
|
2379
2542
|
int error;
|
2380
2543
|
|
2381
|
-
|
2544
|
+
GIT_ASSERT_ARG(out);
|
2382
2545
|
|
2383
2546
|
if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
|
2384
2547
|
goto done;
|
@@ -2388,7 +2551,8 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
|
|
2388
2551
|
goto done;
|
2389
2552
|
}
|
2390
2553
|
|
2391
|
-
git_buf_sanitize(out)
|
2554
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
2555
|
+
return error;
|
2392
2556
|
|
2393
2557
|
/* the first one must be HEAD so if that has the symref info, we're done */
|
2394
2558
|
if (heads[0]->symref_target) {
|
@@ -2446,7 +2610,7 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
|
|
2446
2610
|
const git_remote_callbacks *cbs = NULL;
|
2447
2611
|
git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT;
|
2448
2612
|
|
2449
|
-
|
2613
|
+
GIT_ASSERT_ARG(remote);
|
2450
2614
|
|
2451
2615
|
if (!remote->repo) {
|
2452
2616
|
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
@@ -2512,7 +2676,7 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|
2512
2676
|
const git_strarray *custom_headers = NULL;
|
2513
2677
|
const git_proxy_options *proxy = NULL;
|
2514
2678
|
|
2515
|
-
|
2679
|
+
GIT_ASSERT_ARG(remote);
|
2516
2680
|
|
2517
2681
|
if (!remote->repo) {
|
2518
2682
|
git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
|
@@ -2527,8 +2691,6 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
|
|
2527
2691
|
proxy = &opts->proxy_opts;
|
2528
2692
|
}
|
2529
2693
|
|
2530
|
-
assert(remote);
|
2531
|
-
|
2532
2694
|
if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
|
2533
2695
|
return error;
|
2534
2696
|
|
@@ -2555,9 +2717,9 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
2555
2717
|
git_config_entry *entry;
|
2556
2718
|
git_config_iterator *iter;
|
2557
2719
|
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2720
|
+
GIT_ASSERT_ARG_WITH_RETVAL(config, NULL);
|
2721
|
+
GIT_ASSERT_ARG_WITH_RETVAL(url, NULL);
|
2722
|
+
GIT_ASSERT_ARG_WITH_RETVAL(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH, NULL);
|
2561
2723
|
|
2562
2724
|
/* Add 1 to prefix/suffix length due to the additional escaped dot */
|
2563
2725
|
prefix_length = strlen(PREFIX) + 1;
|
@@ -2605,3 +2767,17 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
|
|
2605
2767
|
|
2606
2768
|
return result.ptr;
|
2607
2769
|
}
|
2770
|
+
|
2771
|
+
/* Deprecated functions */
|
2772
|
+
|
2773
|
+
#ifndef GIT_DEPRECATE_HARD
|
2774
|
+
|
2775
|
+
int git_remote_is_valid_name(const char *remote_name)
|
2776
|
+
{
|
2777
|
+
int valid = 0;
|
2778
|
+
|
2779
|
+
git_remote_name_is_valid(&valid, remote_name);
|
2780
|
+
return valid;
|
2781
|
+
}
|
2782
|
+
|
2783
|
+
#endif
|