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
@@ -7,24 +7,26 @@
7
7
 
8
8
  #include "filter.h"
9
9
 
10
+ #include "buf.h"
10
11
  #include "common.h"
11
12
  #include "futils.h"
12
13
  #include "hash.h"
13
14
  #include "repository.h"
14
- #include "global.h"
15
+ #include "runtime.h"
15
16
  #include "git2/sys/filter.h"
16
17
  #include "git2/config.h"
17
18
  #include "blob.h"
18
19
  #include "attr_file.h"
19
20
  #include "array.h"
21
+ #include "path.h"
20
22
 
21
23
  struct git_filter_source {
22
- git_repository *repo;
23
- const char *path;
24
- git_oid oid; /* zero if unknown (which is likely) */
25
- uint16_t filemode; /* zero if unknown */
26
- git_filter_mode_t mode;
27
- uint32_t flags;
24
+ git_repository *repo;
25
+ const char *path;
26
+ git_oid oid; /* zero if unknown (which is likely) */
27
+ uint16_t filemode; /* zero if unknown */
28
+ git_filter_mode_t mode;
29
+ git_filter_options options;
28
30
  };
29
31
 
30
32
  typedef struct {
@@ -36,7 +38,7 @@ typedef struct {
36
38
  struct git_filter_list {
37
39
  git_array_t(git_filter_entry) filters;
38
40
  git_filter_source source;
39
- git_buf *temp_buf;
41
+ git_str *temp_buf;
40
42
  char path[GIT_FLEX_ARRAY];
41
43
  };
42
44
 
@@ -68,7 +70,7 @@ static void git_filter_global_shutdown(void);
68
70
 
69
71
 
70
72
  static int filter_def_scan_attrs(
71
- git_buf *attrs, size_t *nattr, size_t *nmatch, const char *attr_str)
73
+ git_str *attrs, size_t *nattr, size_t *nmatch, const char *attr_str)
72
74
  {
73
75
  const char *start, *scan = attr_str;
74
76
  int has_eq;
@@ -92,9 +94,9 @@ static int filter_def_scan_attrs(
92
94
  (*nmatch)++;
93
95
 
94
96
  if (has_eq)
95
- git_buf_putc(attrs, '=');
96
- git_buf_put(attrs, start, scan - start);
97
- git_buf_putc(attrs, '\0');
97
+ git_str_putc(attrs, '=');
98
+ git_str_put(attrs, start, scan - start);
99
+ git_str_putc(attrs, '\0');
98
100
  }
99
101
  }
100
102
 
@@ -152,7 +154,7 @@ static int filter_registry_insert(
152
154
  {
153
155
  git_filter_def *fdef;
154
156
  size_t nattr = 0, nmatch = 0, alloc_len;
155
- git_buf attrs = GIT_BUF_INIT;
157
+ git_str attrs = GIT_STR_INIT;
156
158
 
157
159
  if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0)
158
160
  return -1;
@@ -171,7 +173,7 @@ static int filter_registry_insert(
171
173
  fdef->priority = priority;
172
174
  fdef->nattrs = nattr;
173
175
  fdef->nmatches = nmatch;
174
- fdef->attrdata = git_buf_detach(&attrs);
176
+ fdef->attrdata = git_str_detach(&attrs);
175
177
 
176
178
  filter_def_set_attrs(fdef);
177
179
 
@@ -206,7 +208,8 @@ int git_filter_global_init(void)
206
208
  GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
207
209
  error = -1;
208
210
 
209
- git__on_shutdown(git_filter_global_shutdown);
211
+ if (!error)
212
+ error = git_runtime_shutdown_register(git_filter_global_shutdown);
210
213
 
211
214
  done:
212
215
  if (error) {
@@ -266,7 +269,8 @@ int git_filter_register(
266
269
  {
267
270
  int error;
268
271
 
269
- assert(name && filter);
272
+ GIT_ASSERT_ARG(name);
273
+ GIT_ASSERT_ARG(filter);
270
274
 
271
275
  if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
272
276
  git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -293,7 +297,7 @@ int git_filter_unregister(const char *name)
293
297
  git_filter_def *fdef;
294
298
  int error = 0;
295
299
 
296
- assert(name);
300
+ GIT_ASSERT_ARG(name);
297
301
 
298
302
  /* cannot unregister default filters */
299
303
  if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
@@ -395,7 +399,7 @@ git_filter_mode_t git_filter_source_mode(const git_filter_source *src)
395
399
 
396
400
  uint32_t git_filter_source_flags(const git_filter_source *src)
397
401
  {
398
- return src->flags;
402
+ return src->options.flags;
399
403
  }
400
404
 
401
405
  static int filter_list_new(
@@ -415,7 +419,8 @@ static int filter_list_new(
415
419
  fl->source.repo = src->repo;
416
420
  fl->source.path = fl->path;
417
421
  fl->source.mode = src->mode;
418
- fl->source.flags = src->flags;
422
+
423
+ memcpy(&fl->source.options, &src->options, sizeof(git_filter_options));
419
424
 
420
425
  *out = fl;
421
426
  return 0;
@@ -424,25 +429,36 @@ static int filter_list_new(
424
429
  static int filter_list_check_attributes(
425
430
  const char ***out,
426
431
  git_repository *repo,
427
- git_attr_session *attr_session,
432
+ git_filter_session *filter_session,
428
433
  git_filter_def *fdef,
429
434
  const git_filter_source *src)
430
435
  {
431
436
  const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
432
- uint32_t flags = 0;
437
+ git_attr_options attr_opts = GIT_ATTR_OPTIONS_INIT;
433
438
  size_t i;
434
439
  int error;
435
440
 
436
441
  GIT_ERROR_CHECK_ALLOC(strs);
437
442
 
438
- if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
439
- flags |= GIT_ATTR_CHECK_NO_SYSTEM;
443
+ if ((src->options.flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
444
+ attr_opts.flags |= GIT_ATTR_CHECK_NO_SYSTEM;
445
+
446
+ if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
447
+ attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
448
+
449
+ if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
450
+ attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_COMMIT;
440
451
 
441
- if ((src->flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
442
- flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
452
+ #ifndef GIT_DEPRECATE_HARD
453
+ if (src->options.commit_id)
454
+ git_oid_cpy(&attr_opts.attr_commit_id, src->options.commit_id);
455
+ else
456
+ #endif
457
+ git_oid_cpy(&attr_opts.attr_commit_id, &src->options.attr_commit_id);
458
+ }
443
459
 
444
460
  error = git_attr_get_many_with_session(
445
- strs, repo, attr_session, flags, src->path, fdef->nattrs, fdef->attrs);
461
+ strs, repo, filter_session->attr_session, &attr_opts, src->path, fdef->nattrs, fdef->attrs);
446
462
 
447
463
  /* if no values were found but no matches are needed, it's okay! */
448
464
  if (error == GIT_ENOTFOUND && !fdef->nmatches) {
@@ -487,17 +503,17 @@ int git_filter_list_new(
487
503
  src.repo = repo;
488
504
  src.path = NULL;
489
505
  src.mode = mode;
490
- src.flags = flags;
506
+ src.options.flags = flags;
491
507
  return filter_list_new(out, &src);
492
508
  }
493
509
 
494
- int git_filter_list__load_ext(
510
+ int git_filter_list__load(
495
511
  git_filter_list **filters,
496
512
  git_repository *repo,
497
513
  git_blob *blob, /* can be NULL */
498
514
  const char *path,
499
515
  git_filter_mode_t mode,
500
- git_filter_options *filter_opts)
516
+ git_filter_session *filter_session)
501
517
  {
502
518
  int error = 0;
503
519
  git_filter_list *fl = NULL;
@@ -514,7 +530,8 @@ int git_filter_list__load_ext(
514
530
  src.repo = repo;
515
531
  src.path = path;
516
532
  src.mode = mode;
517
- src.flags = filter_opts->flags;
533
+
534
+ memcpy(&src.options, &filter_session->options, sizeof(git_filter_options));
518
535
 
519
536
  if (blob)
520
537
  git_oid_cpy(&src.oid, git_blob_id(blob));
@@ -528,7 +545,8 @@ int git_filter_list__load_ext(
528
545
 
529
546
  if (fdef->nattrs > 0) {
530
547
  error = filter_list_check_attributes(
531
- &values, repo, filter_opts->attr_session, fdef, &src);
548
+ &values, repo,
549
+ filter_session, fdef, &src);
532
550
 
533
551
  if (error == GIT_ENOTFOUND) {
534
552
  error = 0;
@@ -555,7 +573,7 @@ int git_filter_list__load_ext(
555
573
  if ((error = filter_list_new(&fl, &src)) < 0)
556
574
  break;
557
575
 
558
- fl->temp_buf = filter_opts->temp_buf;
576
+ fl->temp_buf = filter_session->temp_buf;
559
577
  }
560
578
 
561
579
  fe = git_array_alloc(fl->filters);
@@ -579,6 +597,23 @@ int git_filter_list__load_ext(
579
597
  return error;
580
598
  }
581
599
 
600
+ int git_filter_list_load_ext(
601
+ git_filter_list **filters,
602
+ git_repository *repo,
603
+ git_blob *blob, /* can be NULL */
604
+ const char *path,
605
+ git_filter_mode_t mode,
606
+ git_filter_options *opts)
607
+ {
608
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
609
+
610
+ if (opts)
611
+ memcpy(&filter_session.options, opts, sizeof(git_filter_options));
612
+
613
+ return git_filter_list__load(
614
+ filters, repo, blob, path, mode, &filter_session);
615
+ }
616
+
582
617
  int git_filter_list_load(
583
618
  git_filter_list **filters,
584
619
  git_repository *repo,
@@ -587,12 +622,12 @@ int git_filter_list_load(
587
622
  git_filter_mode_t mode,
588
623
  uint32_t flags)
589
624
  {
590
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
625
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
591
626
 
592
- filter_opts.flags = flags;
627
+ filter_session.options.flags = flags;
593
628
 
594
- return git_filter_list__load_ext(
595
- filters, repo, blob, path, mode, &filter_opts);
629
+ return git_filter_list__load(
630
+ filters, repo, blob, path, mode, &filter_session);
596
631
  }
597
632
 
598
633
  void git_filter_list_free(git_filter_list *fl)
@@ -618,7 +653,7 @@ int git_filter_list_contains(
618
653
  {
619
654
  size_t i;
620
655
 
621
- assert(name);
656
+ GIT_ASSERT_ARG(name);
622
657
 
623
658
  if (!fl)
624
659
  return 0;
@@ -639,7 +674,8 @@ int git_filter_list_push(
639
674
  git_filter_def *fdef = NULL;
640
675
  git_filter_entry *fe;
641
676
 
642
- assert(fl && filter);
677
+ GIT_ASSERT_ARG(fl);
678
+ GIT_ASSERT_ARG(filter);
643
679
 
644
680
  if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
645
681
  git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -676,7 +712,7 @@ size_t git_filter_list_length(const git_filter_list *fl)
676
712
 
677
713
  struct buf_stream {
678
714
  git_writestream parent;
679
- git_buf *target;
715
+ git_str *target;
680
716
  bool complete;
681
717
  };
682
718
 
@@ -684,19 +720,18 @@ static int buf_stream_write(
684
720
  git_writestream *s, const char *buffer, size_t len)
685
721
  {
686
722
  struct buf_stream *buf_stream = (struct buf_stream *)s;
687
- assert(buf_stream);
688
-
689
- assert(buf_stream->complete == 0);
723
+ GIT_ASSERT_ARG(buf_stream);
724
+ GIT_ASSERT(buf_stream->complete == 0);
690
725
 
691
- return git_buf_put(buf_stream->target, buffer, len);
726
+ return git_str_put(buf_stream->target, buffer, len);
692
727
  }
693
728
 
694
729
  static int buf_stream_close(git_writestream *s)
695
730
  {
696
731
  struct buf_stream *buf_stream = (struct buf_stream *)s;
697
- assert(buf_stream);
732
+ GIT_ASSERT_ARG(buf_stream);
698
733
 
699
- assert(buf_stream->complete == 0);
734
+ GIT_ASSERT(buf_stream->complete == 0);
700
735
  buf_stream->complete = 1;
701
736
 
702
737
  return 0;
@@ -707,7 +742,7 @@ static void buf_stream_free(git_writestream *s)
707
742
  GIT_UNUSED(s);
708
743
  }
709
744
 
710
- static void buf_stream_init(struct buf_stream *writer, git_buf *target)
745
+ static void buf_stream_init(struct buf_stream *writer, git_str *target)
711
746
  {
712
747
  memset(writer, 0, sizeof(struct buf_stream));
713
748
 
@@ -716,30 +751,56 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
716
751
  writer->parent.free = buf_stream_free;
717
752
  writer->target = target;
718
753
 
719
- git_buf_clear(target);
754
+ git_str_clear(target);
720
755
  }
721
756
 
722
- int git_filter_list_apply_to_data(
723
- git_buf *tgt, git_filter_list *filters, git_buf *src)
757
+ int git_filter_list_apply_to_buffer(
758
+ git_buf *out,
759
+ git_filter_list *filters,
760
+ const char *in,
761
+ size_t in_len)
762
+ {
763
+ GIT_BUF_WRAP_PRIVATE(out, git_filter_list__apply_to_buffer, filters, in, in_len);
764
+ }
765
+
766
+ int git_filter_list__apply_to_buffer(
767
+ git_str *out,
768
+ git_filter_list *filters,
769
+ const char *in,
770
+ size_t in_len)
724
771
  {
725
772
  struct buf_stream writer;
726
773
  int error;
727
774
 
728
- git_buf_sanitize(tgt);
729
- git_buf_sanitize(src);
775
+ buf_stream_init(&writer, out);
776
+
777
+ if ((error = git_filter_list_stream_buffer(filters,
778
+ in, in_len, &writer.parent)) < 0)
779
+ return error;
730
780
 
731
- if (!filters) {
732
- git_buf_attach_notowned(tgt, src->ptr, src->size);
781
+ GIT_ASSERT(writer.complete);
782
+ return error;
783
+ }
784
+
785
+ int git_filter_list__convert_buf(
786
+ git_str *out,
787
+ git_filter_list *filters,
788
+ git_str *in)
789
+ {
790
+ int error;
791
+
792
+ if (!filters || git_filter_list_length(filters) == 0) {
793
+ git_str_swap(out, in);
794
+ git_str_dispose(in);
733
795
  return 0;
734
796
  }
735
797
 
736
- buf_stream_init(&writer, tgt);
798
+ error = git_filter_list__apply_to_buffer(out, filters,
799
+ in->ptr, in->size);
737
800
 
738
- if ((error = git_filter_list_stream_data(filters, src,
739
- &writer.parent)) < 0)
740
- return error;
801
+ if (!error)
802
+ git_str_dispose(in);
741
803
 
742
- assert(writer.complete);
743
804
  return error;
744
805
  }
745
806
 
@@ -748,6 +809,15 @@ int git_filter_list_apply_to_file(
748
809
  git_filter_list *filters,
749
810
  git_repository *repo,
750
811
  const char *path)
812
+ {
813
+ GIT_BUF_WRAP_PRIVATE(out, git_filter_list__apply_to_file, filters, repo, path);
814
+ }
815
+
816
+ int git_filter_list__apply_to_file(
817
+ git_str *out,
818
+ git_filter_list *filters,
819
+ git_repository *repo,
820
+ const char *path)
751
821
  {
752
822
  struct buf_stream writer;
753
823
  int error;
@@ -758,11 +828,11 @@ int git_filter_list_apply_to_file(
758
828
  filters, repo, path, &writer.parent)) < 0)
759
829
  return error;
760
830
 
761
- assert(writer.complete);
831
+ GIT_ASSERT(writer.complete);
762
832
  return error;
763
833
  }
764
834
 
765
- static int buf_from_blob(git_buf *out, git_blob *blob)
835
+ static int buf_from_blob(git_str *out, git_blob *blob)
766
836
  {
767
837
  git_object_size_t rawsize = git_blob_rawsize(blob);
768
838
 
@@ -771,7 +841,7 @@ static int buf_from_blob(git_buf *out, git_blob *blob)
771
841
  return -1;
772
842
  }
773
843
 
774
- git_buf_attach_notowned(out, git_blob_rawcontent(blob), (size_t)rawsize);
844
+ git_str_attach_notowned(out, git_blob_rawcontent(blob), (size_t)rawsize);
775
845
  return 0;
776
846
  }
777
847
 
@@ -779,6 +849,14 @@ int git_filter_list_apply_to_blob(
779
849
  git_buf *out,
780
850
  git_filter_list *filters,
781
851
  git_blob *blob)
852
+ {
853
+ GIT_BUF_WRAP_PRIVATE(out, git_filter_list__apply_to_blob, filters, blob);
854
+ }
855
+
856
+ int git_filter_list__apply_to_blob(
857
+ git_str *out,
858
+ git_filter_list *filters,
859
+ git_blob *blob)
782
860
  {
783
861
  struct buf_stream writer;
784
862
  int error;
@@ -789,103 +867,164 @@ int git_filter_list_apply_to_blob(
789
867
  filters, blob, &writer.parent)) < 0)
790
868
  return error;
791
869
 
792
- assert(writer.complete);
870
+ GIT_ASSERT(writer.complete);
793
871
  return error;
794
872
  }
795
873
 
796
- struct proxy_stream {
874
+ struct buffered_stream {
797
875
  git_writestream parent;
798
876
  git_filter *filter;
877
+ int (*write_fn)(git_filter *, void **, git_str *, const git_str *, const git_filter_source *);
878
+ int (*legacy_write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *);
799
879
  const git_filter_source *source;
800
880
  void **payload;
801
- git_buf input;
802
- git_buf temp_buf;
803
- git_buf *output;
881
+ git_str input;
882
+ git_str temp_buf;
883
+ git_str *output;
804
884
  git_writestream *target;
805
885
  };
806
886
 
807
- static int proxy_stream_write(
887
+ static int buffered_stream_write(
808
888
  git_writestream *s, const char *buffer, size_t len)
809
889
  {
810
- struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
811
- assert(proxy_stream);
890
+ struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
891
+ GIT_ASSERT_ARG(buffered_stream);
812
892
 
813
- return git_buf_put(&proxy_stream->input, buffer, len);
893
+ return git_str_put(&buffered_stream->input, buffer, len);
814
894
  }
815
895
 
816
- static int proxy_stream_close(git_writestream *s)
896
+ static int buffered_stream_close(git_writestream *s)
817
897
  {
818
- struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
819
- git_buf *writebuf;
898
+ struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
899
+ git_str *writebuf;
820
900
  git_error_state error_state = {0};
821
901
  int error;
822
902
 
823
- assert(proxy_stream);
903
+ GIT_ASSERT_ARG(buffered_stream);
824
904
 
825
- error = proxy_stream->filter->apply(
826
- proxy_stream->filter,
827
- proxy_stream->payload,
828
- proxy_stream->output,
829
- &proxy_stream->input,
830
- proxy_stream->source);
905
+ error = buffered_stream->write_fn(
906
+ buffered_stream->filter,
907
+ buffered_stream->payload,
908
+ buffered_stream->output,
909
+ &buffered_stream->input,
910
+ buffered_stream->source);
831
911
 
832
912
  if (error == GIT_PASSTHROUGH) {
833
- writebuf = &proxy_stream->input;
913
+ writebuf = &buffered_stream->input;
834
914
  } else if (error == 0) {
835
- git_buf_sanitize(proxy_stream->output);
836
- writebuf = proxy_stream->output;
915
+ writebuf = buffered_stream->output;
837
916
  } else {
838
917
  /* close stream before erroring out taking care
839
918
  * to preserve the original error */
840
919
  git_error_state_capture(&error_state, error);
841
- proxy_stream->target->close(proxy_stream->target);
920
+ buffered_stream->target->close(buffered_stream->target);
842
921
  git_error_state_restore(&error_state);
843
922
  return error;
844
923
  }
845
924
 
846
- if ((error = proxy_stream->target->write(
847
- proxy_stream->target, writebuf->ptr, writebuf->size)) == 0)
848
- error = proxy_stream->target->close(proxy_stream->target);
925
+ if ((error = buffered_stream->target->write(
926
+ buffered_stream->target, writebuf->ptr, writebuf->size)) == 0)
927
+ error = buffered_stream->target->close(buffered_stream->target);
849
928
 
850
929
  return error;
851
930
  }
852
931
 
853
- static void proxy_stream_free(git_writestream *s)
932
+ static void buffered_stream_free(git_writestream *s)
933
+ {
934
+ struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
935
+
936
+ if (buffered_stream) {
937
+ git_str_dispose(&buffered_stream->input);
938
+ git_str_dispose(&buffered_stream->temp_buf);
939
+ git__free(buffered_stream);
940
+ }
941
+ }
942
+
943
+ int git_filter_buffered_stream_new(
944
+ git_writestream **out,
945
+ git_filter *filter,
946
+ int (*write_fn)(git_filter *, void **, git_str *, const git_str *, const git_filter_source *),
947
+ git_str *temp_buf,
948
+ void **payload,
949
+ const git_filter_source *source,
950
+ git_writestream *target)
854
951
  {
855
- struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
856
- assert(proxy_stream);
952
+ struct buffered_stream *buffered_stream = git__calloc(1, sizeof(struct buffered_stream));
953
+ GIT_ERROR_CHECK_ALLOC(buffered_stream);
954
+
955
+ buffered_stream->parent.write = buffered_stream_write;
956
+ buffered_stream->parent.close = buffered_stream_close;
957
+ buffered_stream->parent.free = buffered_stream_free;
958
+ buffered_stream->filter = filter;
959
+ buffered_stream->write_fn = write_fn;
960
+ buffered_stream->output = temp_buf ? temp_buf : &buffered_stream->temp_buf;
961
+ buffered_stream->payload = payload;
962
+ buffered_stream->source = source;
963
+ buffered_stream->target = target;
964
+
965
+ if (temp_buf)
966
+ git_str_clear(temp_buf);
857
967
 
858
- git_buf_dispose(&proxy_stream->input);
859
- git_buf_dispose(&proxy_stream->temp_buf);
860
- git__free(proxy_stream);
968
+ *out = (git_writestream *)buffered_stream;
969
+ return 0;
861
970
  }
862
971
 
863
- static int proxy_stream_init(
972
+ #ifndef GIT_DEPRECATE_HARD
973
+ static int buffered_legacy_stream_new(
864
974
  git_writestream **out,
865
975
  git_filter *filter,
866
- git_buf *temp_buf,
976
+ int (*legacy_write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *),
977
+ git_str *temp_buf,
867
978
  void **payload,
868
979
  const git_filter_source *source,
869
980
  git_writestream *target)
870
981
  {
871
- struct proxy_stream *proxy_stream = git__calloc(1, sizeof(struct proxy_stream));
872
- GIT_ERROR_CHECK_ALLOC(proxy_stream);
873
-
874
- proxy_stream->parent.write = proxy_stream_write;
875
- proxy_stream->parent.close = proxy_stream_close;
876
- proxy_stream->parent.free = proxy_stream_free;
877
- proxy_stream->filter = filter;
878
- proxy_stream->payload = payload;
879
- proxy_stream->source = source;
880
- proxy_stream->target = target;
881
- proxy_stream->output = temp_buf ? temp_buf : &proxy_stream->temp_buf;
982
+ struct buffered_stream *buffered_stream = git__calloc(1, sizeof(struct buffered_stream));
983
+ GIT_ERROR_CHECK_ALLOC(buffered_stream);
984
+
985
+ buffered_stream->parent.write = buffered_stream_write;
986
+ buffered_stream->parent.close = buffered_stream_close;
987
+ buffered_stream->parent.free = buffered_stream_free;
988
+ buffered_stream->filter = filter;
989
+ buffered_stream->legacy_write_fn = legacy_write_fn;
990
+ buffered_stream->output = temp_buf ? temp_buf : &buffered_stream->temp_buf;
991
+ buffered_stream->payload = payload;
992
+ buffered_stream->source = source;
993
+ buffered_stream->target = target;
882
994
 
883
995
  if (temp_buf)
884
- git_buf_clear(temp_buf);
996
+ git_str_clear(temp_buf);
885
997
 
886
- *out = (git_writestream *)proxy_stream;
998
+ *out = (git_writestream *)buffered_stream;
887
999
  return 0;
888
1000
  }
1001
+ #endif
1002
+
1003
+ static int setup_stream(
1004
+ git_writestream **out,
1005
+ git_filter_entry *fe,
1006
+ git_filter_list *filters,
1007
+ git_writestream *last_stream)
1008
+ {
1009
+ #ifndef GIT_DEPRECATE_HARD
1010
+ GIT_ASSERT(fe->filter->stream || fe->filter->apply);
1011
+
1012
+ /*
1013
+ * If necessary, create a stream that proxies the traditional
1014
+ * application.
1015
+ */
1016
+ if (!fe->filter->stream) {
1017
+ /* Create a stream that proxies the one-shot apply */
1018
+ return buffered_legacy_stream_new(out,
1019
+ fe->filter, fe->filter->apply, filters->temp_buf,
1020
+ &fe->payload, &filters->source, last_stream);
1021
+ }
1022
+ #endif
1023
+
1024
+ GIT_ASSERT(fe->filter->stream);
1025
+ return fe->filter->stream(out, fe->filter,
1026
+ &fe->payload, &filters->source, last_stream);
1027
+ }
889
1028
 
890
1029
  static int stream_list_init(
891
1030
  git_writestream **out,
@@ -908,22 +1047,11 @@ static int stream_list_init(
908
1047
  for (i = 0; i < git_array_size(filters->filters); ++i) {
909
1048
  size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ?
910
1049
  git_array_size(filters->filters) - 1 - i : i;
1050
+
911
1051
  git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
912
1052
  git_writestream *filter_stream;
913
1053
 
914
- assert(fe->filter->stream || fe->filter->apply);
915
-
916
- /* If necessary, create a stream that proxies the traditional
917
- * application.
918
- */
919
- if (fe->filter->stream)
920
- error = fe->filter->stream(&filter_stream, fe->filter,
921
- &fe->payload, &filters->source, last_stream);
922
- else
923
- /* Create a stream that proxies the one-shot apply */
924
- error = proxy_stream_init(&filter_stream, fe->filter,
925
- filters->temp_buf, &fe->payload, &filters->source,
926
- last_stream);
1054
+ error = setup_stream(&filter_stream, fe, filters, last_stream);
927
1055
 
928
1056
  if (error < 0)
929
1057
  goto out;
@@ -958,7 +1086,7 @@ int git_filter_list_stream_file(
958
1086
  git_writestream *target)
959
1087
  {
960
1088
  char buf[FILTERIO_BUFSIZE];
961
- git_buf abspath = GIT_BUF_INIT;
1089
+ git_str abspath = GIT_STR_INIT;
962
1090
  const char *base = repo ? git_repository_workdir(repo) : NULL;
963
1091
  git_vector filter_streams = GIT_VECTOR_INIT;
964
1092
  git_writestream *stream_start;
@@ -967,8 +1095,10 @@ int git_filter_list_stream_file(
967
1095
 
968
1096
  if ((error = stream_list_init(
969
1097
  &stream_start, &filter_streams, filters, target)) < 0 ||
970
- (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0)
1098
+ (error = git_fs_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
1099
+ (error = git_path_validate_str_length(repo, &abspath)) < 0)
971
1100
  goto done;
1101
+
972
1102
  initialized = 1;
973
1103
 
974
1104
  if ((fd = git_futils_open_ro(abspath.ptr)) < 0) {
@@ -991,27 +1121,25 @@ done:
991
1121
  if (fd >= 0)
992
1122
  p_close(fd);
993
1123
  filter_streams_free(&filter_streams);
994
- git_buf_dispose(&abspath);
1124
+ git_str_dispose(&abspath);
995
1125
  return error;
996
1126
  }
997
1127
 
998
- int git_filter_list_stream_data(
1128
+ int git_filter_list_stream_buffer(
999
1129
  git_filter_list *filters,
1000
- git_buf *data,
1130
+ const char *buffer,
1131
+ size_t len,
1001
1132
  git_writestream *target)
1002
1133
  {
1003
1134
  git_vector filter_streams = GIT_VECTOR_INIT;
1004
1135
  git_writestream *stream_start;
1005
1136
  int error, initialized = 0;
1006
1137
 
1007
- git_buf_sanitize(data);
1008
-
1009
1138
  if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
1010
1139
  goto out;
1011
1140
  initialized = 1;
1012
1141
 
1013
- if ((error = stream_start->write(
1014
- stream_start, data->ptr, data->size)) < 0)
1142
+ if ((error = stream_start->write(stream_start, buffer, len)) < 0)
1015
1143
  goto out;
1016
1144
 
1017
1145
  out:
@@ -1027,7 +1155,7 @@ int git_filter_list_stream_blob(
1027
1155
  git_blob *blob,
1028
1156
  git_writestream *target)
1029
1157
  {
1030
- git_buf in = GIT_BUF_INIT;
1158
+ git_str in = GIT_STR_INIT;
1031
1159
 
1032
1160
  if (buf_from_blob(&in, blob) < 0)
1033
1161
  return -1;
@@ -1035,7 +1163,7 @@ int git_filter_list_stream_blob(
1035
1163
  if (filters)
1036
1164
  git_oid_cpy(&filters->source.oid, git_blob_id(blob));
1037
1165
 
1038
- return git_filter_list_stream_data(filters, &in, target);
1166
+ return git_filter_list_stream_buffer(filters, in.ptr, in.size, target);
1039
1167
  }
1040
1168
 
1041
1169
  int git_filter_init(git_filter *filter, unsigned int version)
@@ -1043,3 +1171,21 @@ int git_filter_init(git_filter *filter, unsigned int version)
1043
1171
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);
1044
1172
  return 0;
1045
1173
  }
1174
+
1175
+ #ifndef GIT_DEPRECATE_HARD
1176
+
1177
+ int git_filter_list_stream_data(
1178
+ git_filter_list *filters,
1179
+ git_buf *data,
1180
+ git_writestream *target)
1181
+ {
1182
+ return git_filter_list_stream_buffer(filters, data->ptr, data->size, target);
1183
+ }
1184
+
1185
+ int git_filter_list_apply_to_data(
1186
+ git_buf *tgt, git_filter_list *filters, git_buf *src)
1187
+ {
1188
+ return git_filter_list_apply_to_buffer(tgt, filters, src->ptr, src->size);
1189
+ }
1190
+
1191
+ #endif