rugged 1.0.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (349) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_commit.c +1 -1
  6. data/ext/rugged/rugged_object.c +1 -1
  7. data/ext/rugged/rugged_repo.c +3 -3
  8. data/lib/rugged/commit.rb +16 -2
  9. data/lib/rugged/repository.rb +2 -2
  10. data/lib/rugged/version.rb +1 -1
  11. data/vendor/libgit2/CMakeLists.txt +41 -74
  12. data/vendor/libgit2/COPYING +109 -1
  13. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  14. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  15. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  16. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  20. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  21. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  23. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  24. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  25. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  26. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  27. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  28. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  29. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  30. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  31. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  32. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
  33. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
  34. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  35. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  36. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
  37. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
  38. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  39. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  40. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  41. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  42. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  43. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  44. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  45. data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
  46. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  47. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  48. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  49. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  50. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  51. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  52. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  53. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  54. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  55. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  56. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  57. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  58. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  59. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  60. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  61. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  62. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  63. data/vendor/libgit2/include/git2/apply.h +2 -0
  64. data/vendor/libgit2/include/git2/attr.h +95 -0
  65. data/vendor/libgit2/include/git2/blame.h +95 -42
  66. data/vendor/libgit2/include/git2/blob.h +37 -3
  67. data/vendor/libgit2/include/git2/branch.h +25 -0
  68. data/vendor/libgit2/include/git2/cert.h +42 -5
  69. data/vendor/libgit2/include/git2/checkout.h +28 -12
  70. data/vendor/libgit2/include/git2/clone.h +1 -1
  71. data/vendor/libgit2/include/git2/commit.h +35 -19
  72. data/vendor/libgit2/include/git2/common.h +51 -6
  73. data/vendor/libgit2/include/git2/config.h +1 -1
  74. data/vendor/libgit2/include/git2/deprecated.h +368 -8
  75. data/vendor/libgit2/include/git2/diff.h +34 -113
  76. data/vendor/libgit2/include/git2/email.h +127 -0
  77. data/vendor/libgit2/include/git2/errors.h +8 -7
  78. data/vendor/libgit2/include/git2/filter.h +63 -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/notes.h +2 -2
  83. data/vendor/libgit2/include/git2/odb.h +44 -20
  84. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  85. data/vendor/libgit2/include/git2/pack.h +1 -1
  86. data/vendor/libgit2/include/git2/patch.h +8 -0
  87. data/vendor/libgit2/include/git2/rebase.h +25 -1
  88. data/vendor/libgit2/include/git2/refs.h +9 -5
  89. data/vendor/libgit2/include/git2/remote.h +62 -9
  90. data/vendor/libgit2/include/git2/repository.h +107 -62
  91. data/vendor/libgit2/include/git2/revparse.h +5 -5
  92. data/vendor/libgit2/include/git2/stash.h +1 -1
  93. data/vendor/libgit2/include/git2/status.h +115 -59
  94. data/vendor/libgit2/include/git2/stdint.h +3 -3
  95. data/vendor/libgit2/include/git2/strarray.h +6 -10
  96. data/vendor/libgit2/include/git2/submodule.h +9 -0
  97. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  98. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  99. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  100. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  101. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  102. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  103. data/vendor/libgit2/include/git2/tag.h +12 -0
  104. data/vendor/libgit2/include/git2/transport.h +1 -1
  105. data/vendor/libgit2/include/git2/tree.h +2 -14
  106. data/vendor/libgit2/include/git2/types.h +9 -0
  107. data/vendor/libgit2/include/git2/version.h +4 -4
  108. data/vendor/libgit2/include/git2/worktree.h +1 -0
  109. data/vendor/libgit2/include/git2.h +1 -0
  110. data/vendor/libgit2/src/CMakeLists.txt +84 -44
  111. data/vendor/libgit2/src/alloc.c +21 -8
  112. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  113. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  114. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  115. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  116. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  117. data/vendor/libgit2/src/annotated_commit.c +21 -9
  118. data/vendor/libgit2/src/apply.c +21 -8
  119. data/vendor/libgit2/src/array.h +11 -11
  120. data/vendor/libgit2/src/assert_safe.h +58 -0
  121. data/vendor/libgit2/src/attr.c +192 -70
  122. data/vendor/libgit2/src/attr_file.c +99 -41
  123. data/vendor/libgit2/src/attr_file.h +32 -11
  124. data/vendor/libgit2/src/attrcache.c +44 -40
  125. data/vendor/libgit2/src/attrcache.h +4 -5
  126. data/vendor/libgit2/src/blame.c +32 -19
  127. data/vendor/libgit2/src/blame_git.c +7 -4
  128. data/vendor/libgit2/src/blob.c +60 -32
  129. data/vendor/libgit2/src/branch.c +87 -37
  130. data/vendor/libgit2/src/buffer.c +349 -29
  131. data/vendor/libgit2/src/buffer.h +154 -2
  132. data/vendor/libgit2/src/cache.c +3 -24
  133. data/vendor/libgit2/src/cache.h +7 -7
  134. data/vendor/libgit2/src/cc-compat.h +10 -8
  135. data/vendor/libgit2/src/checkout.c +103 -105
  136. data/vendor/libgit2/src/cherrypick.c +8 -2
  137. data/vendor/libgit2/src/clone.c +105 -30
  138. data/vendor/libgit2/src/commit.c +41 -28
  139. data/vendor/libgit2/src/commit_graph.c +1209 -0
  140. data/vendor/libgit2/src/commit_graph.h +162 -0
  141. data/vendor/libgit2/src/commit_list.c +46 -0
  142. data/vendor/libgit2/src/commit_list.h +2 -0
  143. data/vendor/libgit2/src/common.h +26 -2
  144. data/vendor/libgit2/src/config.c +41 -23
  145. data/vendor/libgit2/src/config_cache.c +9 -4
  146. data/vendor/libgit2/src/config_entries.c +35 -27
  147. data/vendor/libgit2/src/config_file.c +17 -9
  148. data/vendor/libgit2/src/config_parse.c +6 -8
  149. data/vendor/libgit2/src/config_snapshot.c +2 -1
  150. data/vendor/libgit2/src/crlf.c +16 -6
  151. data/vendor/libgit2/src/date.c +4 -3
  152. data/vendor/libgit2/src/delta.c +1 -1
  153. data/vendor/libgit2/src/describe.c +12 -5
  154. data/vendor/libgit2/src/diff.c +55 -183
  155. data/vendor/libgit2/src/diff_driver.c +21 -17
  156. data/vendor/libgit2/src/diff_file.c +5 -7
  157. data/vendor/libgit2/src/diff_generate.c +56 -28
  158. data/vendor/libgit2/src/diff_parse.c +2 -3
  159. data/vendor/libgit2/src/diff_print.c +81 -65
  160. data/vendor/libgit2/src/diff_stats.c +19 -16
  161. data/vendor/libgit2/src/diff_tform.c +13 -13
  162. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  163. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  164. data/vendor/libgit2/src/email.c +299 -0
  165. data/vendor/libgit2/src/email.h +25 -0
  166. data/vendor/libgit2/src/errors.c +26 -19
  167. data/vendor/libgit2/src/features.h.in +5 -1
  168. data/vendor/libgit2/src/fetch.c +7 -2
  169. data/vendor/libgit2/src/fetchhead.c +8 -4
  170. data/vendor/libgit2/src/filebuf.c +9 -7
  171. data/vendor/libgit2/src/filter.c +215 -113
  172. data/vendor/libgit2/src/filter.h +24 -5
  173. data/vendor/libgit2/src/futils.c +8 -8
  174. data/vendor/libgit2/src/futils.h +4 -4
  175. data/vendor/libgit2/src/graph.c +64 -9
  176. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  177. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  178. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  179. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  180. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  181. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +8 -10
  182. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  183. data/vendor/libgit2/src/hash.c +16 -13
  184. data/vendor/libgit2/src/hash.h +1 -1
  185. data/vendor/libgit2/src/hashsig.c +23 -10
  186. data/vendor/libgit2/src/ident.c +13 -3
  187. data/vendor/libgit2/src/idxmap.c +0 -22
  188. data/vendor/libgit2/src/ignore.c +33 -17
  189. data/vendor/libgit2/src/index.c +124 -82
  190. data/vendor/libgit2/src/index.h +1 -1
  191. data/vendor/libgit2/src/indexer.c +95 -37
  192. data/vendor/libgit2/src/integer.h +79 -2
  193. data/vendor/libgit2/src/iterator.c +40 -28
  194. data/vendor/libgit2/src/iterator.h +1 -1
  195. data/vendor/libgit2/src/khash.h +2 -11
  196. data/vendor/libgit2/src/{settings.c → libgit2.c} +148 -49
  197. data/vendor/libgit2/src/libgit2.h +15 -0
  198. data/vendor/libgit2/src/mailmap.c +23 -10
  199. data/vendor/libgit2/src/map.h +3 -3
  200. data/vendor/libgit2/src/merge.c +95 -43
  201. data/vendor/libgit2/src/merge.h +2 -1
  202. data/vendor/libgit2/src/merge_driver.c +19 -13
  203. data/vendor/libgit2/src/merge_file.c +15 -9
  204. data/vendor/libgit2/src/message.c +3 -1
  205. data/vendor/libgit2/src/midx.c +879 -0
  206. data/vendor/libgit2/src/midx.h +110 -0
  207. data/vendor/libgit2/src/mwindow.c +214 -95
  208. data/vendor/libgit2/src/mwindow.h +3 -3
  209. data/vendor/libgit2/src/net.c +133 -4
  210. data/vendor/libgit2/src/net.h +16 -2
  211. data/vendor/libgit2/src/netops.c +6 -4
  212. data/vendor/libgit2/src/netops.h +2 -2
  213. data/vendor/libgit2/src/notes.c +40 -40
  214. data/vendor/libgit2/src/object.c +24 -15
  215. data/vendor/libgit2/src/odb.c +298 -57
  216. data/vendor/libgit2/src/odb.h +16 -2
  217. data/vendor/libgit2/src/odb_loose.c +31 -21
  218. data/vendor/libgit2/src/odb_mempack.c +3 -1
  219. data/vendor/libgit2/src/odb_pack.c +391 -114
  220. data/vendor/libgit2/src/oid.c +7 -4
  221. data/vendor/libgit2/src/oidarray.c +10 -1
  222. data/vendor/libgit2/src/pack-objects.c +83 -69
  223. data/vendor/libgit2/src/pack.c +383 -150
  224. data/vendor/libgit2/src/pack.h +44 -9
  225. data/vendor/libgit2/src/patch.c +14 -7
  226. data/vendor/libgit2/src/patch_generate.c +3 -5
  227. data/vendor/libgit2/src/patch_parse.c +6 -3
  228. data/vendor/libgit2/src/path.c +103 -58
  229. data/vendor/libgit2/src/path.h +80 -7
  230. data/vendor/libgit2/src/pathspec.c +12 -11
  231. data/vendor/libgit2/src/pool.c +34 -22
  232. data/vendor/libgit2/src/pool.h +9 -1
  233. data/vendor/libgit2/src/posix.c +43 -12
  234. data/vendor/libgit2/src/posix.h +9 -0
  235. data/vendor/libgit2/src/proxy.c +2 -0
  236. data/vendor/libgit2/src/push.c +2 -0
  237. data/vendor/libgit2/src/reader.c +10 -6
  238. data/vendor/libgit2/src/rebase.c +95 -49
  239. data/vendor/libgit2/src/refdb.c +165 -13
  240. data/vendor/libgit2/src/refdb.h +69 -0
  241. data/vendor/libgit2/src/refdb_fs.c +145 -153
  242. data/vendor/libgit2/src/reflog.c +21 -20
  243. data/vendor/libgit2/src/refs.c +153 -233
  244. data/vendor/libgit2/src/refs.h +2 -20
  245. data/vendor/libgit2/src/refspec.c +81 -45
  246. data/vendor/libgit2/src/regexp.c +2 -2
  247. data/vendor/libgit2/src/remote.c +320 -122
  248. data/vendor/libgit2/src/remote.h +2 -1
  249. data/vendor/libgit2/src/repository.c +476 -203
  250. data/vendor/libgit2/src/repository.h +27 -29
  251. data/vendor/libgit2/src/reset.c +8 -7
  252. data/vendor/libgit2/src/revert.c +8 -2
  253. data/vendor/libgit2/src/revparse.c +23 -17
  254. data/vendor/libgit2/src/revwalk.c +35 -20
  255. data/vendor/libgit2/src/runtime.c +162 -0
  256. data/vendor/libgit2/src/runtime.h +62 -0
  257. data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
  258. data/vendor/libgit2/src/signature.c +6 -5
  259. data/vendor/libgit2/src/sortedcache.c +2 -3
  260. data/vendor/libgit2/src/sortedcache.h +10 -8
  261. data/vendor/libgit2/src/stash.c +6 -2
  262. data/vendor/libgit2/src/status.c +9 -4
  263. data/vendor/libgit2/src/strarray.c +64 -0
  264. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  265. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  266. data/vendor/libgit2/src/streams/openssl.c +113 -207
  267. data/vendor/libgit2/src/streams/openssl.h +9 -1
  268. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  269. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  270. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  271. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  272. data/vendor/libgit2/src/streams/registry.c +10 -9
  273. data/vendor/libgit2/src/streams/socket.c +6 -2
  274. data/vendor/libgit2/src/streams/stransport.c +6 -3
  275. data/vendor/libgit2/src/streams/tls.c +5 -3
  276. data/vendor/libgit2/src/submodule.c +134 -66
  277. data/vendor/libgit2/src/submodule.h +9 -9
  278. data/vendor/libgit2/src/sysdir.c +8 -26
  279. data/vendor/libgit2/src/sysdir.h +0 -11
  280. data/vendor/libgit2/src/tag.c +49 -11
  281. data/vendor/libgit2/src/thread.c +140 -0
  282. data/vendor/libgit2/src/thread.h +479 -0
  283. data/vendor/libgit2/src/threadstate.c +84 -0
  284. data/vendor/libgit2/src/threadstate.h +24 -0
  285. data/vendor/libgit2/src/trace.c +2 -2
  286. data/vendor/libgit2/src/trace.h +17 -13
  287. data/vendor/libgit2/src/trailer.c +1 -1
  288. data/vendor/libgit2/src/transaction.c +21 -9
  289. data/vendor/libgit2/src/transport.c +3 -3
  290. data/vendor/libgit2/src/transports/auth.c +1 -1
  291. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  292. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  293. data/vendor/libgit2/src/transports/credential.c +17 -7
  294. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  295. data/vendor/libgit2/src/transports/git.c +1 -3
  296. data/vendor/libgit2/src/transports/http.c +19 -17
  297. data/vendor/libgit2/src/transports/http.h +1 -0
  298. data/vendor/libgit2/src/transports/httpclient.c +68 -38
  299. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  300. data/vendor/libgit2/src/transports/local.c +5 -5
  301. data/vendor/libgit2/src/transports/smart.c +14 -9
  302. data/vendor/libgit2/src/transports/smart.h +1 -1
  303. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  304. data/vendor/libgit2/src/transports/ssh.c +55 -21
  305. data/vendor/libgit2/src/transports/winhttp.c +157 -89
  306. data/vendor/libgit2/src/tree.c +100 -77
  307. data/vendor/libgit2/src/tree.h +1 -0
  308. data/vendor/libgit2/src/tsort.c +0 -2
  309. data/vendor/libgit2/src/unix/map.c +3 -1
  310. data/vendor/libgit2/src/unix/posix.h +16 -1
  311. data/vendor/libgit2/src/unix/pthread.h +2 -1
  312. data/vendor/libgit2/src/utf8.c +150 -0
  313. data/vendor/libgit2/src/utf8.h +52 -0
  314. data/vendor/libgit2/src/util.c +75 -184
  315. data/vendor/libgit2/src/util.h +34 -40
  316. data/vendor/libgit2/src/vector.c +23 -19
  317. data/vendor/libgit2/src/vector.h +4 -2
  318. data/vendor/libgit2/src/win32/findfile.c +5 -3
  319. data/vendor/libgit2/src/win32/git2.rc +18 -3
  320. data/vendor/libgit2/src/win32/map.c +1 -1
  321. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  322. data/vendor/libgit2/src/win32/path_w32.c +23 -25
  323. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  324. data/vendor/libgit2/src/win32/posix.h +6 -6
  325. data/vendor/libgit2/src/win32/posix_w32.c +86 -7
  326. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  327. data/vendor/libgit2/src/win32/reparse.h +4 -4
  328. data/vendor/libgit2/src/win32/thread.c +24 -15
  329. data/vendor/libgit2/src/win32/thread.h +1 -1
  330. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  331. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  332. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  333. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  334. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  335. data/vendor/libgit2/src/worktree.c +36 -14
  336. data/vendor/libgit2/src/zstream.c +1 -1
  337. metadata +65 -42
  338. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  339. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  340. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  341. data/vendor/libgit2/src/buf_text.c +0 -316
  342. data/vendor/libgit2/src/buf_text.h +0 -122
  343. data/vendor/libgit2/src/global.c +0 -361
  344. data/vendor/libgit2/src/global.h +0 -41
  345. data/vendor/libgit2/src/thread-utils.c +0 -58
  346. data/vendor/libgit2/src/thread-utils.h +0 -246
  347. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  348. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  349. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -7,7 +7,6 @@
7
7
  #include "buffer.h"
8
8
  #include "posix.h"
9
9
  #include "git2/buffer.h"
10
- #include "buf_text.h"
11
10
  #include <ctype.h>
12
11
 
13
12
  /* Used as default value for git_buf->ptr so that people can always
@@ -133,18 +132,24 @@ void git_buf_dispose(git_buf *buf)
133
132
  git_buf_init(buf, 0);
134
133
  }
135
134
 
135
+ #ifndef GIT_DEPRECATE_HARD
136
136
  void git_buf_free(git_buf *buf)
137
137
  {
138
138
  git_buf_dispose(buf);
139
139
  }
140
+ #endif
140
141
 
141
- void git_buf_sanitize(git_buf *buf)
142
+ int git_buf_sanitize(git_buf *buf)
142
143
  {
143
144
  if (buf->ptr == NULL) {
144
- assert(buf->size == 0 && buf->asize == 0);
145
+ GIT_ASSERT_ARG(buf->size == 0 && buf->asize == 0);
146
+
145
147
  buf->ptr = git_buf__initbuf;
146
- } else if (buf->asize > buf->size)
148
+ } else if (buf->asize > buf->size) {
147
149
  buf->ptr[buf->size] = '\0';
150
+ }
151
+
152
+ return 0;
148
153
  }
149
154
 
150
155
  void git_buf_clear(git_buf *buf)
@@ -181,16 +186,6 @@ int git_buf_set(git_buf *buf, const void *data, size_t len)
181
186
  return 0;
182
187
  }
183
188
 
184
- int git_buf_is_binary(const git_buf *buf)
185
- {
186
- return git_buf_text_is_binary(buf);
187
- }
188
-
189
- int git_buf_contains_nul(const git_buf *buf)
190
- {
191
- return git_buf_text_contains_nul(buf);
192
- }
193
-
194
189
  int git_buf_sets(git_buf *buf, const char *string)
195
190
  {
196
191
  return git_buf_set(buf, string, string ? strlen(string) : 0);
@@ -223,7 +218,7 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
223
218
  if (len) {
224
219
  size_t new_size;
225
220
 
226
- assert(data);
221
+ GIT_ASSERT_ARG(data);
227
222
 
228
223
  GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, len);
229
224
  GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
@@ -237,7 +232,8 @@ int git_buf_put(git_buf *buf, const char *data, size_t len)
237
232
 
238
233
  int git_buf_puts(git_buf *buf, const char *string)
239
234
  {
240
- assert(string);
235
+ GIT_ASSERT_ARG(string);
236
+
241
237
  return git_buf_put(buf, string, strlen(string));
242
238
  }
243
239
 
@@ -317,7 +313,7 @@ int git_buf_decode_base64(git_buf *buf, const char *base64, size_t len)
317
313
  return -1;
318
314
  }
319
315
 
320
- assert(len % 4 == 0);
316
+ GIT_ASSERT_ARG(len % 4 == 0);
321
317
  GIT_ERROR_CHECK_ALLOC_ADD(&new_size, (len / 4 * 3), buf->size);
322
318
  GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
323
319
  ENSURE_SIZE(buf, new_size);
@@ -363,7 +359,7 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len)
363
359
 
364
360
  for (i = 24; i >= 0; i -= 8) {
365
361
  uint8_t ch = *data++;
366
- acc |= ch << i;
362
+ acc |= (uint32_t)ch << i;
367
363
 
368
364
  if (--len == 0)
369
365
  break;
@@ -549,22 +545,26 @@ int git_buf_printf(git_buf *buf, const char *format, ...)
549
545
  return r;
550
546
  }
551
547
 
552
- void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
548
+ int git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
553
549
  {
554
550
  size_t copylen;
555
551
 
556
- assert(data && datasize && buf);
552
+ GIT_ASSERT_ARG(data);
553
+ GIT_ASSERT_ARG(datasize);
554
+ GIT_ASSERT_ARG(buf);
557
555
 
558
556
  data[0] = '\0';
559
557
 
560
558
  if (buf->size == 0 || buf->asize <= 0)
561
- return;
559
+ return 0;
562
560
 
563
561
  copylen = buf->size;
564
562
  if (copylen > datasize - 1)
565
563
  copylen = datasize - 1;
566
564
  memmove(data, buf->ptr, copylen);
567
565
  data[copylen] = '\0';
566
+
567
+ return 0;
568
568
  }
569
569
 
570
570
  void git_buf_consume_bytes(git_buf *buf, size_t len)
@@ -600,6 +600,13 @@ void git_buf_shorten(git_buf *buf, size_t amount)
600
600
  git_buf_clear(buf);
601
601
  }
602
602
 
603
+ void git_buf_truncate_at_char(git_buf *buf, char separator)
604
+ {
605
+ ssize_t idx = git_buf_find(buf, separator);
606
+ if (idx >= 0)
607
+ git_buf_truncate(buf, (size_t)idx);
608
+ }
609
+
603
610
  void git_buf_rtruncate_at_char(git_buf *buf, char separator)
604
611
  {
605
612
  ssize_t idx = git_buf_rfind_next(buf, separator);
@@ -670,7 +677,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
670
677
 
671
678
  va_start(ap, nbuf);
672
679
  for (i = 0; i < nbuf; ++i) {
673
- const char* segment;
680
+ const char *segment;
674
681
  size_t segment_len;
675
682
 
676
683
  segment = va_arg(ap, const char *);
@@ -702,7 +709,7 @@ int git_buf_join_n(git_buf *buf, char separator, int nbuf, ...)
702
709
 
703
710
  va_start(ap, nbuf);
704
711
  for (i = 0; i < nbuf; ++i) {
705
- const char* segment;
712
+ const char *segment;
706
713
  size_t segment_len;
707
714
 
708
715
  segment = va_arg(ap, const char *);
@@ -757,7 +764,8 @@ int git_buf_join(
757
764
  ssize_t offset_a = -1;
758
765
 
759
766
  /* not safe to have str_b point internally to the buffer */
760
- assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
767
+ if (buf->size)
768
+ GIT_ASSERT_ARG(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
761
769
 
762
770
  /* figure out if we need to insert a separator */
763
771
  if (separator && strlen_a) {
@@ -767,7 +775,7 @@ int git_buf_join(
767
775
  }
768
776
 
769
777
  /* str_a could be part of the buffer */
770
- if (str_a >= buf->ptr && str_a < buf->ptr + buf->size)
778
+ if (buf->size && str_a >= buf->ptr && str_a < buf->ptr + buf->size)
771
779
  offset_a = str_a - buf->ptr;
772
780
 
773
781
  GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b);
@@ -807,9 +815,9 @@ int git_buf_join3(
807
815
  char *tgt;
808
816
 
809
817
  /* for this function, disallow pointers into the existing buffer */
810
- assert(str_a < buf->ptr || str_a >= buf->ptr + buf->size);
811
- assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
812
- assert(str_c < buf->ptr || str_c >= buf->ptr + buf->size);
818
+ GIT_ASSERT(str_a < buf->ptr || str_a >= buf->ptr + buf->size);
819
+ GIT_ASSERT(str_b < buf->ptr || str_b >= buf->ptr + buf->size);
820
+ GIT_ASSERT(str_c < buf->ptr || str_c >= buf->ptr + buf->size);
813
821
 
814
822
  if (separator) {
815
823
  if (len_a > 0) {
@@ -882,7 +890,9 @@ int git_buf_splice(
882
890
  char *splice_loc;
883
891
  size_t new_size, alloc_size;
884
892
 
885
- assert(buf && where <= buf->size && nb_to_remove <= buf->size - where);
893
+ GIT_ASSERT(buf);
894
+ GIT_ASSERT(where <= buf->size);
895
+ GIT_ASSERT(nb_to_remove <= buf->size - where);
886
896
 
887
897
  splice_loc = buf->ptr + where;
888
898
 
@@ -1044,3 +1054,313 @@ invalid:
1044
1054
  git_error_set(GIT_ERROR_INVALID, "invalid quoted line");
1045
1055
  return -1;
1046
1056
  }
1057
+
1058
+ int git_buf_puts_escaped(
1059
+ git_buf *buf,
1060
+ const char *string,
1061
+ const char *esc_chars,
1062
+ const char *esc_with)
1063
+ {
1064
+ const char *scan;
1065
+ size_t total = 0, esc_len = strlen(esc_with), count, alloclen;
1066
+
1067
+ if (!string)
1068
+ return 0;
1069
+
1070
+ for (scan = string; *scan; ) {
1071
+ /* count run of non-escaped characters */
1072
+ count = strcspn(scan, esc_chars);
1073
+ total += count;
1074
+ scan += count;
1075
+ /* count run of escaped characters */
1076
+ count = strspn(scan, esc_chars);
1077
+ total += count * (esc_len + 1);
1078
+ scan += count;
1079
+ }
1080
+
1081
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, total, 1);
1082
+ if (git_buf_grow_by(buf, alloclen) < 0)
1083
+ return -1;
1084
+
1085
+ for (scan = string; *scan; ) {
1086
+ count = strcspn(scan, esc_chars);
1087
+
1088
+ memmove(buf->ptr + buf->size, scan, count);
1089
+ scan += count;
1090
+ buf->size += count;
1091
+
1092
+ for (count = strspn(scan, esc_chars); count > 0; --count) {
1093
+ /* copy escape sequence */
1094
+ memmove(buf->ptr + buf->size, esc_with, esc_len);
1095
+ buf->size += esc_len;
1096
+ /* copy character to be escaped */
1097
+ buf->ptr[buf->size] = *scan;
1098
+ buf->size++;
1099
+ scan++;
1100
+ }
1101
+ }
1102
+
1103
+ buf->ptr[buf->size] = '\0';
1104
+
1105
+ return 0;
1106
+ }
1107
+
1108
+ void git_buf_unescape(git_buf *buf)
1109
+ {
1110
+ buf->size = git__unescape(buf->ptr);
1111
+ }
1112
+
1113
+ int git_buf_crlf_to_lf(git_buf *tgt, const git_buf *src)
1114
+ {
1115
+ const char *scan = src->ptr;
1116
+ const char *scan_end = src->ptr + src->size;
1117
+ const char *next = memchr(scan, '\r', src->size);
1118
+ size_t new_size;
1119
+ char *out;
1120
+
1121
+ GIT_ASSERT(tgt != src);
1122
+
1123
+ if (!next)
1124
+ return git_buf_set(tgt, src->ptr, src->size);
1125
+
1126
+ /* reduce reallocs while in the loop */
1127
+ GIT_ERROR_CHECK_ALLOC_ADD(&new_size, src->size, 1);
1128
+ if (git_buf_grow(tgt, new_size) < 0)
1129
+ return -1;
1130
+
1131
+ out = tgt->ptr;
1132
+ tgt->size = 0;
1133
+
1134
+ /* Find the next \r and copy whole chunk up to there to tgt */
1135
+ for (; next; scan = next + 1, next = memchr(scan, '\r', scan_end - scan)) {
1136
+ if (next > scan) {
1137
+ size_t copylen = (size_t)(next - scan);
1138
+ memcpy(out, scan, copylen);
1139
+ out += copylen;
1140
+ }
1141
+
1142
+ /* Do not drop \r unless it is followed by \n */
1143
+ if (next + 1 == scan_end || next[1] != '\n')
1144
+ *out++ = '\r';
1145
+ }
1146
+
1147
+ /* Copy remaining input into dest */
1148
+ if (scan < scan_end) {
1149
+ size_t remaining = (size_t)(scan_end - scan);
1150
+ memcpy(out, scan, remaining);
1151
+ out += remaining;
1152
+ }
1153
+
1154
+ tgt->size = (size_t)(out - tgt->ptr);
1155
+ tgt->ptr[tgt->size] = '\0';
1156
+
1157
+ return 0;
1158
+ }
1159
+
1160
+ int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src)
1161
+ {
1162
+ const char *start = src->ptr;
1163
+ const char *end = start + src->size;
1164
+ const char *scan = start;
1165
+ const char *next = memchr(scan, '\n', src->size);
1166
+ size_t alloclen;
1167
+
1168
+ GIT_ASSERT(tgt != src);
1169
+
1170
+ if (!next)
1171
+ return git_buf_set(tgt, src->ptr, src->size);
1172
+
1173
+ /* attempt to reduce reallocs while in the loop */
1174
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, src->size, src->size >> 4);
1175
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
1176
+ if (git_buf_grow(tgt, alloclen) < 0)
1177
+ return -1;
1178
+ tgt->size = 0;
1179
+
1180
+ for (; next; scan = next + 1, next = memchr(scan, '\n', end - scan)) {
1181
+ size_t copylen = next - scan;
1182
+
1183
+ /* if we find mixed line endings, carry on */
1184
+ if (copylen && next[-1] == '\r')
1185
+ copylen--;
1186
+
1187
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, copylen, 3);
1188
+ if (git_buf_grow_by(tgt, alloclen) < 0)
1189
+ return -1;
1190
+
1191
+ if (copylen) {
1192
+ memcpy(tgt->ptr + tgt->size, scan, copylen);
1193
+ tgt->size += copylen;
1194
+ }
1195
+
1196
+ tgt->ptr[tgt->size++] = '\r';
1197
+ tgt->ptr[tgt->size++] = '\n';
1198
+ }
1199
+
1200
+ tgt->ptr[tgt->size] = '\0';
1201
+ return git_buf_put(tgt, scan, end - scan);
1202
+ }
1203
+
1204
+ int git_buf_common_prefix(git_buf *buf, char *const *const strings, size_t count)
1205
+ {
1206
+ size_t i;
1207
+ const char *str, *pfx;
1208
+
1209
+ git_buf_clear(buf);
1210
+
1211
+ if (!strings || !count)
1212
+ return 0;
1213
+
1214
+ /* initialize common prefix to first string */
1215
+ if (git_buf_sets(buf, strings[0]) < 0)
1216
+ return -1;
1217
+
1218
+ /* go through the rest of the strings, truncating to shared prefix */
1219
+ for (i = 1; i < count; ++i) {
1220
+
1221
+ for (str = strings[i], pfx = buf->ptr;
1222
+ *str && *str == *pfx;
1223
+ str++, pfx++)
1224
+ /* scanning */;
1225
+
1226
+ git_buf_truncate(buf, pfx - buf->ptr);
1227
+
1228
+ if (!buf->size)
1229
+ break;
1230
+ }
1231
+
1232
+ return 0;
1233
+ }
1234
+
1235
+ int git_buf_is_binary(const git_buf *buf)
1236
+ {
1237
+ const char *scan = buf->ptr, *end = buf->ptr + buf->size;
1238
+ git_buf_bom_t bom;
1239
+ int printable = 0, nonprintable = 0;
1240
+
1241
+ scan += git_buf_detect_bom(&bom, buf);
1242
+
1243
+ if (bom > GIT_BUF_BOM_UTF8)
1244
+ return 1;
1245
+
1246
+ while (scan < end) {
1247
+ unsigned char c = *scan++;
1248
+
1249
+ /* Printable characters are those above SPACE (0x1F) excluding DEL,
1250
+ * and including BS, ESC and FF.
1251
+ */
1252
+ if ((c > 0x1F && c != 127) || c == '\b' || c == '\033' || c == '\014')
1253
+ printable++;
1254
+ else if (c == '\0')
1255
+ return true;
1256
+ else if (!git__isspace(c))
1257
+ nonprintable++;
1258
+ }
1259
+
1260
+ return ((printable >> 7) < nonprintable);
1261
+ }
1262
+
1263
+ int git_buf_contains_nul(const git_buf *buf)
1264
+ {
1265
+ return (memchr(buf->ptr, '\0', buf->size) != NULL);
1266
+ }
1267
+
1268
+ int git_buf_detect_bom(git_buf_bom_t *bom, const git_buf *buf)
1269
+ {
1270
+ const char *ptr;
1271
+ size_t len;
1272
+
1273
+ *bom = GIT_BUF_BOM_NONE;
1274
+ /* need at least 2 bytes to look for any BOM */
1275
+ if (buf->size < 2)
1276
+ return 0;
1277
+
1278
+ ptr = buf->ptr;
1279
+ len = buf->size;
1280
+
1281
+ switch (*ptr++) {
1282
+ case 0:
1283
+ if (len >= 4 && ptr[0] == 0 && ptr[1] == '\xFE' && ptr[2] == '\xFF') {
1284
+ *bom = GIT_BUF_BOM_UTF32_BE;
1285
+ return 4;
1286
+ }
1287
+ break;
1288
+ case '\xEF':
1289
+ if (len >= 3 && ptr[0] == '\xBB' && ptr[1] == '\xBF') {
1290
+ *bom = GIT_BUF_BOM_UTF8;
1291
+ return 3;
1292
+ }
1293
+ break;
1294
+ case '\xFE':
1295
+ if (*ptr == '\xFF') {
1296
+ *bom = GIT_BUF_BOM_UTF16_BE;
1297
+ return 2;
1298
+ }
1299
+ break;
1300
+ case '\xFF':
1301
+ if (*ptr != '\xFE')
1302
+ break;
1303
+ if (len >= 4 && ptr[1] == 0 && ptr[2] == 0) {
1304
+ *bom = GIT_BUF_BOM_UTF32_LE;
1305
+ return 4;
1306
+ } else {
1307
+ *bom = GIT_BUF_BOM_UTF16_LE;
1308
+ return 2;
1309
+ }
1310
+ break;
1311
+ default:
1312
+ break;
1313
+ }
1314
+
1315
+ return 0;
1316
+ }
1317
+
1318
+ bool git_buf_gather_text_stats(
1319
+ git_buf_text_stats *stats, const git_buf *buf, bool skip_bom)
1320
+ {
1321
+ const char *scan = buf->ptr, *end = buf->ptr + buf->size;
1322
+ int skip;
1323
+
1324
+ memset(stats, 0, sizeof(*stats));
1325
+
1326
+ /* BOM detection */
1327
+ skip = git_buf_detect_bom(&stats->bom, buf);
1328
+ if (skip_bom)
1329
+ scan += skip;
1330
+
1331
+ /* Ignore EOF character */
1332
+ if (buf->size > 0 && end[-1] == '\032')
1333
+ end--;
1334
+
1335
+ /* Counting loop */
1336
+ while (scan < end) {
1337
+ unsigned char c = *scan++;
1338
+
1339
+ if (c > 0x1F && c != 0x7F)
1340
+ stats->printable++;
1341
+ else switch (c) {
1342
+ case '\0':
1343
+ stats->nul++;
1344
+ stats->nonprintable++;
1345
+ break;
1346
+ case '\n':
1347
+ stats->lf++;
1348
+ break;
1349
+ case '\r':
1350
+ stats->cr++;
1351
+ if (scan < end && *scan == '\n')
1352
+ stats->crlf++;
1353
+ break;
1354
+ case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/
1355
+ stats->printable++;
1356
+ break;
1357
+ default:
1358
+ stats->nonprintable++;
1359
+ break;
1360
+ }
1361
+ }
1362
+
1363
+ /* Treat files with a bare CR as binary */
1364
+ return (stats->cr != stats->crlf || stats->nul > 0 ||
1365
+ ((stats->printable >> 7) < stats->nonprintable));
1366
+ }
@@ -17,12 +17,34 @@
17
17
  * } git_buf;
18
18
  */
19
19
 
20
+ typedef enum {
21
+ GIT_BUF_BOM_NONE = 0,
22
+ GIT_BUF_BOM_UTF8 = 1,
23
+ GIT_BUF_BOM_UTF16_LE = 2,
24
+ GIT_BUF_BOM_UTF16_BE = 3,
25
+ GIT_BUF_BOM_UTF32_LE = 4,
26
+ GIT_BUF_BOM_UTF32_BE = 5
27
+ } git_buf_bom_t;
28
+
29
+ typedef struct {
30
+ git_buf_bom_t bom; /* BOM found at head of text */
31
+ unsigned int nul, cr, lf, crlf; /* NUL, CR, LF and CRLF counts */
32
+ unsigned int printable, nonprintable; /* These are just approximations! */
33
+ } git_buf_text_stats;
34
+
20
35
  extern char git_buf__initbuf[];
21
36
  extern char git_buf__oom[];
22
37
 
23
38
  /* Use to initialize buffer structure when git_buf is on stack */
24
39
  #define GIT_BUF_INIT { git_buf__initbuf, 0, 0 }
25
40
 
41
+ /**
42
+ * Static initializer for git_buf from static buffer
43
+ */
44
+ #ifdef GIT_DEPRECATE_HARD
45
+ # define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) }
46
+ #endif
47
+
26
48
  GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf)
27
49
  {
28
50
  return (buf->ptr != NULL && buf->asize > 0);
@@ -36,6 +58,33 @@ GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf)
36
58
  */
37
59
  extern int git_buf_init(git_buf *buf, size_t initial_size);
38
60
 
61
+ #ifdef GIT_DEPRECATE_HARD
62
+
63
+ /**
64
+ * Resize the buffer allocation to make more space.
65
+ *
66
+ * This will attempt to grow the buffer to accommodate the target size.
67
+ *
68
+ * If the buffer refers to memory that was not allocated by libgit2 (i.e.
69
+ * the `asize` field is zero), then `ptr` will be replaced with a newly
70
+ * allocated block of data. Be careful so that memory allocated by the
71
+ * caller is not lost. As a special variant, if you pass `target_size` as
72
+ * 0 and the memory is not allocated by libgit2, this will allocate a new
73
+ * buffer of size `size` and copy the external data into it.
74
+ *
75
+ * Currently, this will never shrink a buffer, only expand it.
76
+ *
77
+ * If the allocation fails, this will return an error and the buffer will be
78
+ * marked as invalid for future operations, invaliding the contents.
79
+ *
80
+ * @param buffer The buffer to be resized; may or may not be allocated yet
81
+ * @param target_size The desired available size
82
+ * @return 0 on success, -1 on allocation failure
83
+ */
84
+ int git_buf_grow(git_buf *buffer, size_t target_size);
85
+
86
+ #endif
87
+
39
88
  /**
40
89
  * Resize the buffer allocation to make more space.
41
90
  *
@@ -69,7 +118,7 @@ extern int git_buf_try_grow(
69
118
  * git_buf__initbuf. If a buffer with a non-NULL ptr is passed in, this method
70
119
  * assures that the buffer is '\0'-terminated.
71
120
  */
72
- extern void git_buf_sanitize(git_buf *buf);
121
+ extern int git_buf_sanitize(git_buf *buf);
73
122
 
74
123
  extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b);
75
124
  extern char *git_buf_detach(git_buf *buf);
@@ -105,6 +154,11 @@ GIT_INLINE(bool) git_buf_oom(const git_buf *buf)
105
154
  * return code of these functions and call them in a series then just call
106
155
  * git_buf_oom at the end.
107
156
  */
157
+
158
+ #ifdef GIT_DEPRECATE_HARD
159
+ int git_buf_set(git_buf *buffer, const void *data, size_t datalen);
160
+ #endif
161
+
108
162
  int git_buf_sets(git_buf *buf, const char *string);
109
163
  int git_buf_putc(git_buf *buf, char c);
110
164
  int git_buf_putcn(git_buf *buf, char c, size_t len);
@@ -117,6 +171,7 @@ void git_buf_consume_bytes(git_buf *buf, size_t len);
117
171
  void git_buf_consume(git_buf *buf, const char *end);
118
172
  void git_buf_truncate(git_buf *buf, size_t len);
119
173
  void git_buf_shorten(git_buf *buf, size_t amount);
174
+ void git_buf_truncate_at_char(git_buf *buf, char separator);
120
175
  void git_buf_rtruncate_at_char(git_buf *path, char separator);
121
176
 
122
177
  /** General join with separator */
@@ -145,7 +200,7 @@ GIT_INLINE(size_t) git_buf_len(const git_buf *buf)
145
200
  return buf->size;
146
201
  }
147
202
 
148
- void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf);
203
+ int git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf);
149
204
 
150
205
  #define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1)
151
206
 
@@ -219,4 +274,101 @@ int git_buf_splice(
219
274
  const char *data,
220
275
  size_t nb_to_insert);
221
276
 
277
+ /**
278
+ * Append string to buffer, prefixing each character from `esc_chars` with
279
+ * `esc_with` string.
280
+ *
281
+ * @param buf Buffer to append data to
282
+ * @param string String to escape and append
283
+ * @param esc_chars Characters to be escaped
284
+ * @param esc_with String to insert in from of each found character
285
+ * @return 0 on success, <0 on failure (probably allocation problem)
286
+ */
287
+ extern int git_buf_puts_escaped(
288
+ git_buf *buf,
289
+ const char *string,
290
+ const char *esc_chars,
291
+ const char *esc_with);
292
+
293
+ /**
294
+ * Append string escaping characters that are regex special
295
+ */
296
+ GIT_INLINE(int) git_buf_puts_escape_regex(git_buf *buf, const char *string)
297
+ {
298
+ return git_buf_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\");
299
+ }
300
+
301
+ /**
302
+ * Unescape all characters in a buffer in place
303
+ *
304
+ * I.e. remove backslashes
305
+ */
306
+ extern void git_buf_unescape(git_buf *buf);
307
+
308
+ /**
309
+ * Replace all \r\n with \n.
310
+ *
311
+ * @return 0 on success, -1 on memory error
312
+ */
313
+ extern int git_buf_crlf_to_lf(git_buf *tgt, const git_buf *src);
314
+
315
+ /**
316
+ * Replace all \n with \r\n. Does not modify existing \r\n.
317
+ *
318
+ * @return 0 on success, -1 on memory error
319
+ */
320
+ extern int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src);
321
+
322
+ /**
323
+ * Fill buffer with the common prefix of a array of strings
324
+ *
325
+ * Buffer will be set to empty if there is no common prefix
326
+ */
327
+ extern int git_buf_common_prefix(git_buf *buf, char *const *const strings, size_t count);
328
+
329
+ /**
330
+ * Check if a buffer begins with a UTF BOM
331
+ *
332
+ * @param bom Set to the type of BOM detected or GIT_BOM_NONE
333
+ * @param buf Buffer in which to check the first bytes for a BOM
334
+ * @return Number of bytes of BOM data (or 0 if no BOM found)
335
+ */
336
+ extern int git_buf_detect_bom(git_buf_bom_t *bom, const git_buf *buf);
337
+
338
+ /**
339
+ * Gather stats for a piece of text
340
+ *
341
+ * Fill the `stats` structure with counts of unreadable characters, carriage
342
+ * returns, etc, so it can be used in heuristics. This automatically skips
343
+ * a trailing EOF (\032 character). Also it will look for a BOM at the
344
+ * start of the text and can be told to skip that as well.
345
+ *
346
+ * @param stats Structure to be filled in
347
+ * @param buf Text to process
348
+ * @param skip_bom Exclude leading BOM from stats if true
349
+ * @return Does the buffer heuristically look like binary data
350
+ */
351
+ extern bool git_buf_gather_text_stats(
352
+ git_buf_text_stats *stats, const git_buf *buf, bool skip_bom);
353
+
354
+ #ifdef GIT_DEPRECATE_HARD
355
+
356
+ /**
357
+ * Check quickly if buffer looks like it contains binary data
358
+ *
359
+ * @param buf Buffer to check
360
+ * @return 1 if buffer looks like non-text data
361
+ */
362
+ int git_buf_is_binary(const git_buf *buf);
363
+
364
+ /**
365
+ * Check quickly if buffer contains a NUL byte
366
+ *
367
+ * @param buf Buffer to check
368
+ * @return 1 if buffer contains a NUL byte
369
+ */
370
+ int git_buf_contains_nul(const git_buf *buf);
371
+
372
+ #endif
373
+
222
374
  #endif