rugged 0.28.3.1 → 0.28.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +1 -0
  4. data/vendor/libgit2/CMakeLists.txt +36 -16
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -1
  7. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  8. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  9. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  10. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  11. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  12. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  13. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  14. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  15. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  16. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  17. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  18. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  19. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
  20. data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
  21. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  22. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  23. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  24. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  25. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  27. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  28. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
  29. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  30. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  31. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  32. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  33. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  34. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  35. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  36. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  37. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  38. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  39. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  40. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  41. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  42. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  43. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  44. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  45. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  46. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  47. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  48. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  49. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  50. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  51. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  52. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  53. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  54. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  55. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  56. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  57. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  58. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  59. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  60. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  61. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  62. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  63. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  64. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  65. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  66. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  67. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  68. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  69. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  70. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  71. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  72. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  73. data/vendor/libgit2/include/git2.h +2 -0
  74. data/vendor/libgit2/include/git2/apply.h +22 -2
  75. data/vendor/libgit2/include/git2/attr.h +19 -12
  76. data/vendor/libgit2/include/git2/blame.h +2 -2
  77. data/vendor/libgit2/include/git2/blob.h +44 -12
  78. data/vendor/libgit2/include/git2/buffer.h +20 -14
  79. data/vendor/libgit2/include/git2/cert.h +135 -0
  80. data/vendor/libgit2/include/git2/checkout.h +46 -14
  81. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  82. data/vendor/libgit2/include/git2/clone.h +2 -2
  83. data/vendor/libgit2/include/git2/commit.h +23 -1
  84. data/vendor/libgit2/include/git2/common.h +7 -5
  85. data/vendor/libgit2/include/git2/config.h +12 -12
  86. data/vendor/libgit2/include/git2/cred.h +308 -0
  87. data/vendor/libgit2/include/git2/deprecated.h +243 -3
  88. data/vendor/libgit2/include/git2/describe.h +4 -4
  89. data/vendor/libgit2/include/git2/diff.h +16 -14
  90. data/vendor/libgit2/include/git2/filter.h +8 -0
  91. data/vendor/libgit2/include/git2/index.h +2 -1
  92. data/vendor/libgit2/include/git2/indexer.h +48 -4
  93. data/vendor/libgit2/include/git2/merge.h +6 -10
  94. data/vendor/libgit2/include/git2/net.h +0 -5
  95. data/vendor/libgit2/include/git2/object.h +2 -14
  96. data/vendor/libgit2/include/git2/odb.h +3 -2
  97. data/vendor/libgit2/include/git2/odb_backend.h +5 -4
  98. data/vendor/libgit2/include/git2/oid.h +1 -1
  99. data/vendor/libgit2/include/git2/pack.h +12 -1
  100. data/vendor/libgit2/include/git2/proxy.h +5 -3
  101. data/vendor/libgit2/include/git2/rebase.h +46 -2
  102. data/vendor/libgit2/include/git2/refs.h +19 -0
  103. data/vendor/libgit2/include/git2/remote.h +35 -12
  104. data/vendor/libgit2/include/git2/repository.h +24 -2
  105. data/vendor/libgit2/include/git2/revert.h +1 -1
  106. data/vendor/libgit2/include/git2/stash.h +3 -3
  107. data/vendor/libgit2/include/git2/status.h +25 -16
  108. data/vendor/libgit2/include/git2/submodule.h +20 -3
  109. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  110. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  111. data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
  112. data/vendor/libgit2/include/git2/sys/refdb_backend.h +57 -21
  113. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  114. data/vendor/libgit2/include/git2/sys/transport.h +2 -2
  115. data/vendor/libgit2/include/git2/tag.h +11 -2
  116. data/vendor/libgit2/include/git2/trace.h +2 -2
  117. data/vendor/libgit2/include/git2/transport.h +11 -340
  118. data/vendor/libgit2/include/git2/tree.h +1 -1
  119. data/vendor/libgit2/include/git2/types.h +4 -89
  120. data/vendor/libgit2/include/git2/version.h +2 -2
  121. data/vendor/libgit2/include/git2/worktree.h +5 -5
  122. data/vendor/libgit2/src/CMakeLists.txt +88 -222
  123. data/vendor/libgit2/src/alloc.c +2 -14
  124. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
  125. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  126. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  127. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  128. data/vendor/libgit2/src/apply.c +60 -30
  129. data/vendor/libgit2/src/attr.c +70 -64
  130. data/vendor/libgit2/src/attr_file.c +189 -96
  131. data/vendor/libgit2/src/attr_file.h +9 -9
  132. data/vendor/libgit2/src/attrcache.c +44 -46
  133. data/vendor/libgit2/src/attrcache.h +2 -1
  134. data/vendor/libgit2/src/blame.c +17 -5
  135. data/vendor/libgit2/src/blame.h +1 -1
  136. data/vendor/libgit2/src/blame_git.c +21 -7
  137. data/vendor/libgit2/src/blob.c +81 -17
  138. data/vendor/libgit2/src/blob.h +2 -2
  139. data/vendor/libgit2/src/branch.c +29 -5
  140. data/vendor/libgit2/src/buffer.c +14 -7
  141. data/vendor/libgit2/src/cache.c +26 -33
  142. data/vendor/libgit2/src/cache.h +1 -1
  143. data/vendor/libgit2/src/cc-compat.h +5 -0
  144. data/vendor/libgit2/src/checkout.c +26 -16
  145. data/vendor/libgit2/src/cherrypick.c +9 -3
  146. data/vendor/libgit2/src/clone.c +29 -7
  147. data/vendor/libgit2/src/clone.h +4 -0
  148. data/vendor/libgit2/src/commit.c +69 -21
  149. data/vendor/libgit2/src/commit.h +6 -0
  150. data/vendor/libgit2/src/commit_list.c +28 -76
  151. data/vendor/libgit2/src/commit_list.h +2 -2
  152. data/vendor/libgit2/src/common.h +3 -75
  153. data/vendor/libgit2/src/config.c +31 -40
  154. data/vendor/libgit2/src/config.h +7 -6
  155. data/vendor/libgit2/src/config_backend.h +12 -0
  156. data/vendor/libgit2/src/config_cache.c +39 -39
  157. data/vendor/libgit2/src/config_entries.c +69 -99
  158. data/vendor/libgit2/src/config_entries.h +1 -0
  159. data/vendor/libgit2/src/config_file.c +337 -380
  160. data/vendor/libgit2/src/config_mem.c +12 -16
  161. data/vendor/libgit2/src/config_parse.c +49 -29
  162. data/vendor/libgit2/src/config_parse.h +13 -12
  163. data/vendor/libgit2/src/config_snapshot.c +206 -0
  164. data/vendor/libgit2/src/crlf.c +14 -14
  165. data/vendor/libgit2/src/describe.c +21 -20
  166. data/vendor/libgit2/src/diff.c +43 -58
  167. data/vendor/libgit2/src/diff.h +2 -1
  168. data/vendor/libgit2/src/diff_driver.c +37 -38
  169. data/vendor/libgit2/src/diff_file.c +9 -7
  170. data/vendor/libgit2/src/diff_file.h +1 -1
  171. data/vendor/libgit2/src/diff_generate.c +135 -85
  172. data/vendor/libgit2/src/diff_generate.h +2 -2
  173. data/vendor/libgit2/src/diff_parse.c +1 -1
  174. data/vendor/libgit2/src/diff_print.c +25 -13
  175. data/vendor/libgit2/src/diff_stats.c +1 -1
  176. data/vendor/libgit2/src/diff_tform.c +4 -4
  177. data/vendor/libgit2/src/errors.c +12 -22
  178. data/vendor/libgit2/src/errors.h +81 -0
  179. data/vendor/libgit2/src/features.h.in +9 -2
  180. data/vendor/libgit2/src/fetch.c +7 -2
  181. data/vendor/libgit2/src/fetchhead.c +1 -1
  182. data/vendor/libgit2/src/filebuf.c +6 -10
  183. data/vendor/libgit2/src/filebuf.h +2 -2
  184. data/vendor/libgit2/src/filter.c +16 -8
  185. data/vendor/libgit2/src/{fileops.c → futils.c} +21 -17
  186. data/vendor/libgit2/src/{fileops.h → futils.h} +5 -5
  187. data/vendor/libgit2/src/global.c +12 -40
  188. data/vendor/libgit2/src/global.h +0 -2
  189. data/vendor/libgit2/src/hash.c +61 -0
  190. data/vendor/libgit2/src/hash.h +19 -21
  191. data/vendor/libgit2/src/hash/sha1.h +38 -0
  192. data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
  193. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  194. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
  195. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  196. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  197. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
  198. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  199. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
  200. data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
  201. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  202. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  203. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  204. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  205. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  206. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
  207. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  208. data/vendor/libgit2/src/hashsig.c +1 -1
  209. data/vendor/libgit2/src/idxmap.c +91 -65
  210. data/vendor/libgit2/src/idxmap.h +151 -15
  211. data/vendor/libgit2/src/ignore.c +32 -38
  212. data/vendor/libgit2/src/index.c +66 -43
  213. data/vendor/libgit2/src/index.h +1 -1
  214. data/vendor/libgit2/src/indexer.c +69 -70
  215. data/vendor/libgit2/src/integer.h +39 -4
  216. data/vendor/libgit2/src/iterator.c +27 -22
  217. data/vendor/libgit2/src/map.h +1 -1
  218. data/vendor/libgit2/src/merge.c +58 -44
  219. data/vendor/libgit2/src/merge_driver.c +4 -4
  220. data/vendor/libgit2/src/merge_file.c +1 -1
  221. data/vendor/libgit2/src/mwindow.c +18 -23
  222. data/vendor/libgit2/src/mwindow.h +4 -4
  223. data/vendor/libgit2/src/net.c +184 -0
  224. data/vendor/libgit2/src/net.h +36 -0
  225. data/vendor/libgit2/src/netops.c +55 -165
  226. data/vendor/libgit2/src/netops.h +3 -25
  227. data/vendor/libgit2/src/notes.c +2 -2
  228. data/vendor/libgit2/src/object.c +2 -2
  229. data/vendor/libgit2/src/object.h +2 -0
  230. data/vendor/libgit2/src/odb.c +41 -23
  231. data/vendor/libgit2/src/odb.h +3 -2
  232. data/vendor/libgit2/src/odb_loose.c +17 -10
  233. data/vendor/libgit2/src/odb_mempack.c +10 -23
  234. data/vendor/libgit2/src/odb_pack.c +4 -4
  235. data/vendor/libgit2/src/offmap.c +43 -55
  236. data/vendor/libgit2/src/offmap.h +102 -24
  237. data/vendor/libgit2/src/oid.c +6 -1
  238. data/vendor/libgit2/src/oidmap.c +39 -57
  239. data/vendor/libgit2/src/oidmap.h +99 -19
  240. data/vendor/libgit2/src/pack-objects.c +25 -32
  241. data/vendor/libgit2/src/pack-objects.h +1 -1
  242. data/vendor/libgit2/src/pack.c +45 -47
  243. data/vendor/libgit2/src/pack.h +12 -14
  244. data/vendor/libgit2/src/parse.c +10 -0
  245. data/vendor/libgit2/src/parse.h +3 -3
  246. data/vendor/libgit2/src/patch.c +1 -1
  247. data/vendor/libgit2/src/patch_generate.c +2 -2
  248. data/vendor/libgit2/src/patch_parse.c +124 -31
  249. data/vendor/libgit2/src/path.c +95 -27
  250. data/vendor/libgit2/src/path.h +2 -0
  251. data/vendor/libgit2/src/pathspec.c +13 -13
  252. data/vendor/libgit2/src/pool.c +26 -22
  253. data/vendor/libgit2/src/pool.h +7 -7
  254. data/vendor/libgit2/src/posix.c +7 -7
  255. data/vendor/libgit2/src/posix.h +12 -1
  256. data/vendor/libgit2/src/proxy.c +7 -2
  257. data/vendor/libgit2/src/push.c +10 -5
  258. data/vendor/libgit2/src/reader.c +2 -2
  259. data/vendor/libgit2/src/rebase.c +66 -7
  260. data/vendor/libgit2/src/refdb.c +12 -0
  261. data/vendor/libgit2/src/refdb_fs.c +214 -165
  262. data/vendor/libgit2/src/reflog.c +11 -13
  263. data/vendor/libgit2/src/refs.c +24 -18
  264. data/vendor/libgit2/src/refspec.c +9 -16
  265. data/vendor/libgit2/src/regexp.c +221 -0
  266. data/vendor/libgit2/src/regexp.h +97 -0
  267. data/vendor/libgit2/src/remote.c +50 -52
  268. data/vendor/libgit2/src/remote.h +2 -2
  269. data/vendor/libgit2/src/repository.c +115 -100
  270. data/vendor/libgit2/src/repository.h +49 -40
  271. data/vendor/libgit2/src/revert.c +8 -3
  272. data/vendor/libgit2/src/revparse.c +18 -19
  273. data/vendor/libgit2/src/revwalk.c +63 -30
  274. data/vendor/libgit2/src/revwalk.h +20 -0
  275. data/vendor/libgit2/src/settings.c +5 -0
  276. data/vendor/libgit2/src/sortedcache.c +12 -26
  277. data/vendor/libgit2/src/sortedcache.h +1 -1
  278. data/vendor/libgit2/src/stash.c +45 -65
  279. data/vendor/libgit2/src/status.c +15 -9
  280. data/vendor/libgit2/src/streams/openssl.c +20 -0
  281. data/vendor/libgit2/src/streams/socket.c +2 -2
  282. data/vendor/libgit2/src/strmap.c +37 -84
  283. data/vendor/libgit2/src/strmap.h +105 -33
  284. data/vendor/libgit2/src/submodule.c +102 -70
  285. data/vendor/libgit2/src/submodule.h +1 -1
  286. data/vendor/libgit2/src/sysdir.c +11 -1
  287. data/vendor/libgit2/src/tag.c +10 -2
  288. data/vendor/libgit2/src/trace.c +1 -1
  289. data/vendor/libgit2/src/trace.h +2 -2
  290. data/vendor/libgit2/src/trailer.c +46 -32
  291. data/vendor/libgit2/src/transaction.c +10 -9
  292. data/vendor/libgit2/src/transports/auth.c +10 -9
  293. data/vendor/libgit2/src/transports/auth.h +11 -4
  294. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -9
  295. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  296. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  297. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  298. data/vendor/libgit2/src/transports/cred.c +6 -6
  299. data/vendor/libgit2/src/transports/git.c +11 -16
  300. data/vendor/libgit2/src/transports/http.c +419 -276
  301. data/vendor/libgit2/src/transports/http.h +1 -1
  302. data/vendor/libgit2/src/transports/local.c +9 -9
  303. data/vendor/libgit2/src/transports/smart.c +17 -17
  304. data/vendor/libgit2/src/transports/smart.h +2 -2
  305. data/vendor/libgit2/src/transports/smart_protocol.c +36 -60
  306. data/vendor/libgit2/src/transports/ssh.c +46 -36
  307. data/vendor/libgit2/src/transports/winhttp.c +231 -207
  308. data/vendor/libgit2/src/tree-cache.c +14 -7
  309. data/vendor/libgit2/src/tree.c +10 -24
  310. data/vendor/libgit2/src/unix/map.c +1 -1
  311. data/vendor/libgit2/src/unix/posix.h +1 -11
  312. data/vendor/libgit2/src/userdiff.h +3 -1
  313. data/vendor/libgit2/src/util.c +51 -53
  314. data/vendor/libgit2/src/util.h +16 -21
  315. data/vendor/libgit2/src/wildmatch.c +320 -0
  316. data/vendor/libgit2/src/wildmatch.h +23 -0
  317. data/vendor/libgit2/src/win32/map.c +3 -5
  318. data/vendor/libgit2/src/win32/path_w32.c +12 -2
  319. data/vendor/libgit2/src/win32/path_w32.h +0 -29
  320. data/vendor/libgit2/src/win32/posix.h +1 -4
  321. data/vendor/libgit2/src/win32/posix_w32.c +40 -5
  322. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  323. data/vendor/libgit2/src/win32/thread.c +5 -10
  324. data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
  325. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  326. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
  327. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  328. data/vendor/libgit2/src/win32/w32_stack.c +4 -9
  329. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  330. data/vendor/libgit2/src/win32/w32_util.c +31 -0
  331. data/vendor/libgit2/src/win32/w32_util.h +6 -32
  332. data/vendor/libgit2/src/worktree.c +36 -22
  333. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  334. data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
  335. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  336. metadata +98 -34
  337. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  338. data/vendor/libgit2/deps/regex/COPYING +0 -502
  339. data/vendor/libgit2/deps/regex/config.h +0 -7
  340. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  341. data/vendor/libgit2/deps/regex/regex.c +0 -92
  342. data/vendor/libgit2/deps/regex/regex.h +0 -582
  343. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  344. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  345. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  346. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  347. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  348. data/vendor/libgit2/libgit2.pc.in +0 -13
  349. data/vendor/libgit2/src/fnmatch.c +0 -248
  350. data/vendor/libgit2/src/fnmatch.h +0 -48
@@ -19,6 +19,7 @@
19
19
  #include "repository.h"
20
20
  #include "global.h"
21
21
  #include "http.h"
22
+ #include "git2/sys/cred.h"
22
23
 
23
24
  #include <wincrypt.h>
24
25
  #include <winhttp.h>
@@ -48,6 +49,14 @@
48
49
  # define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800
49
50
  #endif
50
51
 
52
+ #ifndef HTTP_STATUS_PERMANENT_REDIRECT
53
+ # define HTTP_STATUS_PERMANENT_REDIRECT 308
54
+ #endif
55
+
56
+ #ifndef DWORD_MAX
57
+ # define DWORD_MAX 0xffffffff
58
+ #endif
59
+
51
60
  static const char *prefix_https = "https://";
52
61
  static const char *upload_pack_service = "upload-pack";
53
62
  static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack";
@@ -101,23 +110,43 @@ typedef struct {
101
110
  } winhttp_stream;
102
111
 
103
112
  typedef struct {
104
- git_smart_subtransport parent;
105
- transport_smart *owner;
106
- gitno_connection_data connection_data;
107
- gitno_connection_data proxy_connection_data;
113
+ git_net_url url;
108
114
  git_cred *cred;
109
- git_cred *url_cred;
110
- git_cred *proxy_cred;
111
115
  int auth_mechanisms;
116
+ bool url_cred_presented;
117
+ } winhttp_server;
118
+
119
+ typedef struct {
120
+ git_smart_subtransport parent;
121
+ transport_smart *owner;
122
+
123
+ winhttp_server server;
124
+ winhttp_server proxy;
125
+
112
126
  HINTERNET session;
113
127
  HINTERNET connection;
114
128
  } winhttp_subtransport;
115
129
 
116
- static int _apply_userpass_credential(HINTERNET request, DWORD target, DWORD scheme, git_cred *cred)
130
+ static int apply_userpass_credentials(HINTERNET request, DWORD target, int mechanisms, git_cred *cred)
117
131
  {
118
132
  git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
119
- wchar_t *user, *pass;
133
+ wchar_t *user = NULL, *pass = NULL;
120
134
  int user_len = 0, pass_len = 0, error = 0;
135
+ DWORD native_scheme;
136
+
137
+ if (mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) {
138
+ native_scheme = WINHTTP_AUTH_SCHEME_NEGOTIATE;
139
+ } else if (mechanisms & GIT_WINHTTP_AUTH_NTLM) {
140
+ native_scheme = WINHTTP_AUTH_SCHEME_NTLM;
141
+ } else if (mechanisms & GIT_WINHTTP_AUTH_DIGEST) {
142
+ native_scheme = WINHTTP_AUTH_SCHEME_DIGEST;
143
+ } else if (mechanisms & GIT_WINHTTP_AUTH_BASIC) {
144
+ native_scheme = WINHTTP_AUTH_SCHEME_BASIC;
145
+ } else {
146
+ git_error_set(GIT_ERROR_NET, "invalid authentication scheme");
147
+ error = -1;
148
+ goto done;
149
+ }
121
150
 
122
151
  if ((error = user_len = git__utf8_to_16_alloc(&user, c->username)) < 0)
123
152
  goto done;
@@ -125,7 +154,7 @@ static int _apply_userpass_credential(HINTERNET request, DWORD target, DWORD sch
125
154
  if ((error = pass_len = git__utf8_to_16_alloc(&pass, c->password)) < 0)
126
155
  goto done;
127
156
 
128
- if (!WinHttpSetCredentials(request, target, scheme, user, pass, NULL)) {
157
+ if (!WinHttpSetCredentials(request, target, native_scheme, user, pass, NULL)) {
129
158
  git_error_set(GIT_ERROR_OS, "failed to set credentials");
130
159
  error = -1;
131
160
  }
@@ -143,77 +172,58 @@ done:
143
172
  return error;
144
173
  }
145
174
 
146
- static int apply_userpass_credential_proxy(HINTERNET request, git_cred *cred, int mechanisms)
147
- {
148
- if (GIT_WINHTTP_AUTH_DIGEST & mechanisms) {
149
- return _apply_userpass_credential(request, WINHTTP_AUTH_TARGET_PROXY,
150
- WINHTTP_AUTH_SCHEME_DIGEST, cred);
151
- }
152
-
153
- return _apply_userpass_credential(request, WINHTTP_AUTH_TARGET_PROXY,
154
- WINHTTP_AUTH_SCHEME_BASIC, cred);
155
- }
156
-
157
- static int apply_userpass_credential(HINTERNET request, int mechanisms, git_cred *cred)
175
+ static int apply_default_credentials(HINTERNET request, DWORD target, int mechanisms)
158
176
  {
159
- DWORD native_scheme;
177
+ DWORD autologon_level = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
178
+ DWORD native_scheme = 0;
160
179
 
161
- if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) ||
162
- (mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE)) {
180
+ if ((mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) != 0) {
181
+ native_scheme = WINHTTP_AUTH_SCHEME_NEGOTIATE;
182
+ } else if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) != 0) {
163
183
  native_scheme = WINHTTP_AUTH_SCHEME_NTLM;
164
- } else if (mechanisms & GIT_WINHTTP_AUTH_BASIC) {
165
- native_scheme = WINHTTP_AUTH_SCHEME_BASIC;
166
184
  } else {
167
185
  git_error_set(GIT_ERROR_NET, "invalid authentication scheme");
168
186
  return -1;
169
187
  }
170
188
 
171
- return _apply_userpass_credential(request, WINHTTP_AUTH_TARGET_SERVER,
172
- native_scheme, cred);
173
- }
174
-
175
- static int apply_default_credentials(HINTERNET request, int mechanisms)
176
- {
177
- /* Either the caller explicitly requested that default credentials be passed,
178
- * or our fallback credential callback was invoked and checked that the target
179
- * URI was in the appropriate Internet Explorer security zone. By setting this
180
- * flag, we guarantee that the credentials are delivered by WinHTTP. The default
181
- * is "medium" which applies to the intranet and sounds like it would correspond
182
- * to Internet Explorer security zones, but in fact does not. */
183
- DWORD data = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW;
184
- DWORD native_scheme = 0;
185
-
186
- if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) != 0)
187
- native_scheme = WINHTTP_AUTH_SCHEME_NTLM;
188
-
189
- if ((mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) != 0)
190
- native_scheme = WINHTTP_AUTH_SCHEME_NEGOTIATE;
191
-
192
- if (!native_scheme) {
193
- git_error_set(GIT_ERROR_NET, "invalid authentication scheme");
189
+ /*
190
+ * Autologon policy must be "low" to use default creds.
191
+ * This is safe as the user has explicitly requested it.
192
+ */
193
+ if (!WinHttpSetOption(request, WINHTTP_OPTION_AUTOLOGON_POLICY, &autologon_level, sizeof(DWORD))) {
194
+ git_error_set(GIT_ERROR_OS, "could not configure logon policy");
194
195
  return -1;
195
196
  }
196
197
 
197
- if (!WinHttpSetOption(request, WINHTTP_OPTION_AUTOLOGON_POLICY, &data, sizeof(DWORD)))
198
- return -1;
199
-
200
- if (!WinHttpSetCredentials(request, WINHTTP_AUTH_TARGET_SERVER, native_scheme, NULL, NULL, NULL))
198
+ if (!WinHttpSetCredentials(request, target, native_scheme, NULL, NULL, NULL)) {
199
+ git_error_set(GIT_ERROR_OS, "could not configure credentials");
201
200
  return -1;
201
+ }
202
202
 
203
203
  return 0;
204
204
  }
205
205
 
206
- static int fallback_cred_acquire_cb(
206
+ static int acquire_url_cred(
207
207
  git_cred **cred,
208
- const char *url,
209
- const char *username_from_url,
210
208
  unsigned int allowed_types,
211
- void *payload)
209
+ const char *username,
210
+ const char *password)
212
211
  {
213
- int error = 1;
212
+ if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT)
213
+ return git_cred_userpass_plaintext_new(cred, username, password);
214
214
 
215
- GIT_UNUSED(username_from_url);
216
- GIT_UNUSED(payload);
215
+ if ((allowed_types & GIT_CREDTYPE_DEFAULT) && *username == '\0' && *password == '\0')
216
+ return git_cred_default_new(cred);
217
+
218
+ return 1;
219
+ }
220
+
221
+ static int acquire_fallback_cred(
222
+ git_cred **cred,
223
+ const char *url,
224
+ unsigned int allowed_types)
225
+ {
226
+ int error = 1;
217
227
 
218
228
  /* If the target URI supports integrated Windows authentication
219
229
  * as an authentication mechanism */
@@ -253,9 +263,9 @@ static int fallback_cred_acquire_cb(
253
263
  pISM->lpVtbl->Release(pISM);
254
264
  }
255
265
 
256
- if (SUCCEEDED(hCoInitResult))
257
- /* Only unitialize if the call to CoInitializeEx was successful. */
258
- CoUninitialize();
266
+ /* Only unitialize if the call to CoInitializeEx was successful. */
267
+ if (SUCCEEDED(hCoInitResult))
268
+ CoUninitialize();
259
269
  }
260
270
 
261
271
  git__free(wide_url);
@@ -280,7 +290,7 @@ static int certificate_check(winhttp_stream *s, int valid)
280
290
  return GIT_ECERTIFICATE;
281
291
  }
282
292
 
283
- if (t->owner->certificate_check_cb == NULL || !t->connection_data.use_ssl)
293
+ if (t->owner->certificate_check_cb == NULL || git__strcmp(t->server.url.scheme, "https") != 0)
284
294
  return 0;
285
295
 
286
296
  if (!WinHttpQueryOption(s->request, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert_ctx, &cert_ctx_size)) {
@@ -292,7 +302,7 @@ static int certificate_check(winhttp_stream *s, int valid)
292
302
  cert.parent.cert_type = GIT_CERT_X509;
293
303
  cert.data = cert_ctx->pbCertEncoded;
294
304
  cert.len = cert_ctx->cbCertEncoded;
295
- error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->message_cb_payload);
305
+ error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->server.url.host, t->owner->message_cb_payload);
296
306
  CertFreeCertificateContext(cert_ctx);
297
307
 
298
308
  if (error == GIT_PASSTHROUGH)
@@ -329,8 +339,25 @@ static void winhttp_stream_close(winhttp_stream *s)
329
339
  s->sent_request = 0;
330
340
  }
331
341
 
332
- #define SCHEME_HTTP "http://"
333
- #define SCHEME_HTTPS "https://"
342
+ static int apply_credentials(
343
+ HINTERNET request,
344
+ git_net_url *url,
345
+ int target,
346
+ git_cred *creds,
347
+ int mechanisms)
348
+ {
349
+ int error = 0;
350
+
351
+ GIT_UNUSED(url);
352
+
353
+ /* If we have creds, just apply them */
354
+ if (creds && creds->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT)
355
+ error = apply_userpass_credentials(request, target, mechanisms, creds);
356
+ else if (creds && creds->credtype == GIT_CREDTYPE_DEFAULT)
357
+ error = apply_default_credentials(request, target, mechanisms);
358
+
359
+ return error;
360
+ }
334
361
 
335
362
  static int winhttp_stream_connect(winhttp_stream *s)
336
363
  {
@@ -344,11 +371,13 @@ static int winhttp_stream_connect(winhttp_stream *s)
344
371
  unsigned long disable_redirects = WINHTTP_DISABLE_REDIRECTS;
345
372
  int default_timeout = TIMEOUT_INFINITE;
346
373
  int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
374
+ DWORD autologon_policy = WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH;
375
+
347
376
  size_t i;
348
377
  const git_proxy_options *proxy_opts;
349
378
 
350
379
  /* Prepare URL */
351
- git_buf_printf(&buf, "%s%s", t->connection_data.path, s->service_url);
380
+ git_buf_printf(&buf, "%s%s", t->server.url.path, s->service_url);
352
381
 
353
382
  if (git_buf_oom(&buf))
354
383
  return -1;
@@ -367,13 +396,17 @@ static int winhttp_stream_connect(winhttp_stream *s)
367
396
  NULL,
368
397
  WINHTTP_NO_REFERER,
369
398
  types,
370
- t->connection_data.use_ssl ? WINHTTP_FLAG_SECURE : 0);
399
+ git__strcmp(t->server.url.scheme, "https") == 0 ? WINHTTP_FLAG_SECURE : 0);
371
400
 
372
401
  if (!s->request) {
373
402
  git_error_set(GIT_ERROR_OS, "failed to open request");
374
403
  goto on_error;
375
404
  }
376
405
 
406
+ /* Never attempt default credentials; we'll provide them explicitly. */
407
+ if (!WinHttpSetOption(s->request, WINHTTP_OPTION_AUTOLOGON_POLICY, &autologon_policy, sizeof(DWORD)))
408
+ return -1;
409
+
377
410
  if (!WinHttpSetTimeouts(s->request, default_timeout, default_connect_timeout, default_timeout, default_timeout)) {
378
411
  git_error_set(GIT_ERROR_OS, "failed to set timeouts for WinHTTP");
379
412
  goto on_error;
@@ -382,7 +415,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
382
415
  proxy_opts = &t->owner->proxy;
383
416
  if (proxy_opts->type == GIT_PROXY_AUTO) {
384
417
  /* Set proxy if necessary */
385
- if (git_remote__get_http_proxy(t->owner->owner, !!t->connection_data.use_ssl, &proxy_url) < 0)
418
+ if (git_remote__get_http_proxy(t->owner->owner, (strcmp(t->server.url.scheme, "https") == 0), &proxy_url) < 0)
386
419
  goto on_error;
387
420
  }
388
421
  else if (proxy_opts->type == GIT_PROXY_SPECIFIED) {
@@ -395,38 +428,24 @@ static int winhttp_stream_connect(winhttp_stream *s)
395
428
  WINHTTP_PROXY_INFO proxy_info;
396
429
  wchar_t *proxy_wide;
397
430
 
398
- if (!git__prefixcmp(proxy_url, SCHEME_HTTP)) {
399
- t->proxy_connection_data.use_ssl = false;
400
- } else if (!git__prefixcmp(proxy_url, SCHEME_HTTPS)) {
401
- t->proxy_connection_data.use_ssl = true;
402
- } else {
403
- git_error_set(GIT_ERROR_NET, "invalid URL: '%s'", proxy_url);
404
- return -1;
405
- }
406
-
407
- gitno_connection_data_free_ptrs(&t->proxy_connection_data);
431
+ git_net_url_dispose(&t->proxy.url);
408
432
 
409
- if ((error = gitno_extract_url_parts(&t->proxy_connection_data.host, &t->proxy_connection_data.port, NULL,
410
- &t->proxy_connection_data.user, &t->proxy_connection_data.pass, proxy_url, NULL)) < 0)
433
+ if ((error = git_net_url_parse(&t->proxy.url, proxy_url)) < 0)
411
434
  goto on_error;
412
435
 
413
- if (t->proxy_connection_data.user && t->proxy_connection_data.pass) {
414
- if (t->proxy_cred) {
415
- t->proxy_cred->free(t->proxy_cred);
416
- }
417
-
418
- if ((error = git_cred_userpass_plaintext_new(&t->proxy_cred, t->proxy_connection_data.user, t->proxy_connection_data.pass)) < 0)
419
- goto on_error;
436
+ if (strcmp(t->proxy.url.scheme, "http") != 0 && strcmp(t->proxy.url.scheme, "https") != 0) {
437
+ git_error_set(GIT_ERROR_NET, "invalid URL: '%s'", proxy_url);
438
+ error = -1;
439
+ goto on_error;
420
440
  }
421
441
 
422
- if (t->proxy_connection_data.use_ssl)
423
- git_buf_PUTS(&processed_url, SCHEME_HTTPS);
424
- else
425
- git_buf_PUTS(&processed_url, SCHEME_HTTP);
442
+ git_buf_puts(&processed_url, t->proxy.url.scheme);
443
+ git_buf_PUTS(&processed_url, "://");
426
444
 
427
- git_buf_puts(&processed_url, t->proxy_connection_data.host);
428
- if (t->proxy_connection_data.port)
429
- git_buf_printf(&processed_url, ":%s", t->proxy_connection_data.port);
445
+ git_buf_puts(&processed_url, t->proxy.url.host);
446
+
447
+ if (!git_net_url_is_default_port(&t->proxy.url))
448
+ git_buf_printf(&processed_url, ":%s", t->proxy.url.port);
430
449
 
431
450
  if (git_buf_oom(&processed_url)) {
432
451
  error = -1;
@@ -454,13 +473,8 @@ static int winhttp_stream_connect(winhttp_stream *s)
454
473
 
455
474
  git__free(proxy_wide);
456
475
 
457
- if (t->proxy_cred) {
458
- if (t->proxy_cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT) {
459
- if ((error = apply_userpass_credential_proxy(s->request, t->proxy_cred, t->auth_mechanisms)) < 0)
460
- goto on_error;
461
- }
462
- }
463
-
476
+ if ((error = apply_credentials(s->request, &t->proxy.url, WINHTTP_AUTH_TARGET_PROXY, t->proxy.cred, t->proxy.auth_mechanisms)) < 0)
477
+ goto on_error;
464
478
  }
465
479
 
466
480
  /* Disable WinHTTP redirects so we can handle them manually. Why, you ask?
@@ -471,6 +485,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
471
485
  &disable_redirects,
472
486
  sizeof(disable_redirects))) {
473
487
  git_error_set(GIT_ERROR_OS, "failed to disable redirects");
488
+ error = -1;
474
489
  goto on_error;
475
490
  }
476
491
 
@@ -543,33 +558,16 @@ static int winhttp_stream_connect(winhttp_stream *s)
543
558
  }
544
559
 
545
560
  /* If requested, disable certificate validation */
546
- if (t->connection_data.use_ssl) {
561
+ if (strcmp(t->server.url.scheme, "https") == 0) {
547
562
  int flags;
548
563
 
549
564
  if (t->owner->parent.read_flags(&t->owner->parent, &flags) < 0)
550
565
  goto on_error;
551
566
  }
552
567
 
553
- /* If we have a credential on the subtransport, apply it to the request */
554
- if (t->cred &&
555
- t->cred->credtype == GIT_CREDTYPE_USERPASS_PLAINTEXT &&
556
- apply_userpass_credential(s->request, t->auth_mechanisms, t->cred) < 0)
557
- goto on_error;
558
- else if (t->cred &&
559
- t->cred->credtype == GIT_CREDTYPE_DEFAULT &&
560
- apply_default_credentials(s->request, t->auth_mechanisms) < 0)
568
+ if ((error = apply_credentials(s->request, &t->server.url, WINHTTP_AUTH_TARGET_SERVER, t->server.cred, t->server.auth_mechanisms)) < 0)
561
569
  goto on_error;
562
570
 
563
- /* If no other credentials have been applied and the URL has username and
564
- * password, use those */
565
- if (!t->cred && t->connection_data.user && t->connection_data.pass) {
566
- if (!t->url_cred &&
567
- git_cred_userpass_plaintext_new(&t->url_cred, t->connection_data.user, t->connection_data.pass) < 0)
568
- goto on_error;
569
- if (apply_userpass_credential(s->request, GIT_WINHTTP_AUTH_BASIC, t->url_cred) < 0)
570
- goto on_error;
571
- }
572
-
573
571
  /* We've done everything up to calling WinHttpSendRequest. */
574
572
 
575
573
  error = 0;
@@ -584,9 +582,9 @@ on_error:
584
582
  }
585
583
 
586
584
  static int parse_unauthorized_response(
587
- HINTERNET request,
588
585
  int *allowed_types,
589
- int *allowed_mechanisms)
586
+ int *allowed_mechanisms,
587
+ HINTERNET request)
590
588
  {
591
589
  DWORD supported, first, target;
592
590
 
@@ -699,6 +697,10 @@ static void CALLBACK winhttp_status(
699
697
  {
700
698
  DWORD status;
701
699
 
700
+ GIT_UNUSED(connection);
701
+ GIT_UNUSED(ctx);
702
+ GIT_UNUSED(info_len);
703
+
702
704
  if (code != WINHTTP_CALLBACK_STATUS_SECURE_FAILURE)
703
705
  return;
704
706
 
@@ -741,12 +743,12 @@ static int winhttp_connect(
741
743
  t->connection = NULL;
742
744
 
743
745
  /* Prepare port */
744
- if (git__strntol32(&port, t->connection_data.port,
745
- strlen(t->connection_data.port), NULL, 10) < 0)
746
+ if (git__strntol32(&port, t->server.url.port,
747
+ strlen(t->server.url.port), NULL, 10) < 0)
746
748
  return -1;
747
749
 
748
750
  /* Prepare host */
749
- if (git__utf8_to_16_alloc(&wide_host, t->connection_data.host) < 0) {
751
+ if (git__utf8_to_16_alloc(&wide_host, t->server.url.host) < 0) {
750
752
  git_error_set(GIT_ERROR_OS, "unable to convert host to wide characters");
751
753
  return -1;
752
754
  }
@@ -829,6 +831,11 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
829
831
  int attempts;
830
832
  bool success;
831
833
 
834
+ if (len > DWORD_MAX) {
835
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
836
+ return -1;
837
+ }
838
+
832
839
  for (attempts = 0; attempts < 5; attempts++) {
833
840
  if (ignore_length) {
834
841
  success = WinHttpSendRequest(s->request,
@@ -839,7 +846,7 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
839
846
  success = WinHttpSendRequest(s->request,
840
847
  WINHTTP_NO_ADDITIONAL_HEADERS, 0,
841
848
  WINHTTP_NO_REQUEST_DATA, 0,
842
- len, 0);
849
+ (DWORD)len, 0);
843
850
  }
844
851
 
845
852
  if (success || GetLastError() != (DWORD)SEC_E_BUFFER_TOO_SMALL)
@@ -890,6 +897,59 @@ static int send_request(winhttp_stream *s, size_t len, int ignore_length)
890
897
  return error;
891
898
  }
892
899
 
900
+ static int acquire_credentials(
901
+ HINTERNET request,
902
+ winhttp_server *server,
903
+ const char *url_str,
904
+ git_cred_acquire_cb cred_cb,
905
+ void *cred_cb_payload)
906
+ {
907
+ int allowed_types;
908
+ int error = 1;
909
+
910
+ if (parse_unauthorized_response(&allowed_types, &server->auth_mechanisms, request) < 0)
911
+ return -1;
912
+
913
+ if (allowed_types) {
914
+ git_cred_free(server->cred);
915
+ server->cred = NULL;
916
+
917
+ /* Start with URL-specified credentials, if there were any. */
918
+ if (!server->url_cred_presented && server->url.username && server->url.password) {
919
+ error = acquire_url_cred(&server->cred, allowed_types, server->url.username, server->url.password);
920
+ server->url_cred_presented = 1;
921
+
922
+ if (error < 0)
923
+ return error;
924
+ }
925
+
926
+ /* Next use the user-defined callback, if there is one. */
927
+ if (error > 0 && cred_cb) {
928
+ error = cred_cb(&server->cred, url_str, server->url.username, allowed_types, cred_cb_payload);
929
+
930
+ /* Treat GIT_PASSTHROUGH as though git_cred_acquire_cb isn't set */
931
+ if (error == GIT_PASSTHROUGH)
932
+ error = 1;
933
+ else if (error < 0)
934
+ return error;
935
+ }
936
+
937
+ /* Finally, invoke the fallback default credential lookup. */
938
+ if (error > 0) {
939
+ error = acquire_fallback_cred(&server->cred, url_str, allowed_types);
940
+
941
+ if (error < 0)
942
+ return error;
943
+ }
944
+ }
945
+
946
+ /*
947
+ * No error occurred but we could not find appropriate credentials.
948
+ * This behaves like a pass-through.
949
+ */
950
+ return error;
951
+ }
952
+
893
953
  static int winhttp_stream_read(
894
954
  git_smart_subtransport_stream *stream,
895
955
  char *buffer,
@@ -956,6 +1016,7 @@ replay:
956
1016
  }
957
1017
 
958
1018
  buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE);
1019
+ GIT_ERROR_CHECK_ALLOC(buffer);
959
1020
 
960
1021
  while (len > 0) {
961
1022
  DWORD bytes_written;
@@ -1014,7 +1075,8 @@ replay:
1014
1075
  HTTP_STATUS_REDIRECT == status_code ||
1015
1076
  (HTTP_STATUS_REDIRECT_METHOD == status_code &&
1016
1077
  get_verb == s->verb) ||
1017
- HTTP_STATUS_REDIRECT_KEEP_VERB == status_code)) {
1078
+ HTTP_STATUS_REDIRECT_KEEP_VERB == status_code ||
1079
+ HTTP_STATUS_PERMANENT_REDIRECT == status_code)) {
1018
1080
 
1019
1081
  /* Check for Windows 7. This workaround is only necessary on
1020
1082
  * Windows Vista and earlier. Windows 7 is version 6.1. */
@@ -1062,7 +1124,7 @@ replay:
1062
1124
 
1063
1125
  if (!git__prefixcmp_icase(location8, prefix_https)) {
1064
1126
  /* Upgrade to secure connection; disconnect and start over */
1065
- if (gitno_connection_data_from_url(&t->connection_data, location8, s->service_url) < 0) {
1127
+ if (gitno_connection_data_handle_redirect(&t->server.url, location8, s->service_url) < 0) {
1066
1128
  git__free(location8);
1067
1129
  return -1;
1068
1130
  }
@@ -1077,67 +1139,34 @@ replay:
1077
1139
  goto replay;
1078
1140
  }
1079
1141
 
1080
- /* Handle proxy authentication failures */
1081
- if (status_code == HTTP_STATUS_PROXY_AUTH_REQ) {
1082
- int allowed_types;
1083
-
1084
- if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanisms) < 0)
1085
- return -1;
1086
-
1087
- /* TODO: extract the username from the url, no payload? */
1088
- if (t->owner->proxy.credentials) {
1089
- int cred_error = 1;
1090
- cred_error = t->owner->proxy.credentials(&t->proxy_cred, t->owner->proxy.url, NULL, allowed_types, t->owner->proxy.payload);
1091
-
1092
- if (cred_error < 0)
1093
- return cred_error;
1094
- }
1095
-
1096
- winhttp_stream_close(s);
1097
- goto replay;
1098
- }
1099
-
1100
1142
  /* Handle authentication failures */
1101
- if (HTTP_STATUS_DENIED == status_code && get_verb == s->verb) {
1102
- int allowed_types;
1103
-
1104
- if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanisms) < 0)
1105
- return -1;
1106
-
1107
- if (allowed_types) {
1108
- int cred_error = 1;
1109
-
1110
- git_cred_free(t->cred);
1111
- t->cred = NULL;
1112
- /* Start with the user-supplied credential callback, if present */
1113
- if (t->owner->cred_acquire_cb) {
1114
- cred_error = t->owner->cred_acquire_cb(&t->cred, t->owner->url,
1115
- t->connection_data.user, allowed_types, t->owner->cred_acquire_payload);
1116
-
1117
- /* Treat GIT_PASSTHROUGH as though git_cred_acquire_cb isn't set */
1118
- if (cred_error == GIT_PASSTHROUGH)
1119
- cred_error = 1;
1120
- else if (cred_error < 0)
1121
- return cred_error;
1122
- }
1123
-
1124
- /* Invoke the fallback credentials acquisition callback if necessary */
1125
- if (cred_error > 0) {
1126
- cred_error = fallback_cred_acquire_cb(&t->cred, t->owner->url,
1127
- t->connection_data.user, allowed_types, NULL);
1128
-
1129
- if (cred_error < 0)
1130
- return cred_error;
1131
- }
1132
-
1133
- if (!cred_error) {
1134
- assert(t->cred);
1135
-
1136
- winhttp_stream_close(s);
1137
-
1138
- /* Successfully acquired a credential */
1139
- goto replay;
1140
- }
1143
+ if (status_code == HTTP_STATUS_DENIED) {
1144
+ int error = acquire_credentials(s->request,
1145
+ &t->server,
1146
+ t->owner->url,
1147
+ t->owner->cred_acquire_cb,
1148
+ t->owner->cred_acquire_payload);
1149
+
1150
+ if (error < 0) {
1151
+ return error;
1152
+ } else if (!error) {
1153
+ assert(t->server.cred);
1154
+ winhttp_stream_close(s);
1155
+ goto replay;
1156
+ }
1157
+ } else if (status_code == HTTP_STATUS_PROXY_AUTH_REQ) {
1158
+ int error = acquire_credentials(s->request,
1159
+ &t->proxy,
1160
+ t->owner->proxy.url,
1161
+ t->owner->proxy.credentials,
1162
+ t->owner->proxy.payload);
1163
+
1164
+ if (error < 0) {
1165
+ return error;
1166
+ } else if (!error) {
1167
+ assert(t->proxy.cred);
1168
+ winhttp_stream_close(s);
1169
+ goto replay;
1141
1170
  }
1142
1171
  }
1143
1172
 
@@ -1370,8 +1399,10 @@ static int winhttp_stream_write_chunked(
1370
1399
  /* Append as much to the buffer as we can */
1371
1400
  int count = (int)min(CACHED_POST_BODY_BUF_SIZE - s->chunk_buffer_len, len);
1372
1401
 
1373
- if (!s->chunk_buffer)
1402
+ if (!s->chunk_buffer) {
1374
1403
  s->chunk_buffer = git__malloc(CACHED_POST_BODY_BUF_SIZE);
1404
+ GIT_ERROR_CHECK_ALLOC(s->chunk_buffer);
1405
+ }
1375
1406
 
1376
1407
  memcpy(s->chunk_buffer + s->chunk_buffer_len, buffer, count);
1377
1408
  s->chunk_buffer_len += count;
@@ -1496,7 +1527,7 @@ static int winhttp_action(
1496
1527
  int ret = -1;
1497
1528
 
1498
1529
  if (!t->connection)
1499
- if ((ret = gitno_connection_data_from_url(&t->connection_data, url, NULL)) < 0 ||
1530
+ if ((ret = git_net_url_parse(&t->server.url, url)) < 0 ||
1500
1531
  (ret = winhttp_connect(t)) < 0)
1501
1532
  return ret;
1502
1533
 
@@ -1538,24 +1569,17 @@ static int winhttp_close(git_smart_subtransport *subtransport)
1538
1569
  {
1539
1570
  winhttp_subtransport *t = (winhttp_subtransport *)subtransport;
1540
1571
 
1541
- gitno_connection_data_free_ptrs(&t->connection_data);
1542
- memset(&t->connection_data, 0x0, sizeof(gitno_connection_data));
1543
- gitno_connection_data_free_ptrs(&t->proxy_connection_data);
1544
- memset(&t->proxy_connection_data, 0x0, sizeof(gitno_connection_data));
1545
-
1546
- if (t->cred) {
1547
- t->cred->free(t->cred);
1548
- t->cred = NULL;
1549
- }
1572
+ git_net_url_dispose(&t->server.url);
1573
+ git_net_url_dispose(&t->proxy.url);
1550
1574
 
1551
- if (t->proxy_cred) {
1552
- t->proxy_cred->free(t->proxy_cred);
1553
- t->proxy_cred = NULL;
1575
+ if (t->server.cred) {
1576
+ t->server.cred->free(t->server.cred);
1577
+ t->server.cred = NULL;
1554
1578
  }
1555
1579
 
1556
- if (t->url_cred) {
1557
- t->url_cred->free(t->url_cred);
1558
- t->url_cred = NULL;
1580
+ if (t->proxy.cred) {
1581
+ t->proxy.cred->free(t->proxy.cred);
1582
+ t->proxy.cred = NULL;
1559
1583
  }
1560
1584
 
1561
1585
  return winhttp_close_connection(t);