rugged 1.3.2.3 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -8,6 +8,7 @@
8
8
  #include "commit_graph.h"
9
9
 
10
10
  #include "array.h"
11
+ #include "buf.h"
11
12
  #include "filebuf.h"
12
13
  #include "futils.h"
13
14
  #include "hash.h"
@@ -200,7 +201,8 @@ int git_commit_graph_file_parse(
200
201
  struct git_commit_graph_chunk *last_chunk;
201
202
  uint32_t i;
202
203
  off64_t last_chunk_offset, chunk_offset, trailer_offset;
203
- git_oid cgraph_checksum = {{0}};
204
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
205
+ size_t checksum_size;
204
206
  int error;
205
207
  struct git_commit_graph_chunk chunk_oid_fanout = {0}, chunk_oid_lookup = {0},
206
208
  chunk_commit_data = {0}, chunk_extra_edge_list = {0},
@@ -226,13 +228,15 @@ int git_commit_graph_file_parse(
226
228
  */
227
229
  last_chunk_offset = sizeof(struct git_commit_graph_header) + (1 + hdr->chunks) * 12;
228
230
  trailer_offset = size - GIT_OID_RAWSZ;
231
+ checksum_size = GIT_HASH_SHA1_SIZE;
232
+
229
233
  if (trailer_offset < last_chunk_offset)
230
234
  return commit_graph_error("wrong commit-graph size");
231
- git_oid_cpy(&file->checksum, (git_oid *)(data + trailer_offset));
235
+ memcpy(file->checksum, (data + trailer_offset), checksum_size);
232
236
 
233
- if (git_hash_buf(&cgraph_checksum, data, (size_t)trailer_offset) < 0)
237
+ if (git_hash_buf(checksum, data, (size_t)trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
234
238
  return commit_graph_error("could not calculate signature");
235
- if (!git_oid_equal(&cgraph_checksum, &file->checksum))
239
+ if (memcmp(checksum, file->checksum, checksum_size) != 0)
236
240
  return commit_graph_error("index signature mismatch");
237
241
 
238
242
  chunk_hdr = data + sizeof(struct git_commit_graph_header);
@@ -308,12 +312,12 @@ int git_commit_graph_new(git_commit_graph **cgraph_out, const char *objects_dir,
308
312
  cgraph = git__calloc(1, sizeof(git_commit_graph));
309
313
  GIT_ERROR_CHECK_ALLOC(cgraph);
310
314
 
311
- error = git_buf_joinpath(&cgraph->filename, objects_dir, "info/commit-graph");
315
+ error = git_str_joinpath(&cgraph->filename, objects_dir, "info/commit-graph");
312
316
  if (error < 0)
313
317
  goto error;
314
318
 
315
319
  if (open_file) {
316
- error = git_commit_graph_file_open(&cgraph->file, git_buf_cstr(&cgraph->filename));
320
+ error = git_commit_graph_file_open(&cgraph->file, git_str_cstr(&cgraph->filename));
317
321
  if (error < 0)
318
322
  goto error;
319
323
  cgraph->checked = 1;
@@ -387,7 +391,7 @@ int git_commit_graph_get_file(git_commit_graph_file **file_out, git_commit_graph
387
391
  cgraph->checked = 1;
388
392
 
389
393
  /* Best effort */
390
- error = git_commit_graph_file_open(&result, git_buf_cstr(&cgraph->filename));
394
+ error = git_commit_graph_file_open(&result, git_str_cstr(&cgraph->filename));
391
395
 
392
396
  if (error < 0)
393
397
  return error;
@@ -407,7 +411,7 @@ void git_commit_graph_refresh(git_commit_graph *cgraph)
407
411
  return;
408
412
 
409
413
  if (cgraph->file
410
- && git_commit_graph_file_needs_refresh(cgraph->file, git_buf_cstr(&cgraph->filename))) {
414
+ && git_commit_graph_file_needs_refresh(cgraph->file, git_str_cstr(&cgraph->filename))) {
411
415
  /* We just free the commit graph. The next time it is requested, it will be
412
416
  * re-loaded. */
413
417
  git_commit_graph_file_free(cgraph->file);
@@ -475,7 +479,8 @@ bool git_commit_graph_file_needs_refresh(const git_commit_graph_file *file, cons
475
479
  git_file fd = -1;
476
480
  struct stat st;
477
481
  ssize_t bytes_read;
478
- git_oid cgraph_checksum = {{0}};
482
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
483
+ size_t checksum_size = GIT_HASH_SHA1_SIZE;
479
484
 
480
485
  /* TODO: properly open the file without access time using O_NOATIME */
481
486
  fd = git_futils_open_ro(path);
@@ -493,12 +498,12 @@ bool git_commit_graph_file_needs_refresh(const git_commit_graph_file *file, cons
493
498
  return true;
494
499
  }
495
500
 
496
- bytes_read = p_pread(fd, cgraph_checksum.id, GIT_OID_RAWSZ, st.st_size - GIT_OID_RAWSZ);
501
+ bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - checksum_size);
497
502
  p_close(fd);
498
- if (bytes_read != GIT_OID_RAWSZ)
503
+ if (bytes_read != (ssize_t)checksum_size)
499
504
  return true;
500
505
 
501
- return !git_oid_equal(&cgraph_checksum, &file->checksum);
506
+ return (memcmp(checksum, file->checksum, checksum_size) != 0);
502
507
  }
503
508
 
504
509
  int git_commit_graph_entry_find(
@@ -597,7 +602,7 @@ void git_commit_graph_free(git_commit_graph *cgraph)
597
602
  if (!cgraph)
598
603
  return;
599
604
 
600
- git_buf_dispose(&cgraph->filename);
605
+ git_str_dispose(&cgraph->filename);
601
606
  git_commit_graph_file_free(cgraph->file);
602
607
  git__free(cgraph);
603
608
  }
@@ -623,13 +628,13 @@ int git_commit_graph_writer_new(git_commit_graph_writer **out, const char *objec
623
628
  git_commit_graph_writer *w = git__calloc(1, sizeof(git_commit_graph_writer));
624
629
  GIT_ERROR_CHECK_ALLOC(w);
625
630
 
626
- if (git_buf_sets(&w->objects_info_dir, objects_info_dir) < 0) {
631
+ if (git_str_sets(&w->objects_info_dir, objects_info_dir) < 0) {
627
632
  git__free(w);
628
633
  return -1;
629
634
  }
630
635
 
631
636
  if (git_vector_init(&w->commits, 0, packed_commit__cmp) < 0) {
632
- git_buf_dispose(&w->objects_info_dir);
637
+ git_str_dispose(&w->objects_info_dir);
633
638
  git__free(w);
634
639
  return -1;
635
640
  }
@@ -649,7 +654,7 @@ void git_commit_graph_writer_free(git_commit_graph_writer *w)
649
654
  git_vector_foreach (&w->commits, i, packed_commit)
650
655
  packed_commit_free(packed_commit);
651
656
  git_vector_free(&w->commits);
652
- git_buf_dispose(&w->objects_info_dir);
657
+ git_str_dispose(&w->objects_info_dir);
653
658
  git__free(w);
654
659
  }
655
660
 
@@ -753,7 +758,7 @@ enum generation_number_commit_state {
753
758
  GENERATION_NUMBER_COMMIT_STATE_UNVISITED = 0,
754
759
  GENERATION_NUMBER_COMMIT_STATE_ADDED = 1,
755
760
  GENERATION_NUMBER_COMMIT_STATE_EXPANDED = 2,
756
- GENERATION_NUMBER_COMMIT_STATE_VISITED = 3,
761
+ GENERATION_NUMBER_COMMIT_STATE_VISITED = 3
757
762
  };
758
763
 
759
764
  static int compute_generation_numbers(git_vector *commits)
@@ -931,8 +936,8 @@ static int write_chunk_header(
931
936
 
932
937
  static int commit_graph_write_buf(const char *buf, size_t size, void *data)
933
938
  {
934
- git_buf *b = (git_buf *)data;
935
- return git_buf_put(b, buf, size);
939
+ git_str *b = (git_str *)data;
940
+ return git_str_put(b, buf, size);
936
941
  }
937
942
 
938
943
  struct commit_graph_write_hash_context {
@@ -971,9 +976,10 @@ static int commit_graph_write(
971
976
  uint32_t extra_edge_list_count;
972
977
  uint32_t oid_fanout[256];
973
978
  off64_t offset;
974
- git_buf oid_lookup = GIT_BUF_INIT, commit_data = GIT_BUF_INIT,
975
- extra_edge_list = GIT_BUF_INIT;
976
- git_oid cgraph_checksum = {{0}};
979
+ git_str oid_lookup = GIT_STR_INIT, commit_data = GIT_STR_INIT,
980
+ extra_edge_list = GIT_STR_INIT;
981
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
982
+ size_t checksum_size;
977
983
  git_hash_ctx ctx;
978
984
  struct commit_graph_write_hash_context hash_cb_data = {0};
979
985
 
@@ -986,7 +992,8 @@ static int commit_graph_write(
986
992
  hash_cb_data.cb_data = cb_data;
987
993
  hash_cb_data.ctx = &ctx;
988
994
 
989
- error = git_hash_ctx_init(&ctx);
995
+ checksum_size = GIT_HASH_SHA1_SIZE;
996
+ error = git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1);
990
997
  if (error < 0)
991
998
  return error;
992
999
  cb_data = &hash_cb_data;
@@ -1011,7 +1018,7 @@ static int commit_graph_write(
1011
1018
 
1012
1019
  /* Fill the OID Lookup table. */
1013
1020
  git_vector_foreach (&w->commits, i, packed_commit) {
1014
- error = git_buf_put(&oid_lookup,
1021
+ error = git_str_put(&oid_lookup,
1015
1022
  (const char *)&packed_commit->sha1, sizeof(git_oid));
1016
1023
  if (error < 0)
1017
1024
  goto cleanup;
@@ -1026,7 +1033,7 @@ static int commit_graph_write(
1026
1033
  size_t *packed_index;
1027
1034
  unsigned int parentcount = (unsigned int)git_array_size(packed_commit->parents);
1028
1035
 
1029
- error = git_buf_put(&commit_data,
1036
+ error = git_str_put(&commit_data,
1030
1037
  (const char *)&packed_commit->tree_oid,
1031
1038
  sizeof(git_oid));
1032
1039
  if (error < 0)
@@ -1038,7 +1045,7 @@ static int commit_graph_write(
1038
1045
  packed_index = git_array_get(packed_commit->parent_indices, 0);
1039
1046
  word = htonl((uint32_t)*packed_index);
1040
1047
  }
1041
- error = git_buf_put(&commit_data, (const char *)&word, sizeof(word));
1048
+ error = git_str_put(&commit_data, (const char *)&word, sizeof(word));
1042
1049
  if (error < 0)
1043
1050
  goto cleanup;
1044
1051
 
@@ -1050,7 +1057,7 @@ static int commit_graph_write(
1050
1057
  } else {
1051
1058
  word = htonl(0x80000000u | extra_edge_list_count);
1052
1059
  }
1053
- error = git_buf_put(&commit_data, (const char *)&word, sizeof(word));
1060
+ error = git_str_put(&commit_data, (const char *)&word, sizeof(word));
1054
1061
  if (error < 0)
1055
1062
  goto cleanup;
1056
1063
 
@@ -1061,7 +1068,7 @@ static int commit_graph_write(
1061
1068
  packed_commit->parent_indices, parent_i);
1062
1069
  word = htonl((uint32_t)(*packed_index | (parent_i + 1 == parentcount ? 0x80000000u : 0)));
1063
1070
 
1064
- error = git_buf_put(&extra_edge_list,
1071
+ error = git_str_put(&extra_edge_list,
1065
1072
  (const char *)&word,
1066
1073
  sizeof(word));
1067
1074
  if (error < 0)
@@ -1074,19 +1081,19 @@ static int commit_graph_write(
1074
1081
  commit_time = (uint64_t)packed_commit->commit_time;
1075
1082
  if (generation > GIT_COMMIT_GRAPH_GENERATION_NUMBER_MAX)
1076
1083
  generation = GIT_COMMIT_GRAPH_GENERATION_NUMBER_MAX;
1077
- word = ntohl((uint32_t)((generation << 2) | ((commit_time >> 32ull) & 0x3ull)));
1078
- error = git_buf_put(&commit_data, (const char *)&word, sizeof(word));
1084
+ word = ntohl((uint32_t)((generation << 2) | (((uint32_t)(commit_time >> 32)) & 0x3) ));
1085
+ error = git_str_put(&commit_data, (const char *)&word, sizeof(word));
1079
1086
  if (error < 0)
1080
1087
  goto cleanup;
1081
- word = ntohl((uint32_t)(commit_time & 0xffffffffull));
1082
- error = git_buf_put(&commit_data, (const char *)&word, sizeof(word));
1088
+ word = ntohl((uint32_t)(commit_time & 0xfffffffful));
1089
+ error = git_str_put(&commit_data, (const char *)&word, sizeof(word));
1083
1090
  if (error < 0)
1084
1091
  goto cleanup;
1085
1092
  }
1086
1093
 
1087
1094
  /* Write the header. */
1088
1095
  hdr.chunks = 3;
1089
- if (git_buf_len(&extra_edge_list) > 0)
1096
+ if (git_str_len(&extra_edge_list) > 0)
1090
1097
  hdr.chunks++;
1091
1098
  error = write_cb((const char *)&hdr, sizeof(hdr), cb_data);
1092
1099
  if (error < 0)
@@ -1101,17 +1108,17 @@ static int commit_graph_write(
1101
1108
  error = write_chunk_header(COMMIT_GRAPH_OID_LOOKUP_ID, offset, write_cb, cb_data);
1102
1109
  if (error < 0)
1103
1110
  goto cleanup;
1104
- offset += git_buf_len(&oid_lookup);
1111
+ offset += git_str_len(&oid_lookup);
1105
1112
  error = write_chunk_header(COMMIT_GRAPH_COMMIT_DATA_ID, offset, write_cb, cb_data);
1106
1113
  if (error < 0)
1107
1114
  goto cleanup;
1108
- offset += git_buf_len(&commit_data);
1109
- if (git_buf_len(&extra_edge_list) > 0) {
1115
+ offset += git_str_len(&commit_data);
1116
+ if (git_str_len(&extra_edge_list) > 0) {
1110
1117
  error = write_chunk_header(
1111
1118
  COMMIT_GRAPH_EXTRA_EDGE_LIST_ID, offset, write_cb, cb_data);
1112
1119
  if (error < 0)
1113
1120
  goto cleanup;
1114
- offset += git_buf_len(&extra_edge_list);
1121
+ offset += git_str_len(&extra_edge_list);
1115
1122
  }
1116
1123
  error = write_chunk_header(0, offset, write_cb, cb_data);
1117
1124
  if (error < 0)
@@ -1121,28 +1128,28 @@ static int commit_graph_write(
1121
1128
  error = write_cb((const char *)oid_fanout, sizeof(oid_fanout), cb_data);
1122
1129
  if (error < 0)
1123
1130
  goto cleanup;
1124
- error = write_cb(git_buf_cstr(&oid_lookup), git_buf_len(&oid_lookup), cb_data);
1131
+ error = write_cb(git_str_cstr(&oid_lookup), git_str_len(&oid_lookup), cb_data);
1125
1132
  if (error < 0)
1126
1133
  goto cleanup;
1127
- error = write_cb(git_buf_cstr(&commit_data), git_buf_len(&commit_data), cb_data);
1134
+ error = write_cb(git_str_cstr(&commit_data), git_str_len(&commit_data), cb_data);
1128
1135
  if (error < 0)
1129
1136
  goto cleanup;
1130
- error = write_cb(git_buf_cstr(&extra_edge_list), git_buf_len(&extra_edge_list), cb_data);
1137
+ error = write_cb(git_str_cstr(&extra_edge_list), git_str_len(&extra_edge_list), cb_data);
1131
1138
  if (error < 0)
1132
1139
  goto cleanup;
1133
1140
 
1134
1141
  /* Finalize the checksum and write the trailer. */
1135
- error = git_hash_final(&cgraph_checksum, &ctx);
1142
+ error = git_hash_final(checksum, &ctx);
1136
1143
  if (error < 0)
1137
1144
  goto cleanup;
1138
- error = write_cb((const char *)&cgraph_checksum, sizeof(cgraph_checksum), cb_data);
1145
+ error = write_cb((char *)checksum, checksum_size, cb_data);
1139
1146
  if (error < 0)
1140
1147
  goto cleanup;
1141
1148
 
1142
1149
  cleanup:
1143
- git_buf_dispose(&oid_lookup);
1144
- git_buf_dispose(&commit_data);
1145
- git_buf_dispose(&extra_edge_list);
1150
+ git_str_dispose(&oid_lookup);
1151
+ git_str_dispose(&commit_data);
1152
+ git_str_dispose(&extra_edge_list);
1146
1153
  git_hash_ctx_cleanup(&ctx);
1147
1154
  return error;
1148
1155
  }
@@ -1171,21 +1178,21 @@ int git_commit_graph_writer_commit(
1171
1178
  {
1172
1179
  int error;
1173
1180
  int filebuf_flags = GIT_FILEBUF_DO_NOT_BUFFER;
1174
- git_buf commit_graph_path = GIT_BUF_INIT;
1181
+ git_str commit_graph_path = GIT_STR_INIT;
1175
1182
  git_filebuf output = GIT_FILEBUF_INIT;
1176
1183
 
1177
1184
  /* TODO: support options and fill in defaults. */
1178
1185
  GIT_UNUSED(opts);
1179
1186
 
1180
- error = git_buf_joinpath(
1181
- &commit_graph_path, git_buf_cstr(&w->objects_info_dir), "commit-graph");
1187
+ error = git_str_joinpath(
1188
+ &commit_graph_path, git_str_cstr(&w->objects_info_dir), "commit-graph");
1182
1189
  if (error < 0)
1183
1190
  return error;
1184
1191
 
1185
1192
  if (git_repository__fsync_gitdir)
1186
1193
  filebuf_flags |= GIT_FILEBUF_FSYNC;
1187
- error = git_filebuf_open(&output, git_buf_cstr(&commit_graph_path), filebuf_flags, 0644);
1188
- git_buf_dispose(&commit_graph_path);
1194
+ error = git_filebuf_open(&output, git_str_cstr(&commit_graph_path), filebuf_flags, 0644);
1195
+ git_str_dispose(&commit_graph_path);
1189
1196
  if (error < 0)
1190
1197
  return error;
1191
1198
 
@@ -1199,9 +1206,17 @@ int git_commit_graph_writer_commit(
1199
1206
  }
1200
1207
 
1201
1208
  int git_commit_graph_writer_dump(
1202
- git_buf *cgraph,
1203
- git_commit_graph_writer *w,
1204
- git_commit_graph_writer_options *opts)
1209
+ git_buf *cgraph,
1210
+ git_commit_graph_writer *w,
1211
+ git_commit_graph_writer_options *opts)
1212
+ {
1213
+ GIT_BUF_WRAP_PRIVATE(cgraph, git_commit_graph__writer_dump, w, opts);
1214
+ }
1215
+
1216
+ int git_commit_graph__writer_dump(
1217
+ git_str *cgraph,
1218
+ git_commit_graph_writer *w,
1219
+ git_commit_graph_writer_options *opts)
1205
1220
  {
1206
1221
  /* TODO: support options. */
1207
1222
  GIT_UNUSED(opts);
@@ -15,6 +15,8 @@
15
15
 
16
16
  #include "map.h"
17
17
  #include "vector.h"
18
+ #include "oid.h"
19
+ #include "hash.h"
18
20
 
19
21
  /**
20
22
  * A commit-graph file.
@@ -55,7 +57,7 @@ typedef struct git_commit_graph_file {
55
57
  size_t num_extra_edge_list;
56
58
 
57
59
  /* The trailer of the file. Contains the SHA1-checksum of the whole file. */
58
- git_oid checksum;
60
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
59
61
  } git_commit_graph_file;
60
62
 
61
63
  /**
@@ -92,7 +94,7 @@ typedef struct git_commit_graph_entry {
92
94
  /* A wrapper for git_commit_graph_file to enable lazy loading in the ODB. */
93
95
  struct git_commit_graph {
94
96
  /* The path to the commit-graph file. Something like ".git/objects/info/commit-graph". */
95
- git_buf filename;
97
+ git_str filename;
96
98
 
97
99
  /* The underlying commit-graph file. */
98
100
  git_commit_graph_file *file;
@@ -127,12 +129,17 @@ struct git_commit_graph_writer {
127
129
  * The path of the `objects/info` directory where the `commit-graph` will be
128
130
  * stored.
129
131
  */
130
- git_buf objects_info_dir;
132
+ git_str objects_info_dir;
131
133
 
132
134
  /* The list of packed commits. */
133
135
  git_vector commits;
134
136
  };
135
137
 
138
+ int git_commit_graph__writer_dump(
139
+ git_str *cgraph,
140
+ git_commit_graph_writer *w,
141
+ git_commit_graph_writer_options *opts);
142
+
136
143
  /*
137
144
  * Returns whether the git_commit_graph_file needs to be reloaded since the
138
145
  * contents of the commit-graph file have changed on disk.
@@ -124,16 +124,15 @@ static int commit_quick_parse(
124
124
  {
125
125
  git_oid *parent_oid;
126
126
  git_commit *commit;
127
- int error;
128
127
  size_t i;
129
128
 
130
129
  commit = git__calloc(1, sizeof(*commit));
131
130
  GIT_ERROR_CHECK_ALLOC(commit);
132
131
  commit->object.repo = walk->repo;
133
132
 
134
- if ((error = git_commit__parse_ext(commit, obj, GIT_COMMIT_PARSE_QUICK)) < 0) {
133
+ if (git_commit__parse_ext(commit, obj, GIT_COMMIT_PARSE_QUICK) < 0) {
135
134
  git__free(commit);
136
- return error;
135
+ return -1;
137
136
  }
138
137
 
139
138
  if (!git__is_uint16(git_array_size(commit->parent_ids))) {
@@ -121,12 +121,16 @@
121
121
  /**
122
122
  * Check a pointer allocation result, returning -1 if it failed.
123
123
  */
124
- #define GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
124
+ #define GIT_ERROR_CHECK_ALLOC(ptr) do { \
125
+ if ((ptr) == NULL) { return -1; } \
126
+ } while(0)
125
127
 
126
128
  /**
127
- * Check a buffer allocation result, returning -1 if it failed.
129
+ * Check a string buffer allocation result, returning -1 if it failed.
128
130
  */
129
- #define GIT_ERROR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; }
131
+ #define GIT_ERROR_CHECK_ALLOC_STR(buf) do { \
132
+ if ((void *)(buf) == NULL || git_str_oom(buf)) { return -1; } \
133
+ } while(0)
130
134
 
131
135
  /**
132
136
  * Check a return value and propagate result if non-zero.
@@ -202,6 +206,9 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
202
206
 
203
207
  /* NOTE: other git_error functions are in the public errors.h header file */
204
208
 
209
+ /* Forward declare git_str */
210
+ typedef struct git_str git_str;
211
+
205
212
  #include "util.h"
206
213
 
207
214
  #endif