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,14 +8,15 @@
8
8
  #include "midx.h"
9
9
 
10
10
  #include "array.h"
11
- #include "buffer.h"
11
+ #include "buf.h"
12
12
  #include "filebuf.h"
13
13
  #include "futils.h"
14
14
  #include "hash.h"
15
15
  #include "odb.h"
16
16
  #include "pack.h"
17
- #include "path.h"
17
+ #include "fs_path.h"
18
18
  #include "repository.h"
19
+ #include "str.h"
19
20
 
20
21
  #define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
21
22
  #define MIDX_VERSION 1
@@ -177,7 +178,8 @@ int git_midx_parse(
177
178
  struct git_midx_chunk *last_chunk;
178
179
  uint32_t i;
179
180
  off64_t last_chunk_offset, chunk_offset, trailer_offset;
180
- git_oid idx_checksum = {{0}};
181
+ size_t checksum_size;
182
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
181
183
  int error;
182
184
  struct git_midx_chunk chunk_packfile_names = {0},
183
185
  chunk_oid_fanout = {0},
@@ -207,14 +209,17 @@ int git_midx_parse(
207
209
  last_chunk_offset =
208
210
  sizeof(struct git_midx_header) +
209
211
  (1 + hdr->chunks) * 12;
210
- trailer_offset = size - GIT_OID_RAWSZ;
212
+
213
+ checksum_size = GIT_HASH_SHA1_SIZE;
214
+ trailer_offset = size - checksum_size;
215
+
211
216
  if (trailer_offset < last_chunk_offset)
212
217
  return midx_error("wrong index size");
213
- git_oid_cpy(&idx->checksum, (git_oid *)(data + trailer_offset));
218
+ memcpy(idx->checksum, data + trailer_offset, checksum_size);
214
219
 
215
- if (git_hash_buf(&idx_checksum, data, (size_t)trailer_offset) < 0)
220
+ if (git_hash_buf(checksum, data, (size_t)trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
216
221
  return midx_error("could not calculate signature");
217
- if (!git_oid_equal(&idx_checksum, &idx->checksum))
222
+ if (memcmp(checksum, idx->checksum, checksum_size) != 0)
218
223
  return midx_error("index signature mismatch");
219
224
 
220
225
  chunk_hdr = data + sizeof(struct git_midx_header);
@@ -313,7 +318,7 @@ int git_midx_open(
313
318
  idx = git__calloc(1, sizeof(git_midx_file));
314
319
  GIT_ERROR_CHECK_ALLOC(idx);
315
320
 
316
- error = git_buf_sets(&idx->filename, path);
321
+ error = git_str_sets(&idx->filename, path);
317
322
  if (error < 0)
318
323
  return error;
319
324
 
@@ -340,7 +345,8 @@ bool git_midx_needs_refresh(
340
345
  git_file fd = -1;
341
346
  struct stat st;
342
347
  ssize_t bytes_read;
343
- git_oid idx_checksum = {{0}};
348
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
349
+ size_t checksum_size;
344
350
 
345
351
  /* TODO: properly open the file without access time using O_NOATIME */
346
352
  fd = git_futils_open_ro(path);
@@ -359,13 +365,14 @@ bool git_midx_needs_refresh(
359
365
  return true;
360
366
  }
361
367
 
362
- bytes_read = p_pread(fd, &idx_checksum, GIT_OID_RAWSZ, st.st_size - GIT_OID_RAWSZ);
368
+ checksum_size = GIT_HASH_SHA1_SIZE;
369
+ bytes_read = p_pread(fd, checksum, checksum_size, st.st_size - GIT_OID_RAWSZ);
363
370
  p_close(fd);
364
371
 
365
- if (bytes_read != GIT_OID_RAWSZ)
372
+ if (bytes_read != (ssize_t)checksum_size)
366
373
  return true;
367
374
 
368
- return !git_oid_equal(&idx_checksum, &idx->checksum);
375
+ return (memcmp(checksum, idx->checksum, checksum_size) != 0);
369
376
  }
370
377
 
371
378
  int git_midx_entry_find(
@@ -477,7 +484,7 @@ void git_midx_free(git_midx_file *idx)
477
484
  if (!idx)
478
485
  return;
479
486
 
480
- git_buf_dispose(&idx->filename);
487
+ git_str_dispose(&idx->filename);
481
488
  git_midx_close(idx);
482
489
  git__free(idx);
483
490
  }
@@ -497,14 +504,14 @@ int git_midx_writer_new(
497
504
  git_midx_writer *w = git__calloc(1, sizeof(git_midx_writer));
498
505
  GIT_ERROR_CHECK_ALLOC(w);
499
506
 
500
- if (git_buf_sets(&w->pack_dir, pack_dir) < 0) {
507
+ if (git_str_sets(&w->pack_dir, pack_dir) < 0) {
501
508
  git__free(w);
502
509
  return -1;
503
510
  }
504
- git_path_squash_slashes(&w->pack_dir);
511
+ git_fs_path_squash_slashes(&w->pack_dir);
505
512
 
506
513
  if (git_vector_init(&w->packs, 0, packfile__cmp) < 0) {
507
- git_buf_dispose(&w->pack_dir);
514
+ git_str_dispose(&w->pack_dir);
508
515
  git__free(w);
509
516
  return -1;
510
517
  }
@@ -524,7 +531,7 @@ void git_midx_writer_free(git_midx_writer *w)
524
531
  git_vector_foreach (&w->packs, i, p)
525
532
  git_mwindow_put_pack(p);
526
533
  git_vector_free(&w->packs);
527
- git_buf_dispose(&w->pack_dir);
534
+ git_str_dispose(&w->pack_dir);
528
535
  git__free(w);
529
536
  }
530
537
 
@@ -532,16 +539,16 @@ int git_midx_writer_add(
532
539
  git_midx_writer *w,
533
540
  const char *idx_path)
534
541
  {
535
- git_buf idx_path_buf = GIT_BUF_INIT;
542
+ git_str idx_path_buf = GIT_STR_INIT;
536
543
  int error;
537
544
  struct git_pack_file *p;
538
545
 
539
- error = git_path_prettify(&idx_path_buf, idx_path, git_buf_cstr(&w->pack_dir));
546
+ error = git_fs_path_prettify(&idx_path_buf, idx_path, git_str_cstr(&w->pack_dir));
540
547
  if (error < 0)
541
548
  return error;
542
549
 
543
- error = git_mwindow_get_pack(&p, git_buf_cstr(&idx_path_buf));
544
- git_buf_dispose(&idx_path_buf);
550
+ error = git_mwindow_get_pack(&p, git_str_cstr(&idx_path_buf));
551
+ git_str_dispose(&idx_path_buf);
545
552
  if (error < 0)
546
553
  return error;
547
554
 
@@ -613,8 +620,8 @@ static int write_chunk_header(int chunk_id, off64_t offset, midx_write_cb write_
613
620
 
614
621
  static int midx_write_buf(const char *buf, size_t size, void *data)
615
622
  {
616
- git_buf *b = (git_buf *)data;
617
- return git_buf_put(b, buf, size);
623
+ git_str *b = (git_str *)data;
624
+ return git_str_put(b, buf, size);
618
625
  }
619
626
 
620
627
  struct midx_write_hash_context {
@@ -648,11 +655,12 @@ static int midx_write(
648
655
  uint32_t object_large_offsets_count;
649
656
  uint32_t oid_fanout[256];
650
657
  off64_t offset;
651
- git_buf packfile_names = GIT_BUF_INIT,
652
- oid_lookup = GIT_BUF_INIT,
653
- object_offsets = GIT_BUF_INIT,
654
- object_large_offsets = GIT_BUF_INIT;
655
- git_oid idx_checksum = {{0}};
658
+ git_str packfile_names = GIT_STR_INIT,
659
+ oid_lookup = GIT_STR_INIT,
660
+ object_offsets = GIT_STR_INIT,
661
+ object_large_offsets = GIT_STR_INIT;
662
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
663
+ size_t checksum_size;
656
664
  git_midx_entry *entry;
657
665
  object_entry_array_t object_entries_array = GIT_ARRAY_INIT;
658
666
  git_vector object_entries = GIT_VECTOR_INIT;
@@ -668,7 +676,8 @@ static int midx_write(
668
676
  hash_cb_data.cb_data = cb_data;
669
677
  hash_cb_data.ctx = &ctx;
670
678
 
671
- error = git_hash_ctx_init(&ctx);
679
+ checksum_size = GIT_HASH_SHA1_SIZE;
680
+ error = git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1);
672
681
  if (error < 0)
673
682
  return error;
674
683
  cb_data = &hash_cb_data;
@@ -676,34 +685,34 @@ static int midx_write(
676
685
 
677
686
  git_vector_sort(&w->packs);
678
687
  git_vector_foreach (&w->packs, i, p) {
679
- git_buf relative_index = GIT_BUF_INIT;
688
+ git_str relative_index = GIT_STR_INIT;
680
689
  struct object_entry_cb_state state = {0};
681
690
  size_t path_len;
682
691
 
683
692
  state.pack_index = (uint32_t)i;
684
693
  state.object_entries_array = &object_entries_array;
685
694
 
686
- error = git_buf_sets(&relative_index, p->pack_name);
695
+ error = git_str_sets(&relative_index, p->pack_name);
687
696
  if (error < 0)
688
697
  goto cleanup;
689
- error = git_path_make_relative(&relative_index, git_buf_cstr(&w->pack_dir));
698
+ error = git_fs_path_make_relative(&relative_index, git_str_cstr(&w->pack_dir));
690
699
  if (error < 0) {
691
- git_buf_dispose(&relative_index);
700
+ git_str_dispose(&relative_index);
692
701
  goto cleanup;
693
702
  }
694
- path_len = git_buf_len(&relative_index);
695
- if (path_len <= strlen(".pack") || git__suffixcmp(git_buf_cstr(&relative_index), ".pack") != 0) {
696
- git_buf_dispose(&relative_index);
703
+ path_len = git_str_len(&relative_index);
704
+ if (path_len <= strlen(".pack") || git__suffixcmp(git_str_cstr(&relative_index), ".pack") != 0) {
705
+ git_str_dispose(&relative_index);
697
706
  git_error_set(GIT_ERROR_INVALID, "invalid packfile name: '%s'", p->pack_name);
698
707
  error = -1;
699
708
  goto cleanup;
700
709
  }
701
710
  path_len -= strlen(".pack");
702
711
 
703
- git_buf_put(&packfile_names, git_buf_cstr(&relative_index), path_len);
704
- git_buf_puts(&packfile_names, ".idx");
705
- git_buf_putc(&packfile_names, '\0');
706
- git_buf_dispose(&relative_index);
712
+ git_str_put(&packfile_names, git_str_cstr(&relative_index), path_len);
713
+ git_str_puts(&packfile_names, ".idx");
714
+ git_str_putc(&packfile_names, '\0');
715
+ git_str_dispose(&relative_index);
707
716
 
708
717
  error = git_pack_foreach_entry_offset(p, object_entry__cb, &state);
709
718
  if (error < 0)
@@ -723,8 +732,8 @@ static int midx_write(
723
732
  git_vector_uniq(&object_entries, NULL);
724
733
 
725
734
  /* Pad the packfile names so it is a multiple of four. */
726
- while (git_buf_len(&packfile_names) & 3)
727
- git_buf_putc(&packfile_names, '\0');
735
+ while (git_str_len(&packfile_names) & 3)
736
+ git_str_putc(&packfile_names, '\0');
728
737
 
729
738
  /* Fill the OID Fanout table. */
730
739
  oid_fanout_count = 0;
@@ -737,7 +746,7 @@ static int midx_write(
737
746
 
738
747
  /* Fill the OID Lookup table. */
739
748
  git_vector_foreach (&object_entries, i, entry) {
740
- error = git_buf_put(&oid_lookup, (const char *)&entry->sha1, sizeof(entry->sha1));
749
+ error = git_str_put(&oid_lookup, (const char *)&entry->sha1, sizeof(entry->sha1));
741
750
  if (error < 0)
742
751
  goto cleanup;
743
752
  }
@@ -748,7 +757,7 @@ static int midx_write(
748
757
  uint32_t word;
749
758
 
750
759
  word = htonl((uint32_t)entry->pack_index);
751
- error = git_buf_put(&object_offsets, (const char *)&word, sizeof(word));
760
+ error = git_str_put(&object_offsets, (const char *)&word, sizeof(word));
752
761
  if (error < 0)
753
762
  goto cleanup;
754
763
  if (entry->offset >= 0x80000000l) {
@@ -759,7 +768,7 @@ static int midx_write(
759
768
  word = htonl((uint32_t)entry->offset & 0x7fffffffu);
760
769
  }
761
770
 
762
- error = git_buf_put(&object_offsets, (const char *)&word, sizeof(word));
771
+ error = git_str_put(&object_offsets, (const char *)&word, sizeof(word));
763
772
  if (error < 0)
764
773
  goto cleanup;
765
774
  }
@@ -767,7 +776,7 @@ static int midx_write(
767
776
  /* Write the header. */
768
777
  hdr.packfiles = htonl((uint32_t)git_vector_length(&w->packs));
769
778
  hdr.chunks = 4;
770
- if (git_buf_len(&object_large_offsets) > 0)
779
+ if (git_str_len(&object_large_offsets) > 0)
771
780
  hdr.chunks++;
772
781
  error = write_cb((const char *)&hdr, sizeof(hdr), cb_data);
773
782
  if (error < 0)
@@ -778,7 +787,7 @@ static int midx_write(
778
787
  error = write_chunk_header(MIDX_PACKFILE_NAMES_ID, offset, write_cb, cb_data);
779
788
  if (error < 0)
780
789
  goto cleanup;
781
- offset += git_buf_len(&packfile_names);
790
+ offset += git_str_len(&packfile_names);
782
791
  error = write_chunk_header(MIDX_OID_FANOUT_ID, offset, write_cb, cb_data);
783
792
  if (error < 0)
784
793
  goto cleanup;
@@ -786,53 +795,53 @@ static int midx_write(
786
795
  error = write_chunk_header(MIDX_OID_LOOKUP_ID, offset, write_cb, cb_data);
787
796
  if (error < 0)
788
797
  goto cleanup;
789
- offset += git_buf_len(&oid_lookup);
798
+ offset += git_str_len(&oid_lookup);
790
799
  error = write_chunk_header(MIDX_OBJECT_OFFSETS_ID, offset, write_cb, cb_data);
791
800
  if (error < 0)
792
801
  goto cleanup;
793
- offset += git_buf_len(&object_offsets);
794
- if (git_buf_len(&object_large_offsets) > 0) {
802
+ offset += git_str_len(&object_offsets);
803
+ if (git_str_len(&object_large_offsets) > 0) {
795
804
  error = write_chunk_header(MIDX_OBJECT_LARGE_OFFSETS_ID, offset, write_cb, cb_data);
796
805
  if (error < 0)
797
806
  goto cleanup;
798
- offset += git_buf_len(&object_large_offsets);
807
+ offset += git_str_len(&object_large_offsets);
799
808
  }
800
809
  error = write_chunk_header(0, offset, write_cb, cb_data);
801
810
  if (error < 0)
802
811
  goto cleanup;
803
812
 
804
813
  /* Write all the chunks. */
805
- error = write_cb(git_buf_cstr(&packfile_names), git_buf_len(&packfile_names), cb_data);
814
+ error = write_cb(git_str_cstr(&packfile_names), git_str_len(&packfile_names), cb_data);
806
815
  if (error < 0)
807
816
  goto cleanup;
808
817
  error = write_cb((const char *)oid_fanout, sizeof(oid_fanout), cb_data);
809
818
  if (error < 0)
810
819
  goto cleanup;
811
- error = write_cb(git_buf_cstr(&oid_lookup), git_buf_len(&oid_lookup), cb_data);
820
+ error = write_cb(git_str_cstr(&oid_lookup), git_str_len(&oid_lookup), cb_data);
812
821
  if (error < 0)
813
822
  goto cleanup;
814
- error = write_cb(git_buf_cstr(&object_offsets), git_buf_len(&object_offsets), cb_data);
823
+ error = write_cb(git_str_cstr(&object_offsets), git_str_len(&object_offsets), cb_data);
815
824
  if (error < 0)
816
825
  goto cleanup;
817
- error = write_cb(git_buf_cstr(&object_large_offsets), git_buf_len(&object_large_offsets), cb_data);
826
+ error = write_cb(git_str_cstr(&object_large_offsets), git_str_len(&object_large_offsets), cb_data);
818
827
  if (error < 0)
819
828
  goto cleanup;
820
829
 
821
830
  /* Finalize the checksum and write the trailer. */
822
- error = git_hash_final(&idx_checksum, &ctx);
831
+ error = git_hash_final(checksum, &ctx);
823
832
  if (error < 0)
824
833
  goto cleanup;
825
- error = write_cb((const char *)&idx_checksum, sizeof(idx_checksum), cb_data);
834
+ error = write_cb((char *)checksum, checksum_size, cb_data);
826
835
  if (error < 0)
827
836
  goto cleanup;
828
837
 
829
838
  cleanup:
830
839
  git_array_clear(object_entries_array);
831
840
  git_vector_free(&object_entries);
832
- git_buf_dispose(&packfile_names);
833
- git_buf_dispose(&oid_lookup);
834
- git_buf_dispose(&object_offsets);
835
- git_buf_dispose(&object_large_offsets);
841
+ git_str_dispose(&packfile_names);
842
+ git_str_dispose(&oid_lookup);
843
+ git_str_dispose(&object_offsets);
844
+ git_str_dispose(&object_large_offsets);
836
845
  git_hash_ctx_cleanup(&ctx);
837
846
  return error;
838
847
  }
@@ -848,17 +857,17 @@ int git_midx_writer_commit(
848
857
  {
849
858
  int error;
850
859
  int filebuf_flags = GIT_FILEBUF_DO_NOT_BUFFER;
851
- git_buf midx_path = GIT_BUF_INIT;
860
+ git_str midx_path = GIT_STR_INIT;
852
861
  git_filebuf output = GIT_FILEBUF_INIT;
853
862
 
854
- error = git_buf_joinpath(&midx_path, git_buf_cstr(&w->pack_dir), "multi-pack-index");
863
+ error = git_str_joinpath(&midx_path, git_str_cstr(&w->pack_dir), "multi-pack-index");
855
864
  if (error < 0)
856
865
  return error;
857
866
 
858
867
  if (git_repository__fsync_gitdir)
859
868
  filebuf_flags |= GIT_FILEBUF_FSYNC;
860
- error = git_filebuf_open(&output, git_buf_cstr(&midx_path), filebuf_flags, 0644);
861
- git_buf_dispose(&midx_path);
869
+ error = git_filebuf_open(&output, git_str_cstr(&midx_path), filebuf_flags, 0644);
870
+ git_str_dispose(&midx_path);
862
871
  if (error < 0)
863
872
  return error;
864
873
 
@@ -875,5 +884,13 @@ int git_midx_writer_dump(
875
884
  git_buf *midx,
876
885
  git_midx_writer *w)
877
886
  {
878
- return midx_write(w, midx_write_buf, midx);
887
+ git_str str = GIT_STR_INIT;
888
+ int error;
889
+
890
+ if ((error = git_buf_tostr(&str, midx)) < 0 ||
891
+ (error = midx_write(w, midx_write_buf, &str)) == 0)
892
+ error = git_buf_fromstr(midx, &str);
893
+
894
+ git_str_dispose(&str);
895
+ return error;
879
896
  }
@@ -51,10 +51,10 @@ typedef struct git_midx_file {
51
51
  size_t num_object_large_offsets;
52
52
 
53
53
  /* The trailer of the file. Contains the SHA1-checksum of the whole file. */
54
- git_oid checksum;
54
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
55
55
 
56
56
  /* something like ".git/objects/pack/multi-pack-index". */
57
- git_buf filename;
57
+ git_str filename;
58
58
  } git_midx_file;
59
59
 
60
60
  /*
@@ -77,7 +77,7 @@ struct git_midx_writer {
77
77
  * The path of the directory where the .pack/.idx files are stored. The
78
78
  * `multi-pack-index` file will be written to the same directory.
79
79
  */
80
- git_buf pack_dir;
80
+ git_str pack_dir;
81
81
 
82
82
  /* The list of `git_pack_file`s. */
83
83
  git_vector packs;
@@ -473,7 +473,7 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
473
473
  git_mwindow_find_lru_file_locked(&lru_file) == 0) {
474
474
  if ((error = git_vector_insert(&closed_files, lru_file)) < 0) {
475
475
  /*
476
- * Exceeding the file limit seems preferrable to being open to
476
+ * Exceeding the file limit seems preferable to being open to
477
477
  * data races that can end up corrupting the heap.
478
478
  */
479
479
  break;