rugged 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -327,7 +327,7 @@ static int _git_close(git_smart_subtransport *subtransport)
327
327
  {
328
328
  git_subtransport *t = (git_subtransport *) subtransport;
329
329
 
330
- assert(!t->current_stream);
330
+ GIT_ASSERT(!t->current_stream);
331
331
 
332
332
  GIT_UNUSED(t);
333
333
 
@@ -338,8 +338,6 @@ static void _git_free(git_smart_subtransport *subtransport)
338
338
  {
339
339
  git_subtransport *t = (git_subtransport *) subtransport;
340
340
 
341
- assert(!t->current_stream);
342
-
343
341
  git__free(t);
344
342
  }
345
343
 
@@ -14,7 +14,6 @@
14
14
  #include "buffer.h"
15
15
  #include "net.h"
16
16
  #include "netops.h"
17
- #include "global.h"
18
17
  #include "remote.h"
19
18
  #include "git2/sys/credential.h"
20
19
  #include "smart.h"
@@ -105,6 +104,11 @@ static int apply_url_credentials(
105
104
  const char *username,
106
105
  const char *password)
107
106
  {
107
+ GIT_ASSERT_ARG(username);
108
+
109
+ if (!password)
110
+ password = "";
111
+
108
112
  if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT)
109
113
  return git_credential_userpass_plaintext_new(cred, username, password);
110
114
 
@@ -139,8 +143,7 @@ static int handle_auth(
139
143
  /* Start with URL-specified credentials, if there were any. */
140
144
  if ((allowed_credtypes & GIT_CREDENTIAL_USERPASS_PLAINTEXT) &&
141
145
  !server->url_cred_presented &&
142
- server->url.username &&
143
- server->url.password) {
146
+ server->url.username) {
144
147
  error = apply_url_credentials(&server->cred, allowed_credtypes, server->url.username, server->url.password);
145
148
  server->url_cred_presented = 1;
146
149
 
@@ -159,7 +162,7 @@ static int handle_auth(
159
162
 
160
163
  if (error > 0) {
161
164
  git_error_set(GIT_ERROR_HTTP, "%s authentication required but no callback set", server_type);
162
- error = -1;
165
+ error = GIT_EAUTH;
163
166
  }
164
167
 
165
168
  if (!error)
@@ -176,7 +179,7 @@ GIT_INLINE(int) handle_remote_auth(
176
179
 
177
180
  if (response->server_auth_credtypes == 0) {
178
181
  git_error_set(GIT_ERROR_HTTP, "server requires authentication that we do not support");
179
- return -1;
182
+ return GIT_EAUTH;
180
183
  }
181
184
 
182
185
  /* Otherwise, prompt for credentials. */
@@ -198,7 +201,7 @@ GIT_INLINE(int) handle_proxy_auth(
198
201
 
199
202
  if (response->proxy_auth_credtypes == 0) {
200
203
  git_error_set(GIT_ERROR_HTTP, "proxy requires authentication that we do not support");
201
- return -1;
204
+ return GIT_EAUTH;
202
205
  }
203
206
 
204
207
  /* Otherwise, prompt for credentials. */
@@ -256,7 +259,7 @@ static int handle_response(
256
259
  } else if (response->status == GIT_HTTP_STATUS_UNAUTHORIZED ||
257
260
  response->status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
258
261
  git_error_set(GIT_ERROR_HTTP, "unexpected authentication failure");
259
- return -1;
262
+ return GIT_EAUTH;
260
263
  }
261
264
 
262
265
  if (response->status != GIT_HTTP_STATUS_OK) {
@@ -287,7 +290,6 @@ static int lookup_proxy(
287
290
  {
288
291
  const char *proxy;
289
292
  git_remote *remote;
290
- bool use_ssl;
291
293
  char *config = NULL;
292
294
  int error = 0;
293
295
 
@@ -301,9 +303,8 @@ static int lookup_proxy(
301
303
 
302
304
  case GIT_PROXY_AUTO:
303
305
  remote = transport->owner->owner;
304
- use_ssl = !strcmp(transport->server.url.scheme, "https");
305
306
 
306
- error = git_remote__get_http_proxy(remote, use_ssl, &config);
307
+ error = git_remote__http_proxy(&config, remote, &transport->server.url);
307
308
 
308
309
  if (error || !config)
309
310
  goto done;
@@ -413,11 +414,11 @@ static int http_stream_read(
413
414
 
414
415
  if (stream->state == HTTP_STATE_SENDING_REQUEST) {
415
416
  git_error_set(GIT_ERROR_HTTP, "too many redirects or authentication replays");
416
- error = -1;
417
+ error = GIT_ERROR; /* not GIT_EAUTH, because the exact cause is unclear */
417
418
  goto done;
418
419
  }
419
420
 
420
- assert (stream->state == HTTP_STATE_RECEIVING_RESPONSE);
421
+ GIT_ASSERT(stream->state == HTTP_STATE_RECEIVING_RESPONSE);
421
422
 
422
423
  error = git_http_client_read_body(transport->http_client, buffer, buffer_size);
423
424
 
@@ -551,11 +552,11 @@ static int http_stream_write(
551
552
  if (stream->state == HTTP_STATE_NONE) {
552
553
  git_error_set(GIT_ERROR_HTTP,
553
554
  "too many redirects or authentication replays");
554
- error = -1;
555
+ error = GIT_ERROR; /* not GIT_EAUTH because the exact cause is unclear */
555
556
  goto done;
556
557
  }
557
558
 
558
- assert(stream->state == HTTP_STATE_SENDING_REQUEST);
559
+ GIT_ASSERT(stream->state == HTTP_STATE_SENDING_REQUEST);
559
560
 
560
561
  error = git_http_client_send_body(transport->http_client, buffer, len);
561
562
 
@@ -589,7 +590,7 @@ static int http_stream_read_response(
589
590
  (error = handle_response(&complete, stream, &response, false)) < 0)
590
591
  goto done;
591
592
 
592
- assert(complete);
593
+ GIT_ASSERT(complete);
593
594
  stream->state = HTTP_STATE_RECEIVING_RESPONSE;
594
595
  }
595
596
 
@@ -638,7 +639,8 @@ static int http_action(
638
639
  const http_service *service;
639
640
  int error;
640
641
 
641
- assert(out && t);
642
+ GIT_ASSERT_ARG(out);
643
+ GIT_ASSERT_ARG(t);
642
644
 
643
645
  *out = NULL;
644
646
 
@@ -721,7 +723,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own
721
723
 
722
724
  GIT_UNUSED(param);
723
725
 
724
- assert(out);
726
+ GIT_ASSERT_ARG(out);
725
727
 
726
728
  transport = git__calloc(sizeof(http_subtransport), 1);
727
729
  GIT_ERROR_CHECK_ALLOC(transport);
@@ -9,6 +9,7 @@
9
9
  #define INCLUDE_transports_http_h__
10
10
 
11
11
  #include "buffer.h"
12
+ #include "settings.h"
12
13
  #include "httpclient.h"
13
14
 
14
15
  #define GIT_HTTP_REPLAY_MAX 15
@@ -10,7 +10,6 @@
10
10
  #include "http_parser.h"
11
11
  #include "vector.h"
12
12
  #include "trace.h"
13
- #include "global.h"
14
13
  #include "httpclient.h"
15
14
  #include "http.h"
16
15
  #include "auth.h"
@@ -146,7 +145,8 @@ bool git_http_response_is_redirect(git_http_response *response)
146
145
 
147
146
  void git_http_response_dispose(git_http_response *response)
148
147
  {
149
- assert(response);
148
+ if (!response)
149
+ return;
150
150
 
151
151
  git__free(response->content_type);
152
152
  git__free(response->location);
@@ -400,7 +400,7 @@ static int on_body(http_parser *parser, const char *buf, size_t len)
400
400
  return 0;
401
401
  }
402
402
 
403
- assert(ctx->output_size >= ctx->output_written);
403
+ GIT_ASSERT(ctx->output_size >= ctx->output_written);
404
404
 
405
405
  max_len = min(ctx->output_size - ctx->output_written, len);
406
406
  max_len = min(max_len, INT_MAX);
@@ -597,7 +597,7 @@ static int apply_credentials(
597
597
  free_auth_context(server);
598
598
  } else if (!token.size) {
599
599
  git_error_set(GIT_ERROR_HTTP, "failed to respond to authentication challenge");
600
- error = -1;
600
+ error = GIT_EAUTH;
601
601
  goto done;
602
602
  }
603
603
 
@@ -631,6 +631,26 @@ GIT_INLINE(int) apply_proxy_credentials(
631
631
  request->proxy_credentials);
632
632
  }
633
633
 
634
+ static int puts_host_and_port(git_buf *buf, git_net_url *url, bool force_port)
635
+ {
636
+ bool ipv6 = git_net_url_is_ipv6(url);
637
+
638
+ if (ipv6)
639
+ git_buf_putc(buf, '[');
640
+
641
+ git_buf_puts(buf, url->host);
642
+
643
+ if (ipv6)
644
+ git_buf_putc(buf, ']');
645
+
646
+ if (force_port || !git_net_url_is_default_port(url)) {
647
+ git_buf_putc(buf, ':');
648
+ git_buf_puts(buf, url->port);
649
+ }
650
+
651
+ return git_buf_oom(buf) ? -1 : 0;
652
+ }
653
+
634
654
  static int generate_connect_request(
635
655
  git_http_client *client,
636
656
  git_http_request *request)
@@ -641,14 +661,17 @@ static int generate_connect_request(
641
661
  git_buf_clear(&client->request_msg);
642
662
  buf = &client->request_msg;
643
663
 
644
- git_buf_printf(buf, "CONNECT %s:%s HTTP/1.1\r\n",
645
- client->server.url.host, client->server.url.port);
664
+ git_buf_puts(buf, "CONNECT ");
665
+ puts_host_and_port(buf, &client->server.url, true);
666
+ git_buf_puts(buf, " HTTP/1.1\r\n");
646
667
 
647
668
  git_buf_puts(buf, "User-Agent: ");
648
669
  git_http__user_agent(buf);
649
670
  git_buf_puts(buf, "\r\n");
650
671
 
651
- git_buf_printf(buf, "Host: %s\r\n", client->proxy.url.host);
672
+ git_buf_puts(buf, "Host: ");
673
+ puts_host_and_port(buf, &client->server.url, true);
674
+ git_buf_puts(buf, "\r\n");
652
675
 
653
676
  if ((error = apply_proxy_credentials(buf, client, request) < 0))
654
677
  return -1;
@@ -671,7 +694,8 @@ static int generate_request(
671
694
  size_t i;
672
695
  int error;
673
696
 
674
- assert(client && request);
697
+ GIT_ASSERT_ARG(client);
698
+ GIT_ASSERT_ARG(request);
675
699
 
676
700
  git_buf_clear(&client->request_msg);
677
701
  buf = &client->request_msg;
@@ -691,11 +715,8 @@ static int generate_request(
691
715
  git_http__user_agent(buf);
692
716
  git_buf_puts(buf, "\r\n");
693
717
 
694
- git_buf_printf(buf, "Host: %s", request->url->host);
695
-
696
- if (!git_net_url_is_default_port(request->url))
697
- git_buf_printf(buf, ":%s", request->url->port);
698
-
718
+ git_buf_puts(buf, "Host: ");
719
+ puts_host_and_port(buf, request->url, false);
699
720
  git_buf_puts(buf, "\r\n");
700
721
 
701
722
  if (request->accept)
@@ -849,7 +870,10 @@ static int setup_hosts(
849
870
  {
850
871
  int ret, diff = 0;
851
872
 
852
- assert(client && request && request->url);
873
+ GIT_ASSERT_ARG(client);
874
+ GIT_ASSERT_ARG(request);
875
+
876
+ GIT_ASSERT(request->url);
853
877
 
854
878
  if ((ret = server_setup_from_url(&client->server, request->url)) < 0)
855
879
  return ret;
@@ -904,7 +928,7 @@ static int proxy_connect(
904
928
  int error;
905
929
 
906
930
  if (!client->proxy_connected || !client->keepalive) {
907
- git_trace(GIT_TRACE_DEBUG, "Connecting to proxy %s:%s",
931
+ git_trace(GIT_TRACE_DEBUG, "Connecting to proxy %s port %s",
908
932
  client->proxy.url.host, client->proxy.url.port);
909
933
 
910
934
  if ((error = server_create_stream(&client->proxy)) < 0 ||
@@ -929,7 +953,7 @@ static int proxy_connect(
929
953
  (error = git_http_client_skip_body(client)) < 0)
930
954
  goto done;
931
955
 
932
- assert(client->state == DONE);
956
+ GIT_ASSERT(client->state == DONE);
933
957
 
934
958
  if (response.status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
935
959
  save_early_response(client, &response);
@@ -1024,7 +1048,7 @@ static int http_client_connect(
1024
1048
  goto on_error;
1025
1049
  }
1026
1050
 
1027
- git_trace(GIT_TRACE_DEBUG, "Connecting to remote %s:%s",
1051
+ git_trace(GIT_TRACE_DEBUG, "Connecting to remote %s port %s",
1028
1052
  client->server.url.host, client->server.url.port);
1029
1053
 
1030
1054
  if ((error = server_connect(client)) < 0)
@@ -1143,7 +1167,7 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client)
1143
1167
  * final byte when paused in a callback. Consume that byte.
1144
1168
  * https://github.com/nodejs/http-parser/issues/97
1145
1169
  */
1146
- assert(client->read_buf.size > parsed_len);
1170
+ GIT_ASSERT(client->read_buf.size > parsed_len);
1147
1171
 
1148
1172
  http_parser_pause(parser, 0);
1149
1173
 
@@ -1221,7 +1245,8 @@ int git_http_client_send_request(
1221
1245
  git_http_response response = {0};
1222
1246
  int error = -1;
1223
1247
 
1224
- assert(client && request);
1248
+ GIT_ASSERT_ARG(client);
1249
+ GIT_ASSERT_ARG(request);
1225
1250
 
1226
1251
  /* If the client did not finish reading, clean up the stream. */
1227
1252
  if (client->state == READING_BODY)
@@ -1292,7 +1317,7 @@ int git_http_client_send_body(
1292
1317
  git_buf hdr = GIT_BUF_INIT;
1293
1318
  int error;
1294
1319
 
1295
- assert(client);
1320
+ GIT_ASSERT_ARG(client);
1296
1321
 
1297
1322
  /* If we're waiting for proxy auth, don't sending more requests. */
1298
1323
  if (client->state == HAS_EARLY_RESPONSE)
@@ -1309,7 +1334,7 @@ int git_http_client_send_body(
1309
1334
  server = &client->server;
1310
1335
 
1311
1336
  if (client->request_body_len) {
1312
- assert(buffer_len <= client->request_body_remain);
1337
+ GIT_ASSERT(buffer_len <= client->request_body_remain);
1313
1338
 
1314
1339
  if ((error = stream_write(server, buffer, buffer_len)) < 0)
1315
1340
  goto done;
@@ -1332,7 +1357,8 @@ static int complete_request(git_http_client *client)
1332
1357
  {
1333
1358
  int error = 0;
1334
1359
 
1335
- assert(client && client->state == SENDING_BODY);
1360
+ GIT_ASSERT_ARG(client);
1361
+ GIT_ASSERT(client->state == SENDING_BODY);
1336
1362
 
1337
1363
  if (client->request_body_len && client->request_body_remain) {
1338
1364
  git_error_set(GIT_ERROR_HTTP, "truncated write");
@@ -1352,7 +1378,8 @@ int git_http_client_read_response(
1352
1378
  http_parser_context parser_context = {0};
1353
1379
  int error;
1354
1380
 
1355
- assert(response && client);
1381
+ GIT_ASSERT_ARG(response);
1382
+ GIT_ASSERT_ARG(client);
1356
1383
 
1357
1384
  if (client->state == SENDING_BODY) {
1358
1385
  if ((error = complete_request(client)) < 0)
@@ -1392,7 +1419,7 @@ int git_http_client_read_response(
1392
1419
  goto done;
1393
1420
  }
1394
1421
 
1395
- assert(client->state == READING_BODY || client->state == DONE);
1422
+ GIT_ASSERT(client->state == READING_BODY || client->state == DONE);
1396
1423
 
1397
1424
  done:
1398
1425
  git_buf_dispose(&parser_context.parse_header_name);
@@ -1445,7 +1472,7 @@ int git_http_client_read_body(
1445
1472
  break;
1446
1473
  }
1447
1474
 
1448
- assert(parser_context.output_written <= INT_MAX);
1475
+ GIT_ASSERT(parser_context.output_written <= INT_MAX);
1449
1476
  error = (int)parser_context.output_written;
1450
1477
 
1451
1478
  done:
@@ -1499,7 +1526,7 @@ int git_http_client_new(
1499
1526
  {
1500
1527
  git_http_client *client;
1501
1528
 
1502
- assert(out);
1529
+ GIT_ASSERT_ARG(out);
1503
1530
 
1504
1531
  client = git__calloc(1, sizeof(git_http_client));
1505
1532
  GIT_ERROR_CHECK_ALLOC(client);
@@ -90,7 +90,7 @@ extern int git_http_client_new(
90
90
 
91
91
  /*
92
92
  * Sends a request to the host specified by the request URL. If the
93
- * method is POST, either the the content_length or the chunked flag must
93
+ * method is POST, either the content_length or the chunked flag must
94
94
  * be specified. The body should be provided in subsequent calls to
95
95
  * git_http_client_send_body.
96
96
  *
@@ -36,7 +36,7 @@ typedef struct {
36
36
  char *url;
37
37
  int direction;
38
38
  int flags;
39
- git_atomic cancelled;
39
+ git_atomic32 cancelled;
40
40
  git_repository *repo;
41
41
  git_transport_message_cb progress_cb;
42
42
  git_transport_message_cb error_cb;
@@ -158,7 +158,7 @@ static int store_refs(transport_local *t)
158
158
  git_remote_head *head;
159
159
  git_strarray ref_names = {0};
160
160
 
161
- assert(t);
161
+ GIT_ASSERT_ARG(t);
162
162
 
163
163
  if (git_reference_list(&ref_names, t->repo) < 0)
164
164
  goto on_error;
@@ -671,7 +671,7 @@ static void local_cancel(git_transport *transport)
671
671
  {
672
672
  transport_local *t = (transport_local *)transport;
673
673
 
674
- git_atomic_set(&t->cancelled, 1);
674
+ git_atomic32_set(&t->cancelled, 1);
675
675
  }
676
676
 
677
677
  static int local_close(git_transport *transport)
@@ -18,7 +18,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
18
18
  size_t old_len, bytes_read;
19
19
  int error;
20
20
 
21
- assert(t->current_stream);
21
+ GIT_ASSERT(t->current_stream);
22
22
 
23
23
  old_len = buf->offset;
24
24
 
@@ -30,7 +30,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
30
30
  if (t->packetsize_cb && !t->cancelled.val) {
31
31
  error = t->packetsize_cb(bytes_read, t->packetsize_payload);
32
32
  if (error) {
33
- git_atomic_set(&t->cancelled, 1);
33
+ git_atomic32_set(&t->cancelled, 1);
34
34
  return GIT_EUSER;
35
35
  }
36
36
  }
@@ -226,6 +226,8 @@ static int git_smart__connect(
226
226
  t->url = git__strdup(url);
227
227
  GIT_ERROR_CHECK_ALLOC(t->url);
228
228
 
229
+ git_proxy_options_clear(&t->proxy);
230
+
229
231
  if (git_proxy_options_dup(&t->proxy, proxy) < 0)
230
232
  return -1;
231
233
 
@@ -346,7 +348,7 @@ int git_smart__negotiation_step(git_transport *transport, void *data, size_t len
346
348
  return error;
347
349
 
348
350
  /* If this is a stateful implementation, the stream we get back should be the same */
349
- assert(t->rpc || t->current_stream == stream);
351
+ GIT_ASSERT(t->rpc || t->current_stream == stream);
350
352
 
351
353
  /* Save off the current stream (i.e. socket) that we are working with */
352
354
  t->current_stream = stream;
@@ -375,7 +377,7 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
375
377
  return error;
376
378
 
377
379
  /* If this is a stateful implementation, the stream we get back should be the same */
378
- assert(t->rpc || t->current_stream == *stream);
380
+ GIT_ASSERT(t->rpc || t->current_stream == *stream);
379
381
 
380
382
  /* Save off the current stream (i.e. socket) that we are working with */
381
383
  t->current_stream = *stream;
@@ -389,7 +391,7 @@ static void git_smart__cancel(git_transport *transport)
389
391
  {
390
392
  transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
391
393
 
392
- git_atomic_set(&t->cancelled, 1);
394
+ git_atomic32_set(&t->cancelled, 1);
393
395
  }
394
396
 
395
397
  static int git_smart__is_connected(git_transport *transport)
@@ -481,7 +483,9 @@ int git_transport_smart_certificate_check(git_transport *transport, git_cert *ce
481
483
  {
482
484
  transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
483
485
 
484
- assert(transport && cert && hostname);
486
+ GIT_ASSERT_ARG(transport);
487
+ GIT_ASSERT_ARG(cert);
488
+ GIT_ASSERT_ARG(hostname);
485
489
 
486
490
  if (!t->certificate_check_cb)
487
491
  return GIT_PASSTHROUGH;
@@ -493,7 +497,8 @@ int git_transport_smart_credentials(git_credential **out, git_transport *transpo
493
497
  {
494
498
  transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
495
499
 
496
- assert(out && transport);
500
+ GIT_ASSERT_ARG(out);
501
+ GIT_ASSERT_ARG(transport);
497
502
 
498
503
  if (!t->cred_acquire_cb)
499
504
  return GIT_PASSTHROUGH;