rugged 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_object.c +1 -1
  6. data/ext/rugged/rugged_repo.c +3 -3
  7. data/lib/rugged/repository.rb +2 -2
  8. data/lib/rugged/version.rb +1 -1
  9. data/vendor/libgit2/CMakeLists.txt +11 -6
  10. data/vendor/libgit2/COPYING +109 -1
  11. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  12. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
  13. data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
  14. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  15. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
  16. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  17. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  18. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  19. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  20. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  21. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  22. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  23. data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
  24. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  25. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  26. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  27. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  28. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  29. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  30. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  31. data/vendor/libgit2/include/git2/attr.h +89 -0
  32. data/vendor/libgit2/include/git2/blame.h +93 -42
  33. data/vendor/libgit2/include/git2/blob.h +14 -2
  34. data/vendor/libgit2/include/git2/branch.h +25 -0
  35. data/vendor/libgit2/include/git2/cert.h +42 -5
  36. data/vendor/libgit2/include/git2/checkout.h +28 -12
  37. data/vendor/libgit2/include/git2/commit.h +35 -19
  38. data/vendor/libgit2/include/git2/common.h +14 -4
  39. data/vendor/libgit2/include/git2/deprecated.h +206 -6
  40. data/vendor/libgit2/include/git2/diff.h +34 -19
  41. data/vendor/libgit2/include/git2/errors.h +6 -6
  42. data/vendor/libgit2/include/git2/filter.h +57 -17
  43. data/vendor/libgit2/include/git2/graph.h +20 -2
  44. data/vendor/libgit2/include/git2/index.h +2 -2
  45. data/vendor/libgit2/include/git2/odb.h +29 -0
  46. data/vendor/libgit2/include/git2/patch.h +8 -0
  47. data/vendor/libgit2/include/git2/rebase.h +25 -1
  48. data/vendor/libgit2/include/git2/refs.h +6 -2
  49. data/vendor/libgit2/include/git2/remote.h +59 -6
  50. data/vendor/libgit2/include/git2/revparse.h +5 -5
  51. data/vendor/libgit2/include/git2/status.h +115 -59
  52. data/vendor/libgit2/include/git2/submodule.h +9 -0
  53. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  54. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  55. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  56. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  57. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  58. data/vendor/libgit2/include/git2/tag.h +12 -0
  59. data/vendor/libgit2/include/git2/tree.h +0 -14
  60. data/vendor/libgit2/include/git2/types.h +9 -0
  61. data/vendor/libgit2/include/git2/version.h +4 -4
  62. data/vendor/libgit2/include/git2/worktree.h +1 -0
  63. data/vendor/libgit2/src/CMakeLists.txt +25 -4
  64. data/vendor/libgit2/src/alloc.c +21 -8
  65. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  66. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  67. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  68. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  69. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  70. data/vendor/libgit2/src/annotated_commit.c +21 -9
  71. data/vendor/libgit2/src/apply.c +16 -7
  72. data/vendor/libgit2/src/array.h +11 -11
  73. data/vendor/libgit2/src/attr.c +181 -74
  74. data/vendor/libgit2/src/attr_file.c +84 -39
  75. data/vendor/libgit2/src/attr_file.h +32 -11
  76. data/vendor/libgit2/src/attrcache.c +42 -37
  77. data/vendor/libgit2/src/attrcache.h +4 -5
  78. data/vendor/libgit2/src/blame.c +11 -5
  79. data/vendor/libgit2/src/blob.c +35 -24
  80. data/vendor/libgit2/src/branch.c +69 -17
  81. data/vendor/libgit2/src/buffer.c +334 -25
  82. data/vendor/libgit2/src/buffer.h +153 -2
  83. data/vendor/libgit2/src/cache.c +2 -2
  84. data/vendor/libgit2/src/cache.h +7 -7
  85. data/vendor/libgit2/src/cc-compat.h +10 -2
  86. data/vendor/libgit2/src/checkout.c +48 -26
  87. data/vendor/libgit2/src/cherrypick.c +6 -2
  88. data/vendor/libgit2/src/clone.c +41 -47
  89. data/vendor/libgit2/src/commit.c +41 -28
  90. data/vendor/libgit2/src/commit_graph.c +1209 -0
  91. data/vendor/libgit2/src/commit_graph.h +162 -0
  92. data/vendor/libgit2/src/commit_list.c +46 -0
  93. data/vendor/libgit2/src/commit_list.h +2 -0
  94. data/vendor/libgit2/src/common.h +25 -2
  95. data/vendor/libgit2/src/config.c +37 -15
  96. data/vendor/libgit2/src/config_cache.c +5 -3
  97. data/vendor/libgit2/src/config_file.c +16 -8
  98. data/vendor/libgit2/src/config_parse.c +4 -6
  99. data/vendor/libgit2/src/crlf.c +16 -6
  100. data/vendor/libgit2/src/date.c +4 -3
  101. data/vendor/libgit2/src/delta.c +1 -1
  102. data/vendor/libgit2/src/describe.c +6 -3
  103. data/vendor/libgit2/src/diff.c +11 -8
  104. data/vendor/libgit2/src/diff_driver.c +21 -17
  105. data/vendor/libgit2/src/diff_file.c +2 -6
  106. data/vendor/libgit2/src/diff_generate.c +46 -17
  107. data/vendor/libgit2/src/diff_print.c +19 -6
  108. data/vendor/libgit2/src/diff_stats.c +7 -5
  109. data/vendor/libgit2/src/diff_tform.c +9 -8
  110. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  111. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  112. data/vendor/libgit2/src/errors.c +24 -19
  113. data/vendor/libgit2/src/features.h.in +5 -1
  114. data/vendor/libgit2/src/fetch.c +5 -2
  115. data/vendor/libgit2/src/fetchhead.c +8 -4
  116. data/vendor/libgit2/src/filebuf.c +9 -7
  117. data/vendor/libgit2/src/filter.c +206 -110
  118. data/vendor/libgit2/src/filter.h +24 -5
  119. data/vendor/libgit2/src/futils.c +5 -5
  120. data/vendor/libgit2/src/futils.h +1 -1
  121. data/vendor/libgit2/src/graph.c +64 -9
  122. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  123. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  124. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  125. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  126. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  127. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  128. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  129. data/vendor/libgit2/src/hash.c +16 -13
  130. data/vendor/libgit2/src/hash.h +1 -1
  131. data/vendor/libgit2/src/hashsig.c +23 -10
  132. data/vendor/libgit2/src/ident.c +13 -3
  133. data/vendor/libgit2/src/ignore.c +35 -19
  134. data/vendor/libgit2/src/index.c +106 -70
  135. data/vendor/libgit2/src/index.h +1 -1
  136. data/vendor/libgit2/src/indexer.c +31 -29
  137. data/vendor/libgit2/src/integer.h +64 -2
  138. data/vendor/libgit2/src/iterator.c +36 -24
  139. data/vendor/libgit2/src/iterator.h +1 -1
  140. data/vendor/libgit2/src/khash.h +2 -11
  141. data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
  142. data/vendor/libgit2/src/libgit2.h +15 -0
  143. data/vendor/libgit2/src/mailmap.c +23 -10
  144. data/vendor/libgit2/src/map.h +3 -3
  145. data/vendor/libgit2/src/merge.c +70 -30
  146. data/vendor/libgit2/src/merge.h +2 -1
  147. data/vendor/libgit2/src/merge_driver.c +19 -13
  148. data/vendor/libgit2/src/merge_file.c +11 -3
  149. data/vendor/libgit2/src/message.c +3 -1
  150. data/vendor/libgit2/src/midx.c +471 -10
  151. data/vendor/libgit2/src/midx.h +28 -1
  152. data/vendor/libgit2/src/mwindow.c +103 -59
  153. data/vendor/libgit2/src/mwindow.h +3 -3
  154. data/vendor/libgit2/src/net.c +127 -3
  155. data/vendor/libgit2/src/net.h +16 -2
  156. data/vendor/libgit2/src/netops.c +6 -4
  157. data/vendor/libgit2/src/netops.h +2 -2
  158. data/vendor/libgit2/src/notes.c +10 -10
  159. data/vendor/libgit2/src/object.c +22 -14
  160. data/vendor/libgit2/src/odb.c +285 -48
  161. data/vendor/libgit2/src/odb.h +16 -2
  162. data/vendor/libgit2/src/odb_loose.c +28 -18
  163. data/vendor/libgit2/src/odb_mempack.c +1 -1
  164. data/vendor/libgit2/src/odb_pack.c +391 -114
  165. data/vendor/libgit2/src/oid.c +5 -4
  166. data/vendor/libgit2/src/pack-objects.c +54 -48
  167. data/vendor/libgit2/src/pack.c +329 -119
  168. data/vendor/libgit2/src/pack.h +25 -7
  169. data/vendor/libgit2/src/patch.c +14 -7
  170. data/vendor/libgit2/src/patch_generate.c +2 -2
  171. data/vendor/libgit2/src/patch_parse.c +2 -1
  172. data/vendor/libgit2/src/path.c +98 -53
  173. data/vendor/libgit2/src/path.h +79 -6
  174. data/vendor/libgit2/src/pathspec.c +8 -8
  175. data/vendor/libgit2/src/pool.c +13 -7
  176. data/vendor/libgit2/src/posix.c +11 -3
  177. data/vendor/libgit2/src/reader.c +10 -6
  178. data/vendor/libgit2/src/rebase.c +93 -49
  179. data/vendor/libgit2/src/refdb.c +30 -13
  180. data/vendor/libgit2/src/refdb_fs.c +121 -69
  181. data/vendor/libgit2/src/reflog.c +19 -14
  182. data/vendor/libgit2/src/refs.c +76 -41
  183. data/vendor/libgit2/src/refspec.c +32 -12
  184. data/vendor/libgit2/src/remote.c +272 -102
  185. data/vendor/libgit2/src/remote.h +2 -1
  186. data/vendor/libgit2/src/repository.c +176 -103
  187. data/vendor/libgit2/src/repository.h +12 -1
  188. data/vendor/libgit2/src/reset.c +7 -6
  189. data/vendor/libgit2/src/revert.c +6 -2
  190. data/vendor/libgit2/src/revparse.c +14 -9
  191. data/vendor/libgit2/src/revwalk.c +32 -15
  192. data/vendor/libgit2/src/runtime.c +162 -0
  193. data/vendor/libgit2/src/runtime.h +62 -0
  194. data/vendor/libgit2/src/settings.h +11 -0
  195. data/vendor/libgit2/src/signature.c +6 -5
  196. data/vendor/libgit2/src/sortedcache.h +10 -8
  197. data/vendor/libgit2/src/stash.c +3 -1
  198. data/vendor/libgit2/src/status.c +7 -4
  199. data/vendor/libgit2/src/strarray.c +2 -1
  200. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  201. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  202. data/vendor/libgit2/src/streams/openssl.c +101 -201
  203. data/vendor/libgit2/src/streams/openssl.h +9 -1
  204. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  205. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  206. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  207. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  208. data/vendor/libgit2/src/streams/registry.c +5 -6
  209. data/vendor/libgit2/src/streams/socket.c +6 -2
  210. data/vendor/libgit2/src/streams/stransport.c +6 -3
  211. data/vendor/libgit2/src/streams/tls.c +5 -3
  212. data/vendor/libgit2/src/submodule.c +128 -62
  213. data/vendor/libgit2/src/submodule.h +9 -9
  214. data/vendor/libgit2/src/sysdir.c +4 -6
  215. data/vendor/libgit2/src/tag.c +47 -11
  216. data/vendor/libgit2/src/thread.c +140 -0
  217. data/vendor/libgit2/src/thread.h +479 -0
  218. data/vendor/libgit2/src/threadstate.c +83 -0
  219. data/vendor/libgit2/src/threadstate.h +24 -0
  220. data/vendor/libgit2/src/trace.c +2 -2
  221. data/vendor/libgit2/src/trace.h +17 -13
  222. data/vendor/libgit2/src/transaction.c +19 -8
  223. data/vendor/libgit2/src/transport.c +3 -3
  224. data/vendor/libgit2/src/transports/auth.c +1 -1
  225. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  226. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  227. data/vendor/libgit2/src/transports/credential.c +15 -7
  228. data/vendor/libgit2/src/transports/git.c +1 -3
  229. data/vendor/libgit2/src/transports/http.c +19 -17
  230. data/vendor/libgit2/src/transports/http.h +1 -0
  231. data/vendor/libgit2/src/transports/httpclient.c +53 -26
  232. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  233. data/vendor/libgit2/src/transports/local.c +3 -3
  234. data/vendor/libgit2/src/transports/smart.c +12 -7
  235. data/vendor/libgit2/src/transports/smart.h +1 -1
  236. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  237. data/vendor/libgit2/src/transports/ssh.c +51 -17
  238. data/vendor/libgit2/src/transports/winhttp.c +41 -31
  239. data/vendor/libgit2/src/tree.c +100 -77
  240. data/vendor/libgit2/src/tree.h +1 -0
  241. data/vendor/libgit2/src/tsort.c +0 -2
  242. data/vendor/libgit2/src/unix/map.c +3 -1
  243. data/vendor/libgit2/src/unix/pthread.h +2 -1
  244. data/vendor/libgit2/src/utf8.c +150 -0
  245. data/vendor/libgit2/src/utf8.h +52 -0
  246. data/vendor/libgit2/src/util.c +53 -129
  247. data/vendor/libgit2/src/util.h +33 -39
  248. data/vendor/libgit2/src/vector.c +23 -19
  249. data/vendor/libgit2/src/vector.h +4 -2
  250. data/vendor/libgit2/src/win32/findfile.c +4 -2
  251. data/vendor/libgit2/src/win32/map.c +1 -1
  252. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  253. data/vendor/libgit2/src/win32/path_w32.c +22 -24
  254. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  255. data/vendor/libgit2/src/win32/posix_w32.c +7 -1
  256. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  257. data/vendor/libgit2/src/win32/reparse.h +4 -4
  258. data/vendor/libgit2/src/win32/thread.c +24 -15
  259. data/vendor/libgit2/src/win32/thread.h +1 -1
  260. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  261. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  262. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  263. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  264. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  265. data/vendor/libgit2/src/worktree.c +27 -16
  266. data/vendor/libgit2/src/zstream.c +1 -1
  267. metadata +32 -16
  268. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  269. data/vendor/libgit2/src/buf_text.c +0 -316
  270. data/vendor/libgit2/src/buf_text.h +0 -122
  271. data/vendor/libgit2/src/global.c +0 -363
  272. data/vendor/libgit2/src/global.h +0 -41
  273. data/vendor/libgit2/src/thread-utils.c +0 -58
  274. data/vendor/libgit2/src/thread-utils.h +0 -369
  275. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  276. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  277. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -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 = 0;
85
+ int valid, error;
86
+
87
+ error = git_remote_name_is_valid(&valid, name);
86
88
 
87
- if (!git_remote_is_valid_name(name)) {
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)");
@@ -119,7 +121,7 @@ static int write_add_refspec(git_repository *repo, const char *name, const char
119
121
  return error;
120
122
 
121
123
  /*
122
- * "$^" is a unmatcheable regexp: it will not match anything at all, so
124
+ * "$^" is an unmatchable regexp: it will not match anything at all, so
123
125
  * all values will be considered new and we will not replace any
124
126
  * present value.
125
127
  */
@@ -208,7 +210,8 @@ int git_remote_create_with_opts(git_remote **out, const char *url, const git_rem
208
210
  const git_remote_create_options dummy_opts = GIT_REMOTE_CREATE_OPTIONS_INIT;
209
211
  int error = -1;
210
212
 
211
- assert(out && url);
213
+ GIT_ASSERT_ARG(out);
214
+ GIT_ASSERT_ARG(url);
212
215
 
213
216
  if (!opts) {
214
217
  opts = &dummy_opts;
@@ -457,7 +460,9 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
457
460
  struct refspec_cb_data data = { NULL };
458
461
  bool optional_setting_found = false, found;
459
462
 
460
- assert(out && repo && name);
463
+ GIT_ASSERT_ARG(out);
464
+ GIT_ASSERT_ARG(repo);
465
+ GIT_ASSERT_ARG(name);
461
466
 
462
467
  if ((error = ensure_remote_name_is_valid(name)) < 0)
463
468
  return error;
@@ -579,29 +584,46 @@ static int lookup_remote_prune_config(git_remote *remote, git_config *config, co
579
584
 
580
585
  const char *git_remote_name(const git_remote *remote)
581
586
  {
582
- assert(remote);
587
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
583
588
  return remote->name;
584
589
  }
585
590
 
586
591
  git_repository *git_remote_owner(const git_remote *remote)
587
592
  {
588
- assert(remote);
593
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
589
594
  return remote->repo;
590
595
  }
591
596
 
592
597
  const char *git_remote_url(const git_remote *remote)
593
598
  {
594
- assert(remote);
599
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
595
600
  return remote->url;
596
601
  }
597
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
+
598
619
  static int set_url(git_repository *repo, const char *remote, const char *pattern, const char *url)
599
620
  {
600
621
  git_config *cfg;
601
622
  git_buf buf = GIT_BUF_INIT, canonical_url = GIT_BUF_INIT;
602
623
  int error;
603
624
 
604
- assert(repo && remote);
625
+ GIT_ASSERT_ARG(repo);
626
+ GIT_ASSERT_ARG(remote);
605
627
 
606
628
  if ((error = ensure_remote_name_is_valid(remote)) < 0)
607
629
  return error;
@@ -635,44 +657,84 @@ int git_remote_set_url(git_repository *repo, const char *remote, const char *url
635
657
 
636
658
  const char *git_remote_pushurl(const git_remote *remote)
637
659
  {
638
- assert(remote);
660
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
639
661
  return remote->pushurl;
640
662
  }
641
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
+
642
680
  int git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url)
643
681
  {
644
682
  return set_url(repo, remote, CONFIG_PUSHURL_FMT, url);
645
683
  }
646
684
 
647
- static int resolve_url(git_buf *resolved_url, const char *url, int direction, const git_remote_callbacks *callbacks)
685
+ static int resolve_url(
686
+ git_buf *resolved_url,
687
+ const char *url,
688
+ int direction,
689
+ const git_remote_callbacks *callbacks)
648
690
  {
649
- int status;
691
+ #ifdef GIT_DEPRECATE_HARD
692
+ GIT_UNUSED(direction);
693
+ GIT_UNUSED(callbacks);
694
+ #else
695
+ int status, error;
650
696
 
651
697
  if (callbacks && callbacks->resolve_url) {
652
698
  git_buf_clear(resolved_url);
653
699
  status = callbacks->resolve_url(resolved_url, url, direction, callbacks->payload);
654
700
  if (status != GIT_PASSTHROUGH) {
655
701
  git_error_set_after_callback_function(status, "git_resolve_url_cb");
656
- git_buf_sanitize(resolved_url);
702
+
703
+ if ((error = git_buf_sanitize(resolved_url)) < 0)
704
+ return error;
705
+
657
706
  return status;
658
707
  }
659
708
  }
709
+ #endif
660
710
 
661
711
  return git_buf_sets(resolved_url, url);
662
712
  }
663
713
 
664
- int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int direction, const git_remote_callbacks *callbacks)
714
+ int git_remote__urlfordirection(
715
+ git_buf *url_out,
716
+ struct git_remote *remote,
717
+ int direction,
718
+ const git_remote_callbacks *callbacks)
665
719
  {
666
720
  const char *url = NULL;
667
721
 
668
- assert(remote);
669
- assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
722
+ GIT_ASSERT_ARG(remote);
723
+ GIT_ASSERT_ARG(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
670
724
 
671
- if (direction == GIT_DIRECTION_FETCH) {
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)
672
735
  url = remote->url;
673
- } else if (direction == GIT_DIRECTION_PUSH) {
736
+ else if (direction == GIT_DIRECTION_PUSH)
674
737
  url = remote->pushurl ? remote->pushurl : remote->url;
675
- }
676
738
 
677
739
  if (!url) {
678
740
  git_error_set(GIT_ERROR_INVALID,
@@ -681,6 +743,7 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int
681
743
  direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
682
744
  return GIT_EINVALID;
683
745
  }
746
+
684
747
  return resolve_url(url_out, url, direction, callbacks);
685
748
  }
686
749
 
@@ -711,7 +774,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
711
774
  git_credential_acquire_cb credentials = NULL;
712
775
  git_transport_cb transport = NULL;
713
776
 
714
- assert(remote);
777
+ GIT_ASSERT_ARG(remote);
715
778
 
716
779
  if (callbacks) {
717
780
  GIT_ERROR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
@@ -776,7 +839,7 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
776
839
 
777
840
  int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote)
778
841
  {
779
- assert(remote);
842
+ GIT_ASSERT_ARG(remote);
780
843
 
781
844
  if (!remote->transport) {
782
845
  git_error_set(GIT_ERROR_NET, "this remote has never connected");
@@ -786,75 +849,140 @@ int git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote
786
849
  return remote->transport->ls(out, size, remote->transport);
787
850
  }
788
851
 
789
- int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url)
852
+ static int lookup_config(char **out, git_config *cfg, const char *name)
790
853
  {
791
- git_config *cfg;
792
854
  git_config_entry *ce = NULL;
793
- git_buf val = GIT_BUF_INIT;
794
855
  int error;
795
856
 
796
- assert(remote);
857
+ if ((error = git_config__lookup_entry(&ce, cfg, name, false)) < 0)
858
+ return error;
859
+
860
+ if (ce && ce->value) {
861
+ *out = git__strdup(ce->value);
862
+ GIT_ERROR_CHECK_ALLOC(*out);
863
+ } else {
864
+ error = GIT_ENOTFOUND;
865
+ }
797
866
 
798
- if (!proxy_url || !remote->repo)
799
- return -1;
867
+ git_config_entry_free(ce);
868
+ return error;
869
+ }
800
870
 
801
- *proxy_url = NULL;
871
+ static void url_config_trim(git_net_url *url)
872
+ {
873
+ size_t len = strlen(url->path);
802
874
 
803
- if ((error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
804
- return error;
875
+ if (url->path[len - 1] == '/') {
876
+ len--;
877
+ } else {
878
+ while (len && url->path[len - 1] != '/')
879
+ len--;
880
+ }
805
881
 
806
- /* Go through the possible sources for proxy configuration, from most specific
807
- * to least specific. */
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;
891
+
892
+ if ((error = git_net_url_dup(&lookup_url, url)) < 0 ||
893
+ (error = git_repository_config__weakptr(&cfg, remote->repo)) < 0)
894
+ goto done;
808
895
 
809
896
  /* remote.<name>.proxy config setting */
810
897
  if (remote->name && remote->name[0]) {
811
- git_buf buf = GIT_BUF_INIT;
898
+ git_buf_clear(&buf);
812
899
 
813
- if ((error = git_buf_printf(&buf, "remote.%s.proxy", remote->name)) < 0)
814
- return error;
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
+ }
815
904
 
816
- error = git_config__lookup_entry(&ce, cfg, git_buf_cstr(&buf), false);
817
- git_buf_dispose(&buf);
905
+ while (true) {
906
+ git_buf_clear(&buf);
818
907
 
819
- if (error < 0)
820
- return error;
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;
821
913
 
822
- if (ce && ce->value) {
823
- *proxy_url = git__strdup(ce->value);
824
- goto found;
825
- }
914
+ if (! lookup_url.path[0])
915
+ break;
916
+
917
+ url_config_trim(&lookup_url);
826
918
  }
827
919
 
828
- /* http.proxy config setting */
829
- if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0)
830
- return error;
920
+ git_buf_clear(&buf);
831
921
 
832
- if (ce && ce->value) {
833
- *proxy_url = git__strdup(ce->value);
834
- goto found;
835
- }
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);
836
937
 
837
938
  /* http_proxy / https_proxy environment variables */
838
- error = git__getenv(&val, use_ssl ? "https_proxy" : "http_proxy");
939
+ error = git__getenv(&proxy_env, use_ssl ? "https_proxy" : "http_proxy");
839
940
 
840
941
  /* try uppercase environment variables */
841
942
  if (error == GIT_ENOTFOUND)
842
- error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
943
+ error = git__getenv(&proxy_env, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
843
944
 
844
- if (error < 0) {
845
- if (error == GIT_ENOTFOUND) {
846
- git_error_clear();
847
- error = 0;
848
- }
945
+ if (error)
946
+ goto done;
849
947
 
850
- return error;
851
- }
948
+ /* no_proxy/NO_PROXY environment variables */
949
+ error = git__getenv(&no_proxy_env, "no_proxy");
852
950
 
853
- *proxy_url = git_buf_detach(&val);
951
+ if (error == GIT_ENOTFOUND)
952
+ error = git__getenv(&no_proxy_env, "NO_PROXY");
854
953
 
855
- found:
856
- GIT_ERROR_CHECK_ALLOC(*proxy_url);
857
- git_config_entry_free(ce);
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;
858
986
 
859
987
  return 0;
860
988
  }
@@ -922,7 +1050,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
922
1050
  const git_strarray *custom_headers = NULL;
923
1051
  const git_proxy_options *proxy = NULL;
924
1052
 
925
- assert(remote);
1053
+ GIT_ASSERT_ARG(remote);
926
1054
 
927
1055
  if (!remote->repo) {
928
1056
  git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
@@ -1061,7 +1189,8 @@ static int remote_head_for_fetchspec_src(git_remote_head **out, git_vector *upda
1061
1189
  unsigned int i;
1062
1190
  git_remote_head *remote_ref;
1063
1191
 
1064
- assert(update_heads && fetchspec_src);
1192
+ GIT_ASSERT_ARG(update_heads);
1193
+ GIT_ASSERT_ARG(fetchspec_src);
1065
1194
 
1066
1195
  *out = NULL;
1067
1196
 
@@ -1112,10 +1241,12 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
1112
1241
  git_reference *resolved_ref = NULL;
1113
1242
  git_buf remote_name = GIT_BUF_INIT;
1114
1243
  git_config *config = NULL;
1115
- const char *ref_name = NULL;
1244
+ const char *ref_name;
1116
1245
  int error = 0, update;
1117
1246
 
1118
- assert(out && spec && ref);
1247
+ GIT_ASSERT_ARG(out);
1248
+ GIT_ASSERT_ARG(spec);
1249
+ GIT_ASSERT_ARG(ref);
1119
1250
 
1120
1251
  *out = NULL;
1121
1252
 
@@ -1125,7 +1256,7 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
1125
1256
  if (error == GIT_ENOTFOUND && git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) {
1126
1257
  ref_name = git_reference_symbolic_target(ref);
1127
1258
  error = 0;
1128
- } else if (resolved_ref) {
1259
+ } else {
1129
1260
  ref_name = git_reference_name(resolved_ref);
1130
1261
  }
1131
1262
 
@@ -1162,7 +1293,7 @@ static int git_remote_write_fetchhead(git_remote *remote, git_refspec *spec, git
1162
1293
  unsigned int i = 0;
1163
1294
  int error = 0;
1164
1295
 
1165
- assert(remote);
1296
+ GIT_ASSERT_ARG(remote);
1166
1297
 
1167
1298
  /* no heads, nothing to do */
1168
1299
  if (update_heads->length == 0)
@@ -1305,7 +1436,7 @@ int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
1305
1436
  if (error == GIT_ENOTFOUND)
1306
1437
  continue;
1307
1438
 
1308
- /* if we did find a source, remove it from the candiates */
1439
+ /* If we did find a source, remove it from the candidates. */
1309
1440
  if ((error = git_vector_set((void **) &src_name, &candidates, i, NULL)) < 0)
1310
1441
  goto cleanup;
1311
1442
 
@@ -1368,7 +1499,7 @@ static int update_tips_for_spec(
1368
1499
  git_vector *refs,
1369
1500
  const char *log_message)
1370
1501
  {
1371
- int error = 0, autotag;
1502
+ int error = 0, autotag, valid;
1372
1503
  unsigned int i = 0;
1373
1504
  git_buf refname = GIT_BUF_INIT;
1374
1505
  git_oid old;
@@ -1378,7 +1509,7 @@ static int update_tips_for_spec(
1378
1509
  git_refspec tagspec;
1379
1510
  git_vector update_heads;
1380
1511
 
1381
- assert(remote);
1512
+ GIT_ASSERT_ARG(remote);
1382
1513
 
1383
1514
  if (git_repository_odb__weakptr(&odb, remote->repo) < 0)
1384
1515
  return -1;
@@ -1396,7 +1527,10 @@ static int update_tips_for_spec(
1396
1527
  git_buf_clear(&refname);
1397
1528
 
1398
1529
  /* Ignore malformed ref names (which also saves us from tag^{} */
1399
- if (!git_reference_is_valid_name(head->name))
1530
+ if (git_reference_name_is_valid(&valid, head->name) < 0)
1531
+ goto on_error;
1532
+
1533
+ if (!valid)
1400
1534
  continue;
1401
1535
 
1402
1536
  /* If we have a tag, see if the auto-follow rules say to update it */
@@ -1445,6 +1579,11 @@ static int update_tips_for_spec(
1445
1579
  if (error < 0 && error != GIT_ENOTFOUND)
1446
1580
  goto on_error;
1447
1581
 
1582
+ if (!(error || error == GIT_ENOTFOUND)
1583
+ && !spec->force
1584
+ && !git_graph_descendant_of(remote->repo, &head->oid, &old))
1585
+ continue;
1586
+
1448
1587
  if (error == GIT_ENOTFOUND) {
1449
1588
  memset(&old, 0, GIT_OID_RAWSZ);
1450
1589
 
@@ -1505,6 +1644,7 @@ static int next_head(const git_remote *remote, git_vector *refs,
1505
1644
  git_remote_head *head;
1506
1645
  git_refspec *spec, *passive_spec;
1507
1646
  size_t i, j, k;
1647
+ int valid;
1508
1648
 
1509
1649
  active = &remote->active_refspecs;
1510
1650
  passive = &remote->passive_refspecs;
@@ -1516,7 +1656,10 @@ static int next_head(const git_remote *remote, git_vector *refs,
1516
1656
  for (; i < refs->length; i++) {
1517
1657
  head = git_vector_get(refs, i);
1518
1658
 
1519
- if (!git_reference_is_valid_name(head->name))
1659
+ if (git_reference_name_is_valid(&valid, head->name) < 0)
1660
+ return -1;
1661
+
1662
+ if (!valid)
1520
1663
  continue;
1521
1664
 
1522
1665
  for (; j < active->length; j++) {
@@ -1663,7 +1806,7 @@ int git_remote_update_tips(
1663
1806
  goto out;
1664
1807
  }
1665
1808
 
1666
- /* only try to do opportunisitic updates if the refpec lists differ */
1809
+ /* Only try to do opportunistic updates if the refpec lists differ. */
1667
1810
  if (remote->passed_refspecs)
1668
1811
  error = opportunistic_updates(remote, callbacks, &refs, reflog_message);
1669
1812
 
@@ -1675,7 +1818,7 @@ out:
1675
1818
 
1676
1819
  int git_remote_connected(const git_remote *remote)
1677
1820
  {
1678
- assert(remote);
1821
+ GIT_ASSERT_ARG(remote);
1679
1822
 
1680
1823
  if (!remote->transport || !remote->transport->is_connected)
1681
1824
  return 0;
@@ -1686,7 +1829,7 @@ int git_remote_connected(const git_remote *remote)
1686
1829
 
1687
1830
  int git_remote_stop(git_remote *remote)
1688
1831
  {
1689
- assert(remote);
1832
+ GIT_ASSERT_ARG(remote);
1690
1833
 
1691
1834
  if (remote->transport && remote->transport->cancel)
1692
1835
  remote->transport->cancel(remote->transport);
@@ -1696,7 +1839,7 @@ int git_remote_stop(git_remote *remote)
1696
1839
 
1697
1840
  int git_remote_disconnect(git_remote *remote)
1698
1841
  {
1699
- assert(remote);
1842
+ GIT_ASSERT_ARG(remote);
1700
1843
 
1701
1844
  if (git_remote_connected(remote))
1702
1845
  remote->transport->close(remote->transport);
@@ -1782,7 +1925,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
1782
1925
 
1783
1926
  const git_indexer_progress *git_remote_stats(git_remote *remote)
1784
1927
  {
1785
- assert(remote);
1928
+ GIT_ASSERT_ARG_WITH_RETVAL(remote, NULL);
1786
1929
  return &remote->stats;
1787
1930
  }
1788
1931
 
@@ -1797,7 +1940,7 @@ int git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_
1797
1940
  git_config *config;
1798
1941
  int error;
1799
1942
 
1800
- assert(repo && remote);
1943
+ GIT_ASSERT_ARG(repo && remote);
1801
1944
 
1802
1945
  if ((error = ensure_remote_name_is_valid(remote)) < 0)
1803
1946
  return error;
@@ -2061,7 +2204,7 @@ int git_remote_rename(git_strarray *out, git_repository *repo, const char *name,
2061
2204
  git_vector problem_refspecs = GIT_VECTOR_INIT;
2062
2205
  git_remote *remote = NULL;
2063
2206
 
2064
- assert(out && repo && name && new_name);
2207
+ GIT_ASSERT_ARG(out && repo && name && new_name);
2065
2208
 
2066
2209
  if ((error = git_remote_lookup(&remote, repo, name)) < 0)
2067
2210
  return error;
@@ -2095,24 +2238,34 @@ cleanup:
2095
2238
  return error;
2096
2239
  }
2097
2240
 
2098
- int git_remote_is_valid_name(
2099
- const char *remote_name)
2241
+ int git_remote_name_is_valid(int *valid, const char *remote_name)
2100
2242
  {
2101
2243
  git_buf buf = GIT_BUF_INIT;
2102
- git_refspec refspec;
2103
- int error = -1;
2244
+ git_refspec refspec = {0};
2245
+ int error;
2246
+
2247
+ GIT_ASSERT(valid);
2248
+
2249
+ *valid = 0;
2104
2250
 
2105
2251
  if (!remote_name || *remote_name == '\0')
2106
2252
  return 0;
2107
2253
 
2108
- 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
+
2109
2257
  error = git_refspec__parse(&refspec, git_buf_cstr(&buf), true);
2110
2258
 
2259
+ if (!error)
2260
+ *valid = 1;
2261
+ else if (error == GIT_EINVALIDSPEC)
2262
+ error = 0;
2263
+
2264
+ done:
2111
2265
  git_buf_dispose(&buf);
2112
2266
  git_refspec__dispose(&refspec);
2113
2267
 
2114
- git_error_clear();
2115
- return error == 0;
2268
+ return error;
2116
2269
  }
2117
2270
 
2118
2271
  git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname)
@@ -2227,7 +2380,7 @@ static const char *name_offset(size_t *len_out, const char *name)
2227
2380
  prefix_len = strlen("remote.");
2228
2381
  dot = strchr(name + prefix_len, '.');
2229
2382
 
2230
- assert(dot);
2383
+ GIT_ASSERT_ARG_WITH_RETVAL(dot, NULL);
2231
2384
 
2232
2385
  *len_out = dot - name - prefix_len;
2233
2386
  return name + prefix_len;
@@ -2257,10 +2410,13 @@ static int remove_branch_config_related_entries(
2257
2410
  if (strcmp(remote_name, entry->value))
2258
2411
  continue;
2259
2412
 
2260
- branch = name_offset(&branch_len, entry->name);
2413
+ if ((branch = name_offset(&branch_len, entry->name)) == NULL) {
2414
+ error = -1;
2415
+ break;
2416
+ }
2261
2417
 
2262
2418
  git_buf_clear(&buf);
2263
- 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)
2264
2420
  break;
2265
2421
 
2266
2422
  if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
@@ -2270,7 +2426,7 @@ static int remove_branch_config_related_entries(
2270
2426
  }
2271
2427
 
2272
2428
  git_buf_clear(&buf);
2273
- 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)
2274
2430
  break;
2275
2431
 
2276
2432
  if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
@@ -2365,7 +2521,8 @@ int git_remote_delete(git_repository *repo, const char *name)
2365
2521
  {
2366
2522
  int error;
2367
2523
 
2368
- assert(repo && name);
2524
+ GIT_ASSERT_ARG(repo);
2525
+ GIT_ASSERT_ARG(name);
2369
2526
 
2370
2527
  if ((error = remove_branch_config_related_entries(repo, name)) < 0 ||
2371
2528
  (error = remove_remote_tracking(repo, name)) < 0 ||
@@ -2384,7 +2541,7 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
2384
2541
  git_buf local_default = GIT_BUF_INIT;
2385
2542
  int error;
2386
2543
 
2387
- assert(out);
2544
+ GIT_ASSERT_ARG(out);
2388
2545
 
2389
2546
  if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0)
2390
2547
  goto done;
@@ -2394,7 +2551,8 @@ int git_remote_default_branch(git_buf *out, git_remote *remote)
2394
2551
  goto done;
2395
2552
  }
2396
2553
 
2397
- git_buf_sanitize(out);
2554
+ if ((error = git_buf_sanitize(out)) < 0)
2555
+ return error;
2398
2556
 
2399
2557
  /* the first one must be HEAD so if that has the symref info, we're done */
2400
2558
  if (heads[0]->symref_target) {
@@ -2452,7 +2610,7 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
2452
2610
  const git_remote_callbacks *cbs = NULL;
2453
2611
  git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT;
2454
2612
 
2455
- assert(remote);
2613
+ GIT_ASSERT_ARG(remote);
2456
2614
 
2457
2615
  if (!remote->repo) {
2458
2616
  git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
@@ -2518,7 +2676,7 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
2518
2676
  const git_strarray *custom_headers = NULL;
2519
2677
  const git_proxy_options *proxy = NULL;
2520
2678
 
2521
- assert(remote);
2679
+ GIT_ASSERT_ARG(remote);
2522
2680
 
2523
2681
  if (!remote->repo) {
2524
2682
  git_error_set(GIT_ERROR_INVALID, "cannot download detached remote");
@@ -2533,8 +2691,6 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
2533
2691
  proxy = &opts->proxy_opts;
2534
2692
  }
2535
2693
 
2536
- assert(remote);
2537
-
2538
2694
  if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs, proxy, custom_headers)) < 0)
2539
2695
  return error;
2540
2696
 
@@ -2561,9 +2717,9 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
2561
2717
  git_config_entry *entry;
2562
2718
  git_config_iterator *iter;
2563
2719
 
2564
- assert(config);
2565
- assert(url);
2566
- assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
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);
2567
2723
 
2568
2724
  /* Add 1 to prefix/suffix length due to the additional escaped dot */
2569
2725
  prefix_length = strlen(PREFIX) + 1;
@@ -2611,3 +2767,17 @@ char *apply_insteadof(git_config *config, const char *url, int direction)
2611
2767
 
2612
2768
  return result.ptr;
2613
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