rugged 1.1.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (407) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/extconf.rb +2 -2
  5. data/ext/rugged/rugged.c +7 -4
  6. data/ext/rugged/rugged_config.c +7 -2
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +17 -0
  9. data/ext/rugged/rugged_repo.c +3 -3
  10. data/lib/rugged/repository.rb +2 -2
  11. data/lib/rugged/version.rb +1 -1
  12. data/vendor/libgit2/CMakeLists.txt +103 -271
  13. data/vendor/libgit2/COPYING +149 -24
  14. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  15. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  16. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  17. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  19. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  20. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  21. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  22. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  23. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  24. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  25. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  26. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  27. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  30. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  31. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  32. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  33. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  34. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  35. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
  36. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
  37. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  38. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  39. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  40. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  41. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  42. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
  43. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  44. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  45. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  46. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  47. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  48. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  49. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  50. data/vendor/libgit2/deps/ntlmclient/ntlm.c +154 -122
  51. data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
  52. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
  53. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  54. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  55. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  56. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  57. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  58. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  59. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  60. data/vendor/libgit2/include/git2/apply.h +16 -2
  61. data/vendor/libgit2/include/git2/attr.h +106 -2
  62. data/vendor/libgit2/include/git2/blame.h +97 -43
  63. data/vendor/libgit2/include/git2/blob.h +33 -2
  64. data/vendor/libgit2/include/git2/branch.h +27 -0
  65. data/vendor/libgit2/include/git2/buffer.h +18 -78
  66. data/vendor/libgit2/include/git2/cert.h +43 -6
  67. data/vendor/libgit2/include/git2/checkout.h +32 -13
  68. data/vendor/libgit2/include/git2/clone.h +4 -4
  69. data/vendor/libgit2/include/git2/commit.h +37 -19
  70. data/vendor/libgit2/include/git2/common.h +46 -5
  71. data/vendor/libgit2/include/git2/config.h +19 -3
  72. data/vendor/libgit2/include/git2/credential.h +2 -1
  73. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  74. data/vendor/libgit2/include/git2/deprecated.h +326 -6
  75. data/vendor/libgit2/include/git2/describe.h +7 -2
  76. data/vendor/libgit2/include/git2/diff.h +50 -121
  77. data/vendor/libgit2/include/git2/email.h +127 -0
  78. data/vendor/libgit2/include/git2/errors.h +7 -6
  79. data/vendor/libgit2/include/git2/filter.h +69 -18
  80. data/vendor/libgit2/include/git2/graph.h +21 -2
  81. data/vendor/libgit2/include/git2/ignore.h +1 -1
  82. data/vendor/libgit2/include/git2/index.h +13 -7
  83. data/vendor/libgit2/include/git2/indexer.h +19 -0
  84. data/vendor/libgit2/include/git2/merge.h +23 -3
  85. data/vendor/libgit2/include/git2/message.h +2 -0
  86. data/vendor/libgit2/include/git2/notes.h +2 -2
  87. data/vendor/libgit2/include/git2/object.h +23 -0
  88. data/vendor/libgit2/include/git2/odb.h +65 -6
  89. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  90. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  91. data/vendor/libgit2/include/git2/pack.h +24 -8
  92. data/vendor/libgit2/include/git2/patch.h +16 -0
  93. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  94. data/vendor/libgit2/include/git2/proxy.h +1 -1
  95. data/vendor/libgit2/include/git2/rebase.h +34 -2
  96. data/vendor/libgit2/include/git2/refdb.h +3 -0
  97. data/vendor/libgit2/include/git2/reflog.h +1 -1
  98. data/vendor/libgit2/include/git2/refs.h +8 -4
  99. data/vendor/libgit2/include/git2/remote.h +246 -46
  100. data/vendor/libgit2/include/git2/repository.h +25 -18
  101. data/vendor/libgit2/include/git2/reset.h +2 -2
  102. data/vendor/libgit2/include/git2/revparse.h +5 -5
  103. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  104. data/vendor/libgit2/include/git2/signature.h +1 -1
  105. data/vendor/libgit2/include/git2/stash.h +4 -4
  106. data/vendor/libgit2/include/git2/status.h +124 -62
  107. data/vendor/libgit2/include/git2/stdint.h +3 -3
  108. data/vendor/libgit2/include/git2/submodule.h +16 -2
  109. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  110. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  111. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  112. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  113. data/vendor/libgit2/include/git2/sys/odb_backend.h +9 -5
  114. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  115. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  116. data/vendor/libgit2/include/git2/sys/transport.h +26 -34
  117. data/vendor/libgit2/include/git2/tag.h +13 -0
  118. data/vendor/libgit2/include/git2/tree.h +4 -17
  119. data/vendor/libgit2/include/git2/types.h +16 -7
  120. data/vendor/libgit2/include/git2/version.h +4 -4
  121. data/vendor/libgit2/include/git2/worktree.h +13 -2
  122. data/vendor/libgit2/include/git2.h +1 -0
  123. data/vendor/libgit2/src/CMakeLists.txt +192 -290
  124. data/vendor/libgit2/src/alloc.c +21 -8
  125. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  126. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  127. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  128. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  129. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  130. data/vendor/libgit2/src/annotated_commit.c +21 -9
  131. data/vendor/libgit2/src/annotated_commit.h +1 -1
  132. data/vendor/libgit2/src/apply.c +34 -25
  133. data/vendor/libgit2/src/apply.h +2 -2
  134. data/vendor/libgit2/src/array.h +11 -11
  135. data/vendor/libgit2/src/attr.c +204 -82
  136. data/vendor/libgit2/src/attr_file.c +105 -52
  137. data/vendor/libgit2/src/attr_file.h +36 -15
  138. data/vendor/libgit2/src/attrcache.c +55 -45
  139. data/vendor/libgit2/src/attrcache.h +4 -5
  140. data/vendor/libgit2/src/blame.c +15 -9
  141. data/vendor/libgit2/src/blame_git.c +2 -2
  142. data/vendor/libgit2/src/blob.c +76 -52
  143. data/vendor/libgit2/src/blob.h +1 -1
  144. data/vendor/libgit2/src/branch.c +203 -110
  145. data/vendor/libgit2/src/branch.h +15 -3
  146. data/vendor/libgit2/src/buf.c +126 -0
  147. data/vendor/libgit2/src/buf.h +50 -0
  148. data/vendor/libgit2/src/cache.c +2 -2
  149. data/vendor/libgit2/src/cache.h +7 -7
  150. data/vendor/libgit2/src/cc-compat.h +11 -9
  151. data/vendor/libgit2/src/checkout.c +118 -91
  152. data/vendor/libgit2/src/cherrypick.c +16 -12
  153. data/vendor/libgit2/src/clone.c +97 -103
  154. data/vendor/libgit2/src/commit.c +167 -84
  155. data/vendor/libgit2/src/commit.h +24 -1
  156. data/vendor/libgit2/src/commit_graph.c +1224 -0
  157. data/vendor/libgit2/src/commit_graph.h +169 -0
  158. data/vendor/libgit2/src/commit_list.c +48 -3
  159. data/vendor/libgit2/src/commit_list.h +2 -0
  160. data/vendor/libgit2/src/common.h +35 -5
  161. data/vendor/libgit2/src/config.c +119 -64
  162. data/vendor/libgit2/src/config.h +15 -2
  163. data/vendor/libgit2/src/config_cache.c +5 -3
  164. data/vendor/libgit2/src/config_file.c +120 -100
  165. data/vendor/libgit2/src/config_mem.c +9 -9
  166. data/vendor/libgit2/src/config_parse.c +29 -27
  167. data/vendor/libgit2/src/crlf.c +36 -23
  168. data/vendor/libgit2/src/date.c +13 -19
  169. data/vendor/libgit2/src/date.h +33 -0
  170. data/vendor/libgit2/src/delta.c +1 -1
  171. data/vendor/libgit2/src/describe.c +32 -21
  172. data/vendor/libgit2/src/diff.c +71 -183
  173. data/vendor/libgit2/src/diff.h +2 -4
  174. data/vendor/libgit2/src/diff_driver.c +53 -51
  175. data/vendor/libgit2/src/diff_driver.h +3 -3
  176. data/vendor/libgit2/src/diff_file.c +31 -26
  177. data/vendor/libgit2/src/diff_generate.c +76 -23
  178. data/vendor/libgit2/src/diff_generate.h +5 -3
  179. data/vendor/libgit2/src/diff_print.c +120 -95
  180. data/vendor/libgit2/src/diff_stats.c +47 -34
  181. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  182. data/vendor/libgit2/src/diff_tform.c +18 -16
  183. data/vendor/libgit2/src/diff_xdiff.c +7 -10
  184. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  185. data/vendor/libgit2/src/email.c +315 -0
  186. data/vendor/libgit2/src/email.h +25 -0
  187. data/vendor/libgit2/src/errors.c +37 -32
  188. data/vendor/libgit2/src/features.h.in +11 -2
  189. data/vendor/libgit2/src/fetch.c +77 -26
  190. data/vendor/libgit2/src/fetch.h +1 -1
  191. data/vendor/libgit2/src/fetchhead.c +27 -23
  192. data/vendor/libgit2/src/filebuf.c +36 -34
  193. data/vendor/libgit2/src/filebuf.h +1 -1
  194. data/vendor/libgit2/src/filter.c +278 -132
  195. data/vendor/libgit2/src/filter.h +46 -6
  196. data/vendor/libgit2/src/fs_path.c +2071 -0
  197. data/vendor/libgit2/src/fs_path.h +772 -0
  198. data/vendor/libgit2/src/futils.c +96 -90
  199. data/vendor/libgit2/src/futils.h +27 -15
  200. data/vendor/libgit2/src/graph.c +64 -9
  201. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
  202. data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
  203. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  204. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  205. data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
  206. data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
  207. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
  208. data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
  209. data/vendor/libgit2/src/hash/sha1.h +3 -1
  210. data/vendor/libgit2/src/hash.c +71 -36
  211. data/vendor/libgit2/src/hash.h +13 -13
  212. data/vendor/libgit2/src/hashsig.c +23 -10
  213. data/vendor/libgit2/src/ident.c +30 -20
  214. data/vendor/libgit2/src/ignore.c +63 -46
  215. data/vendor/libgit2/src/ignore.h +2 -2
  216. data/vendor/libgit2/src/index.c +184 -149
  217. data/vendor/libgit2/src/index.h +7 -4
  218. data/vendor/libgit2/src/indexer.c +143 -89
  219. data/vendor/libgit2/src/integer.h +64 -2
  220. data/vendor/libgit2/src/iterator.c +93 -73
  221. data/vendor/libgit2/src/iterator.h +6 -6
  222. data/vendor/libgit2/src/khash.h +3 -12
  223. data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
  224. data/vendor/libgit2/src/libgit2.h +15 -0
  225. data/vendor/libgit2/src/mailmap.c +60 -45
  226. data/vendor/libgit2/src/map.h +3 -3
  227. data/vendor/libgit2/src/merge.c +104 -61
  228. data/vendor/libgit2/src/merge.h +3 -15
  229. data/vendor/libgit2/src/merge_driver.c +21 -15
  230. data/vendor/libgit2/src/merge_file.c +24 -6
  231. data/vendor/libgit2/src/message.c +21 -8
  232. data/vendor/libgit2/src/midx.c +501 -18
  233. data/vendor/libgit2/src/midx.h +29 -2
  234. data/vendor/libgit2/src/mwindow.c +103 -59
  235. data/vendor/libgit2/src/mwindow.h +3 -3
  236. data/vendor/libgit2/src/net.c +405 -71
  237. data/vendor/libgit2/src/net.h +26 -5
  238. data/vendor/libgit2/src/netops.c +7 -5
  239. data/vendor/libgit2/src/netops.h +3 -3
  240. data/vendor/libgit2/src/notes.c +40 -49
  241. data/vendor/libgit2/src/object.c +68 -20
  242. data/vendor/libgit2/src/object.h +1 -1
  243. data/vendor/libgit2/src/odb.c +320 -80
  244. data/vendor/libgit2/src/odb.h +17 -3
  245. data/vendor/libgit2/src/odb_loose.c +96 -86
  246. data/vendor/libgit2/src/odb_mempack.c +19 -6
  247. data/vendor/libgit2/src/odb_pack.c +402 -125
  248. data/vendor/libgit2/src/oid.c +16 -8
  249. data/vendor/libgit2/src/oid.h +15 -0
  250. data/vendor/libgit2/src/oidarray.c +10 -1
  251. data/vendor/libgit2/src/pack-objects.c +90 -69
  252. data/vendor/libgit2/src/pack-objects.h +11 -6
  253. data/vendor/libgit2/src/pack.c +337 -127
  254. data/vendor/libgit2/src/pack.h +25 -7
  255. data/vendor/libgit2/src/patch.c +17 -10
  256. data/vendor/libgit2/src/patch.h +1 -0
  257. data/vendor/libgit2/src/patch_generate.c +29 -13
  258. data/vendor/libgit2/src/patch_generate.h +5 -5
  259. data/vendor/libgit2/src/patch_parse.c +26 -25
  260. data/vendor/libgit2/src/path.c +86 -1768
  261. data/vendor/libgit2/src/path.h +39 -635
  262. data/vendor/libgit2/src/pathspec.c +12 -12
  263. data/vendor/libgit2/src/pathspec.h +2 -2
  264. data/vendor/libgit2/src/pool.c +13 -7
  265. data/vendor/libgit2/src/posix.c +14 -6
  266. data/vendor/libgit2/src/posix.h +1 -0
  267. data/vendor/libgit2/src/pqueue.h +1 -1
  268. data/vendor/libgit2/src/proxy.c +4 -1
  269. data/vendor/libgit2/src/proxy.h +1 -1
  270. data/vendor/libgit2/src/push.c +30 -35
  271. data/vendor/libgit2/src/push.h +4 -16
  272. data/vendor/libgit2/src/rand.c +226 -0
  273. data/vendor/libgit2/src/rand.h +37 -0
  274. data/vendor/libgit2/src/reader.c +18 -14
  275. data/vendor/libgit2/src/reader.h +2 -2
  276. data/vendor/libgit2/src/rebase.c +177 -132
  277. data/vendor/libgit2/src/refdb.c +30 -13
  278. data/vendor/libgit2/src/refdb_fs.c +548 -222
  279. data/vendor/libgit2/src/reflog.c +19 -14
  280. data/vendor/libgit2/src/refs.c +107 -72
  281. data/vendor/libgit2/src/refs.h +2 -2
  282. data/vendor/libgit2/src/refspec.c +53 -38
  283. data/vendor/libgit2/src/refspec.h +5 -2
  284. data/vendor/libgit2/src/regexp.c +1 -1
  285. data/vendor/libgit2/src/remote.c +960 -486
  286. data/vendor/libgit2/src/remote.h +16 -10
  287. data/vendor/libgit2/src/repository.c +702 -422
  288. data/vendor/libgit2/src/repository.h +26 -8
  289. data/vendor/libgit2/src/reset.c +16 -12
  290. data/vendor/libgit2/src/revert.c +16 -12
  291. data/vendor/libgit2/src/revparse.c +66 -48
  292. data/vendor/libgit2/src/revwalk.c +39 -22
  293. data/vendor/libgit2/src/runtime.c +162 -0
  294. data/vendor/libgit2/src/runtime.h +62 -0
  295. data/vendor/libgit2/src/settings.h +11 -0
  296. data/vendor/libgit2/src/signature.c +18 -11
  297. data/vendor/libgit2/src/signature.h +1 -1
  298. data/vendor/libgit2/src/sortedcache.c +1 -1
  299. data/vendor/libgit2/src/sortedcache.h +10 -8
  300. data/vendor/libgit2/src/stash.c +39 -38
  301. data/vendor/libgit2/src/status.c +11 -5
  302. data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
  303. data/vendor/libgit2/src/str.h +357 -0
  304. data/vendor/libgit2/src/strarray.c +2 -1
  305. data/vendor/libgit2/src/streams/mbedtls.c +22 -23
  306. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  307. data/vendor/libgit2/src/streams/openssl.c +101 -201
  308. data/vendor/libgit2/src/streams/openssl.h +9 -1
  309. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  310. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  311. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  312. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  313. data/vendor/libgit2/src/streams/registry.c +5 -6
  314. data/vendor/libgit2/src/streams/socket.c +6 -2
  315. data/vendor/libgit2/src/streams/stransport.c +6 -3
  316. data/vendor/libgit2/src/streams/tls.c +5 -3
  317. data/vendor/libgit2/src/submodule.c +290 -212
  318. data/vendor/libgit2/src/submodule.h +10 -10
  319. data/vendor/libgit2/src/sysdir.c +70 -56
  320. data/vendor/libgit2/src/sysdir.h +15 -10
  321. data/vendor/libgit2/src/tag.c +72 -34
  322. data/vendor/libgit2/src/thread.c +140 -0
  323. data/vendor/libgit2/src/thread.h +479 -0
  324. data/vendor/libgit2/src/threadstate.c +84 -0
  325. data/vendor/libgit2/src/threadstate.h +24 -0
  326. data/vendor/libgit2/src/trace.c +3 -16
  327. data/vendor/libgit2/src/trace.h +17 -30
  328. data/vendor/libgit2/src/trailer.c +2 -2
  329. data/vendor/libgit2/src/transaction.c +20 -9
  330. data/vendor/libgit2/src/transport.c +13 -13
  331. data/vendor/libgit2/src/transports/auth.c +8 -10
  332. data/vendor/libgit2/src/transports/auth.h +2 -3
  333. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
  334. data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
  335. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  336. data/vendor/libgit2/src/transports/credential.c +15 -7
  337. data/vendor/libgit2/src/transports/git.c +10 -14
  338. data/vendor/libgit2/src/transports/http.c +56 -34
  339. data/vendor/libgit2/src/transports/http.h +3 -3
  340. data/vendor/libgit2/src/transports/httpclient.c +106 -79
  341. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  342. data/vendor/libgit2/src/transports/local.c +127 -119
  343. data/vendor/libgit2/src/transports/smart.c +61 -144
  344. data/vendor/libgit2/src/transports/smart.h +26 -32
  345. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  346. data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
  347. data/vendor/libgit2/src/transports/ssh.c +100 -131
  348. data/vendor/libgit2/src/transports/winhttp.c +86 -82
  349. data/vendor/libgit2/src/tree-cache.c +5 -5
  350. data/vendor/libgit2/src/tree-cache.h +2 -2
  351. data/vendor/libgit2/src/tree.c +150 -116
  352. data/vendor/libgit2/src/tree.h +1 -0
  353. data/vendor/libgit2/src/tsort.c +0 -2
  354. data/vendor/libgit2/src/unix/map.c +3 -3
  355. data/vendor/libgit2/src/unix/posix.h +1 -4
  356. data/vendor/libgit2/src/unix/pthread.h +2 -1
  357. data/vendor/libgit2/src/unix/realpath.c +0 -2
  358. data/vendor/libgit2/src/utf8.c +150 -0
  359. data/vendor/libgit2/src/utf8.h +52 -0
  360. data/vendor/libgit2/src/util.c +68 -144
  361. data/vendor/libgit2/src/util.h +36 -68
  362. data/vendor/libgit2/src/vector.c +23 -19
  363. data/vendor/libgit2/src/vector.h +5 -3
  364. data/vendor/libgit2/src/win32/findfile.c +172 -114
  365. data/vendor/libgit2/src/win32/findfile.h +7 -4
  366. data/vendor/libgit2/src/win32/map.c +1 -1
  367. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  368. data/vendor/libgit2/src/win32/path_w32.c +162 -33
  369. data/vendor/libgit2/src/win32/path_w32.h +2 -1
  370. data/vendor/libgit2/src/win32/posix.h +6 -7
  371. data/vendor/libgit2/src/win32/posix_w32.c +26 -33
  372. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  373. data/vendor/libgit2/src/win32/reparse.h +4 -4
  374. data/vendor/libgit2/src/win32/thread.c +24 -15
  375. data/vendor/libgit2/src/win32/thread.h +1 -1
  376. data/vendor/libgit2/src/win32/w32_buffer.c +5 -6
  377. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  378. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  379. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  380. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  381. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  382. data/vendor/libgit2/src/worktree.c +138 -105
  383. data/vendor/libgit2/src/worktree.h +1 -1
  384. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  385. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  386. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  387. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  388. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  389. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  390. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  391. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  392. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  393. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  394. data/vendor/libgit2/src/zstream.c +6 -6
  395. data/vendor/libgit2/src/zstream.h +4 -4
  396. metadata +60 -24
  397. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  398. data/vendor/libgit2/src/buf_text.c +0 -316
  399. data/vendor/libgit2/src/buf_text.h +0 -122
  400. data/vendor/libgit2/src/buffer.h +0 -222
  401. data/vendor/libgit2/src/global.c +0 -363
  402. data/vendor/libgit2/src/global.h +0 -41
  403. data/vendor/libgit2/src/thread-utils.c +0 -58
  404. data/vendor/libgit2/src/thread-utils.h +0 -369
  405. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  406. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  407. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -9,18 +9,35 @@
9
9
  #include "netops.h"
10
10
 
11
11
  #include <ctype.h>
12
- #include "git2/errors.h"
13
12
 
14
13
  #include "posix.h"
15
- #include "buffer.h"
14
+ #include "str.h"
16
15
  #include "http_parser.h"
17
- #include "global.h"
16
+ #include "runtime.h"
18
17
 
19
18
  #define DEFAULT_PORT_HTTP "80"
20
19
  #define DEFAULT_PORT_HTTPS "443"
21
20
  #define DEFAULT_PORT_GIT "9418"
22
21
  #define DEFAULT_PORT_SSH "22"
23
22
 
23
+ bool git_net_str_is_url(const char *str)
24
+ {
25
+ const char *c;
26
+
27
+ for (c = str; *c; c++) {
28
+ if (*c == ':' && *(c+1) == '/' && *(c+2) == '/')
29
+ return true;
30
+
31
+ if ((*c < 'a' || *c > 'z') &&
32
+ (*c < 'A' || *c > 'Z') &&
33
+ (*c < '0' || *c > '9') &&
34
+ (*c != '+' && *c != '-' && *c != '.'))
35
+ break;
36
+ }
37
+
38
+ return false;
39
+ }
40
+
24
41
  static const char *default_port_for_scheme(const char *scheme)
25
42
  {
26
43
  if (strcmp(scheme, "http") == 0)
@@ -29,23 +46,65 @@ static const char *default_port_for_scheme(const char *scheme)
29
46
  return DEFAULT_PORT_HTTPS;
30
47
  else if (strcmp(scheme, "git") == 0)
31
48
  return DEFAULT_PORT_GIT;
32
- else if (strcmp(scheme, "ssh") == 0)
49
+ else if (strcmp(scheme, "ssh") == 0 ||
50
+ strcmp(scheme, "ssh+git") == 0 ||
51
+ strcmp(scheme, "git+ssh") == 0)
33
52
  return DEFAULT_PORT_SSH;
34
53
 
35
54
  return NULL;
36
55
  }
37
56
 
57
+ int git_net_url_dup(git_net_url *out, git_net_url *in)
58
+ {
59
+ if (in->scheme) {
60
+ out->scheme = git__strdup(in->scheme);
61
+ GIT_ERROR_CHECK_ALLOC(out->scheme);
62
+ }
63
+
64
+ if (in->host) {
65
+ out->host = git__strdup(in->host);
66
+ GIT_ERROR_CHECK_ALLOC(out->host);
67
+ }
68
+
69
+ if (in->port) {
70
+ out->port = git__strdup(in->port);
71
+ GIT_ERROR_CHECK_ALLOC(out->port);
72
+ }
73
+
74
+ if (in->path) {
75
+ out->path = git__strdup(in->path);
76
+ GIT_ERROR_CHECK_ALLOC(out->path);
77
+ }
78
+
79
+ if (in->query) {
80
+ out->query = git__strdup(in->query);
81
+ GIT_ERROR_CHECK_ALLOC(out->query);
82
+ }
83
+
84
+ if (in->username) {
85
+ out->username = git__strdup(in->username);
86
+ GIT_ERROR_CHECK_ALLOC(out->username);
87
+ }
88
+
89
+ if (in->password) {
90
+ out->password = git__strdup(in->password);
91
+ GIT_ERROR_CHECK_ALLOC(out->password);
92
+ }
93
+
94
+ return 0;
95
+ }
96
+
38
97
  int git_net_url_parse(git_net_url *url, const char *given)
39
98
  {
40
99
  struct http_parser_url u = {0};
41
100
  bool has_scheme, has_host, has_port, has_path, has_query, has_userinfo;
42
- git_buf scheme = GIT_BUF_INIT,
43
- host = GIT_BUF_INIT,
44
- port = GIT_BUF_INIT,
45
- path = GIT_BUF_INIT,
46
- username = GIT_BUF_INIT,
47
- password = GIT_BUF_INIT,
48
- query = GIT_BUF_INIT;
101
+ git_str scheme = GIT_STR_INIT,
102
+ host = GIT_STR_INIT,
103
+ port = GIT_STR_INIT,
104
+ path = GIT_STR_INIT,
105
+ username = GIT_STR_INIT,
106
+ password = GIT_STR_INIT,
107
+ query = GIT_STR_INIT;
49
108
  int error = GIT_EINVALIDSPEC;
50
109
 
51
110
  if (http_parser_parse_url(given, strlen(given), false, &u)) {
@@ -63,7 +122,7 @@ int git_net_url_parse(git_net_url *url, const char *given)
63
122
  if (has_scheme) {
64
123
  const char *url_scheme = given + u.field_data[UF_SCHEMA].off;
65
124
  size_t url_scheme_len = u.field_data[UF_SCHEMA].len;
66
- git_buf_put(&scheme, url_scheme, url_scheme_len);
125
+ git_str_put(&scheme, url_scheme, url_scheme_len);
67
126
  git__strntolower(scheme.ptr, scheme.size);
68
127
  } else {
69
128
  git_error_set(GIT_ERROR_NET, "malformed URL '%s'", given);
@@ -73,13 +132,13 @@ int git_net_url_parse(git_net_url *url, const char *given)
73
132
  if (has_host) {
74
133
  const char *url_host = given + u.field_data[UF_HOST].off;
75
134
  size_t url_host_len = u.field_data[UF_HOST].len;
76
- git_buf_decode_percent(&host, url_host, url_host_len);
135
+ git_str_decode_percent(&host, url_host, url_host_len);
77
136
  }
78
137
 
79
138
  if (has_port) {
80
139
  const char *url_port = given + u.field_data[UF_PORT].off;
81
140
  size_t url_port_len = u.field_data[UF_PORT].len;
82
- git_buf_put(&port, url_port, url_port_len);
141
+ git_str_put(&port, url_port, url_port_len);
83
142
  } else {
84
143
  const char *default_port = default_port_for_scheme(scheme.ptr);
85
144
 
@@ -88,21 +147,21 @@ int git_net_url_parse(git_net_url *url, const char *given)
88
147
  goto done;
89
148
  }
90
149
 
91
- git_buf_puts(&port, default_port);
150
+ git_str_puts(&port, default_port);
92
151
  }
93
152
 
94
153
  if (has_path) {
95
154
  const char *url_path = given + u.field_data[UF_PATH].off;
96
155
  size_t url_path_len = u.field_data[UF_PATH].len;
97
- git_buf_put(&path, url_path, url_path_len);
156
+ git_str_put(&path, url_path, url_path_len);
98
157
  } else {
99
- git_buf_puts(&path, "/");
158
+ git_str_puts(&path, "/");
100
159
  }
101
160
 
102
161
  if (has_query) {
103
162
  const char *url_query = given + u.field_data[UF_QUERY].off;
104
163
  size_t url_query_len = u.field_data[UF_QUERY].len;
105
- git_buf_decode_percent(&query, url_query, url_query_len);
164
+ git_str_decode_percent(&query, url_query, url_query_len);
106
165
  }
107
166
 
108
167
  if (has_userinfo) {
@@ -116,49 +175,238 @@ int git_net_url_parse(git_net_url *url, const char *given)
116
175
  const char *url_password = colon + 1;
117
176
  size_t url_password_len = url_userinfo_len - (url_username_len + 1);
118
177
 
119
- git_buf_decode_percent(&username, url_username, url_username_len);
120
- git_buf_decode_percent(&password, url_password, url_password_len);
178
+ git_str_decode_percent(&username, url_username, url_username_len);
179
+ git_str_decode_percent(&password, url_password, url_password_len);
121
180
  } else {
122
- git_buf_decode_percent(&username, url_userinfo, url_userinfo_len);
181
+ git_str_decode_percent(&username, url_userinfo, url_userinfo_len);
123
182
  }
124
183
  }
125
184
 
126
- if (git_buf_oom(&scheme) ||
127
- git_buf_oom(&host) ||
128
- git_buf_oom(&port) ||
129
- git_buf_oom(&path) ||
130
- git_buf_oom(&query) ||
131
- git_buf_oom(&username) ||
132
- git_buf_oom(&password))
185
+ if (git_str_oom(&scheme) ||
186
+ git_str_oom(&host) ||
187
+ git_str_oom(&port) ||
188
+ git_str_oom(&path) ||
189
+ git_str_oom(&query) ||
190
+ git_str_oom(&username) ||
191
+ git_str_oom(&password))
133
192
  return -1;
134
193
 
135
- url->scheme = git_buf_detach(&scheme);
136
- url->host = git_buf_detach(&host);
137
- url->port = git_buf_detach(&port);
138
- url->path = git_buf_detach(&path);
139
- url->query = git_buf_detach(&query);
140
- url->username = git_buf_detach(&username);
141
- url->password = git_buf_detach(&password);
194
+ url->scheme = git_str_detach(&scheme);
195
+ url->host = git_str_detach(&host);
196
+ url->port = git_str_detach(&port);
197
+ url->path = git_str_detach(&path);
198
+ url->query = git_str_detach(&query);
199
+ url->username = git_str_detach(&username);
200
+ url->password = git_str_detach(&password);
142
201
 
143
202
  error = 0;
144
203
 
145
204
  done:
146
- git_buf_dispose(&scheme);
147
- git_buf_dispose(&host);
148
- git_buf_dispose(&port);
149
- git_buf_dispose(&path);
150
- git_buf_dispose(&query);
151
- git_buf_dispose(&username);
152
- git_buf_dispose(&password);
205
+ git_str_dispose(&scheme);
206
+ git_str_dispose(&host);
207
+ git_str_dispose(&port);
208
+ git_str_dispose(&path);
209
+ git_str_dispose(&query);
210
+ git_str_dispose(&username);
211
+ git_str_dispose(&password);
153
212
  return error;
154
213
  }
155
214
 
215
+ static int scp_invalid(const char *message)
216
+ {
217
+ git_error_set(GIT_ERROR_NET, "invalid scp-style path: %s", message);
218
+ return GIT_EINVALIDSPEC;
219
+ }
220
+
221
+ static bool is_ipv6(const char *str)
222
+ {
223
+ const char *c;
224
+ size_t colons = 0;
225
+
226
+ if (*str++ != '[')
227
+ return false;
228
+
229
+ for (c = str; *c; c++) {
230
+ if (*c == ':')
231
+ colons++;
232
+
233
+ if (*c == ']')
234
+ return (colons > 1);
235
+
236
+ if (*c != ':' &&
237
+ (*c < '0' || *c > '9') &&
238
+ (*c < 'a' || *c > 'f') &&
239
+ (*c < 'A' || *c > 'F'))
240
+ return false;
241
+ }
242
+
243
+ return false;
244
+ }
245
+
246
+ static bool has_at(const char *str)
247
+ {
248
+ const char *c;
249
+
250
+ for (c = str; *c; c++) {
251
+ if (*c == '@')
252
+ return true;
253
+
254
+ if (*c == ':')
255
+ break;
256
+ }
257
+
258
+ return false;
259
+ }
260
+
261
+ int git_net_url_parse_scp(git_net_url *url, const char *given)
262
+ {
263
+ const char *default_port = default_port_for_scheme("ssh");
264
+ const char *c, *user, *host, *port, *path = NULL;
265
+ size_t user_len = 0, host_len = 0, port_len = 0;
266
+ unsigned short bracket = 0;
267
+
268
+ enum {
269
+ NONE,
270
+ USER,
271
+ HOST_START, HOST, HOST_END,
272
+ IPV6, IPV6_END,
273
+ PORT_START, PORT, PORT_END,
274
+ PATH_START
275
+ } state = NONE;
276
+
277
+ memset(url, 0, sizeof(git_net_url));
278
+
279
+ for (c = given; *c && !path; c++) {
280
+ switch (state) {
281
+ case NONE:
282
+ switch (*c) {
283
+ case '@':
284
+ return scp_invalid("unexpected '@'");
285
+ case ':':
286
+ return scp_invalid("unexpected ':'");
287
+ case '[':
288
+ if (is_ipv6(c)) {
289
+ state = IPV6;
290
+ host = c;
291
+ } else if (bracket++ > 1) {
292
+ return scp_invalid("unexpected '['");
293
+ }
294
+ break;
295
+ default:
296
+ if (has_at(c)) {
297
+ state = USER;
298
+ user = c;
299
+ } else {
300
+ state = HOST;
301
+ host = c;
302
+ }
303
+ break;
304
+ }
305
+ break;
306
+
307
+ case USER:
308
+ if (*c == '@') {
309
+ user_len = (c - user);
310
+ state = HOST_START;
311
+ }
312
+ break;
313
+
314
+ case HOST_START:
315
+ state = (*c == '[') ? IPV6 : HOST;
316
+ host = c;
317
+ break;
318
+
319
+ case HOST:
320
+ if (*c == ':') {
321
+ host_len = (c - host);
322
+ state = bracket ? PORT_START : PATH_START;
323
+ } else if (*c == ']') {
324
+ if (bracket-- == 0)
325
+ return scp_invalid("unexpected ']'");
326
+
327
+ host_len = (c - host);
328
+ state = HOST_END;
329
+ }
330
+ break;
331
+
332
+ case HOST_END:
333
+ if (*c != ':')
334
+ return scp_invalid("unexpected character after hostname");
335
+ state = PATH_START;
336
+ break;
337
+
338
+ case IPV6:
339
+ if (*c == ']')
340
+ state = IPV6_END;
341
+ break;
342
+
343
+ case IPV6_END:
344
+ if (*c != ':')
345
+ return scp_invalid("unexpected character after ipv6 address");
346
+
347
+ host_len = (c - host);
348
+ state = bracket ? PORT_START : PATH_START;
349
+ break;
350
+
351
+ case PORT_START:
352
+ port = c;
353
+ state = PORT;
354
+ break;
355
+
356
+ case PORT:
357
+ if (*c == ']') {
358
+ if (bracket-- == 0)
359
+ return scp_invalid("unexpected ']'");
360
+
361
+ port_len = c - port;
362
+ state = PORT_END;
363
+ }
364
+ break;
365
+
366
+ case PORT_END:
367
+ if (*c != ':')
368
+ return scp_invalid("unexpected character after ipv6 address");
369
+
370
+ state = PATH_START;
371
+ break;
372
+
373
+ case PATH_START:
374
+ path = c;
375
+ break;
376
+
377
+ default:
378
+ GIT_ASSERT("unhandled state");
379
+ }
380
+ }
381
+
382
+ if (!path)
383
+ return scp_invalid("path is required");
384
+
385
+ GIT_ERROR_CHECK_ALLOC(url->scheme = git__strdup("ssh"));
386
+
387
+ if (user_len)
388
+ GIT_ERROR_CHECK_ALLOC(url->username = git__strndup(user, user_len));
389
+
390
+ GIT_ASSERT(host_len);
391
+ GIT_ERROR_CHECK_ALLOC(url->host = git__strndup(host, host_len));
392
+
393
+ if (port_len)
394
+ GIT_ERROR_CHECK_ALLOC(url->port = git__strndup(port, port_len));
395
+ else
396
+ GIT_ERROR_CHECK_ALLOC(url->port = git__strdup(default_port));
397
+
398
+ GIT_ASSERT(path);
399
+ GIT_ERROR_CHECK_ALLOC(url->path = git__strdup(path));
400
+
401
+ return 0;
402
+ }
403
+
156
404
  int git_net_url_joinpath(
157
405
  git_net_url *out,
158
406
  git_net_url *one,
159
407
  const char *two)
160
408
  {
161
- git_buf path = GIT_BUF_INIT;
409
+ git_str path = GIT_STR_INIT;
162
410
  const char *query;
163
411
  size_t one_len, two_len;
164
412
 
@@ -186,14 +434,14 @@ int git_net_url_joinpath(
186
434
  two_len--;
187
435
  }
188
436
 
189
- git_buf_put(&path, one->path, one_len);
190
- git_buf_putc(&path, '/');
191
- git_buf_put(&path, two, two_len);
437
+ git_str_put(&path, one->path, one_len);
438
+ git_str_putc(&path, '/');
439
+ git_str_put(&path, two, two_len);
192
440
 
193
- if (git_buf_oom(&path))
441
+ if (git_str_oom(&path))
194
442
  return -1;
195
443
 
196
- out->path = git_buf_detach(&path);
444
+ out->path = git_str_detach(&path);
197
445
 
198
446
  if (one->scheme) {
199
447
  out->scheme = git__strdup(one->scheme);
@@ -276,12 +524,14 @@ static void remove_service_suffix(
276
524
  int git_net_url_apply_redirect(
277
525
  git_net_url *url,
278
526
  const char *redirect_location,
527
+ bool allow_offsite,
279
528
  const char *service_suffix)
280
529
  {
281
530
  git_net_url tmp = GIT_NET_URL_INIT;
282
531
  int error = 0;
283
532
 
284
- assert(url && redirect_location);
533
+ GIT_ASSERT(url);
534
+ GIT_ASSERT(redirect_location);
285
535
 
286
536
  if (redirect_location[0] == '/') {
287
537
  git__free(url->path);
@@ -299,8 +549,8 @@ int git_net_url_apply_redirect(
299
549
  /* Validate that this is a legal redirection */
300
550
 
301
551
  if (original->scheme &&
302
- strcmp(original->scheme, tmp.scheme) != 0 &&
303
- strcmp(tmp.scheme, "https") != 0) {
552
+ strcmp(original->scheme, tmp.scheme) != 0 &&
553
+ strcmp(tmp.scheme, "https") != 0) {
304
554
  git_error_set(GIT_ERROR_NET, "cannot redirect from '%s' to '%s'",
305
555
  original->scheme, tmp.scheme);
306
556
 
@@ -309,6 +559,7 @@ int git_net_url_apply_redirect(
309
559
  }
310
560
 
311
561
  if (original->host &&
562
+ !allow_offsite &&
312
563
  git__strcasecmp(original->host, tmp.host) != 0) {
313
564
  git_error_set(GIT_ERROR_NET, "cannot redirect from '%s' to '%s'",
314
565
  original->host, tmp.host);
@@ -334,7 +585,7 @@ bool git_net_url_valid(git_net_url *url)
334
585
  return (url->host && url->port && url->path);
335
586
  }
336
587
 
337
- int git_net_url_is_default_port(git_net_url *url)
588
+ bool git_net_url_is_default_port(git_net_url *url)
338
589
  {
339
590
  const char *default_port;
340
591
 
@@ -344,6 +595,11 @@ int git_net_url_is_default_port(git_net_url *url)
344
595
  return false;
345
596
  }
346
597
 
598
+ bool git_net_url_is_ipv6(git_net_url *url)
599
+ {
600
+ return (strchr(url->host, ':') != NULL);
601
+ }
602
+
347
603
  void git_net_url_swap(git_net_url *a, git_net_url *b)
348
604
  {
349
605
  git_net_url tmp = GIT_NET_URL_INIT;
@@ -353,49 +609,127 @@ void git_net_url_swap(git_net_url *a, git_net_url *b)
353
609
  memcpy(b, &tmp, sizeof(git_net_url));
354
610
  }
355
611
 
356
- int git_net_url_fmt(git_buf *buf, git_net_url *url)
612
+ int git_net_url_fmt(git_str *buf, git_net_url *url)
357
613
  {
358
- git_buf_puts(buf, url->scheme);
359
- git_buf_puts(buf, "://");
614
+ GIT_ASSERT_ARG(url);
615
+ GIT_ASSERT_ARG(url->scheme);
616
+ GIT_ASSERT_ARG(url->host);
617
+
618
+ git_str_puts(buf, url->scheme);
619
+ git_str_puts(buf, "://");
360
620
 
361
621
  if (url->username) {
362
- git_buf_puts(buf, url->username);
622
+ git_str_puts(buf, url->username);
363
623
 
364
624
  if (url->password) {
365
- git_buf_puts(buf, ":");
366
- git_buf_puts(buf, url->password);
625
+ git_str_puts(buf, ":");
626
+ git_str_puts(buf, url->password);
367
627
  }
368
628
 
369
- git_buf_putc(buf, '@');
629
+ git_str_putc(buf, '@');
370
630
  }
371
631
 
372
- git_buf_puts(buf, url->host);
632
+ git_str_puts(buf, url->host);
373
633
 
374
634
  if (url->port && !git_net_url_is_default_port(url)) {
375
- git_buf_putc(buf, ':');
376
- git_buf_puts(buf, url->port);
635
+ git_str_putc(buf, ':');
636
+ git_str_puts(buf, url->port);
377
637
  }
378
638
 
379
- git_buf_puts(buf, url->path ? url->path : "/");
639
+ git_str_puts(buf, url->path ? url->path : "/");
380
640
 
381
641
  if (url->query) {
382
- git_buf_putc(buf, '?');
383
- git_buf_puts(buf, url->query);
642
+ git_str_putc(buf, '?');
643
+ git_str_puts(buf, url->query);
384
644
  }
385
645
 
386
- return git_buf_oom(buf) ? -1 : 0;
646
+ return git_str_oom(buf) ? -1 : 0;
387
647
  }
388
648
 
389
- int git_net_url_fmt_path(git_buf *buf, git_net_url *url)
649
+ int git_net_url_fmt_path(git_str *buf, git_net_url *url)
390
650
  {
391
- git_buf_puts(buf, url->path ? url->path : "/");
651
+ git_str_puts(buf, url->path ? url->path : "/");
392
652
 
393
653
  if (url->query) {
394
- git_buf_putc(buf, '?');
395
- git_buf_puts(buf, url->query);
654
+ git_str_putc(buf, '?');
655
+ git_str_puts(buf, url->query);
656
+ }
657
+
658
+ return git_str_oom(buf) ? -1 : 0;
659
+ }
660
+
661
+ static bool matches_pattern(
662
+ git_net_url *url,
663
+ const char *pattern,
664
+ size_t pattern_len)
665
+ {
666
+ const char *domain, *port = NULL, *colon;
667
+ size_t host_len, domain_len, port_len = 0, wildcard = 0;
668
+
669
+ GIT_UNUSED(url);
670
+ GIT_UNUSED(pattern);
671
+
672
+ if (!pattern_len)
673
+ return false;
674
+ else if (pattern_len == 1 && pattern[0] == '*')
675
+ return true;
676
+ else if (pattern_len > 1 && pattern[0] == '*' && pattern[1] == '.')
677
+ wildcard = 2;
678
+ else if (pattern[0] == '.')
679
+ wildcard = 1;
680
+
681
+ domain = pattern + wildcard;
682
+ domain_len = pattern_len - wildcard;
683
+
684
+ if ((colon = memchr(domain, ':', domain_len)) != NULL) {
685
+ domain_len = colon - domain;
686
+ port = colon + 1;
687
+ port_len = pattern_len - wildcard - domain_len - 1;
688
+ }
689
+
690
+ /* A pattern's port *must* match if it's specified */
691
+ if (port_len && git__strlcmp(url->port, port, port_len) != 0)
692
+ return false;
693
+
694
+ /* No wildcard? Host must match exactly. */
695
+ if (!wildcard)
696
+ return !git__strlcmp(url->host, domain, domain_len);
697
+
698
+ /* Wildcard: ensure there's (at least) a suffix match */
699
+ if ((host_len = strlen(url->host)) < domain_len ||
700
+ memcmp(url->host + (host_len - domain_len), domain, domain_len))
701
+ return false;
702
+
703
+ /* The pattern is *.domain and the host is simply domain */
704
+ if (host_len == domain_len)
705
+ return true;
706
+
707
+ /* The pattern is *.domain and the host is foo.domain */
708
+ return (url->host[host_len - domain_len - 1] == '.');
709
+ }
710
+
711
+ bool git_net_url_matches_pattern(git_net_url *url, const char *pattern)
712
+ {
713
+ return matches_pattern(url, pattern, strlen(pattern));
714
+ }
715
+
716
+ bool git_net_url_matches_pattern_list(
717
+ git_net_url *url,
718
+ const char *pattern_list)
719
+ {
720
+ const char *pattern, *pattern_end, *sep;
721
+
722
+ for (pattern = pattern_list;
723
+ pattern && *pattern;
724
+ pattern = sep ? sep + 1 : NULL) {
725
+ sep = strchr(pattern, ',');
726
+ pattern_end = sep ? sep : strchr(pattern, '\0');
727
+
728
+ if (matches_pattern(url, pattern, (pattern_end - pattern)))
729
+ return true;
396
730
  }
397
731
 
398
- return git_buf_oom(buf) ? -1 : 0;
732
+ return false;
399
733
  }
400
734
 
401
735
  void git_net_url_dispose(git_net_url *url)
@@ -21,9 +21,18 @@ typedef struct git_net_url {
21
21
 
22
22
  #define GIT_NET_URL_INIT { NULL }
23
23
 
24
- /** Parses a string containing a URL into a structure. */
24
+ /** Is a given string a url? */
25
+ extern bool git_net_str_is_url(const char *str);
26
+
27
+ /** Duplicate a URL */
28
+ extern int git_net_url_dup(git_net_url *out, git_net_url *in);
29
+
30
+ /** Parses a string containing a URL into a structure. */
25
31
  extern int git_net_url_parse(git_net_url *url, const char *str);
26
32
 
33
+ /** Parses a string containing an SCP style path into a URL structure. */
34
+ extern int git_net_url_parse_scp(git_net_url *url, const char *str);
35
+
27
36
  /** Appends a path and/or query string to the given URL */
28
37
  extern int git_net_url_joinpath(
29
38
  git_net_url *out,
@@ -33,23 +42,35 @@ extern int git_net_url_joinpath(
33
42
  /** Ensures that a URL is minimally valid (contains a host, port and path) */
34
43
  extern bool git_net_url_valid(git_net_url *url);
35
44
 
36
- /** Returns nonzero if the URL is on the default port. */
37
- extern int git_net_url_is_default_port(git_net_url *url);
45
+ /** Returns true if the URL is on the default port. */
46
+ extern bool git_net_url_is_default_port(git_net_url *url);
47
+
48
+ /** Returns true if the host portion of the URL is an ipv6 address. */
49
+ extern bool git_net_url_is_ipv6(git_net_url *url);
38
50
 
39
51
  /* Applies a redirect to the URL with a git-aware service suffix. */
40
52
  extern int git_net_url_apply_redirect(
41
53
  git_net_url *url,
42
54
  const char *redirect_location,
55
+ bool allow_offsite,
43
56
  const char *service_suffix);
44
57
 
45
58
  /** Swaps the contents of one URL for another. */
46
59
  extern void git_net_url_swap(git_net_url *a, git_net_url *b);
47
60
 
48
61
  /** Places the URL into the given buffer. */
49
- extern int git_net_url_fmt(git_buf *out, git_net_url *url);
62
+ extern int git_net_url_fmt(git_str *out, git_net_url *url);
50
63
 
51
64
  /** Place the path and query string into the given buffer. */
52
- extern int git_net_url_fmt_path(git_buf *buf, git_net_url *url);
65
+ extern int git_net_url_fmt_path(git_str *buf, git_net_url *url);
66
+
67
+ /** Determines if the url matches given pattern or pattern list */
68
+ extern bool git_net_url_matches_pattern(
69
+ git_net_url *url,
70
+ const char *pattern);
71
+ extern bool git_net_url_matches_pattern_list(
72
+ git_net_url *url,
73
+ const char *pattern_list);
53
74
 
54
75
  /** Disposes the contents of the structure. */
55
76
  extern void git_net_url_dispose(git_net_url *url);