rugged 1.6.3 → 1.9.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 (443) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_allocator.c +0 -54
  3. data/lib/rugged/version.rb +1 -1
  4. data/vendor/libgit2/AUTHORS +1 -0
  5. data/vendor/libgit2/CMakeLists.txt +25 -17
  6. data/vendor/libgit2/COPYING +195 -1
  7. data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
  8. data/vendor/libgit2/cmake/{FindIconv.cmake → FindIntlIconv.cmake} +6 -0
  9. data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
  10. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +4 -4
  11. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +23 -8
  12. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +34 -6
  13. data/vendor/libgit2/cmake/SelectHashes.cmake +32 -11
  14. data/vendor/libgit2/cmake/SelectRegex.cmake +6 -1
  15. data/vendor/libgit2/cmake/SelectSSH.cmake +22 -17
  16. data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
  17. data/vendor/libgit2/cmake/SelectZlib.cmake +4 -0
  18. data/vendor/libgit2/deps/llhttp/CMakeLists.txt +8 -0
  19. data/vendor/libgit2/deps/llhttp/LICENSE-MIT +22 -0
  20. data/vendor/libgit2/deps/llhttp/api.c +510 -0
  21. data/vendor/libgit2/deps/llhttp/http.c +170 -0
  22. data/vendor/libgit2/deps/llhttp/llhttp.c +10168 -0
  23. data/vendor/libgit2/deps/llhttp/llhttp.h +897 -0
  24. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +1 -1
  25. data/vendor/libgit2/deps/ntlmclient/crypt_builtin_md4.c +311 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +2 -1
  27. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -20
  28. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +4 -4
  29. data/vendor/libgit2/deps/ntlmclient/ntlm.c +21 -21
  30. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +5 -4
  31. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +2 -1
  32. data/vendor/libgit2/deps/ntlmclient/utf8.h +1176 -721
  33. data/vendor/libgit2/deps/ntlmclient/util.h +11 -0
  34. data/vendor/libgit2/deps/pcre/CMakeLists.txt +1 -0
  35. data/vendor/libgit2/deps/pcre/LICENCE +5 -5
  36. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  37. data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
  38. data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
  39. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
  40. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
  41. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
  42. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
  43. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
  44. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
  45. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
  46. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +22 -20
  47. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
  48. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
  49. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
  50. data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
  51. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -1
  52. data/vendor/libgit2/deps/zlib/LICENSE +22 -0
  53. data/vendor/libgit2/deps/zlib/adler32.c +5 -27
  54. data/vendor/libgit2/deps/zlib/crc32.c +94 -167
  55. data/vendor/libgit2/deps/zlib/deflate.c +358 -435
  56. data/vendor/libgit2/deps/zlib/deflate.h +41 -10
  57. data/vendor/libgit2/deps/zlib/gzguts.h +13 -18
  58. data/vendor/libgit2/deps/zlib/infback.c +17 -30
  59. data/vendor/libgit2/deps/zlib/inffast.c +1 -4
  60. data/vendor/libgit2/deps/zlib/inffast.h +1 -1
  61. data/vendor/libgit2/deps/zlib/inflate.c +36 -102
  62. data/vendor/libgit2/deps/zlib/inftrees.c +6 -11
  63. data/vendor/libgit2/deps/zlib/inftrees.h +6 -6
  64. data/vendor/libgit2/deps/zlib/trees.c +287 -352
  65. data/vendor/libgit2/deps/zlib/zconf.h +23 -14
  66. data/vendor/libgit2/deps/zlib/zlib.h +202 -202
  67. data/vendor/libgit2/deps/zlib/zutil.c +18 -44
  68. data/vendor/libgit2/deps/zlib/zutil.h +13 -33
  69. data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
  70. data/vendor/libgit2/include/git2/apply.h +27 -6
  71. data/vendor/libgit2/include/git2/attr.h +17 -4
  72. data/vendor/libgit2/include/git2/blame.h +133 -28
  73. data/vendor/libgit2/include/git2/blob.h +71 -28
  74. data/vendor/libgit2/include/git2/branch.h +22 -15
  75. data/vendor/libgit2/include/git2/buffer.h +6 -4
  76. data/vendor/libgit2/include/git2/cert.h +2 -1
  77. data/vendor/libgit2/include/git2/checkout.h +83 -32
  78. data/vendor/libgit2/include/git2/cherrypick.h +10 -3
  79. data/vendor/libgit2/include/git2/clone.h +25 -9
  80. data/vendor/libgit2/include/git2/commit.h +132 -3
  81. data/vendor/libgit2/include/git2/common.h +138 -56
  82. data/vendor/libgit2/include/git2/config.h +93 -23
  83. data/vendor/libgit2/include/git2/credential.h +30 -2
  84. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  85. data/vendor/libgit2/include/git2/deprecated.h +133 -3
  86. data/vendor/libgit2/include/git2/describe.h +13 -1
  87. data/vendor/libgit2/include/git2/diff.h +77 -9
  88. data/vendor/libgit2/include/git2/email.h +9 -29
  89. data/vendor/libgit2/include/git2/errors.h +49 -74
  90. data/vendor/libgit2/include/git2/filter.h +14 -7
  91. data/vendor/libgit2/include/git2/global.h +8 -1
  92. data/vendor/libgit2/include/git2/graph.h +3 -2
  93. data/vendor/libgit2/include/git2/ignore.h +10 -0
  94. data/vendor/libgit2/include/git2/index.h +100 -6
  95. data/vendor/libgit2/include/git2/indexer.h +21 -4
  96. data/vendor/libgit2/include/git2/mailmap.h +7 -1
  97. data/vendor/libgit2/include/git2/merge.h +46 -1
  98. data/vendor/libgit2/include/git2/message.h +2 -2
  99. data/vendor/libgit2/include/git2/net.h +3 -1
  100. data/vendor/libgit2/include/git2/notes.h +9 -6
  101. data/vendor/libgit2/include/git2/object.h +9 -8
  102. data/vendor/libgit2/include/git2/odb.h +91 -49
  103. data/vendor/libgit2/include/git2/odb_backend.h +80 -52
  104. data/vendor/libgit2/include/git2/oid.h +24 -25
  105. data/vendor/libgit2/include/git2/oidarray.h +7 -1
  106. data/vendor/libgit2/include/git2/pack.h +13 -1
  107. data/vendor/libgit2/include/git2/patch.h +2 -3
  108. data/vendor/libgit2/include/git2/pathspec.h +9 -0
  109. data/vendor/libgit2/include/git2/proxy.h +10 -0
  110. data/vendor/libgit2/include/git2/rebase.h +9 -6
  111. data/vendor/libgit2/include/git2/refdb.h +2 -2
  112. data/vendor/libgit2/include/git2/reflog.h +3 -2
  113. data/vendor/libgit2/include/git2/refs.h +9 -6
  114. data/vendor/libgit2/include/git2/refspec.h +14 -4
  115. data/vendor/libgit2/include/git2/remote.h +112 -18
  116. data/vendor/libgit2/include/git2/repository.h +61 -15
  117. data/vendor/libgit2/include/git2/reset.h +16 -3
  118. data/vendor/libgit2/include/git2/revert.h +9 -4
  119. data/vendor/libgit2/include/git2/revparse.h +3 -3
  120. data/vendor/libgit2/include/git2/revwalk.h +3 -2
  121. data/vendor/libgit2/include/git2/signature.h +46 -1
  122. data/vendor/libgit2/include/git2/stash.h +17 -3
  123. data/vendor/libgit2/include/git2/status.h +10 -6
  124. data/vendor/libgit2/include/git2/stdint.h +87 -85
  125. data/vendor/libgit2/include/git2/strarray.h +2 -3
  126. data/vendor/libgit2/include/git2/submodule.h +20 -9
  127. data/vendor/libgit2/include/git2/sys/alloc.h +12 -34
  128. data/vendor/libgit2/include/git2/sys/commit.h +77 -3
  129. data/vendor/libgit2/include/git2/sys/commit_graph.h +109 -58
  130. data/vendor/libgit2/include/git2/sys/config.h +80 -4
  131. data/vendor/libgit2/include/git2/sys/credential.h +4 -3
  132. data/vendor/libgit2/include/git2/sys/diff.h +21 -1
  133. data/vendor/libgit2/include/git2/sys/email.h +7 -0
  134. data/vendor/libgit2/include/git2/sys/errors.h +76 -0
  135. data/vendor/libgit2/include/git2/sys/filter.h +66 -3
  136. data/vendor/libgit2/include/git2/sys/hashsig.h +11 -0
  137. data/vendor/libgit2/include/git2/sys/index.h +3 -2
  138. data/vendor/libgit2/include/git2/sys/mempack.h +32 -2
  139. data/vendor/libgit2/include/git2/sys/merge.h +55 -7
  140. data/vendor/libgit2/include/git2/sys/midx.h +47 -4
  141. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -3
  142. data/vendor/libgit2/include/git2/sys/openssl.h +8 -1
  143. data/vendor/libgit2/include/git2/sys/path.h +12 -1
  144. data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -36
  145. data/vendor/libgit2/include/git2/sys/refs.h +3 -2
  146. data/vendor/libgit2/include/git2/sys/remote.h +8 -1
  147. data/vendor/libgit2/include/git2/sys/repository.h +63 -3
  148. data/vendor/libgit2/include/git2/sys/stream.h +25 -2
  149. data/vendor/libgit2/include/git2/sys/transport.h +44 -5
  150. data/vendor/libgit2/include/git2/tag.h +3 -1
  151. data/vendor/libgit2/include/git2/trace.h +9 -3
  152. data/vendor/libgit2/include/git2/transaction.h +3 -2
  153. data/vendor/libgit2/include/git2/transport.h +11 -3
  154. data/vendor/libgit2/include/git2/tree.h +16 -5
  155. data/vendor/libgit2/include/git2/types.h +19 -3
  156. data/vendor/libgit2/include/git2/version.h +44 -8
  157. data/vendor/libgit2/include/git2/worktree.h +19 -7
  158. data/vendor/libgit2/src/CMakeLists.txt +40 -15
  159. data/vendor/libgit2/src/cli/CMakeLists.txt +2 -2
  160. data/vendor/libgit2/src/cli/cmd.c +1 -1
  161. data/vendor/libgit2/src/cli/cmd.h +4 -0
  162. data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
  163. data/vendor/libgit2/src/cli/cmd_cat_file.c +6 -8
  164. data/vendor/libgit2/src/cli/cmd_clone.c +27 -13
  165. data/vendor/libgit2/src/cli/cmd_config.c +241 -0
  166. data/vendor/libgit2/src/cli/cmd_hash_object.c +6 -8
  167. data/vendor/libgit2/src/cli/cmd_help.c +6 -7
  168. data/vendor/libgit2/src/cli/cmd_index_pack.c +114 -0
  169. data/vendor/libgit2/src/cli/cmd_init.c +102 -0
  170. data/vendor/libgit2/src/cli/common.c +168 -0
  171. data/vendor/libgit2/src/cli/common.h +63 -0
  172. data/vendor/libgit2/src/cli/error.h +1 -1
  173. data/vendor/libgit2/src/cli/main.c +52 -24
  174. data/vendor/libgit2/src/cli/opt.c +29 -3
  175. data/vendor/libgit2/src/cli/opt.h +21 -3
  176. data/vendor/libgit2/src/cli/opt_usage.c +102 -33
  177. data/vendor/libgit2/src/cli/opt_usage.h +6 -1
  178. data/vendor/libgit2/src/cli/progress.c +60 -10
  179. data/vendor/libgit2/src/cli/progress.h +16 -4
  180. data/vendor/libgit2/src/cli/unix/sighandler.c +2 -1
  181. data/vendor/libgit2/src/cli/win32/precompiled.h +1 -1
  182. data/vendor/libgit2/src/cli/win32/sighandler.c +1 -1
  183. data/vendor/libgit2/src/libgit2/CMakeLists.txt +27 -27
  184. data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
  185. data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
  186. data/vendor/libgit2/src/libgit2/apply.c +14 -16
  187. data/vendor/libgit2/src/libgit2/attr.c +30 -13
  188. data/vendor/libgit2/src/libgit2/attr_file.c +7 -2
  189. data/vendor/libgit2/src/libgit2/attr_file.h +2 -0
  190. data/vendor/libgit2/src/libgit2/attrcache.c +69 -33
  191. data/vendor/libgit2/src/libgit2/attrcache.h +5 -9
  192. data/vendor/libgit2/src/libgit2/blame.c +152 -59
  193. data/vendor/libgit2/src/libgit2/blame.h +1 -0
  194. data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
  195. data/vendor/libgit2/src/libgit2/branch.c +2 -2
  196. data/vendor/libgit2/src/libgit2/cache.c +22 -17
  197. data/vendor/libgit2/src/libgit2/cache.h +7 -9
  198. data/vendor/libgit2/src/libgit2/checkout.c +34 -24
  199. data/vendor/libgit2/src/libgit2/checkout.h +0 -2
  200. data/vendor/libgit2/src/libgit2/cherrypick.c +4 -5
  201. data/vendor/libgit2/src/libgit2/clone.c +186 -164
  202. data/vendor/libgit2/src/libgit2/clone.h +4 -1
  203. data/vendor/libgit2/src/libgit2/commit.c +123 -9
  204. data/vendor/libgit2/src/libgit2/commit_graph.c +166 -88
  205. data/vendor/libgit2/src/libgit2/commit_graph.h +21 -6
  206. data/vendor/libgit2/src/libgit2/commit_list.c +12 -5
  207. data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
  208. data/vendor/libgit2/src/libgit2/config.c +394 -300
  209. data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
  210. data/vendor/libgit2/src/libgit2/config.h +9 -4
  211. data/vendor/libgit2/src/libgit2/config_backend.h +8 -10
  212. data/vendor/libgit2/src/libgit2/config_cache.c +4 -5
  213. data/vendor/libgit2/src/libgit2/config_file.c +113 -96
  214. data/vendor/libgit2/src/libgit2/config_list.c +285 -0
  215. data/vendor/libgit2/src/libgit2/config_list.h +32 -0
  216. data/vendor/libgit2/src/libgit2/config_mem.c +194 -40
  217. data/vendor/libgit2/src/libgit2/config_parse.c +10 -9
  218. data/vendor/libgit2/src/libgit2/config_snapshot.c +24 -31
  219. data/vendor/libgit2/src/libgit2/describe.c +34 -31
  220. data/vendor/libgit2/src/libgit2/diff.c +17 -8
  221. data/vendor/libgit2/src/libgit2/diff.h +6 -6
  222. data/vendor/libgit2/src/libgit2/diff_driver.c +12 -19
  223. data/vendor/libgit2/src/libgit2/diff_driver.h +2 -2
  224. data/vendor/libgit2/src/libgit2/diff_file.c +7 -7
  225. data/vendor/libgit2/src/libgit2/diff_generate.c +39 -18
  226. data/vendor/libgit2/src/libgit2/diff_parse.c +22 -6
  227. data/vendor/libgit2/src/libgit2/diff_print.c +88 -13
  228. data/vendor/libgit2/src/libgit2/diff_tform.c +40 -12
  229. data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
  230. data/vendor/libgit2/src/libgit2/email.c +5 -3
  231. data/vendor/libgit2/src/libgit2/fetch.c +39 -9
  232. data/vendor/libgit2/src/libgit2/fetch.h +0 -2
  233. data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
  234. data/vendor/libgit2/src/libgit2/filter.c +5 -5
  235. data/vendor/libgit2/src/libgit2/git2.rc +3 -3
  236. data/vendor/libgit2/src/libgit2/grafts.c +270 -0
  237. data/vendor/libgit2/src/libgit2/grafts.h +35 -0
  238. data/vendor/libgit2/src/libgit2/graph.c +1 -1
  239. data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
  240. data/vendor/libgit2/src/libgit2/ident.c +3 -3
  241. data/vendor/libgit2/src/libgit2/ignore.c +9 -5
  242. data/vendor/libgit2/src/libgit2/index.c +392 -208
  243. data/vendor/libgit2/src/libgit2/index.h +16 -3
  244. data/vendor/libgit2/src/libgit2/index_map.c +95 -0
  245. data/vendor/libgit2/src/libgit2/index_map.h +28 -0
  246. data/vendor/libgit2/src/libgit2/indexer.c +44 -41
  247. data/vendor/libgit2/src/libgit2/iterator.c +34 -13
  248. data/vendor/libgit2/src/libgit2/iterator.h +3 -0
  249. data/vendor/libgit2/src/libgit2/libgit2.c +155 -331
  250. data/vendor/libgit2/src/libgit2/mailmap.c +1 -1
  251. data/vendor/libgit2/src/libgit2/merge.c +56 -46
  252. data/vendor/libgit2/src/libgit2/merge_driver.c +2 -2
  253. data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
  254. data/vendor/libgit2/src/libgit2/midx.c +86 -44
  255. data/vendor/libgit2/src/libgit2/midx.h +13 -3
  256. data/vendor/libgit2/src/libgit2/mwindow.c +38 -45
  257. data/vendor/libgit2/src/libgit2/mwindow.h +4 -0
  258. data/vendor/libgit2/src/libgit2/notes.c +9 -8
  259. data/vendor/libgit2/src/libgit2/object.c +42 -16
  260. data/vendor/libgit2/src/libgit2/object.h +6 -0
  261. data/vendor/libgit2/src/libgit2/odb.c +16 -9
  262. data/vendor/libgit2/src/libgit2/odb_mempack.c +49 -17
  263. data/vendor/libgit2/src/libgit2/odb_pack.c +28 -7
  264. data/vendor/libgit2/src/libgit2/oid.c +35 -2
  265. data/vendor/libgit2/src/libgit2/oid.h +11 -0
  266. data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
  267. data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
  268. data/vendor/libgit2/src/libgit2/pack-objects.c +77 -43
  269. data/vendor/libgit2/src/libgit2/pack-objects.h +17 -6
  270. data/vendor/libgit2/src/libgit2/pack.c +33 -27
  271. data/vendor/libgit2/src/libgit2/pack.h +15 -10
  272. data/vendor/libgit2/src/libgit2/parse.c +7 -4
  273. data/vendor/libgit2/src/libgit2/parse.h +1 -1
  274. data/vendor/libgit2/src/libgit2/patch.h +7 -1
  275. data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
  276. data/vendor/libgit2/src/libgit2/patch_parse.c +18 -10
  277. data/vendor/libgit2/src/libgit2/path.c +1 -1
  278. data/vendor/libgit2/src/libgit2/pathspec.c +1 -1
  279. data/vendor/libgit2/src/libgit2/push.c +81 -30
  280. data/vendor/libgit2/src/libgit2/push.h +1 -0
  281. data/vendor/libgit2/src/libgit2/reader.c +1 -1
  282. data/vendor/libgit2/src/libgit2/rebase.c +72 -84
  283. data/vendor/libgit2/src/libgit2/refdb_fs.c +146 -70
  284. data/vendor/libgit2/src/libgit2/reflog.c +1 -2
  285. data/vendor/libgit2/src/libgit2/reflog.h +2 -0
  286. data/vendor/libgit2/src/libgit2/refs.c +34 -8
  287. data/vendor/libgit2/src/libgit2/refs.h +6 -1
  288. data/vendor/libgit2/src/libgit2/refspec.c +28 -1
  289. data/vendor/libgit2/src/libgit2/refspec.h +8 -0
  290. data/vendor/libgit2/src/libgit2/remote.c +136 -67
  291. data/vendor/libgit2/src/libgit2/remote.h +1 -0
  292. data/vendor/libgit2/src/libgit2/repository.c +789 -330
  293. data/vendor/libgit2/src/libgit2/repository.h +22 -3
  294. data/vendor/libgit2/src/libgit2/reset.c +2 -2
  295. data/vendor/libgit2/src/libgit2/revert.c +9 -13
  296. data/vendor/libgit2/src/libgit2/revparse.c +6 -3
  297. data/vendor/libgit2/src/libgit2/revwalk.c +36 -11
  298. data/vendor/libgit2/src/libgit2/revwalk.h +3 -3
  299. data/vendor/libgit2/src/libgit2/settings.c +468 -0
  300. data/vendor/libgit2/src/libgit2/settings.h +6 -2
  301. data/vendor/libgit2/src/libgit2/signature.c +132 -15
  302. data/vendor/libgit2/src/libgit2/signature.h +0 -1
  303. data/vendor/libgit2/src/libgit2/stash.c +9 -8
  304. data/vendor/libgit2/src/libgit2/status.c +1 -1
  305. data/vendor/libgit2/src/libgit2/streams/mbedtls.c +54 -61
  306. data/vendor/libgit2/src/libgit2/streams/openssl.c +40 -23
  307. data/vendor/libgit2/src/libgit2/streams/openssl.h +2 -0
  308. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +4 -0
  309. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.h +3 -0
  310. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  311. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  312. data/vendor/libgit2/src/libgit2/streams/socket.c +237 -51
  313. data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
  314. data/vendor/libgit2/src/libgit2/streams/stransport.c +79 -19
  315. data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
  316. data/vendor/libgit2/src/libgit2/submodule.c +106 -63
  317. data/vendor/libgit2/src/libgit2/submodule.h +9 -10
  318. data/vendor/libgit2/src/libgit2/tag.c +1 -1
  319. data/vendor/libgit2/src/libgit2/trailer.c +6 -6
  320. data/vendor/libgit2/src/libgit2/transaction.c +26 -20
  321. data/vendor/libgit2/src/libgit2/transaction.h +4 -1
  322. data/vendor/libgit2/src/libgit2/transport.c +4 -1
  323. data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
  324. data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
  325. data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
  326. data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
  327. data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
  328. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  329. data/vendor/libgit2/src/libgit2/transports/credential.c +1 -1
  330. data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
  331. data/vendor/libgit2/src/libgit2/transports/http.c +8 -4
  332. data/vendor/libgit2/src/libgit2/transports/http.h +0 -10
  333. data/vendor/libgit2/src/libgit2/transports/httpclient.c +117 -72
  334. data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
  335. data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
  336. data/vendor/libgit2/src/libgit2/transports/local.c +21 -11
  337. data/vendor/libgit2/src/libgit2/transports/smart.c +50 -32
  338. data/vendor/libgit2/src/libgit2/transports/smart.h +26 -9
  339. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +139 -18
  340. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +209 -57
  341. data/vendor/libgit2/src/libgit2/transports/ssh.c +41 -1103
  342. data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +347 -0
  343. data/vendor/libgit2/src/libgit2/transports/ssh_exec.h +26 -0
  344. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.c +1126 -0
  345. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
  346. data/vendor/libgit2/src/libgit2/transports/winhttp.c +48 -21
  347. data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
  348. data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
  349. data/vendor/libgit2/src/libgit2/tree.c +35 -27
  350. data/vendor/libgit2/src/libgit2/tree.h +3 -2
  351. data/vendor/libgit2/src/libgit2/worktree.c +39 -27
  352. data/vendor/libgit2/src/util/CMakeLists.txt +4 -6
  353. data/vendor/libgit2/src/util/alloc.c +69 -7
  354. data/vendor/libgit2/src/util/alloc.h +34 -9
  355. data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
  356. data/vendor/libgit2/src/{cli/cli.h → util/allocators/debugalloc.h} +6 -9
  357. data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
  358. data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
  359. data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -115
  360. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
  361. data/vendor/libgit2/src/util/array.h +24 -18
  362. data/vendor/libgit2/src/util/cc-compat.h +4 -0
  363. data/vendor/libgit2/src/util/ctype_compat.h +70 -0
  364. data/vendor/libgit2/src/util/date.c +22 -14
  365. data/vendor/libgit2/src/util/date.h +12 -0
  366. data/vendor/libgit2/src/util/errors.c +401 -0
  367. data/vendor/libgit2/src/{libgit2 → util}/errors.h +21 -17
  368. data/vendor/libgit2/src/util/filebuf.c +6 -1
  369. data/vendor/libgit2/src/util/filebuf.h +19 -6
  370. data/vendor/libgit2/src/util/fs_path.c +16 -5
  371. data/vendor/libgit2/src/util/fs_path.h +23 -0
  372. data/vendor/libgit2/src/util/futils.c +14 -10
  373. data/vendor/libgit2/src/util/futils.h +13 -4
  374. data/vendor/libgit2/src/util/git2_features.h.in +21 -4
  375. data/vendor/libgit2/src/util/git2_util.h +6 -0
  376. data/vendor/libgit2/src/util/hash/openssl.c +152 -0
  377. data/vendor/libgit2/src/util/hash/openssl.h +17 -1
  378. data/vendor/libgit2/src/util/hash/sha.h +4 -1
  379. data/vendor/libgit2/src/util/hashmap.h +424 -0
  380. data/vendor/libgit2/src/util/hashmap_str.h +43 -0
  381. data/vendor/libgit2/src/util/integer.h +3 -1
  382. data/vendor/libgit2/src/util/net.c +318 -161
  383. data/vendor/libgit2/src/util/net.h +27 -0
  384. data/vendor/libgit2/src/util/pool.c +1 -1
  385. data/vendor/libgit2/src/util/pool.h +5 -0
  386. data/vendor/libgit2/src/util/posix.c +54 -0
  387. data/vendor/libgit2/src/util/posix.h +22 -0
  388. data/vendor/libgit2/src/util/pqueue.h +1 -1
  389. data/vendor/libgit2/src/util/process.h +222 -0
  390. data/vendor/libgit2/src/util/rand.c +6 -10
  391. data/vendor/libgit2/src/util/regexp.c +1 -1
  392. data/vendor/libgit2/src/util/sortedcache.c +14 -13
  393. data/vendor/libgit2/src/util/sortedcache.h +3 -3
  394. data/vendor/libgit2/src/util/staticstr.h +66 -0
  395. data/vendor/libgit2/src/util/str.c +2 -2
  396. data/vendor/libgit2/src/util/strlist.c +108 -0
  397. data/vendor/libgit2/src/util/strlist.h +36 -0
  398. data/vendor/libgit2/src/util/unix/posix.h +0 -2
  399. data/vendor/libgit2/src/util/unix/process.c +629 -0
  400. data/vendor/libgit2/src/util/unix/realpath.c +23 -5
  401. data/vendor/libgit2/src/util/util.c +17 -12
  402. data/vendor/libgit2/src/util/util.h +28 -54
  403. data/vendor/libgit2/src/util/vector.c +3 -3
  404. data/vendor/libgit2/src/util/vector.h +2 -2
  405. data/vendor/libgit2/src/util/win32/error.c +1 -1
  406. data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
  407. data/vendor/libgit2/src/util/win32/posix_w32.c +30 -7
  408. data/vendor/libgit2/src/util/win32/process.c +506 -0
  409. data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
  410. data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
  411. data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
  412. metadata +72 -49
  413. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
  414. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -6
  415. data/vendor/libgit2/deps/http-parser/COPYING +0 -23
  416. data/vendor/libgit2/deps/http-parser/http_parser.c +0 -2182
  417. data/vendor/libgit2/deps/http-parser/http_parser.h +0 -305
  418. data/vendor/libgit2/deps/zlib/COPYING +0 -27
  419. data/vendor/libgit2/include/git2/sys/reflog.h +0 -21
  420. data/vendor/libgit2/src/libgit2/config_entries.c +0 -237
  421. data/vendor/libgit2/src/libgit2/config_entries.h +0 -24
  422. data/vendor/libgit2/src/libgit2/errors.c +0 -238
  423. data/vendor/libgit2/src/libgit2/idxmap.c +0 -157
  424. data/vendor/libgit2/src/libgit2/idxmap.h +0 -177
  425. data/vendor/libgit2/src/libgit2/libgit2.h +0 -15
  426. data/vendor/libgit2/src/libgit2/netops.c +0 -124
  427. data/vendor/libgit2/src/libgit2/netops.h +0 -68
  428. data/vendor/libgit2/src/libgit2/offmap.c +0 -101
  429. data/vendor/libgit2/src/libgit2/offmap.h +0 -133
  430. data/vendor/libgit2/src/libgit2/oidmap.c +0 -107
  431. data/vendor/libgit2/src/libgit2/oidmap.h +0 -128
  432. data/vendor/libgit2/src/libgit2/threadstate.c +0 -84
  433. data/vendor/libgit2/src/libgit2/threadstate.h +0 -24
  434. data/vendor/libgit2/src/libgit2/transports/ssh.h +0 -14
  435. data/vendor/libgit2/src/util/khash.h +0 -615
  436. data/vendor/libgit2/src/util/strmap.c +0 -100
  437. data/vendor/libgit2/src/util/strmap.h +0 -131
  438. /data/vendor/libgit2/cmake/{FindHTTPParser.cmake → FindHTTP_Parser.cmake} +0 -0
  439. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
  440. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
  441. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
  442. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
  443. /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -11,7 +11,6 @@
11
11
 
12
12
  #include "posix.h"
13
13
  #include "str.h"
14
- #include "http_parser.h"
15
14
  #include "runtime.h"
16
15
 
17
16
  #define DEFAULT_PORT_HTTP "80"
@@ -19,6 +18,80 @@
19
18
  #define DEFAULT_PORT_GIT "9418"
20
19
  #define DEFAULT_PORT_SSH "22"
21
20
 
21
+ #define GIT_NET_URL_PARSER_INIT { 0 }
22
+
23
+ typedef struct {
24
+ unsigned int hierarchical : 1;
25
+
26
+ const char *scheme;
27
+ const char *user;
28
+ const char *password;
29
+ const char *host;
30
+ const char *port;
31
+ const char *path;
32
+ const char *query;
33
+ const char *fragment;
34
+
35
+ size_t scheme_len;
36
+ size_t user_len;
37
+ size_t password_len;
38
+ size_t host_len;
39
+ size_t port_len;
40
+ size_t path_len;
41
+ size_t query_len;
42
+ size_t fragment_len;
43
+ } git_net_url_parser;
44
+
45
+ bool git_net_hostname_matches_cert(
46
+ const char *hostname,
47
+ const char *pattern)
48
+ {
49
+ for (;;) {
50
+ char c = git__tolower(*pattern++);
51
+
52
+ if (c == '\0')
53
+ return *hostname ? false : true;
54
+
55
+ if (c == '*') {
56
+ c = *pattern;
57
+
58
+ /* '*' at the end matches everything left */
59
+ if (c == '\0')
60
+ return true;
61
+
62
+ /*
63
+ * We've found a pattern, so move towards the
64
+ * next matching char. The '.' is handled
65
+ * specially because wildcards aren't allowed
66
+ * to cross subdomains.
67
+ */
68
+ while(*hostname) {
69
+ char h = git__tolower(*hostname);
70
+
71
+ if (h == c)
72
+ return git_net_hostname_matches_cert(hostname++, pattern);
73
+ else if (h == '.')
74
+ return git_net_hostname_matches_cert(hostname, pattern);
75
+
76
+ hostname++;
77
+ }
78
+
79
+ return false;
80
+ }
81
+
82
+ if (c != git__tolower(*hostname++))
83
+ return false;
84
+ }
85
+
86
+ return false;
87
+ }
88
+
89
+ #define is_valid_scheme_char(c) \
90
+ (((c) >= 'a' && (c) <= 'z') || \
91
+ ((c) >= 'A' && (c) <= 'Z') || \
92
+ ((c) >= '0' && (c) <= '9') || \
93
+ (c) == '+' || (c) == '-' || (c) == '.')
94
+
22
95
  bool git_net_str_is_url(const char *str)
23
96
  {
24
97
  const char *c;
@@ -27,10 +100,7 @@ bool git_net_str_is_url(const char *str)
27
100
  if (*c == ':' && *(c+1) == '/' && *(c+2) == '/')
28
101
  return true;
29
102
 
30
- if ((*c < 'a' || *c > 'z') &&
31
- (*c < 'A' || *c > 'Z') &&
32
- (*c < '0' || *c > '9') &&
33
- (*c != '+' && *c != '-' && *c != '.'))
103
+ if (!is_valid_scheme_char(*c))
34
104
  break;
35
105
  }
36
106
 
@@ -53,6 +123,16 @@ static const char *default_port_for_scheme(const char *scheme)
53
123
  return NULL;
54
124
  }
55
125
 
126
+ static bool is_ssh_scheme(const char *scheme, size_t scheme_len)
127
+ {
128
+ if (!scheme_len)
129
+ return false;
130
+
131
+ return strncasecmp(scheme, "ssh", scheme_len) == 0 ||
132
+ strncasecmp(scheme, "ssh+git", scheme_len) == 0 ||
133
+ strncasecmp(scheme, "git+ssh", scheme_len) == 0;
134
+ }
135
+
56
136
  int git_net_url_dup(git_net_url *out, git_net_url *in)
57
137
  {
58
138
  if (in->scheme) {
@@ -100,12 +180,9 @@ static int url_invalid(const char *message)
100
180
  }
101
181
 
102
182
  static int url_parse_authority(
103
- const char **user_start, size_t *user_len,
104
- const char **password_start, size_t *password_len,
105
- const char **host_start, size_t *host_len,
106
- const char **port_start, size_t *port_len,
107
- const char *authority_start, size_t len,
108
- const char *scheme_start, size_t scheme_len)
183
+ git_net_url_parser *parser,
184
+ const char *authority,
185
+ size_t len)
109
186
  {
110
187
  const char *c, *hostport_end, *host_end = NULL,
111
188
  *userpass_end, *user_end = NULL;
@@ -121,14 +198,14 @@ static int url_parse_authority(
121
198
  * walk the authority backwards so that we can parse google code's
122
199
  * ssh urls that are not rfc compliant and allow @ in the username
123
200
  */
124
- for (hostport_end = authority_start + len, c = hostport_end - 1;
125
- c >= authority_start && !user_end;
201
+ for (hostport_end = authority + len, c = hostport_end - 1;
202
+ c >= authority && !user_end;
126
203
  c--) {
127
204
  switch (state) {
128
205
  case HOSTPORT:
129
206
  if (*c == ':') {
130
- *port_start = c + 1;
131
- *port_len = hostport_end - *port_start;
207
+ parser->port = c + 1;
208
+ parser->port_len = hostport_end - parser->port;
132
209
  host_end = c;
133
210
  state = HOST;
134
211
  break;
@@ -156,9 +233,10 @@ static int url_parse_authority(
156
233
  }
157
234
 
158
235
  else if (*c == '@') {
159
- *host_start = c + 1;
160
- *host_len = host_end ? host_end - *host_start :
161
- hostport_end - *host_start;
236
+ parser->host = c + 1;
237
+ parser->host_len = host_end ?
238
+ host_end - parser->host :
239
+ hostport_end - parser->host;
162
240
  userpass_end = c;
163
241
  state = USERPASS;
164
242
  }
@@ -171,8 +249,8 @@ static int url_parse_authority(
171
249
 
172
250
  case IPV6:
173
251
  if (*c == '[') {
174
- *host_start = c + 1;
175
- *host_len = host_end - *host_start;
252
+ parser->host = c + 1;
253
+ parser->host_len = host_end - parser->host;
176
254
  state = HOST_END;
177
255
  }
178
256
 
@@ -196,12 +274,12 @@ static int url_parse_authority(
196
274
 
197
275
  case USERPASS:
198
276
  if (*c == '@' &&
199
- strncasecmp(scheme_start, "ssh", scheme_len))
277
+ !is_ssh_scheme(parser->scheme, parser->scheme_len))
200
278
  return url_invalid("malformed hostname");
201
279
 
202
280
  if (*c == ':') {
203
- *password_start = c + 1;
204
- *password_len = userpass_end - *password_start;
281
+ parser->password = c + 1;
282
+ parser->password_len = userpass_end - parser->password;
205
283
  user_end = c;
206
284
  state = USER;
207
285
  break;
@@ -216,24 +294,24 @@ static int url_parse_authority(
216
294
 
217
295
  switch (state) {
218
296
  case HOSTPORT:
219
- *host_start = authority_start;
220
- *host_len = (hostport_end - *host_start);
297
+ parser->host = authority;
298
+ parser->host_len = (hostport_end - parser->host);
221
299
  break;
222
300
  case HOST:
223
- *host_start = authority_start;
224
- *host_len = (host_end - *host_start);
301
+ parser->host = authority;
302
+ parser->host_len = (host_end - parser->host);
225
303
  break;
226
304
  case IPV6:
227
305
  return url_invalid("malformed hostname");
228
306
  case HOST_END:
229
307
  break;
230
308
  case USERPASS:
231
- *user_start = authority_start;
232
- *user_len = (userpass_end - *user_start);
309
+ parser->user = authority;
310
+ parser->user_len = (userpass_end - parser->user);
233
311
  break;
234
312
  case USER:
235
- *user_start = authority_start;
236
- *user_len = (user_end - *user_start);
313
+ parser->user = authority;
314
+ parser->user_len = (user_end - parser->user);
237
315
  break;
238
316
  default:
239
317
  GIT_ASSERT(!"unhandled state");
@@ -242,97 +320,30 @@ static int url_parse_authority(
242
320
  return 0;
243
321
  }
244
322
 
245
- int git_net_url_parse(git_net_url *url, const char *given)
323
+ static int url_parse_path(
324
+ git_net_url_parser *parser,
325
+ const char *path,
326
+ size_t len)
246
327
  {
247
- const char *c, *scheme_start, *authority_start, *user_start,
248
- *password_start, *host_start, *port_start, *path_start,
249
- *query_start, *fragment_start, *default_port;
250
- git_str scheme = GIT_STR_INIT, user = GIT_STR_INIT,
251
- password = GIT_STR_INIT, host = GIT_STR_INIT,
252
- port = GIT_STR_INIT, path = GIT_STR_INIT,
253
- query = GIT_STR_INIT, fragment = GIT_STR_INIT;
254
- size_t scheme_len = 0, user_len = 0, password_len = 0, host_len = 0,
255
- port_len = 0, path_len = 0, query_len = 0, fragment_len = 0;
256
- bool hierarchical = false;
257
- int error = 0;
328
+ const char *c, *end;
258
329
 
259
- enum {
260
- SCHEME,
261
- AUTHORITY_START, AUTHORITY,
262
- PATH_START, PATH,
263
- QUERY,
264
- FRAGMENT
265
- } state = SCHEME;
330
+ enum { PATH, QUERY, FRAGMENT } state = PATH;
266
331
 
267
- memset(url, 0, sizeof(git_net_url));
332
+ parser->path = path;
333
+ end = path + len;
268
334
 
269
- for (c = scheme_start = given; *c; c++) {
335
+ for (c = path; c < end; c++) {
270
336
  switch (state) {
271
- case SCHEME:
272
- if (*c == ':') {
273
- scheme_len = (c - scheme_start);
274
-
275
- if (*(c+1) == '/' && *(c+2) == '/') {
276
- c += 2;
277
- hierarchical = true;
278
- state = AUTHORITY_START;
279
- } else {
280
- state = PATH_START;
281
- }
282
- } else if ((*c < 'A' || *c > 'Z') &&
283
- (*c < 'a' || *c > 'z') &&
284
- (*c < '0' || *c > '9') &&
285
- (*c != '+' && *c != '-' && *c != '.')) {
286
- /*
287
- * an illegal scheme character means that we
288
- * were just given a relative path
289
- */
290
- path_start = given;
291
- state = PATH;
292
- break;
293
- }
294
- break;
295
-
296
- case AUTHORITY_START:
297
- authority_start = c;
298
- state = AUTHORITY;
299
-
300
- /* fall through */
301
-
302
- case AUTHORITY:
303
- if (*c != '/')
304
- break;
305
-
306
- /*
307
- * authority is sufficiently complex that we parse
308
- * it separately
309
- */
310
- if ((error = url_parse_authority(
311
- &user_start, &user_len,
312
- &password_start,&password_len,
313
- &host_start, &host_len,
314
- &port_start, &port_len,
315
- authority_start, (c - authority_start),
316
- scheme_start, scheme_len)) < 0)
317
- goto done;
318
-
319
- /* fall through */
320
-
321
- case PATH_START:
322
- path_start = c;
323
- state = PATH;
324
- /* fall through */
325
-
326
337
  case PATH:
327
338
  switch (*c) {
328
339
  case '?':
329
- path_len = (c - path_start);
330
- query_start = c + 1;
340
+ parser->path_len = (c - parser->path);
341
+ parser->query = c + 1;
331
342
  state = QUERY;
332
343
  break;
333
344
  case '#':
334
- path_len = (c - path_start);
335
- fragment_start = c + 1;
345
+ parser->path_len = (c - parser->path);
346
+ parser->fragment = c + 1;
336
347
  state = FRAGMENT;
337
348
  break;
338
349
  }
@@ -340,8 +351,8 @@ int git_net_url_parse(git_net_url *url, const char *given)
340
351
 
341
352
  case QUERY:
342
353
  if (*c == '#') {
343
- query_len = (c - query_start);
344
- fragment_start = c + 1;
354
+ parser->query_len = (c - parser->query);
355
+ parser->fragment = c + 1;
345
356
  state = FRAGMENT;
346
357
  }
347
358
  break;
@@ -355,82 +366,74 @@ int git_net_url_parse(git_net_url *url, const char *given)
355
366
  }
356
367
 
357
368
  switch (state) {
358
- case SCHEME:
359
- /*
360
- * if we never saw a ':' then we were given a relative
361
- * path, not a bare scheme
362
- */
363
- path_start = given;
364
- path_len = (c - scheme_start);
365
- break;
366
- case AUTHORITY_START:
367
- break;
368
- case AUTHORITY:
369
- if ((error = url_parse_authority(
370
- &user_start, &user_len,
371
- &password_start,&password_len,
372
- &host_start, &host_len,
373
- &port_start, &port_len,
374
- authority_start, (c - authority_start),
375
- scheme_start, scheme_len)) < 0)
376
- goto done;
377
- break;
378
- case PATH_START:
379
- break;
380
369
  case PATH:
381
- path_len = (c - path_start);
370
+ parser->path_len = (c - parser->path);
382
371
  break;
383
372
  case QUERY:
384
- query_len = (c - query_start);
373
+ parser->query_len = (c - parser->query);
385
374
  break;
386
375
  case FRAGMENT:
387
- fragment_len = (c - fragment_start);
376
+ parser->fragment_len = (c - parser->fragment);
388
377
  break;
389
- default:
390
- GIT_ASSERT(!"unhandled state");
391
378
  }
392
379
 
393
- if (scheme_len) {
394
- if ((error = git_str_put(&scheme, scheme_start, scheme_len)) < 0)
380
+ return 0;
381
+ }
382
+
383
+ static int url_parse_finalize(git_net_url *url, git_net_url_parser *parser)
384
+ {
385
+ git_str scheme = GIT_STR_INIT, user = GIT_STR_INIT,
386
+ password = GIT_STR_INIT, host = GIT_STR_INIT,
387
+ port = GIT_STR_INIT, path = GIT_STR_INIT,
388
+ query = GIT_STR_INIT, fragment = GIT_STR_INIT;
389
+ const char *default_port;
390
+ int port_specified = 0;
391
+ int error = 0;
392
+
393
+ if (parser->scheme_len) {
394
+ if ((error = git_str_put(&scheme, parser->scheme, parser->scheme_len)) < 0)
395
395
  goto done;
396
396
 
397
397
  git__strntolower(scheme.ptr, scheme.size);
398
398
  }
399
399
 
400
- if (user_len &&
401
- (error = git_str_decode_percent(&user, user_start, user_len)) < 0)
400
+ if (parser->user_len &&
401
+ (error = git_str_decode_percent(&user, parser->user, parser->user_len)) < 0)
402
402
  goto done;
403
403
 
404
- if (password_len &&
405
- (error = git_str_decode_percent(&password, password_start, password_len)) < 0)
404
+ if (parser->password_len &&
405
+ (error = git_str_decode_percent(&password, parser->password, parser->password_len)) < 0)
406
406
  goto done;
407
407
 
408
- if (host_len &&
409
- (error = git_str_decode_percent(&host, host_start, host_len)) < 0)
408
+ if (parser->host_len &&
409
+ (error = git_str_decode_percent(&host, parser->host, parser->host_len)) < 0)
410
410
  goto done;
411
411
 
412
- if (port_len)
413
- error = git_str_put(&port, port_start, port_len);
414
- else if (scheme_len && (default_port = default_port_for_scheme(scheme.ptr)) != NULL)
412
+ if (parser->port_len) {
413
+ port_specified = 1;
414
+ error = git_str_put(&port, parser->port, parser->port_len);
415
+ } else if (parser->scheme_len &&
416
+ (default_port = default_port_for_scheme(scheme.ptr)) != NULL) {
415
417
  error = git_str_puts(&port, default_port);
418
+ }
416
419
 
417
420
  if (error < 0)
418
421
  goto done;
419
422
 
420
- if (path_len)
421
- error = git_str_put(&path, path_start, path_len);
422
- else if (hierarchical)
423
+ if (parser->path_len)
424
+ error = git_str_put(&path, parser->path, parser->path_len);
425
+ else if (parser->hierarchical)
423
426
  error = git_str_puts(&path, "/");
424
427
 
425
428
  if (error < 0)
426
429
  goto done;
427
430
 
428
- if (query_len &&
429
- (error = git_str_decode_percent(&query, query_start, query_len)) < 0)
431
+ if (parser->query_len &&
432
+ (error = git_str_decode_percent(&query, parser->query, parser->query_len)) < 0)
430
433
  goto done;
431
434
 
432
- if (fragment_len &&
433
- (error = git_str_decode_percent(&fragment, fragment_start, fragment_len)) < 0)
435
+ if (parser->fragment_len &&
436
+ (error = git_str_decode_percent(&fragment, parser->fragment, parser->fragment_len)) < 0)
434
437
  goto done;
435
438
 
436
439
  url->scheme = git_str_detach(&scheme);
@@ -441,6 +444,7 @@ int git_net_url_parse(git_net_url *url, const char *given)
441
444
  url->fragment = git_str_detach(&fragment);
442
445
  url->username = git_str_detach(&user);
443
446
  url->password = git_str_detach(&password);
447
+ url->port_specified = port_specified;
444
448
 
445
449
  error = 0;
446
450
 
@@ -457,6 +461,157 @@ done:
457
461
  return error;
458
462
  }
459
463
 
464
+ int git_net_url_parse(git_net_url *url, const char *given)
465
+ {
466
+ git_net_url_parser parser = GIT_NET_URL_PARSER_INIT;
467
+ const char *c, *authority, *path;
468
+ size_t authority_len = 0, path_len = 0;
469
+ int error = 0;
470
+
471
+ enum {
472
+ SCHEME_START, SCHEME,
473
+ AUTHORITY_START, AUTHORITY,
474
+ PATH_START, PATH
475
+ } state = SCHEME_START;
476
+
477
+ memset(url, 0, sizeof(git_net_url));
478
+
479
+ for (c = given; *c; c++) {
480
+ switch (state) {
481
+ case SCHEME_START:
482
+ parser.scheme = c;
483
+ state = SCHEME;
484
+
485
+ /* fall through */
486
+
487
+ case SCHEME:
488
+ if (*c == ':') {
489
+ parser.scheme_len = (c - parser.scheme);
490
+
491
+ if (parser.scheme_len &&
492
+ *(c+1) == '/' && *(c+2) == '/') {
493
+ c += 2;
494
+ parser.hierarchical = 1;
495
+ state = AUTHORITY_START;
496
+ } else {
497
+ state = PATH_START;
498
+ }
499
+ } else if (!is_valid_scheme_char(*c)) {
500
+ /*
501
+ * an illegal scheme character means that we
502
+ * were just given a relative path
503
+ */
504
+ path = given;
505
+ state = PATH;
506
+ break;
507
+ }
508
+ break;
509
+
510
+ case AUTHORITY_START:
511
+ authority = c;
512
+ state = AUTHORITY;
513
+
514
+ /* fall through */
515
+ case AUTHORITY:
516
+ if (*c != '/')
517
+ break;
518
+
519
+ authority_len = (c - authority);
520
+
521
+ /* fall through */
522
+ case PATH_START:
523
+ path = c;
524
+ state = PATH;
525
+ break;
526
+
527
+ case PATH:
528
+ break;
529
+
530
+ default:
531
+ GIT_ASSERT(!"unhandled state");
532
+ }
533
+ }
534
+
535
+ switch (state) {
536
+ case SCHEME:
537
+ /*
538
+ * if we never saw a ':' then we were given a relative
539
+ * path, not a bare scheme
540
+ */
541
+ path = given;
542
+ path_len = (c - path);
543
+ break;
544
+ case AUTHORITY_START:
545
+ break;
546
+ case AUTHORITY:
547
+ authority_len = (c - authority);
548
+ break;
549
+ case PATH_START:
550
+ break;
551
+ case PATH:
552
+ path_len = (c - path);
553
+ break;
554
+ default:
555
+ GIT_ASSERT(!"unhandled state");
556
+ }
557
+
558
+ if (authority_len &&
559
+ (error = url_parse_authority(&parser, authority, authority_len)) < 0)
560
+ goto done;
561
+
562
+ if (path_len &&
563
+ (error = url_parse_path(&parser, path, path_len)) < 0)
564
+ goto done;
565
+
566
+ error = url_parse_finalize(url, &parser);
567
+
568
+ done:
569
+ return error;
570
+ }
571
+
572
+ int git_net_url_parse_http(
573
+ git_net_url *url,
574
+ const char *given)
575
+ {
576
+ git_net_url_parser parser = GIT_NET_URL_PARSER_INIT;
577
+ const char *c, *authority, *path = NULL;
578
+ size_t authority_len = 0, path_len = 0;
579
+ int error;
580
+
581
+ /* Hopefully this is a proper URL with a scheme. */
582
+ if (git_net_str_is_url(given))
583
+ return git_net_url_parse(url, given);
584
+
585
+ memset(url, 0, sizeof(git_net_url));
586
+
587
+ /* Without a scheme, we are in the host (authority) section. */
588
+ for (c = authority = given; *c; c++) {
589
+ if (!path && *c == '/') {
590
+ authority_len = (c - authority);
591
+ path = c;
592
+ }
593
+ }
594
+
595
+ if (path)
596
+ path_len = (c - path);
597
+ else
598
+ authority_len = (c - authority);
599
+
600
+ parser.scheme = "http";
601
+ parser.scheme_len = 4;
602
+ parser.hierarchical = 1;
603
+
604
+ if (authority_len &&
605
+ (error = url_parse_authority(&parser, authority, authority_len)) < 0)
606
+ return error;
607
+
608
+ if (path_len &&
609
+ (error = url_parse_path(&parser, path, path_len)) < 0)
610
+ return error;
611
+
612
+ return url_parse_finalize(url, &parser);
613
+ }
614
+
460
615
  static int scp_invalid(const char *message)
461
616
  {
462
617
  git_error_set(GIT_ERROR_NET, "invalid scp-style path: %s", message);
@@ -506,7 +661,7 @@ static bool has_at(const char *str)
506
661
  int git_net_url_parse_scp(git_net_url *url, const char *given)
507
662
  {
508
663
  const char *default_port = default_port_for_scheme("ssh");
509
- const char *c, *user, *host, *port, *path = NULL;
664
+ const char *c, *user, *host, *port = NULL, *path = NULL;
510
665
  size_t user_len = 0, host_len = 0, port_len = 0;
511
666
  unsigned short bracket = 0;
512
667
 
@@ -635,10 +790,12 @@ int git_net_url_parse_scp(git_net_url *url, const char *given)
635
790
  GIT_ASSERT(host_len);
636
791
  GIT_ERROR_CHECK_ALLOC(url->host = git__strndup(host, host_len));
637
792
 
638
- if (port_len)
793
+ if (port_len) {
794
+ url->port_specified = 1;
639
795
  GIT_ERROR_CHECK_ALLOC(url->port = git__strndup(port, port_len));
640
- else
796
+ } else {
641
797
  GIT_ERROR_CHECK_ALLOC(url->port = git__strdup(default_port));
798
+ }
642
799
 
643
800
  GIT_ASSERT(path);
644
801
  GIT_ERROR_CHECK_ALLOC(url->path = git__strdup(path));
@@ -9,6 +9,23 @@
9
9
 
10
10
  #include "git2_util.h"
11
11
 
12
+ /*
13
+ * Hostname handling
14
+ */
15
+
16
+ /*
17
+ * See if a given hostname matches a certificate name pattern, according
18
+ * to RFC2818 rules (which specifies HTTP over TLS). Mainly, an asterisk
19
+ * matches anything, but is limited to a single url component.
20
+ */
21
+ extern bool git_net_hostname_matches_cert(
22
+ const char *hostname,
23
+ const char *pattern);
24
+
25
+ /*
26
+ * URL handling
27
+ */
28
+
12
29
  typedef struct git_net_url {
13
30
  char *scheme;
14
31
  char *host;
@@ -18,6 +35,8 @@ typedef struct git_net_url {
18
35
  char *fragment;
19
36
  char *username;
20
37
  char *password;
38
+
39
+ unsigned int port_specified;
21
40
  } git_net_url;
22
41
 
23
42
  #define GIT_NET_URL_INIT { NULL }
@@ -40,6 +59,14 @@ extern int git_net_url_parse_scp(git_net_url *url, const char *str);
40
59
  */
41
60
  extern int git_net_url_parse_standard_or_scp(git_net_url *url, const char *str);
42
61
 
62
+ /**
63
+ * Parses a string containing an HTTP endpoint that may not be a
64
+ * well-formed URL. For example, "localhost" or "localhost:port".
65
+ */
66
+ extern int git_net_url_parse_http(
67
+ git_net_url *url,
68
+ const char *str);
69
+
43
70
  /** Appends a path and/or query string to the given URL */
44
71
  extern int git_net_url_joinpath(
45
72
  git_net_url *out,
@@ -144,7 +144,7 @@ int git_pool_init(git_pool *pool, size_t item_size)
144
144
 
145
145
  void git_pool_clear(git_pool *pool)
146
146
  {
147
- git_vector_free_deep(&pool->allocations);
147
+ git_vector_dispose_deep(&pool->allocations);
148
148
  }
149
149
 
150
150
  static void *pool_alloc(git_pool *pool, size_t size) {