rugged 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (338) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +3 -3
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_commit.c +1 -1
  6. data/ext/rugged/rugged_config.c +1 -1
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +32 -2
  9. data/ext/rugged/rugged_repo.c +13 -3
  10. data/lib/rugged/commit.rb +17 -4
  11. data/lib/rugged/repository.rb +7 -8
  12. data/lib/rugged/submodule_collection.rb +4 -4
  13. data/lib/rugged/version.rb +1 -1
  14. data/vendor/libgit2/CMakeLists.txt +41 -74
  15. data/vendor/libgit2/COPYING +109 -1
  16. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  20. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  21. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  23. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  24. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  25. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  26. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  27. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  30. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  31. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  32. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  33. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  34. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
  35. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
  36. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  37. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  38. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
  39. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
  40. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  41. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  42. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  43. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  44. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  45. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  46. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  47. data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
  48. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  49. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  50. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  51. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  52. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  53. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  54. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  55. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  56. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  57. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  58. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  59. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  60. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  61. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  62. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  63. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  64. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  65. data/vendor/libgit2/include/git2/apply.h +2 -0
  66. data/vendor/libgit2/include/git2/attr.h +89 -0
  67. data/vendor/libgit2/include/git2/blame.h +95 -42
  68. data/vendor/libgit2/include/git2/blob.h +31 -3
  69. data/vendor/libgit2/include/git2/branch.h +25 -0
  70. data/vendor/libgit2/include/git2/cert.h +42 -5
  71. data/vendor/libgit2/include/git2/checkout.h +28 -12
  72. data/vendor/libgit2/include/git2/commit.h +35 -19
  73. data/vendor/libgit2/include/git2/common.h +33 -6
  74. data/vendor/libgit2/include/git2/config.h +1 -1
  75. data/vendor/libgit2/include/git2/deprecated.h +248 -8
  76. data/vendor/libgit2/include/git2/diff.h +35 -20
  77. data/vendor/libgit2/include/git2/errors.h +8 -7
  78. data/vendor/libgit2/include/git2/filter.h +57 -17
  79. data/vendor/libgit2/include/git2/graph.h +20 -2
  80. data/vendor/libgit2/include/git2/index.h +4 -5
  81. data/vendor/libgit2/include/git2/indexer.h +2 -1
  82. data/vendor/libgit2/include/git2/odb.h +44 -20
  83. data/vendor/libgit2/include/git2/pack.h +1 -1
  84. data/vendor/libgit2/include/git2/patch.h +8 -0
  85. data/vendor/libgit2/include/git2/rebase.h +25 -1
  86. data/vendor/libgit2/include/git2/refs.h +9 -5
  87. data/vendor/libgit2/include/git2/remote.h +59 -6
  88. data/vendor/libgit2/include/git2/repository.h +95 -52
  89. data/vendor/libgit2/include/git2/revparse.h +5 -5
  90. data/vendor/libgit2/include/git2/status.h +115 -59
  91. data/vendor/libgit2/include/git2/strarray.h +6 -10
  92. data/vendor/libgit2/include/git2/submodule.h +9 -0
  93. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  94. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  95. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  96. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  97. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  98. data/vendor/libgit2/include/git2/tag.h +12 -0
  99. data/vendor/libgit2/include/git2/transport.h +1 -1
  100. data/vendor/libgit2/include/git2/tree.h +2 -14
  101. data/vendor/libgit2/include/git2/types.h +9 -0
  102. data/vendor/libgit2/include/git2/version.h +3 -3
  103. data/vendor/libgit2/include/git2/worktree.h +1 -0
  104. data/vendor/libgit2/src/CMakeLists.txt +77 -44
  105. data/vendor/libgit2/src/alloc.c +21 -8
  106. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  107. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  108. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  109. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  110. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  111. data/vendor/libgit2/src/annotated_commit.c +21 -9
  112. data/vendor/libgit2/src/apply.c +21 -8
  113. data/vendor/libgit2/src/array.h +11 -11
  114. data/vendor/libgit2/src/assert_safe.h +58 -0
  115. data/vendor/libgit2/src/attr.c +181 -74
  116. data/vendor/libgit2/src/attr_file.c +92 -42
  117. data/vendor/libgit2/src/attr_file.h +32 -11
  118. data/vendor/libgit2/src/attrcache.c +44 -40
  119. data/vendor/libgit2/src/attrcache.h +4 -5
  120. data/vendor/libgit2/src/blame.c +28 -15
  121. data/vendor/libgit2/src/blame_git.c +6 -3
  122. data/vendor/libgit2/src/blob.c +46 -24
  123. data/vendor/libgit2/src/branch.c +87 -37
  124. data/vendor/libgit2/src/buffer.c +339 -27
  125. data/vendor/libgit2/src/buffer.h +153 -2
  126. data/vendor/libgit2/src/cache.c +3 -24
  127. data/vendor/libgit2/src/cache.h +7 -7
  128. data/vendor/libgit2/src/cc-compat.h +10 -2
  129. data/vendor/libgit2/src/checkout.c +97 -98
  130. data/vendor/libgit2/src/cherrypick.c +8 -2
  131. data/vendor/libgit2/src/clone.c +104 -29
  132. data/vendor/libgit2/src/commit.c +41 -28
  133. data/vendor/libgit2/src/commit_graph.c +1209 -0
  134. data/vendor/libgit2/src/commit_graph.h +162 -0
  135. data/vendor/libgit2/src/commit_list.c +46 -0
  136. data/vendor/libgit2/src/commit_list.h +2 -0
  137. data/vendor/libgit2/src/common.h +26 -2
  138. data/vendor/libgit2/src/config.c +40 -22
  139. data/vendor/libgit2/src/config_cache.c +9 -4
  140. data/vendor/libgit2/src/config_entries.c +35 -27
  141. data/vendor/libgit2/src/config_file.c +25 -8
  142. data/vendor/libgit2/src/config_parse.c +5 -7
  143. data/vendor/libgit2/src/config_snapshot.c +2 -1
  144. data/vendor/libgit2/src/crlf.c +16 -6
  145. data/vendor/libgit2/src/date.c +4 -3
  146. data/vendor/libgit2/src/delta.c +1 -1
  147. data/vendor/libgit2/src/describe.c +11 -4
  148. data/vendor/libgit2/src/diff.c +23 -19
  149. data/vendor/libgit2/src/diff_driver.c +21 -17
  150. data/vendor/libgit2/src/diff_file.c +5 -7
  151. data/vendor/libgit2/src/diff_generate.c +56 -28
  152. data/vendor/libgit2/src/diff_parse.c +2 -3
  153. data/vendor/libgit2/src/diff_print.c +81 -65
  154. data/vendor/libgit2/src/diff_stats.c +19 -16
  155. data/vendor/libgit2/src/diff_tform.c +13 -13
  156. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  157. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  158. data/vendor/libgit2/src/errors.c +26 -19
  159. data/vendor/libgit2/src/features.h.in +5 -1
  160. data/vendor/libgit2/src/fetch.c +7 -2
  161. data/vendor/libgit2/src/fetchhead.c +8 -4
  162. data/vendor/libgit2/src/filebuf.c +9 -7
  163. data/vendor/libgit2/src/filter.c +209 -113
  164. data/vendor/libgit2/src/filter.h +24 -5
  165. data/vendor/libgit2/src/futils.c +8 -8
  166. data/vendor/libgit2/src/futils.h +4 -4
  167. data/vendor/libgit2/src/graph.c +64 -9
  168. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  169. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  170. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  171. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  172. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  173. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  174. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  175. data/vendor/libgit2/src/hash.c +16 -13
  176. data/vendor/libgit2/src/hash.h +1 -1
  177. data/vendor/libgit2/src/hashsig.c +23 -10
  178. data/vendor/libgit2/src/ident.c +13 -3
  179. data/vendor/libgit2/src/idxmap.c +0 -22
  180. data/vendor/libgit2/src/ignore.c +35 -19
  181. data/vendor/libgit2/src/index.c +126 -84
  182. data/vendor/libgit2/src/index.h +1 -1
  183. data/vendor/libgit2/src/indexer.c +60 -36
  184. data/vendor/libgit2/src/integer.h +79 -2
  185. data/vendor/libgit2/src/iterator.c +40 -28
  186. data/vendor/libgit2/src/iterator.h +1 -1
  187. data/vendor/libgit2/src/khash.h +2 -11
  188. data/vendor/libgit2/src/{settings.c → libgit2.c} +125 -49
  189. data/vendor/libgit2/src/libgit2.h +15 -0
  190. data/vendor/libgit2/src/mailmap.c +23 -10
  191. data/vendor/libgit2/src/map.h +3 -3
  192. data/vendor/libgit2/src/merge.c +108 -46
  193. data/vendor/libgit2/src/merge.h +2 -1
  194. data/vendor/libgit2/src/merge_driver.c +19 -13
  195. data/vendor/libgit2/src/merge_file.c +15 -9
  196. data/vendor/libgit2/src/message.c +3 -1
  197. data/vendor/libgit2/src/midx.c +879 -0
  198. data/vendor/libgit2/src/midx.h +110 -0
  199. data/vendor/libgit2/src/mwindow.c +214 -95
  200. data/vendor/libgit2/src/mwindow.h +3 -3
  201. data/vendor/libgit2/src/net.c +133 -4
  202. data/vendor/libgit2/src/net.h +16 -2
  203. data/vendor/libgit2/src/netops.c +6 -4
  204. data/vendor/libgit2/src/netops.h +2 -2
  205. data/vendor/libgit2/src/notes.c +10 -10
  206. data/vendor/libgit2/src/object.c +24 -15
  207. data/vendor/libgit2/src/odb.c +298 -57
  208. data/vendor/libgit2/src/odb.h +16 -2
  209. data/vendor/libgit2/src/odb_loose.c +31 -21
  210. data/vendor/libgit2/src/odb_mempack.c +3 -1
  211. data/vendor/libgit2/src/odb_pack.c +391 -114
  212. data/vendor/libgit2/src/oid.c +7 -4
  213. data/vendor/libgit2/src/pack-objects.c +83 -69
  214. data/vendor/libgit2/src/pack.c +383 -150
  215. data/vendor/libgit2/src/pack.h +44 -9
  216. data/vendor/libgit2/src/patch.c +14 -7
  217. data/vendor/libgit2/src/patch_generate.c +3 -5
  218. data/vendor/libgit2/src/patch_parse.c +6 -3
  219. data/vendor/libgit2/src/path.c +102 -57
  220. data/vendor/libgit2/src/path.h +79 -6
  221. data/vendor/libgit2/src/pathspec.c +12 -11
  222. data/vendor/libgit2/src/pool.c +34 -22
  223. data/vendor/libgit2/src/pool.h +9 -1
  224. data/vendor/libgit2/src/posix.c +43 -12
  225. data/vendor/libgit2/src/posix.h +9 -0
  226. data/vendor/libgit2/src/proxy.c +2 -0
  227. data/vendor/libgit2/src/push.c +2 -0
  228. data/vendor/libgit2/src/reader.c +10 -6
  229. data/vendor/libgit2/src/rebase.c +95 -49
  230. data/vendor/libgit2/src/refdb.c +165 -13
  231. data/vendor/libgit2/src/refdb.h +69 -0
  232. data/vendor/libgit2/src/refdb_fs.c +144 -152
  233. data/vendor/libgit2/src/reflog.c +21 -20
  234. data/vendor/libgit2/src/refs.c +151 -231
  235. data/vendor/libgit2/src/refs.h +2 -20
  236. data/vendor/libgit2/src/refspec.c +80 -44
  237. data/vendor/libgit2/src/regexp.c +2 -2
  238. data/vendor/libgit2/src/remote.c +312 -121
  239. data/vendor/libgit2/src/remote.h +2 -1
  240. data/vendor/libgit2/src/repository.c +351 -189
  241. data/vendor/libgit2/src/repository.h +23 -29
  242. data/vendor/libgit2/src/reset.c +7 -6
  243. data/vendor/libgit2/src/revert.c +8 -2
  244. data/vendor/libgit2/src/revparse.c +19 -13
  245. data/vendor/libgit2/src/revwalk.c +35 -20
  246. data/vendor/libgit2/src/runtime.c +162 -0
  247. data/vendor/libgit2/src/runtime.h +62 -0
  248. data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
  249. data/vendor/libgit2/src/signature.c +6 -5
  250. data/vendor/libgit2/src/sortedcache.c +2 -3
  251. data/vendor/libgit2/src/sortedcache.h +10 -8
  252. data/vendor/libgit2/src/stash.c +7 -3
  253. data/vendor/libgit2/src/status.c +9 -4
  254. data/vendor/libgit2/src/strarray.c +64 -0
  255. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  256. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  257. data/vendor/libgit2/src/streams/openssl.c +113 -207
  258. data/vendor/libgit2/src/streams/openssl.h +9 -1
  259. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  260. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  261. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  262. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  263. data/vendor/libgit2/src/streams/registry.c +10 -9
  264. data/vendor/libgit2/src/streams/socket.c +6 -2
  265. data/vendor/libgit2/src/streams/stransport.c +6 -3
  266. data/vendor/libgit2/src/streams/tls.c +5 -3
  267. data/vendor/libgit2/src/submodule.c +134 -66
  268. data/vendor/libgit2/src/submodule.h +9 -9
  269. data/vendor/libgit2/src/sysdir.c +8 -26
  270. data/vendor/libgit2/src/sysdir.h +0 -11
  271. data/vendor/libgit2/src/tag.c +49 -11
  272. data/vendor/libgit2/src/thread.c +140 -0
  273. data/vendor/libgit2/src/thread.h +479 -0
  274. data/vendor/libgit2/src/threadstate.c +83 -0
  275. data/vendor/libgit2/src/threadstate.h +24 -0
  276. data/vendor/libgit2/src/trace.c +2 -2
  277. data/vendor/libgit2/src/trace.h +17 -13
  278. data/vendor/libgit2/src/transaction.c +21 -9
  279. data/vendor/libgit2/src/transport.c +3 -3
  280. data/vendor/libgit2/src/transports/auth.c +1 -1
  281. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  282. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  283. data/vendor/libgit2/src/transports/credential.c +17 -7
  284. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  285. data/vendor/libgit2/src/transports/git.c +1 -3
  286. data/vendor/libgit2/src/transports/http.c +19 -17
  287. data/vendor/libgit2/src/transports/http.h +1 -0
  288. data/vendor/libgit2/src/transports/httpclient.c +84 -42
  289. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  290. data/vendor/libgit2/src/transports/local.c +5 -5
  291. data/vendor/libgit2/src/transports/smart.c +14 -9
  292. data/vendor/libgit2/src/transports/smart.h +1 -1
  293. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  294. data/vendor/libgit2/src/transports/ssh.c +51 -17
  295. data/vendor/libgit2/src/transports/winhttp.c +156 -88
  296. data/vendor/libgit2/src/tree.c +100 -77
  297. data/vendor/libgit2/src/tree.h +1 -0
  298. data/vendor/libgit2/src/tsort.c +0 -2
  299. data/vendor/libgit2/src/unix/map.c +3 -1
  300. data/vendor/libgit2/src/unix/posix.h +16 -1
  301. data/vendor/libgit2/src/unix/pthread.h +2 -1
  302. data/vendor/libgit2/src/utf8.c +150 -0
  303. data/vendor/libgit2/src/utf8.h +52 -0
  304. data/vendor/libgit2/src/util.c +74 -183
  305. data/vendor/libgit2/src/util.h +33 -39
  306. data/vendor/libgit2/src/vector.c +23 -19
  307. data/vendor/libgit2/src/vector.h +4 -2
  308. data/vendor/libgit2/src/win32/findfile.c +4 -2
  309. data/vendor/libgit2/src/win32/git2.rc +18 -3
  310. data/vendor/libgit2/src/win32/map.c +1 -1
  311. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  312. data/vendor/libgit2/src/win32/path_w32.c +23 -25
  313. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  314. data/vendor/libgit2/src/win32/posix_w32.c +77 -1
  315. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  316. data/vendor/libgit2/src/win32/reparse.h +4 -4
  317. data/vendor/libgit2/src/win32/thread.c +24 -15
  318. data/vendor/libgit2/src/win32/thread.h +1 -1
  319. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  320. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  321. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  322. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  323. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  324. data/vendor/libgit2/src/worktree.c +37 -15
  325. data/vendor/libgit2/src/zstream.c +1 -1
  326. metadata +56 -38
  327. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  328. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  329. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  330. data/vendor/libgit2/src/buf_text.c +0 -316
  331. data/vendor/libgit2/src/buf_text.h +0 -122
  332. data/vendor/libgit2/src/global.c +0 -361
  333. data/vendor/libgit2/src/global.h +0 -41
  334. data/vendor/libgit2/src/thread-utils.c +0 -58
  335. data/vendor/libgit2/src/thread-utils.h +0 -246
  336. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  337. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  338. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -6,7 +6,6 @@
6
6
  */
7
7
 
8
8
  #include "diff_xdiff.h"
9
- #include "util.h"
10
9
 
11
10
  #include "git2/errors.h"
12
11
  #include "diff.h"
@@ -128,7 +127,7 @@ static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len)
128
127
  info->hunk.header_len = sizeof(info->hunk.header) - 1;
129
128
 
130
129
  /* Sanitize the hunk header in case there is invalid Unicode */
131
- buffer_len = git__utf8_valid_buf_length((const uint8_t *) bufs[0].ptr, info->hunk.header_len);
130
+ buffer_len = git_utf8_valid_buf_length(bufs[0].ptr, info->hunk.header_len);
132
131
  /* Sanitizing the hunk header may delete the newline, so add it back again if there is room */
133
132
  if (buffer_len < info->hunk.header_len) {
134
133
  bufs[0].ptr[buffer_len] = '\n';
@@ -259,5 +258,8 @@ void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts)
259
258
  if (flags & GIT_DIFF_MINIMAL)
260
259
  xo->params.flags |= XDF_NEED_MINIMAL;
261
260
 
261
+ if (flags & GIT_DIFF_IGNORE_BLANK_LINES)
262
+ xo->params.flags |= XDF_IGNORE_BLANK_LINES;
263
+
262
264
  xo->callback.outf = git_xdiff_cb;
263
265
  }
@@ -16,7 +16,7 @@
16
16
  /* xdiff cannot cope with large files. these files should not be passed to
17
17
  * xdiff. callers should treat these large files as binary.
18
18
  */
19
- #define GIT_XDIFF_MAX_SIZE (1024LL * 1024 * 1023)
19
+ #define GIT_XDIFF_MAX_SIZE (INT64_C(1024) * 1024 * 1023)
20
20
 
21
21
  /* A git_xdiff_output is a git_patch_generate_output with extra fields
22
22
  * necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
@@ -7,9 +7,10 @@
7
7
 
8
8
  #include "common.h"
9
9
 
10
- #include "global.h"
10
+ #include "threadstate.h"
11
11
  #include "posix.h"
12
12
  #include "buffer.h"
13
+ #include "libgit2.h"
13
14
 
14
15
  /********************************************
15
16
  * New error handling
@@ -20,20 +21,25 @@ static git_error g_git_oom_error = {
20
21
  GIT_ERROR_NOMEMORY
21
22
  };
22
23
 
24
+ static git_error g_git_uninitialized_error = {
25
+ "libgit2 has not been initialized; you must call git_libgit2_init",
26
+ GIT_ERROR_INVALID
27
+ };
28
+
23
29
  static void set_error_from_buffer(int error_class)
24
30
  {
25
- git_error *error = &GIT_GLOBAL->error_t;
26
- git_buf *buf = &GIT_GLOBAL->error_buf;
31
+ git_error *error = &GIT_THREADSTATE->error_t;
32
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
27
33
 
28
34
  error->message = buf->ptr;
29
35
  error->klass = error_class;
30
36
 
31
- GIT_GLOBAL->last_error = error;
37
+ GIT_THREADSTATE->last_error = error;
32
38
  }
33
39
 
34
40
  static void set_error(int error_class, char *string)
35
41
  {
36
- git_buf *buf = &GIT_GLOBAL->error_buf;
42
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
37
43
 
38
44
  git_buf_clear(buf);
39
45
  if (string) {
@@ -46,7 +52,7 @@ static void set_error(int error_class, char *string)
46
52
 
47
53
  void git_error_set_oom(void)
48
54
  {
49
- GIT_GLOBAL->last_error = &g_git_oom_error;
55
+ GIT_THREADSTATE->last_error = &g_git_oom_error;
50
56
  }
51
57
 
52
58
  void git_error_set(int error_class, const char *fmt, ...)
@@ -64,7 +70,7 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
64
70
  DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0;
65
71
  #endif
66
72
  int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
67
- git_buf *buf = &GIT_GLOBAL->error_buf;
73
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
68
74
 
69
75
  git_buf_clear(buf);
70
76
  if (fmt) {
@@ -97,14 +103,9 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
97
103
 
98
104
  int git_error_set_str(int error_class, const char *string)
99
105
  {
100
- git_buf *buf = &GIT_GLOBAL->error_buf;
106
+ git_buf *buf = &GIT_THREADSTATE->error_buf;
101
107
 
102
- assert(string);
103
-
104
- if (!string) {
105
- git_error_set(GIT_ERROR_INVALID, "unspecified caller error");
106
- return -1;
107
- }
108
+ GIT_ASSERT_ARG(string);
108
109
 
109
110
  git_buf_clear(buf);
110
111
  git_buf_puts(buf, string);
@@ -118,9 +119,9 @@ int git_error_set_str(int error_class, const char *string)
118
119
 
119
120
  void git_error_clear(void)
120
121
  {
121
- if (GIT_GLOBAL->last_error != NULL) {
122
+ if (GIT_THREADSTATE->last_error != NULL) {
122
123
  set_error(0, NULL);
123
- GIT_GLOBAL->last_error = NULL;
124
+ GIT_THREADSTATE->last_error = NULL;
124
125
  }
125
126
 
126
127
  errno = 0;
@@ -131,13 +132,17 @@ void git_error_clear(void)
131
132
 
132
133
  const git_error *git_error_last(void)
133
134
  {
134
- return GIT_GLOBAL->last_error;
135
+ /* If the library is not initialized, return a static error. */
136
+ if (!git_libgit2_init_count())
137
+ return &g_git_uninitialized_error;
138
+
139
+ return GIT_THREADSTATE->last_error;
135
140
  }
136
141
 
137
142
  int git_error_state_capture(git_error_state *state, int error_code)
138
143
  {
139
- git_error *error = GIT_GLOBAL->last_error;
140
- git_buf *error_buf = &GIT_GLOBAL->error_buf;
144
+ git_error *error = GIT_THREADSTATE->last_error;
145
+ git_buf *error_buf = &GIT_THREADSTATE->error_buf;
141
146
 
142
147
  memset(state, 0, sizeof(git_error_state));
143
148
 
@@ -210,6 +215,7 @@ void git_error_system_set(int code)
210
215
 
211
216
  /* Deprecated error values and functions */
212
217
 
218
+ #ifndef GIT_DEPRECATE_HARD
213
219
  const git_error *giterr_last(void)
214
220
  {
215
221
  return git_error_last();
@@ -229,3 +235,4 @@ void giterr_set_oom(void)
229
235
  {
230
236
  git_error_set_oom();
231
237
  }
238
+ #endif
@@ -2,9 +2,12 @@
2
2
  #define INCLUDE_features_h__
3
3
 
4
4
  #cmakedefine GIT_DEBUG_POOL 1
5
+ #cmakedefine GIT_DEBUG_STRICT_ALLOC 1
6
+ #cmakedefine GIT_DEBUG_STRICT_OPEN 1
7
+
5
8
  #cmakedefine GIT_TRACE 1
6
9
  #cmakedefine GIT_THREADS 1
7
- #cmakedefine GIT_MSVC_CRTDBG 1
10
+ #cmakedefine GIT_WIN32_LEAKCHECK 1
8
11
 
9
12
  #cmakedefine GIT_ARCH_64 1
10
13
  #cmakedefine GIT_ARCH_32 1
@@ -32,6 +35,7 @@
32
35
  #cmakedefine GIT_WINHTTP 1
33
36
  #cmakedefine GIT_HTTPS 1
34
37
  #cmakedefine GIT_OPENSSL 1
38
+ #cmakedefine GIT_OPENSSL_DYNAMIC 1
35
39
  #cmakedefine GIT_SECURE_TRANSPORT 1
36
40
  #cmakedefine GIT_MBEDTLS 1
37
41
 
@@ -21,9 +21,12 @@
21
21
 
22
22
  static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
23
23
  {
24
- int match = 0;
24
+ int match = 0, valid;
25
25
 
26
- if (!git_reference_is_valid_name(head->name))
26
+ if (git_reference_name_is_valid(&valid, head->name) < 0)
27
+ return -1;
28
+
29
+ if (!valid)
27
30
  return 0;
28
31
 
29
32
  if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
@@ -155,7 +158,9 @@ int git_fetch_options_init(git_fetch_options *opts, unsigned int version)
155
158
  return 0;
156
159
  }
157
160
 
161
+ #ifndef GIT_DEPRECATE_HARD
158
162
  int git_fetch_init_options(git_fetch_options *opts, unsigned int version)
159
163
  {
160
164
  return git_fetch_options_init(opts, version);
161
165
  }
166
+ #endif
@@ -73,7 +73,8 @@ int git_fetchhead_ref_create(
73
73
  {
74
74
  git_fetchhead_ref *fetchhead_ref;
75
75
 
76
- assert(out && oid);
76
+ GIT_ASSERT_ARG(out);
77
+ GIT_ASSERT_ARG(oid);
77
78
 
78
79
  *out = NULL;
79
80
 
@@ -108,7 +109,8 @@ static int fetchhead_ref_write(
108
109
  const char *type, *name;
109
110
  int head = 0;
110
111
 
111
- assert(file && fetchhead_ref);
112
+ GIT_ASSERT_ARG(file);
113
+ GIT_ASSERT_ARG(fetchhead_ref);
112
114
 
113
115
  git_oid_fmt(oid, &fetchhead_ref->oid);
114
116
  oid[GIT_OID_HEXSZ] = '\0';
@@ -145,7 +147,8 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
145
147
  unsigned int i;
146
148
  git_fetchhead_ref *fetchhead_ref;
147
149
 
148
- assert(repo && fetchhead_refs);
150
+ GIT_ASSERT_ARG(repo);
151
+ GIT_ASSERT_ARG(fetchhead_refs);
149
152
 
150
153
  if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
151
154
  return -1;
@@ -279,7 +282,8 @@ int git_repository_fetchhead_foreach(git_repository *repo,
279
282
  size_t line_num = 0;
280
283
  int error = 0;
281
284
 
282
- assert(repo && cb);
285
+ GIT_ASSERT_ARG(repo);
286
+ GIT_ASSERT_ARG(cb);
283
287
 
284
288
  if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
285
289
  return -1;
@@ -184,7 +184,7 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
184
184
 
185
185
  } while (zs->avail_out == 0);
186
186
 
187
- assert(zs->avail_in == 0);
187
+ GIT_ASSERT(zs->avail_in == 0);
188
188
 
189
189
  if (file->compute_digest)
190
190
  git_hash_update(&file->digest, source, len);
@@ -278,10 +278,9 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
278
278
  int compression, error = -1;
279
279
  size_t path_len, alloc_len;
280
280
 
281
- /* opening an already open buffer is a programming error;
282
- * assert that this never happens instead of returning
283
- * an error code */
284
- assert(file && path && file->buffer == NULL);
281
+ GIT_ASSERT_ARG(file);
282
+ GIT_ASSERT_ARG(path);
283
+ GIT_ASSERT(file->buffer == NULL);
285
284
 
286
285
  memset(file, 0x0, sizeof(git_filebuf));
287
286
 
@@ -389,7 +388,9 @@ cleanup:
389
388
 
390
389
  int git_filebuf_hash(git_oid *oid, git_filebuf *file)
391
390
  {
392
- assert(oid && file && file->compute_digest);
391
+ GIT_ASSERT_ARG(oid);
392
+ GIT_ASSERT_ARG(file);
393
+ GIT_ASSERT_ARG(file->compute_digest);
393
394
 
394
395
  flush_buffer(file);
395
396
 
@@ -415,7 +416,8 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path)
415
416
  int git_filebuf_commit(git_filebuf *file)
416
417
  {
417
418
  /* temporary files cannot be committed */
418
- assert(file && file->path_original);
419
+ GIT_ASSERT_ARG(file);
420
+ GIT_ASSERT(file->path_original);
419
421
 
420
422
  file->flush_mode = Z_FINISH;
421
423
  flush_buffer(file);
@@ -11,7 +11,7 @@
11
11
  #include "futils.h"
12
12
  #include "hash.h"
13
13
  #include "repository.h"
14
- #include "global.h"
14
+ #include "runtime.h"
15
15
  #include "git2/sys/filter.h"
16
16
  #include "git2/config.h"
17
17
  #include "blob.h"
@@ -19,12 +19,12 @@
19
19
  #include "array.h"
20
20
 
21
21
  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;
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
+ git_filter_options options;
28
28
  };
29
29
 
30
30
  typedef struct {
@@ -206,7 +206,8 @@ int git_filter_global_init(void)
206
206
  GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
207
207
  error = -1;
208
208
 
209
- git__on_shutdown(git_filter_global_shutdown);
209
+ if (!error)
210
+ error = git_runtime_shutdown_register(git_filter_global_shutdown);
210
211
 
211
212
  done:
212
213
  if (error) {
@@ -266,7 +267,8 @@ int git_filter_register(
266
267
  {
267
268
  int error;
268
269
 
269
- assert(name && filter);
270
+ GIT_ASSERT_ARG(name);
271
+ GIT_ASSERT_ARG(filter);
270
272
 
271
273
  if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
272
274
  git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -293,7 +295,7 @@ int git_filter_unregister(const char *name)
293
295
  git_filter_def *fdef;
294
296
  int error = 0;
295
297
 
296
- assert(name);
298
+ GIT_ASSERT_ARG(name);
297
299
 
298
300
  /* cannot unregister default filters */
299
301
  if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
@@ -395,7 +397,7 @@ git_filter_mode_t git_filter_source_mode(const git_filter_source *src)
395
397
 
396
398
  uint32_t git_filter_source_flags(const git_filter_source *src)
397
399
  {
398
- return src->flags;
400
+ return src->options.flags;
399
401
  }
400
402
 
401
403
  static int filter_list_new(
@@ -415,7 +417,8 @@ static int filter_list_new(
415
417
  fl->source.repo = src->repo;
416
418
  fl->source.path = fl->path;
417
419
  fl->source.mode = src->mode;
418
- fl->source.flags = src->flags;
420
+
421
+ memcpy(&fl->source.options, &src->options, sizeof(git_filter_options));
419
422
 
420
423
  *out = fl;
421
424
  return 0;
@@ -424,25 +427,30 @@ static int filter_list_new(
424
427
  static int filter_list_check_attributes(
425
428
  const char ***out,
426
429
  git_repository *repo,
427
- git_attr_session *attr_session,
430
+ git_filter_session *filter_session,
428
431
  git_filter_def *fdef,
429
432
  const git_filter_source *src)
430
433
  {
431
434
  const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
432
- uint32_t flags = 0;
435
+ git_attr_options attr_opts = GIT_ATTR_OPTIONS_INIT;
433
436
  size_t i;
434
437
  int error;
435
438
 
436
439
  GIT_ERROR_CHECK_ALLOC(strs);
437
440
 
438
- if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
439
- flags |= GIT_ATTR_CHECK_NO_SYSTEM;
441
+ if ((src->options.flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
442
+ attr_opts.flags |= GIT_ATTR_CHECK_NO_SYSTEM;
443
+
444
+ if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
445
+ attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
440
446
 
441
- if ((src->flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
442
- flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
447
+ if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
448
+ attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_COMMIT;
449
+ attr_opts.commit_id = src->options.commit_id;
450
+ }
443
451
 
444
452
  error = git_attr_get_many_with_session(
445
- strs, repo, attr_session, flags, src->path, fdef->nattrs, fdef->attrs);
453
+ strs, repo, filter_session->attr_session, &attr_opts, src->path, fdef->nattrs, fdef->attrs);
446
454
 
447
455
  /* if no values were found but no matches are needed, it's okay! */
448
456
  if (error == GIT_ENOTFOUND && !fdef->nmatches) {
@@ -487,17 +495,17 @@ int git_filter_list_new(
487
495
  src.repo = repo;
488
496
  src.path = NULL;
489
497
  src.mode = mode;
490
- src.flags = flags;
498
+ src.options.flags = flags;
491
499
  return filter_list_new(out, &src);
492
500
  }
493
501
 
494
- int git_filter_list__load_ext(
502
+ int git_filter_list__load(
495
503
  git_filter_list **filters,
496
504
  git_repository *repo,
497
505
  git_blob *blob, /* can be NULL */
498
506
  const char *path,
499
507
  git_filter_mode_t mode,
500
- git_filter_options *filter_opts)
508
+ git_filter_session *filter_session)
501
509
  {
502
510
  int error = 0;
503
511
  git_filter_list *fl = NULL;
@@ -514,7 +522,8 @@ int git_filter_list__load_ext(
514
522
  src.repo = repo;
515
523
  src.path = path;
516
524
  src.mode = mode;
517
- src.flags = filter_opts->flags;
525
+
526
+ memcpy(&src.options, &filter_session->options, sizeof(git_filter_options));
518
527
 
519
528
  if (blob)
520
529
  git_oid_cpy(&src.oid, git_blob_id(blob));
@@ -528,7 +537,8 @@ int git_filter_list__load_ext(
528
537
 
529
538
  if (fdef->nattrs > 0) {
530
539
  error = filter_list_check_attributes(
531
- &values, repo, filter_opts->attr_session, fdef, &src);
540
+ &values, repo,
541
+ filter_session, fdef, &src);
532
542
 
533
543
  if (error == GIT_ENOTFOUND) {
534
544
  error = 0;
@@ -555,7 +565,7 @@ int git_filter_list__load_ext(
555
565
  if ((error = filter_list_new(&fl, &src)) < 0)
556
566
  break;
557
567
 
558
- fl->temp_buf = filter_opts->temp_buf;
568
+ fl->temp_buf = filter_session->temp_buf;
559
569
  }
560
570
 
561
571
  fe = git_array_alloc(fl->filters);
@@ -579,6 +589,23 @@ int git_filter_list__load_ext(
579
589
  return error;
580
590
  }
581
591
 
592
+ int git_filter_list_load_ext(
593
+ git_filter_list **filters,
594
+ git_repository *repo,
595
+ git_blob *blob, /* can be NULL */
596
+ const char *path,
597
+ git_filter_mode_t mode,
598
+ git_filter_options *opts)
599
+ {
600
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
601
+
602
+ if (opts)
603
+ memcpy(&filter_session.options, opts, sizeof(git_filter_options));
604
+
605
+ return git_filter_list__load(
606
+ filters, repo, blob, path, mode, &filter_session);
607
+ }
608
+
582
609
  int git_filter_list_load(
583
610
  git_filter_list **filters,
584
611
  git_repository *repo,
@@ -587,12 +614,12 @@ int git_filter_list_load(
587
614
  git_filter_mode_t mode,
588
615
  uint32_t flags)
589
616
  {
590
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
617
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
591
618
 
592
- filter_opts.flags = flags;
619
+ filter_session.options.flags = flags;
593
620
 
594
- return git_filter_list__load_ext(
595
- filters, repo, blob, path, mode, &filter_opts);
621
+ return git_filter_list__load(
622
+ filters, repo, blob, path, mode, &filter_session);
596
623
  }
597
624
 
598
625
  void git_filter_list_free(git_filter_list *fl)
@@ -618,7 +645,7 @@ int git_filter_list_contains(
618
645
  {
619
646
  size_t i;
620
647
 
621
- assert(name);
648
+ GIT_ASSERT_ARG(name);
622
649
 
623
650
  if (!fl)
624
651
  return 0;
@@ -639,7 +666,8 @@ int git_filter_list_push(
639
666
  git_filter_def *fdef = NULL;
640
667
  git_filter_entry *fe;
641
668
 
642
- assert(fl && filter);
669
+ GIT_ASSERT_ARG(fl);
670
+ GIT_ASSERT_ARG(filter);
643
671
 
644
672
  if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
645
673
  git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
@@ -684,9 +712,8 @@ static int buf_stream_write(
684
712
  git_writestream *s, const char *buffer, size_t len)
685
713
  {
686
714
  struct buf_stream *buf_stream = (struct buf_stream *)s;
687
- assert(buf_stream);
688
-
689
- assert(buf_stream->complete == 0);
715
+ GIT_ASSERT_ARG(buf_stream);
716
+ GIT_ASSERT(buf_stream->complete == 0);
690
717
 
691
718
  return git_buf_put(buf_stream->target, buffer, len);
692
719
  }
@@ -694,9 +721,9 @@ static int buf_stream_write(
694
721
  static int buf_stream_close(git_writestream *s)
695
722
  {
696
723
  struct buf_stream *buf_stream = (struct buf_stream *)s;
697
- assert(buf_stream);
724
+ GIT_ASSERT_ARG(buf_stream);
698
725
 
699
- assert(buf_stream->complete == 0);
726
+ GIT_ASSERT(buf_stream->complete == 0);
700
727
  buf_stream->complete = 1;
701
728
 
702
729
  return 0;
@@ -719,27 +746,47 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
719
746
  git_buf_clear(target);
720
747
  }
721
748
 
722
- int git_filter_list_apply_to_data(
723
- git_buf *tgt, git_filter_list *filters, git_buf *src)
749
+ int git_filter_list_apply_to_buffer(
750
+ git_buf *out,
751
+ git_filter_list *filters,
752
+ const char *in,
753
+ size_t in_len)
724
754
  {
725
755
  struct buf_stream writer;
726
756
  int error;
727
757
 
728
- git_buf_sanitize(tgt);
729
- git_buf_sanitize(src);
758
+ if ((error = git_buf_sanitize(out)) < 0)
759
+ return error;
730
760
 
731
- if (!filters) {
732
- git_buf_attach_notowned(tgt, src->ptr, src->size);
761
+ buf_stream_init(&writer, out);
762
+
763
+ if ((error = git_filter_list_stream_buffer(filters,
764
+ in, in_len, &writer.parent)) < 0)
765
+ return error;
766
+
767
+ GIT_ASSERT(writer.complete);
768
+ return error;
769
+ }
770
+
771
+ int git_filter_list__convert_buf(
772
+ git_buf *out,
773
+ git_filter_list *filters,
774
+ git_buf *in)
775
+ {
776
+ int error;
777
+
778
+ if (!filters || git_filter_list_length(filters) == 0) {
779
+ git_buf_swap(out, in);
780
+ git_buf_dispose(in);
733
781
  return 0;
734
782
  }
735
783
 
736
- buf_stream_init(&writer, tgt);
784
+ error = git_filter_list_apply_to_buffer(out, filters,
785
+ in->ptr, in->size);
737
786
 
738
- if ((error = git_filter_list_stream_data(filters, src,
739
- &writer.parent)) < 0)
740
- return error;
787
+ if (!error)
788
+ git_buf_dispose(in);
741
789
 
742
- assert(writer.complete);
743
790
  return error;
744
791
  }
745
792
 
@@ -758,7 +805,7 @@ int git_filter_list_apply_to_file(
758
805
  filters, repo, path, &writer.parent)) < 0)
759
806
  return error;
760
807
 
761
- assert(writer.complete);
808
+ GIT_ASSERT(writer.complete);
762
809
  return error;
763
810
  }
764
811
 
@@ -789,13 +836,14 @@ int git_filter_list_apply_to_blob(
789
836
  filters, blob, &writer.parent)) < 0)
790
837
  return error;
791
838
 
792
- assert(writer.complete);
839
+ GIT_ASSERT(writer.complete);
793
840
  return error;
794
841
  }
795
842
 
796
- struct proxy_stream {
843
+ struct buffered_stream {
797
844
  git_writestream parent;
798
845
  git_filter *filter;
846
+ int (*write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *);
799
847
  const git_filter_source *source;
800
848
  void **payload;
801
849
  git_buf input;
@@ -804,89 +852,120 @@ struct proxy_stream {
804
852
  git_writestream *target;
805
853
  };
806
854
 
807
- static int proxy_stream_write(
855
+ static int buffered_stream_write(
808
856
  git_writestream *s, const char *buffer, size_t len)
809
857
  {
810
- struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
811
- assert(proxy_stream);
858
+ struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
859
+ GIT_ASSERT_ARG(buffered_stream);
812
860
 
813
- return git_buf_put(&proxy_stream->input, buffer, len);
861
+ return git_buf_put(&buffered_stream->input, buffer, len);
814
862
  }
815
863
 
816
- static int proxy_stream_close(git_writestream *s)
864
+ static int buffered_stream_close(git_writestream *s)
817
865
  {
818
- struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
866
+ struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
819
867
  git_buf *writebuf;
820
868
  git_error_state error_state = {0};
821
869
  int error;
822
870
 
823
- assert(proxy_stream);
871
+ GIT_ASSERT_ARG(buffered_stream);
824
872
 
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);
873
+ error = buffered_stream->write_fn(
874
+ buffered_stream->filter,
875
+ buffered_stream->payload,
876
+ buffered_stream->output,
877
+ &buffered_stream->input,
878
+ buffered_stream->source);
831
879
 
832
880
  if (error == GIT_PASSTHROUGH) {
833
- writebuf = &proxy_stream->input;
881
+ writebuf = &buffered_stream->input;
834
882
  } else if (error == 0) {
835
- git_buf_sanitize(proxy_stream->output);
836
- writebuf = proxy_stream->output;
883
+ if ((error = git_buf_sanitize(buffered_stream->output)) < 0)
884
+ return error;
885
+
886
+ writebuf = buffered_stream->output;
837
887
  } else {
838
888
  /* close stream before erroring out taking care
839
889
  * to preserve the original error */
840
890
  git_error_state_capture(&error_state, error);
841
- proxy_stream->target->close(proxy_stream->target);
891
+ buffered_stream->target->close(buffered_stream->target);
842
892
  git_error_state_restore(&error_state);
843
893
  return error;
844
894
  }
845
895
 
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);
896
+ if ((error = buffered_stream->target->write(
897
+ buffered_stream->target, writebuf->ptr, writebuf->size)) == 0)
898
+ error = buffered_stream->target->close(buffered_stream->target);
849
899
 
850
900
  return error;
851
901
  }
852
902
 
853
- static void proxy_stream_free(git_writestream *s)
903
+ static void buffered_stream_free(git_writestream *s)
854
904
  {
855
- struct proxy_stream *proxy_stream = (struct proxy_stream *)s;
856
- assert(proxy_stream);
905
+ struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
857
906
 
858
- git_buf_dispose(&proxy_stream->input);
859
- git_buf_dispose(&proxy_stream->temp_buf);
860
- git__free(proxy_stream);
907
+ if (buffered_stream) {
908
+ git_buf_dispose(&buffered_stream->input);
909
+ git_buf_dispose(&buffered_stream->temp_buf);
910
+ git__free(buffered_stream);
911
+ }
861
912
  }
862
913
 
863
- static int proxy_stream_init(
914
+ int git_filter_buffered_stream_new(
864
915
  git_writestream **out,
865
916
  git_filter *filter,
917
+ int (*write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *),
866
918
  git_buf *temp_buf,
867
919
  void **payload,
868
920
  const git_filter_source *source,
869
921
  git_writestream *target)
870
922
  {
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;
923
+ struct buffered_stream *buffered_stream = git__calloc(1, sizeof(struct buffered_stream));
924
+ GIT_ERROR_CHECK_ALLOC(buffered_stream);
925
+
926
+ buffered_stream->parent.write = buffered_stream_write;
927
+ buffered_stream->parent.close = buffered_stream_close;
928
+ buffered_stream->parent.free = buffered_stream_free;
929
+ buffered_stream->filter = filter;
930
+ buffered_stream->write_fn = write_fn;
931
+ buffered_stream->output = temp_buf ? temp_buf : &buffered_stream->temp_buf;
932
+ buffered_stream->payload = payload;
933
+ buffered_stream->source = source;
934
+ buffered_stream->target = target;
882
935
 
883
936
  if (temp_buf)
884
937
  git_buf_clear(temp_buf);
885
938
 
886
- *out = (git_writestream *)proxy_stream;
939
+ *out = (git_writestream *)buffered_stream;
887
940
  return 0;
888
941
  }
889
942
 
943
+ static int setup_stream(
944
+ git_writestream **out,
945
+ git_filter_entry *fe,
946
+ git_filter_list *filters,
947
+ git_writestream *last_stream)
948
+ {
949
+ #ifndef GIT_DEPRECATE_HARD
950
+ GIT_ASSERT(fe->filter->stream || fe->filter->apply);
951
+
952
+ /*
953
+ * If necessary, create a stream that proxies the traditional
954
+ * application.
955
+ */
956
+ if (!fe->filter->stream) {
957
+ /* Create a stream that proxies the one-shot apply */
958
+ return git_filter_buffered_stream_new(out,
959
+ fe->filter, fe->filter->apply, filters->temp_buf,
960
+ &fe->payload, &filters->source, last_stream);
961
+ }
962
+ #endif
963
+
964
+ GIT_ASSERT(fe->filter->stream);
965
+ return fe->filter->stream(out, fe->filter,
966
+ &fe->payload, &filters->source, last_stream);
967
+ }
968
+
890
969
  static int stream_list_init(
891
970
  git_writestream **out,
892
971
  git_vector *streams,
@@ -908,22 +987,11 @@ static int stream_list_init(
908
987
  for (i = 0; i < git_array_size(filters->filters); ++i) {
909
988
  size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ?
910
989
  git_array_size(filters->filters) - 1 - i : i;
990
+
911
991
  git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
912
992
  git_writestream *filter_stream;
913
993
 
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);
994
+ error = setup_stream(&filter_stream, fe, filters, last_stream);
927
995
 
928
996
  if (error < 0)
929
997
  goto out;
@@ -941,7 +1009,7 @@ out:
941
1009
  return error;
942
1010
  }
943
1011
 
944
- void stream_list_free(git_vector *streams)
1012
+ static void filter_streams_free(git_vector *streams)
945
1013
  {
946
1014
  git_writestream *stream;
947
1015
  size_t i;
@@ -967,8 +1035,10 @@ int git_filter_list_stream_file(
967
1035
 
968
1036
  if ((error = stream_list_init(
969
1037
  &stream_start, &filter_streams, filters, target)) < 0 ||
970
- (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0)
1038
+ (error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
1039
+ (error = git_path_validate_workdir_buf(repo, &abspath)) < 0)
971
1040
  goto done;
1041
+
972
1042
  initialized = 1;
973
1043
 
974
1044
  if ((fd = git_futils_open_ro(abspath.ptr)) < 0) {
@@ -990,35 +1060,33 @@ done:
990
1060
 
991
1061
  if (fd >= 0)
992
1062
  p_close(fd);
993
- stream_list_free(&filter_streams);
1063
+ filter_streams_free(&filter_streams);
994
1064
  git_buf_dispose(&abspath);
995
1065
  return error;
996
1066
  }
997
1067
 
998
- int git_filter_list_stream_data(
1068
+ int git_filter_list_stream_buffer(
999
1069
  git_filter_list *filters,
1000
- git_buf *data,
1070
+ const char *buffer,
1071
+ size_t len,
1001
1072
  git_writestream *target)
1002
1073
  {
1003
1074
  git_vector filter_streams = GIT_VECTOR_INIT;
1004
1075
  git_writestream *stream_start;
1005
1076
  int error, initialized = 0;
1006
1077
 
1007
- git_buf_sanitize(data);
1008
-
1009
1078
  if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
1010
1079
  goto out;
1011
1080
  initialized = 1;
1012
1081
 
1013
- if ((error = stream_start->write(
1014
- stream_start, data->ptr, data->size)) < 0)
1082
+ if ((error = stream_start->write(stream_start, buffer, len)) < 0)
1015
1083
  goto out;
1016
1084
 
1017
1085
  out:
1018
1086
  if (initialized)
1019
1087
  error |= stream_start->close(stream_start);
1020
1088
 
1021
- stream_list_free(&filter_streams);
1089
+ filter_streams_free(&filter_streams);
1022
1090
  return error;
1023
1091
  }
1024
1092
 
@@ -1035,7 +1103,7 @@ int git_filter_list_stream_blob(
1035
1103
  if (filters)
1036
1104
  git_oid_cpy(&filters->source.oid, git_blob_id(blob));
1037
1105
 
1038
- return git_filter_list_stream_data(filters, &in, target);
1106
+ return git_filter_list_stream_buffer(filters, in.ptr, in.size, target);
1039
1107
  }
1040
1108
 
1041
1109
  int git_filter_init(git_filter *filter, unsigned int version)
@@ -1043,3 +1111,31 @@ int git_filter_init(git_filter *filter, unsigned int version)
1043
1111
  GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);
1044
1112
  return 0;
1045
1113
  }
1114
+
1115
+ #ifndef GIT_DEPRECATE_HARD
1116
+
1117
+ int git_filter_list_stream_data(
1118
+ git_filter_list *filters,
1119
+ git_buf *data,
1120
+ git_writestream *target)
1121
+ {
1122
+ int error;
1123
+
1124
+ if ((error = git_buf_sanitize(data)) < 0)
1125
+ return error;
1126
+
1127
+ return git_filter_list_stream_buffer(filters, data->ptr, data->size, target);
1128
+ }
1129
+
1130
+ int git_filter_list_apply_to_data(
1131
+ git_buf *tgt, git_filter_list *filters, git_buf *src)
1132
+ {
1133
+ int error;
1134
+
1135
+ if ((error = git_buf_sanitize(src)) < 0)
1136
+ return error;
1137
+
1138
+ return git_filter_list_apply_to_buffer(tgt, filters, src->ptr, src->size);
1139
+ }
1140
+
1141
+ #endif