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
@@ -14,10 +14,10 @@
14
14
  #include "git2/mailmap.h"
15
15
  #include "git2/sys/commit.h"
16
16
 
17
+ #include "buf.h"
17
18
  #include "odb.h"
18
19
  #include "commit.h"
19
20
  #include "signature.h"
20
- #include "message.h"
21
21
  #include "refs.h"
22
22
  #include "object.h"
23
23
  #include "array.h"
@@ -42,7 +42,7 @@ void git_commit__free(void *_commit)
42
42
  }
43
43
 
44
44
  static int git_commit__create_buffer_internal(
45
- git_buf *out,
45
+ git_str *out,
46
46
  const git_signature *author,
47
47
  const git_signature *committer,
48
48
  const char *message_encoding,
@@ -53,7 +53,8 @@ static int git_commit__create_buffer_internal(
53
53
  size_t i = 0;
54
54
  const git_oid *parent;
55
55
 
56
- assert(out && tree);
56
+ GIT_ASSERT_ARG(out);
57
+ GIT_ASSERT_ARG(tree);
57
58
 
58
59
  git_oid__writebuf(out, "tree ", tree);
59
60
 
@@ -66,17 +67,17 @@ static int git_commit__create_buffer_internal(
66
67
  git_signature__writebuf(out, "committer ", committer);
67
68
 
68
69
  if (message_encoding != NULL)
69
- git_buf_printf(out, "encoding %s\n", message_encoding);
70
+ git_str_printf(out, "encoding %s\n", message_encoding);
70
71
 
71
- git_buf_putc(out, '\n');
72
+ git_str_putc(out, '\n');
72
73
 
73
- if (git_buf_puts(out, message) < 0)
74
+ if (git_str_puts(out, message) < 0)
74
75
  goto on_error;
75
76
 
76
77
  return 0;
77
78
 
78
79
  on_error:
79
- git_buf_dispose(out);
80
+ git_str_dispose(out);
80
81
  return -1;
81
82
  }
82
83
 
@@ -135,7 +136,7 @@ static int git_commit__create_internal(
135
136
  int error;
136
137
  git_odb *odb;
137
138
  git_reference *ref = NULL;
138
- git_buf buf = GIT_BUF_INIT;
139
+ git_str buf = GIT_STR_INIT;
139
140
  const git_oid *current_id = NULL;
140
141
  git_array_oid_t parents = GIT_ARRAY_INIT;
141
142
 
@@ -178,7 +179,7 @@ static int git_commit__create_internal(
178
179
  cleanup:
179
180
  git_array_clear(parents);
180
181
  git_reference_free(ref);
181
- git_buf_dispose(&buf);
182
+ git_str_dispose(&buf);
182
183
  return error;
183
184
  }
184
185
 
@@ -229,7 +230,8 @@ int git_commit_create_v(
229
230
  int error = 0;
230
231
  commit_parent_varargs data;
231
232
 
232
- assert(tree && git_tree_owner(tree) == repo);
233
+ GIT_ASSERT_ARG(tree);
234
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
233
235
 
234
236
  data.total = parent_count;
235
237
  va_start(data.args, parent_count);
@@ -306,7 +308,8 @@ int git_commit_create(
306
308
  {
307
309
  commit_parent_data data = { parent_count, parents, repo };
308
310
 
309
- assert(tree && git_tree_owner(tree) == repo);
311
+ GIT_ASSERT_ARG(tree);
312
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
310
313
 
311
314
  return git_commit__create_internal(
312
315
  id, repo, update_ref, author, committer,
@@ -337,7 +340,8 @@ int git_commit_amend(
337
340
  git_reference *ref;
338
341
  int error;
339
342
 
340
- assert(id && commit_to_amend);
343
+ GIT_ASSERT_ARG(id);
344
+ GIT_ASSERT_ARG(commit_to_amend);
341
345
 
342
346
  repo = git_commit_owner(commit_to_amend);
343
347
 
@@ -356,7 +360,7 @@ int git_commit_amend(
356
360
  git_oid_cpy(&tree_id, git_tree_id(old_tree));
357
361
  git_tree_free(old_tree);
358
362
  } else {
359
- assert(git_tree_owner(tree) == repo);
363
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
360
364
  git_oid_cpy(&tree_id, git_tree_id(tree));
361
365
  }
362
366
 
@@ -391,8 +395,10 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
391
395
  git_oid parent_id;
392
396
  size_t header_len;
393
397
  git_signature dummy_sig;
398
+ int error;
394
399
 
395
- assert(commit && data);
400
+ GIT_ASSERT_ARG(commit);
401
+ GIT_ASSERT_ARG(data);
396
402
 
397
403
  buffer = buffer_start;
398
404
 
@@ -426,14 +432,14 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
426
432
  commit->author = git__malloc(sizeof(git_signature));
427
433
  GIT_ERROR_CHECK_ALLOC(commit->author);
428
434
 
429
- if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0)
430
- return -1;
435
+ if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n')) < 0)
436
+ return error;
431
437
  }
432
438
 
433
439
  /* Some tools create multiple author fields, ignore the extra ones */
434
440
  while (!git__prefixncmp(buffer, buffer_end - buffer, "author ")) {
435
- if (git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n') < 0)
436
- return -1;
441
+ if ((error = git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n')) < 0)
442
+ return error;
437
443
 
438
444
  git__free(dummy_sig.name);
439
445
  git__free(dummy_sig.email);
@@ -443,8 +449,8 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
443
449
  commit->committer = git__malloc(sizeof(git_signature));
444
450
  GIT_ERROR_CHECK_ALLOC(commit->committer);
445
451
 
446
- if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0)
447
- return -1;
452
+ if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n')) < 0)
453
+ return error;
448
454
 
449
455
  if (flags & GIT_COMMIT_PARSE_QUICK)
450
456
  return 0;
@@ -488,7 +494,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
488
494
 
489
495
  bad_buffer:
490
496
  git_error_set(GIT_ERROR_OBJECT, "failed to parse bad commit object");
491
- return -1;
497
+ return GIT_EINVALID;
492
498
  }
493
499
 
494
500
  int git_commit__parse_raw(void *commit, const char *data, size_t size)
@@ -506,28 +512,28 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
506
512
  return git_commit__parse_ext(_commit, odb_obj, 0);
507
513
  }
508
514
 
509
- #define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
515
+ #define GIT_COMMIT_GETTER(_rvalue, _name, _return, _invalid) \
510
516
  _rvalue git_commit_##_name(const git_commit *commit) \
511
517
  {\
512
- assert(commit); \
518
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, _invalid); \
513
519
  return _return; \
514
520
  }
515
521
 
516
- GIT_COMMIT_GETTER(const git_signature *, author, commit->author)
517
- GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer)
518
- GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message)
519
- GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding)
520
- GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header)
521
- GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time)
522
- GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset)
523
- GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids))
524
- GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id)
522
+ GIT_COMMIT_GETTER(const git_signature *, author, commit->author, NULL)
523
+ GIT_COMMIT_GETTER(const git_signature *, committer, commit->committer, NULL)
524
+ GIT_COMMIT_GETTER(const char *, message_raw, commit->raw_message, NULL)
525
+ GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding, NULL)
526
+ GIT_COMMIT_GETTER(const char *, raw_header, commit->raw_header, NULL)
527
+ GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time, INT64_MIN)
528
+ GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset, -1)
529
+ GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)git_array_size(commit->parent_ids), 0)
530
+ GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id, NULL)
525
531
 
526
532
  const char *git_commit_message(const git_commit *commit)
527
533
  {
528
534
  const char *message;
529
535
 
530
- assert(commit);
536
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
531
537
 
532
538
  message = commit->raw_message;
533
539
 
@@ -540,20 +546,31 @@ const char *git_commit_message(const git_commit *commit)
540
546
 
541
547
  const char *git_commit_summary(git_commit *commit)
542
548
  {
543
- git_buf summary = GIT_BUF_INIT;
544
- const char *msg, *space;
549
+ git_str summary = GIT_STR_INIT;
550
+ const char *msg, *space, *next;
545
551
  bool space_contains_newline = false;
546
552
 
547
- assert(commit);
553
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
548
554
 
549
555
  if (!commit->summary) {
550
556
  for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) {
551
557
  char next_character = msg[0];
552
558
  /* stop processing at the end of the first paragraph */
553
- if (next_character == '\n' && (!msg[1] || msg[1] == '\n'))
554
- break;
559
+ if (next_character == '\n') {
560
+ if (!msg[1])
561
+ break;
562
+ if (msg[1] == '\n')
563
+ break;
564
+ /* stop processing if next line contains only whitespace */
565
+ next = msg + 1;
566
+ while (*next && git__isspace_nonlf(*next)) {
567
+ ++next;
568
+ }
569
+ if (!*next || *next == '\n')
570
+ break;
571
+ }
555
572
  /* record the beginning of contiguous whitespace runs */
556
- else if (git__isspace(next_character)) {
573
+ if (git__isspace(next_character)) {
557
574
  if(space == NULL) {
558
575
  space = msg;
559
576
  space_contains_newline = false;
@@ -565,17 +582,17 @@ const char *git_commit_summary(git_commit *commit)
565
582
  /* process any recorded whitespace */
566
583
  if (space) {
567
584
  if(space_contains_newline)
568
- git_buf_putc(&summary, ' '); /* if the space contains a newline, collapse to ' ' */
585
+ git_str_putc(&summary, ' '); /* if the space contains a newline, collapse to ' ' */
569
586
  else
570
- git_buf_put(&summary, space, (msg - space)); /* otherwise copy it */
587
+ git_str_put(&summary, space, (msg - space)); /* otherwise copy it */
571
588
  space = NULL;
572
589
  }
573
590
  /* copy the next character */
574
- git_buf_putc(&summary, next_character);
591
+ git_str_putc(&summary, next_character);
575
592
  }
576
593
  }
577
594
 
578
- commit->summary = git_buf_detach(&summary);
595
+ commit->summary = git_str_detach(&summary);
579
596
  if (!commit->summary)
580
597
  commit->summary = git__strdup("");
581
598
  }
@@ -587,7 +604,7 @@ const char *git_commit_body(git_commit *commit)
587
604
  {
588
605
  const char *msg, *end;
589
606
 
590
- assert(commit);
607
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
591
608
 
592
609
  if (!commit->body) {
593
610
  /* search for end of summary */
@@ -612,14 +629,14 @@ const char *git_commit_body(git_commit *commit)
612
629
 
613
630
  int git_commit_tree(git_tree **tree_out, const git_commit *commit)
614
631
  {
615
- assert(commit);
632
+ GIT_ASSERT_ARG(commit);
616
633
  return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_id);
617
634
  }
618
635
 
619
636
  const git_oid *git_commit_parent_id(
620
637
  const git_commit *commit, unsigned int n)
621
638
  {
622
- assert(commit);
639
+ GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
623
640
 
624
641
  return git_array_get(commit->parent_ids, n);
625
642
  }
@@ -628,7 +645,7 @@ int git_commit_parent(
628
645
  git_commit **parent, const git_commit *commit, unsigned int n)
629
646
  {
630
647
  const git_oid *parent_id;
631
- assert(commit);
648
+ GIT_ASSERT_ARG(commit);
632
649
 
633
650
  parent_id = git_commit_parent_id(commit, n);
634
651
  if (parent_id == NULL) {
@@ -647,7 +664,8 @@ int git_commit_nth_gen_ancestor(
647
664
  git_commit *current, *parent = NULL;
648
665
  int error;
649
666
 
650
- assert(ancestor && commit);
667
+ GIT_ASSERT_ARG(ancestor);
668
+ GIT_ASSERT_ARG(commit);
651
669
 
652
670
  if (git_commit_dup(&current, (git_commit *)commit) < 0)
653
671
  return -1;
@@ -672,11 +690,22 @@ int git_commit_nth_gen_ancestor(
672
690
  return 0;
673
691
  }
674
692
 
675
- int git_commit_header_field(git_buf *out, const git_commit *commit, const char *field)
693
+ int git_commit_header_field(
694
+ git_buf *out,
695
+ const git_commit *commit,
696
+ const char *field)
697
+ {
698
+ GIT_BUF_WRAP_PRIVATE(out, git_commit__header_field, commit, field);
699
+ }
700
+
701
+ int git_commit__header_field(
702
+ git_str *out,
703
+ const git_commit *commit,
704
+ const char *field)
676
705
  {
677
706
  const char *eol, *buf = commit->raw_header;
678
707
 
679
- git_buf_clear(out);
708
+ git_str_clear(out);
680
709
 
681
710
  while ((eol = strchr(buf, '\n'))) {
682
711
  /* We can skip continuations here */
@@ -700,22 +729,22 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
700
729
 
701
730
  buf++; /* skip the SP */
702
731
 
703
- git_buf_put(out, buf, eol - buf);
704
- if (git_buf_oom(out))
732
+ git_str_put(out, buf, eol - buf);
733
+ if (git_str_oom(out))
705
734
  goto oom;
706
735
 
707
736
  /* If the next line starts with SP, it's multi-line, we must continue */
708
737
  while (eol[1] == ' ') {
709
- git_buf_putc(out, '\n');
738
+ git_str_putc(out, '\n');
710
739
  buf = eol + 2;
711
740
  eol = strchr(buf, '\n');
712
741
  if (!eol)
713
742
  goto malformed;
714
743
 
715
- git_buf_put(out, buf, eol - buf);
744
+ git_str_put(out, buf, eol - buf);
716
745
  }
717
746
 
718
- if (git_buf_oom(out))
747
+ if (git_str_oom(out))
719
748
  goto oom;
720
749
 
721
750
  return 0;
@@ -732,7 +761,35 @@ oom:
732
761
  return -1;
733
762
  }
734
763
 
735
- int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_repository *repo, git_oid *commit_id, const char *field)
764
+ int git_commit_extract_signature(
765
+ git_buf *signature_out,
766
+ git_buf *signed_data_out,
767
+ git_repository *repo,
768
+ git_oid *commit_id,
769
+ const char *field)
770
+ {
771
+ git_str signature = GIT_STR_INIT, signed_data = GIT_STR_INIT;
772
+ int error;
773
+
774
+ if ((error = git_buf_tostr(&signature, signature_out)) < 0 ||
775
+ (error = git_buf_tostr(&signed_data, signed_data_out)) < 0 ||
776
+ (error = git_commit__extract_signature(&signature, &signed_data, repo, commit_id, field)) < 0 ||
777
+ (error = git_buf_fromstr(signature_out, &signature)) < 0 ||
778
+ (error = git_buf_fromstr(signed_data_out, &signed_data)) < 0)
779
+ goto done;
780
+
781
+ done:
782
+ git_str_dispose(&signature);
783
+ git_str_dispose(&signed_data);
784
+ return error;
785
+ }
786
+
787
+ int git_commit__extract_signature(
788
+ git_str *signature,
789
+ git_str *signed_data,
790
+ git_repository *repo,
791
+ git_oid *commit_id,
792
+ const char *field)
736
793
  {
737
794
  git_odb_object *obj;
738
795
  git_odb *odb;
@@ -740,8 +797,8 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
740
797
  const char *h, *eol;
741
798
  int error;
742
799
 
743
- git_buf_clear(signature);
744
- git_buf_clear(signed_data);
800
+ git_str_clear(signature);
801
+ git_str_clear(signed_data);
745
802
 
746
803
  if (!field)
747
804
  field = "gpgsig";
@@ -763,7 +820,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
763
820
  while ((h = strchr(buf, '\n')) && h[1] != '\0') {
764
821
  h++;
765
822
  if (git__prefixcmp(buf, field)) {
766
- if (git_buf_put(signed_data, buf, h - buf) < 0)
823
+ if (git_str_put(signed_data, buf, h - buf) < 0)
767
824
  return -1;
768
825
 
769
826
  buf = h;
@@ -782,25 +839,25 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
782
839
 
783
840
  h++; /* skip the SP */
784
841
 
785
- git_buf_put(signature, h, eol - h);
786
- if (git_buf_oom(signature))
842
+ git_str_put(signature, h, eol - h);
843
+ if (git_str_oom(signature))
787
844
  goto oom;
788
845
 
789
846
  /* If the next line starts with SP, it's multi-line, we must continue */
790
847
  while (eol[1] == ' ') {
791
- git_buf_putc(signature, '\n');
848
+ git_str_putc(signature, '\n');
792
849
  h = eol + 2;
793
850
  eol = strchr(h, '\n');
794
851
  if (!eol)
795
852
  goto malformed;
796
853
 
797
- git_buf_put(signature, h, eol - h);
854
+ git_str_put(signature, h, eol - h);
798
855
  }
799
856
 
800
- if (git_buf_oom(signature))
857
+ if (git_str_oom(signature))
801
858
  goto oom;
802
859
 
803
- error = git_buf_puts(signed_data, eol+1);
860
+ error = git_str_puts(signed_data, eol+1);
804
861
  git_odb_object_free(obj);
805
862
  return error;
806
863
  }
@@ -820,12 +877,29 @@ oom:
820
877
 
821
878
  cleanup:
822
879
  git_odb_object_free(obj);
823
- git_buf_clear(signature);
824
- git_buf_clear(signed_data);
880
+ git_str_clear(signature);
881
+ git_str_clear(signed_data);
825
882
  return error;
826
883
  }
827
884
 
828
- int git_commit_create_buffer(git_buf *out,
885
+ int git_commit_create_buffer(
886
+ git_buf *out,
887
+ git_repository *repo,
888
+ const git_signature *author,
889
+ const git_signature *committer,
890
+ const char *message_encoding,
891
+ const char *message,
892
+ const git_tree *tree,
893
+ size_t parent_count,
894
+ const git_commit *parents[])
895
+ {
896
+ GIT_BUF_WRAP_PRIVATE(out, git_commit__create_buffer, repo,
897
+ author, committer, message_encoding, message,
898
+ tree, parent_count, parents);
899
+ }
900
+
901
+ int git_commit__create_buffer(
902
+ git_str *out,
829
903
  git_repository *repo,
830
904
  const git_signature *author,
831
905
  const git_signature *committer,
@@ -840,7 +914,8 @@ int git_commit_create_buffer(git_buf *out,
840
914
  git_array_oid_t parents_arr = GIT_ARRAY_INIT;
841
915
  const git_oid *tree_id;
842
916
 
843
- assert(tree && git_tree_owner(tree) == repo);
917
+ GIT_ASSERT_ARG(tree);
918
+ GIT_ASSERT_ARG(git_tree_owner(tree) == repo);
844
919
 
845
920
  tree_id = git_tree_id(tree);
846
921
 
@@ -859,23 +934,27 @@ int git_commit_create_buffer(git_buf *out,
859
934
  /**
860
935
  * Append to 'out' properly marking continuations when there's a newline in 'content'
861
936
  */
862
- static void format_header_field(git_buf *out, const char *field, const char *content)
937
+ static int format_header_field(git_str *out, const char *field, const char *content)
863
938
  {
864
939
  const char *lf;
865
940
 
866
- assert(out && field && content);
941
+ GIT_ASSERT_ARG(out);
942
+ GIT_ASSERT_ARG(field);
943
+ GIT_ASSERT_ARG(content);
867
944
 
868
- git_buf_puts(out, field);
869
- git_buf_putc(out, ' ');
945
+ git_str_puts(out, field);
946
+ git_str_putc(out, ' ');
870
947
 
871
948
  while ((lf = strchr(content, '\n')) != NULL) {
872
- git_buf_put(out, content, lf - content);
873
- git_buf_puts(out, "\n ");
949
+ git_str_put(out, content, lf - content);
950
+ git_str_puts(out, "\n ");
874
951
  content = lf + 1;
875
952
  }
876
953
 
877
- git_buf_puts(out, content);
878
- git_buf_putc(out, '\n');
954
+ git_str_puts(out, content);
955
+ git_str_putc(out, '\n');
956
+
957
+ return git_str_oom(out) ? -1 : 0;
879
958
  }
880
959
 
881
960
  static const git_oid *commit_parent_from_commit(size_t n, void *payload)
@@ -897,15 +976,17 @@ int git_commit_create_with_signature(
897
976
  int error = 0;
898
977
  const char *field;
899
978
  const char *header_end;
900
- git_buf commit = GIT_BUF_INIT;
979
+ git_str commit = GIT_STR_INIT;
901
980
  git_commit *parsed;
902
981
  git_array_oid_t parents = GIT_ARRAY_INIT;
903
982
 
904
983
  /* The first step is to verify that all the tree and parents exist */
905
984
  parsed = git__calloc(1, sizeof(git_commit));
906
985
  GIT_ERROR_CHECK_ALLOC(parsed);
907
- if ((error = commit_parse(parsed, commit_content, strlen(commit_content), 0)) < 0)
986
+ if (commit_parse(parsed, commit_content, strlen(commit_content), 0) < 0) {
987
+ error = -1;
908
988
  goto cleanup;
989
+ }
909
990
 
910
991
  if ((error = validate_tree_and_parents(&parents, repo, &parsed->tree_id, commit_parent_from_commit, parsed, NULL, true)) < 0)
911
992
  goto cleanup;
@@ -922,16 +1003,18 @@ int git_commit_create_with_signature(
922
1003
 
923
1004
  /* The header ends after the first LF */
924
1005
  header_end++;
925
- git_buf_put(&commit, commit_content, header_end - commit_content);
1006
+ git_str_put(&commit, commit_content, header_end - commit_content);
926
1007
 
927
1008
  if (signature != NULL) {
928
1009
  field = signature_field ? signature_field : "gpgsig";
929
- format_header_field(&commit, field, signature);
1010
+
1011
+ if ((error = format_header_field(&commit, field, signature)) < 0)
1012
+ goto cleanup;
930
1013
  }
931
1014
 
932
- git_buf_puts(&commit, header_end);
1015
+ git_str_puts(&commit, header_end);
933
1016
 
934
- if (git_buf_oom(&commit))
1017
+ if (git_str_oom(&commit))
935
1018
  return -1;
936
1019
 
937
1020
  if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
@@ -942,7 +1025,7 @@ int git_commit_create_with_signature(
942
1025
 
943
1026
  cleanup:
944
1027
  git_commit__free(parsed);
945
- git_buf_dispose(&commit);
1028
+ git_str_dispose(&commit);
946
1029
  return error;
947
1030
  }
948
1031
 
@@ -33,12 +33,35 @@ struct git_commit {
33
33
  char *body;
34
34
  };
35
35
 
36
+ int git_commit__header_field(
37
+ git_str *out,
38
+ const git_commit *commit,
39
+ const char *field);
40
+
41
+ int git_commit__extract_signature(
42
+ git_str *signature,
43
+ git_str *signed_data,
44
+ git_repository *repo,
45
+ git_oid *commit_id,
46
+ const char *field);
47
+
48
+ int git_commit__create_buffer(
49
+ git_str *out,
50
+ git_repository *repo,
51
+ const git_signature *author,
52
+ const git_signature *committer,
53
+ const char *message_encoding,
54
+ const char *message,
55
+ const git_tree *tree,
56
+ size_t parent_count,
57
+ const git_commit *parents[]);
58
+
36
59
  void git_commit__free(void *commit);
37
60
  int git_commit__parse(void *commit, git_odb_object *obj);
38
61
  int git_commit__parse_raw(void *commit, const char *data, size_t size);
39
62
 
40
63
  typedef enum {
41
- GIT_COMMIT_PARSE_QUICK = (1 << 0), /**< Only parse parents and committer info */
64
+ GIT_COMMIT_PARSE_QUICK = (1 << 0) /**< Only parse parents and committer info */
42
65
  } git_commit__parse_flags;
43
66
 
44
67
  int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned int flags);