rugged 1.3.2.3 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (329) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +1 -1
  3. data/ext/rugged/rugged_config.c +7 -2
  4. data/ext/rugged/rugged_remote.c +17 -0
  5. data/lib/rugged/version.rb +1 -1
  6. data/vendor/libgit2/CMakeLists.txt +103 -276
  7. data/vendor/libgit2/COPYING +36 -19
  8. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  9. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  10. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  11. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  12. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  13. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  14. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  15. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  16. data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
  17. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  19. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  20. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  21. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  22. data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
  23. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  24. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  25. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  26. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  27. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  28. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  29. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
  30. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -49
  31. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  32. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  33. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  34. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  35. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
  36. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +31 -31
  37. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +1 -1
  38. data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
  39. data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
  40. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  42. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  43. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  44. data/vendor/libgit2/deps/zlib/crc32.c +288 -975
  45. data/vendor/libgit2/deps/zlib/crc32.h +436 -9441
  46. data/vendor/libgit2/deps/zlib/deflate.c +31 -83
  47. data/vendor/libgit2/deps/zlib/deflate.h +15 -12
  48. data/vendor/libgit2/deps/zlib/gzguts.h +2 -3
  49. data/vendor/libgit2/deps/zlib/infback.c +1 -2
  50. data/vendor/libgit2/deps/zlib/inffast.c +14 -14
  51. data/vendor/libgit2/deps/zlib/inflate.c +8 -39
  52. data/vendor/libgit2/deps/zlib/inflate.h +2 -3
  53. data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
  54. data/vendor/libgit2/deps/zlib/trees.c +48 -27
  55. data/vendor/libgit2/deps/zlib/zlib.h +100 -126
  56. data/vendor/libgit2/deps/zlib/zutil.c +2 -2
  57. data/vendor/libgit2/deps/zlib/zutil.h +9 -12
  58. data/vendor/libgit2/include/git2/apply.h +16 -2
  59. data/vendor/libgit2/include/git2/attr.h +11 -2
  60. data/vendor/libgit2/include/git2/blame.h +4 -1
  61. data/vendor/libgit2/include/git2/blob.h +14 -1
  62. data/vendor/libgit2/include/git2/branch.h +2 -0
  63. data/vendor/libgit2/include/git2/buffer.h +18 -78
  64. data/vendor/libgit2/include/git2/cert.h +2 -2
  65. data/vendor/libgit2/include/git2/checkout.h +5 -2
  66. data/vendor/libgit2/include/git2/clone.h +3 -3
  67. data/vendor/libgit2/include/git2/commit.h +2 -0
  68. data/vendor/libgit2/include/git2/common.h +5 -12
  69. data/vendor/libgit2/include/git2/config.h +19 -3
  70. data/vendor/libgit2/include/git2/credential.h +2 -1
  71. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  72. data/vendor/libgit2/include/git2/deprecated.h +1 -1
  73. data/vendor/libgit2/include/git2/describe.h +7 -2
  74. data/vendor/libgit2/include/git2/diff.h +17 -9
  75. data/vendor/libgit2/include/git2/email.h +1 -1
  76. data/vendor/libgit2/include/git2/errors.h +1 -2
  77. data/vendor/libgit2/include/git2/filter.h +7 -2
  78. data/vendor/libgit2/include/git2/graph.h +1 -0
  79. data/vendor/libgit2/include/git2/ignore.h +1 -1
  80. data/vendor/libgit2/include/git2/index.h +11 -5
  81. data/vendor/libgit2/include/git2/indexer.h +19 -0
  82. data/vendor/libgit2/include/git2/merge.h +23 -3
  83. data/vendor/libgit2/include/git2/message.h +2 -0
  84. data/vendor/libgit2/include/git2/object.h +23 -0
  85. data/vendor/libgit2/include/git2/odb.h +37 -7
  86. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  87. data/vendor/libgit2/include/git2/pack.h +24 -8
  88. data/vendor/libgit2/include/git2/patch.h +8 -0
  89. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  90. data/vendor/libgit2/include/git2/proxy.h +1 -1
  91. data/vendor/libgit2/include/git2/rebase.h +9 -1
  92. data/vendor/libgit2/include/git2/refdb.h +3 -0
  93. data/vendor/libgit2/include/git2/reflog.h +1 -1
  94. data/vendor/libgit2/include/git2/refs.h +2 -2
  95. data/vendor/libgit2/include/git2/remote.h +184 -37
  96. data/vendor/libgit2/include/git2/repository.h +14 -9
  97. data/vendor/libgit2/include/git2/reset.h +2 -2
  98. data/vendor/libgit2/include/git2/revparse.h +1 -1
  99. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  100. data/vendor/libgit2/include/git2/signature.h +1 -1
  101. data/vendor/libgit2/include/git2/stash.h +3 -3
  102. data/vendor/libgit2/include/git2/status.h +9 -3
  103. data/vendor/libgit2/include/git2/submodule.h +7 -2
  104. data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
  105. data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
  106. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  107. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  108. data/vendor/libgit2/include/git2/sys/transport.h +25 -34
  109. data/vendor/libgit2/include/git2/tag.h +1 -0
  110. data/vendor/libgit2/include/git2/tree.h +4 -3
  111. data/vendor/libgit2/include/git2/types.h +7 -7
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/include/git2/worktree.h +12 -2
  114. data/vendor/libgit2/src/CMakeLists.txt +189 -315
  115. data/vendor/libgit2/src/annotated_commit.h +1 -1
  116. data/vendor/libgit2/src/apply.c +18 -18
  117. data/vendor/libgit2/src/apply.h +2 -2
  118. data/vendor/libgit2/src/attr.c +18 -18
  119. data/vendor/libgit2/src/attr_file.c +17 -17
  120. data/vendor/libgit2/src/attr_file.h +4 -4
  121. data/vendor/libgit2/src/attrcache.c +17 -12
  122. data/vendor/libgit2/src/blame_git.c +1 -1
  123. data/vendor/libgit2/src/blob.c +33 -26
  124. data/vendor/libgit2/src/blob.h +1 -1
  125. data/vendor/libgit2/src/branch.c +150 -109
  126. data/vendor/libgit2/src/branch.h +15 -3
  127. data/vendor/libgit2/src/buf.c +126 -0
  128. data/vendor/libgit2/src/buf.h +50 -0
  129. data/vendor/libgit2/src/cc-compat.h +1 -1
  130. data/vendor/libgit2/src/checkout.c +74 -68
  131. data/vendor/libgit2/src/cherrypick.c +10 -10
  132. data/vendor/libgit2/src/clone.c +66 -66
  133. data/vendor/libgit2/src/commit.c +128 -58
  134. data/vendor/libgit2/src/commit.h +24 -1
  135. data/vendor/libgit2/src/commit_graph.c +68 -53
  136. data/vendor/libgit2/src/commit_graph.h +10 -3
  137. data/vendor/libgit2/src/commit_list.c +2 -3
  138. data/vendor/libgit2/src/common.h +10 -3
  139. data/vendor/libgit2/src/config.c +99 -77
  140. data/vendor/libgit2/src/config.h +15 -2
  141. data/vendor/libgit2/src/config_file.c +103 -91
  142. data/vendor/libgit2/src/config_mem.c +9 -9
  143. data/vendor/libgit2/src/config_parse.c +27 -23
  144. data/vendor/libgit2/src/crlf.c +24 -21
  145. data/vendor/libgit2/src/date.c +10 -17
  146. data/vendor/libgit2/src/date.h +33 -0
  147. data/vendor/libgit2/src/describe.c +27 -19
  148. data/vendor/libgit2/src/diff.c +25 -8
  149. data/vendor/libgit2/src/diff.h +2 -4
  150. data/vendor/libgit2/src/diff_driver.c +34 -36
  151. data/vendor/libgit2/src/diff_driver.h +3 -3
  152. data/vendor/libgit2/src/diff_file.c +29 -20
  153. data/vendor/libgit2/src/diff_generate.c +30 -6
  154. data/vendor/libgit2/src/diff_generate.h +5 -3
  155. data/vendor/libgit2/src/diff_print.c +102 -95
  156. data/vendor/libgit2/src/diff_stats.c +40 -29
  157. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  158. data/vendor/libgit2/src/diff_tform.c +9 -8
  159. data/vendor/libgit2/src/diff_xdiff.c +3 -8
  160. data/vendor/libgit2/src/email.c +54 -38
  161. data/vendor/libgit2/src/email.h +1 -1
  162. data/vendor/libgit2/src/errors.c +18 -18
  163. data/vendor/libgit2/src/features.h.in +6 -1
  164. data/vendor/libgit2/src/fetch.c +69 -24
  165. data/vendor/libgit2/src/fetch.h +1 -1
  166. data/vendor/libgit2/src/fetchhead.c +19 -19
  167. data/vendor/libgit2/src/filebuf.c +28 -28
  168. data/vendor/libgit2/src/filebuf.h +1 -1
  169. data/vendor/libgit2/src/filter.c +96 -52
  170. data/vendor/libgit2/src/filter.h +26 -5
  171. data/vendor/libgit2/src/fs_path.c +1912 -0
  172. data/vendor/libgit2/src/fs_path.h +752 -0
  173. data/vendor/libgit2/src/futils.c +91 -85
  174. data/vendor/libgit2/src/futils.h +26 -14
  175. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
  176. data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
  177. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  178. data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
  179. data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
  180. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
  181. data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
  182. data/vendor/libgit2/src/hash/sha1.h +3 -1
  183. data/vendor/libgit2/src/hash.c +67 -35
  184. data/vendor/libgit2/src/hash.h +12 -12
  185. data/vendor/libgit2/src/ident.c +18 -18
  186. data/vendor/libgit2/src/ignore.c +35 -34
  187. data/vendor/libgit2/src/ignore.h +2 -2
  188. data/vendor/libgit2/src/index.c +79 -80
  189. data/vendor/libgit2/src/index.h +6 -3
  190. data/vendor/libgit2/src/indexer.c +75 -57
  191. data/vendor/libgit2/src/iterator.c +64 -56
  192. data/vendor/libgit2/src/iterator.h +5 -5
  193. data/vendor/libgit2/src/khash.h +1 -1
  194. data/vendor/libgit2/src/libgit2.c +22 -19
  195. data/vendor/libgit2/src/mailmap.c +38 -36
  196. data/vendor/libgit2/src/merge.c +27 -27
  197. data/vendor/libgit2/src/merge.h +1 -14
  198. data/vendor/libgit2/src/merge_driver.c +2 -2
  199. data/vendor/libgit2/src/merge_file.c +13 -3
  200. data/vendor/libgit2/src/message.c +21 -10
  201. data/vendor/libgit2/src/midx.c +83 -66
  202. data/vendor/libgit2/src/midx.h +3 -3
  203. data/vendor/libgit2/src/mwindow.c +1 -1
  204. data/vendor/libgit2/src/net.c +278 -68
  205. data/vendor/libgit2/src/net.h +10 -3
  206. data/vendor/libgit2/src/netops.c +1 -1
  207. data/vendor/libgit2/src/netops.h +1 -1
  208. data/vendor/libgit2/src/notes.c +20 -29
  209. data/vendor/libgit2/src/object.c +49 -9
  210. data/vendor/libgit2/src/object.h +1 -1
  211. data/vendor/libgit2/src/odb.c +35 -32
  212. data/vendor/libgit2/src/odb.h +1 -1
  213. data/vendor/libgit2/src/odb_loose.c +68 -68
  214. data/vendor/libgit2/src/odb_mempack.c +18 -5
  215. data/vendor/libgit2/src/odb_pack.c +43 -43
  216. data/vendor/libgit2/src/oid.c +11 -4
  217. data/vendor/libgit2/src/oid.h +15 -0
  218. data/vendor/libgit2/src/pack-objects.c +41 -26
  219. data/vendor/libgit2/src/pack-objects.h +11 -6
  220. data/vendor/libgit2/src/pack.c +10 -10
  221. data/vendor/libgit2/src/patch.c +3 -3
  222. data/vendor/libgit2/src/patch.h +1 -0
  223. data/vendor/libgit2/src/patch_generate.c +27 -11
  224. data/vendor/libgit2/src/patch_generate.h +5 -5
  225. data/vendor/libgit2/src/patch_parse.c +24 -24
  226. data/vendor/libgit2/src/path.c +76 -1951
  227. data/vendor/libgit2/src/path.h +34 -741
  228. data/vendor/libgit2/src/pathspec.c +6 -6
  229. data/vendor/libgit2/src/pathspec.h +2 -2
  230. data/vendor/libgit2/src/posix.c +3 -3
  231. data/vendor/libgit2/src/posix.h +1 -0
  232. data/vendor/libgit2/src/pqueue.h +1 -1
  233. data/vendor/libgit2/src/proxy.c +4 -1
  234. data/vendor/libgit2/src/proxy.h +1 -1
  235. data/vendor/libgit2/src/push.c +30 -35
  236. data/vendor/libgit2/src/push.h +4 -16
  237. data/vendor/libgit2/src/rand.c +226 -0
  238. data/vendor/libgit2/src/rand.h +37 -0
  239. data/vendor/libgit2/src/reader.c +8 -8
  240. data/vendor/libgit2/src/reader.h +2 -2
  241. data/vendor/libgit2/src/rebase.c +89 -88
  242. data/vendor/libgit2/src/refdb_fs.c +447 -173
  243. data/vendor/libgit2/src/refs.c +32 -32
  244. data/vendor/libgit2/src/refs.h +2 -2
  245. data/vendor/libgit2/src/refspec.c +32 -37
  246. data/vendor/libgit2/src/refspec.h +5 -2
  247. data/vendor/libgit2/src/regexp.c +1 -1
  248. data/vendor/libgit2/src/remote.c +713 -419
  249. data/vendor/libgit2/src/remote.h +15 -10
  250. data/vendor/libgit2/src/repository.c +350 -467
  251. data/vendor/libgit2/src/repository.h +11 -10
  252. data/vendor/libgit2/src/reset.c +8 -5
  253. data/vendor/libgit2/src/revert.c +10 -10
  254. data/vendor/libgit2/src/revparse.c +48 -35
  255. data/vendor/libgit2/src/revwalk.c +7 -7
  256. data/vendor/libgit2/src/signature.c +12 -6
  257. data/vendor/libgit2/src/signature.h +1 -1
  258. data/vendor/libgit2/src/sortedcache.c +1 -1
  259. data/vendor/libgit2/src/sortedcache.h +1 -1
  260. data/vendor/libgit2/src/stash.c +36 -37
  261. data/vendor/libgit2/src/status.c +4 -1
  262. data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
  263. data/vendor/libgit2/src/str.h +357 -0
  264. data/vendor/libgit2/src/streams/mbedtls.c +8 -6
  265. data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
  266. data/vendor/libgit2/src/submodule.c +171 -159
  267. data/vendor/libgit2/src/submodule.h +1 -1
  268. data/vendor/libgit2/src/sysdir.c +68 -52
  269. data/vendor/libgit2/src/sysdir.h +15 -10
  270. data/vendor/libgit2/src/tag.c +29 -27
  271. data/vendor/libgit2/src/thread.h +3 -3
  272. data/vendor/libgit2/src/threadstate.c +3 -3
  273. data/vendor/libgit2/src/threadstate.h +1 -1
  274. data/vendor/libgit2/src/trace.c +1 -14
  275. data/vendor/libgit2/src/trace.h +5 -22
  276. data/vendor/libgit2/src/trailer.c +1 -1
  277. data/vendor/libgit2/src/transaction.c +1 -1
  278. data/vendor/libgit2/src/transport.c +10 -10
  279. data/vendor/libgit2/src/transports/auth.c +7 -9
  280. data/vendor/libgit2/src/transports/auth.h +2 -3
  281. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
  282. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
  283. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  284. data/vendor/libgit2/src/transports/git.c +9 -11
  285. data/vendor/libgit2/src/transports/http.c +37 -17
  286. data/vendor/libgit2/src/transports/http.h +2 -3
  287. data/vendor/libgit2/src/transports/httpclient.c +65 -65
  288. data/vendor/libgit2/src/transports/local.c +124 -116
  289. data/vendor/libgit2/src/transports/smart.c +51 -139
  290. data/vendor/libgit2/src/transports/smart.h +25 -31
  291. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  292. data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
  293. data/vendor/libgit2/src/transports/ssh.c +47 -112
  294. data/vendor/libgit2/src/transports/winhttp.c +50 -56
  295. data/vendor/libgit2/src/tree-cache.c +5 -5
  296. data/vendor/libgit2/src/tree-cache.h +2 -2
  297. data/vendor/libgit2/src/tree.c +59 -48
  298. data/vendor/libgit2/src/tree.h +1 -1
  299. data/vendor/libgit2/src/unix/map.c +0 -2
  300. data/vendor/libgit2/src/unix/posix.h +1 -4
  301. data/vendor/libgit2/src/unix/realpath.c +0 -2
  302. data/vendor/libgit2/src/util.c +14 -14
  303. data/vendor/libgit2/src/util.h +2 -28
  304. data/vendor/libgit2/src/vector.h +1 -1
  305. data/vendor/libgit2/src/win32/findfile.c +172 -116
  306. data/vendor/libgit2/src/win32/findfile.h +7 -4
  307. data/vendor/libgit2/src/win32/path_w32.c +140 -9
  308. data/vendor/libgit2/src/win32/path_w32.h +2 -0
  309. data/vendor/libgit2/src/win32/posix.h +0 -1
  310. data/vendor/libgit2/src/win32/posix_w32.c +11 -27
  311. data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
  312. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  313. data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
  314. data/vendor/libgit2/src/worktree.c +116 -94
  315. data/vendor/libgit2/src/worktree.h +1 -1
  316. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  317. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  318. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  319. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  320. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  321. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  322. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  323. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  324. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  325. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  326. data/vendor/libgit2/src/zstream.c +5 -5
  327. data/vendor/libgit2/src/zstream.h +4 -4
  328. metadata +25 -10
  329. data/vendor/libgit2/src/buffer.h +0 -374
@@ -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,
@@ -67,17 +67,17 @@ static int git_commit__create_buffer_internal(
67
67
  git_signature__writebuf(out, "committer ", committer);
68
68
 
69
69
  if (message_encoding != NULL)
70
- git_buf_printf(out, "encoding %s\n", message_encoding);
70
+ git_str_printf(out, "encoding %s\n", message_encoding);
71
71
 
72
- git_buf_putc(out, '\n');
72
+ git_str_putc(out, '\n');
73
73
 
74
- if (git_buf_puts(out, message) < 0)
74
+ if (git_str_puts(out, message) < 0)
75
75
  goto on_error;
76
76
 
77
77
  return 0;
78
78
 
79
79
  on_error:
80
- git_buf_dispose(out);
80
+ git_str_dispose(out);
81
81
  return -1;
82
82
  }
83
83
 
@@ -136,7 +136,7 @@ static int git_commit__create_internal(
136
136
  int error;
137
137
  git_odb *odb;
138
138
  git_reference *ref = NULL;
139
- git_buf buf = GIT_BUF_INIT;
139
+ git_str buf = GIT_STR_INIT;
140
140
  const git_oid *current_id = NULL;
141
141
  git_array_oid_t parents = GIT_ARRAY_INIT;
142
142
 
@@ -179,7 +179,7 @@ static int git_commit__create_internal(
179
179
  cleanup:
180
180
  git_array_clear(parents);
181
181
  git_reference_free(ref);
182
- git_buf_dispose(&buf);
182
+ git_str_dispose(&buf);
183
183
  return error;
184
184
  }
185
185
 
@@ -395,6 +395,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
395
395
  git_oid parent_id;
396
396
  size_t header_len;
397
397
  git_signature dummy_sig;
398
+ int error;
398
399
 
399
400
  GIT_ASSERT_ARG(commit);
400
401
  GIT_ASSERT_ARG(data);
@@ -431,14 +432,14 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
431
432
  commit->author = git__malloc(sizeof(git_signature));
432
433
  GIT_ERROR_CHECK_ALLOC(commit->author);
433
434
 
434
- if (git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n') < 0)
435
- return -1;
435
+ if ((error = git_signature__parse(commit->author, &buffer, buffer_end, "author ", '\n')) < 0)
436
+ return error;
436
437
  }
437
438
 
438
439
  /* Some tools create multiple author fields, ignore the extra ones */
439
440
  while (!git__prefixncmp(buffer, buffer_end - buffer, "author ")) {
440
- if (git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n') < 0)
441
- return -1;
441
+ if ((error = git_signature__parse(&dummy_sig, &buffer, buffer_end, "author ", '\n')) < 0)
442
+ return error;
442
443
 
443
444
  git__free(dummy_sig.name);
444
445
  git__free(dummy_sig.email);
@@ -448,8 +449,8 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
448
449
  commit->committer = git__malloc(sizeof(git_signature));
449
450
  GIT_ERROR_CHECK_ALLOC(commit->committer);
450
451
 
451
- if (git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n') < 0)
452
- return -1;
452
+ if ((error = git_signature__parse(commit->committer, &buffer, buffer_end, "committer ", '\n')) < 0)
453
+ return error;
453
454
 
454
455
  if (flags & GIT_COMMIT_PARSE_QUICK)
455
456
  return 0;
@@ -493,7 +494,7 @@ static int commit_parse(git_commit *commit, const char *data, size_t size, unsig
493
494
 
494
495
  bad_buffer:
495
496
  git_error_set(GIT_ERROR_OBJECT, "failed to parse bad commit object");
496
- return -1;
497
+ return GIT_EINVALID;
497
498
  }
498
499
 
499
500
  int git_commit__parse_raw(void *commit, const char *data, size_t size)
@@ -545,8 +546,8 @@ const char *git_commit_message(const git_commit *commit)
545
546
 
546
547
  const char *git_commit_summary(git_commit *commit)
547
548
  {
548
- git_buf summary = GIT_BUF_INIT;
549
- const char *msg, *space;
549
+ git_str summary = GIT_STR_INIT;
550
+ const char *msg, *space, *next;
550
551
  bool space_contains_newline = false;
551
552
 
552
553
  GIT_ASSERT_ARG_WITH_RETVAL(commit, NULL);
@@ -555,10 +556,21 @@ const char *git_commit_summary(git_commit *commit)
555
556
  for (msg = git_commit_message(commit), space = NULL; *msg; ++msg) {
556
557
  char next_character = msg[0];
557
558
  /* stop processing at the end of the first paragraph */
558
- if (next_character == '\n' && (!msg[1] || msg[1] == '\n'))
559
- 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
+ }
560
572
  /* record the beginning of contiguous whitespace runs */
561
- else if (git__isspace(next_character)) {
573
+ if (git__isspace(next_character)) {
562
574
  if(space == NULL) {
563
575
  space = msg;
564
576
  space_contains_newline = false;
@@ -570,17 +582,17 @@ const char *git_commit_summary(git_commit *commit)
570
582
  /* process any recorded whitespace */
571
583
  if (space) {
572
584
  if(space_contains_newline)
573
- 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 ' ' */
574
586
  else
575
- git_buf_put(&summary, space, (msg - space)); /* otherwise copy it */
587
+ git_str_put(&summary, space, (msg - space)); /* otherwise copy it */
576
588
  space = NULL;
577
589
  }
578
590
  /* copy the next character */
579
- git_buf_putc(&summary, next_character);
591
+ git_str_putc(&summary, next_character);
580
592
  }
581
593
  }
582
594
 
583
- commit->summary = git_buf_detach(&summary);
595
+ commit->summary = git_str_detach(&summary);
584
596
  if (!commit->summary)
585
597
  commit->summary = git__strdup("");
586
598
  }
@@ -678,11 +690,22 @@ int git_commit_nth_gen_ancestor(
678
690
  return 0;
679
691
  }
680
692
 
681
- 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)
682
705
  {
683
706
  const char *eol, *buf = commit->raw_header;
684
707
 
685
- git_buf_clear(out);
708
+ git_str_clear(out);
686
709
 
687
710
  while ((eol = strchr(buf, '\n'))) {
688
711
  /* We can skip continuations here */
@@ -706,22 +729,22 @@ int git_commit_header_field(git_buf *out, const git_commit *commit, const char *
706
729
 
707
730
  buf++; /* skip the SP */
708
731
 
709
- git_buf_put(out, buf, eol - buf);
710
- if (git_buf_oom(out))
732
+ git_str_put(out, buf, eol - buf);
733
+ if (git_str_oom(out))
711
734
  goto oom;
712
735
 
713
736
  /* If the next line starts with SP, it's multi-line, we must continue */
714
737
  while (eol[1] == ' ') {
715
- git_buf_putc(out, '\n');
738
+ git_str_putc(out, '\n');
716
739
  buf = eol + 2;
717
740
  eol = strchr(buf, '\n');
718
741
  if (!eol)
719
742
  goto malformed;
720
743
 
721
- git_buf_put(out, buf, eol - buf);
744
+ git_str_put(out, buf, eol - buf);
722
745
  }
723
746
 
724
- if (git_buf_oom(out))
747
+ if (git_str_oom(out))
725
748
  goto oom;
726
749
 
727
750
  return 0;
@@ -738,7 +761,35 @@ oom:
738
761
  return -1;
739
762
  }
740
763
 
741
- 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)
742
793
  {
743
794
  git_odb_object *obj;
744
795
  git_odb *odb;
@@ -746,8 +797,8 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
746
797
  const char *h, *eol;
747
798
  int error;
748
799
 
749
- git_buf_clear(signature);
750
- git_buf_clear(signed_data);
800
+ git_str_clear(signature);
801
+ git_str_clear(signed_data);
751
802
 
752
803
  if (!field)
753
804
  field = "gpgsig";
@@ -769,7 +820,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
769
820
  while ((h = strchr(buf, '\n')) && h[1] != '\0') {
770
821
  h++;
771
822
  if (git__prefixcmp(buf, field)) {
772
- if (git_buf_put(signed_data, buf, h - buf) < 0)
823
+ if (git_str_put(signed_data, buf, h - buf) < 0)
773
824
  return -1;
774
825
 
775
826
  buf = h;
@@ -788,25 +839,25 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
788
839
 
789
840
  h++; /* skip the SP */
790
841
 
791
- git_buf_put(signature, h, eol - h);
792
- if (git_buf_oom(signature))
842
+ git_str_put(signature, h, eol - h);
843
+ if (git_str_oom(signature))
793
844
  goto oom;
794
845
 
795
846
  /* If the next line starts with SP, it's multi-line, we must continue */
796
847
  while (eol[1] == ' ') {
797
- git_buf_putc(signature, '\n');
848
+ git_str_putc(signature, '\n');
798
849
  h = eol + 2;
799
850
  eol = strchr(h, '\n');
800
851
  if (!eol)
801
852
  goto malformed;
802
853
 
803
- git_buf_put(signature, h, eol - h);
854
+ git_str_put(signature, h, eol - h);
804
855
  }
805
856
 
806
- if (git_buf_oom(signature))
857
+ if (git_str_oom(signature))
807
858
  goto oom;
808
859
 
809
- error = git_buf_puts(signed_data, eol+1);
860
+ error = git_str_puts(signed_data, eol+1);
810
861
  git_odb_object_free(obj);
811
862
  return error;
812
863
  }
@@ -826,12 +877,29 @@ oom:
826
877
 
827
878
  cleanup:
828
879
  git_odb_object_free(obj);
829
- git_buf_clear(signature);
830
- git_buf_clear(signed_data);
880
+ git_str_clear(signature);
881
+ git_str_clear(signed_data);
831
882
  return error;
832
883
  }
833
884
 
834
- 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,
835
903
  git_repository *repo,
836
904
  const git_signature *author,
837
905
  const git_signature *committer,
@@ -866,7 +934,7 @@ int git_commit_create_buffer(git_buf *out,
866
934
  /**
867
935
  * Append to 'out' properly marking continuations when there's a newline in 'content'
868
936
  */
869
- static int 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)
870
938
  {
871
939
  const char *lf;
872
940
 
@@ -874,19 +942,19 @@ static int format_header_field(git_buf *out, const char *field, const char *cont
874
942
  GIT_ASSERT_ARG(field);
875
943
  GIT_ASSERT_ARG(content);
876
944
 
877
- git_buf_puts(out, field);
878
- git_buf_putc(out, ' ');
945
+ git_str_puts(out, field);
946
+ git_str_putc(out, ' ');
879
947
 
880
948
  while ((lf = strchr(content, '\n')) != NULL) {
881
- git_buf_put(out, content, lf - content);
882
- git_buf_puts(out, "\n ");
949
+ git_str_put(out, content, lf - content);
950
+ git_str_puts(out, "\n ");
883
951
  content = lf + 1;
884
952
  }
885
953
 
886
- git_buf_puts(out, content);
887
- git_buf_putc(out, '\n');
954
+ git_str_puts(out, content);
955
+ git_str_putc(out, '\n');
888
956
 
889
- return git_buf_oom(out) ? -1 : 0;
957
+ return git_str_oom(out) ? -1 : 0;
890
958
  }
891
959
 
892
960
  static const git_oid *commit_parent_from_commit(size_t n, void *payload)
@@ -908,15 +976,17 @@ int git_commit_create_with_signature(
908
976
  int error = 0;
909
977
  const char *field;
910
978
  const char *header_end;
911
- git_buf commit = GIT_BUF_INIT;
979
+ git_str commit = GIT_STR_INIT;
912
980
  git_commit *parsed;
913
981
  git_array_oid_t parents = GIT_ARRAY_INIT;
914
982
 
915
983
  /* The first step is to verify that all the tree and parents exist */
916
984
  parsed = git__calloc(1, sizeof(git_commit));
917
985
  GIT_ERROR_CHECK_ALLOC(parsed);
918
- 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;
919
988
  goto cleanup;
989
+ }
920
990
 
921
991
  if ((error = validate_tree_and_parents(&parents, repo, &parsed->tree_id, commit_parent_from_commit, parsed, NULL, true)) < 0)
922
992
  goto cleanup;
@@ -933,7 +1003,7 @@ int git_commit_create_with_signature(
933
1003
 
934
1004
  /* The header ends after the first LF */
935
1005
  header_end++;
936
- git_buf_put(&commit, commit_content, header_end - commit_content);
1006
+ git_str_put(&commit, commit_content, header_end - commit_content);
937
1007
 
938
1008
  if (signature != NULL) {
939
1009
  field = signature_field ? signature_field : "gpgsig";
@@ -942,9 +1012,9 @@ int git_commit_create_with_signature(
942
1012
  goto cleanup;
943
1013
  }
944
1014
 
945
- git_buf_puts(&commit, header_end);
1015
+ git_str_puts(&commit, header_end);
946
1016
 
947
- if (git_buf_oom(&commit))
1017
+ if (git_str_oom(&commit))
948
1018
  return -1;
949
1019
 
950
1020
  if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
@@ -955,7 +1025,7 @@ int git_commit_create_with_signature(
955
1025
 
956
1026
  cleanup:
957
1027
  git_commit__free(parsed);
958
- git_buf_dispose(&commit);
1028
+ git_str_dispose(&commit);
959
1029
  return error;
960
1030
  }
961
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);