rugged 1.3.1 → 1.9.0

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 (656) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -2
  3. data/ext/rugged/extconf.rb +6 -3
  4. data/ext/rugged/rugged.c +16 -0
  5. data/ext/rugged/rugged.h +4 -0
  6. data/ext/rugged/rugged_allocator.c +0 -54
  7. data/ext/rugged/rugged_blame.c +2 -0
  8. data/ext/rugged/rugged_blob.c +3 -0
  9. data/ext/rugged/rugged_commit.c +1 -0
  10. data/ext/rugged/rugged_config.c +9 -2
  11. data/ext/rugged/rugged_diff.c +1 -0
  12. data/ext/rugged/rugged_index.c +2 -0
  13. data/ext/rugged/rugged_patch.c +1 -0
  14. data/ext/rugged/rugged_rebase.c +1 -0
  15. data/ext/rugged/rugged_reference.c +1 -0
  16. data/ext/rugged/rugged_remote.c +28 -10
  17. data/ext/rugged/rugged_repo.c +7 -9
  18. data/ext/rugged/rugged_revwalk.c +5 -1
  19. data/ext/rugged/rugged_settings.c +5 -0
  20. data/ext/rugged/rugged_submodule.c +1 -0
  21. data/ext/rugged/rugged_tag.c +1 -0
  22. data/ext/rugged/rugged_tree.c +4 -0
  23. data/lib/rugged/index.rb +1 -1
  24. data/lib/rugged/tree.rb +5 -1
  25. data/lib/rugged/version.rb +1 -1
  26. data/vendor/libgit2/AUTHORS +1 -0
  27. data/vendor/libgit2/CMakeLists.txt +141 -289
  28. data/vendor/libgit2/COPYING +301 -20
  29. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  30. data/vendor/libgit2/cmake/AddClarTest.cmake +7 -0
  31. data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
  32. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  33. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  34. data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
  35. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  36. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  37. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  38. data/vendor/libgit2/cmake/FindHTTP_Parser.cmake +17 -17
  39. data/vendor/libgit2/cmake/FindIntlIconv.cmake +51 -0
  40. data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
  41. data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
  42. data/vendor/libgit2/cmake/FindPCRE.cmake +12 -13
  43. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  44. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  45. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  46. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  47. data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
  48. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  49. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  50. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  51. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  52. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  53. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +34 -0
  54. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +129 -101
  55. data/vendor/libgit2/cmake/SelectHashes.cmake +113 -54
  56. data/vendor/libgit2/cmake/SelectRegex.cmake +56 -0
  57. data/vendor/libgit2/cmake/SelectSSH.cmake +46 -0
  58. data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
  59. data/vendor/libgit2/cmake/SelectZlib.cmake +38 -0
  60. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
  61. data/vendor/libgit2/deps/llhttp/CMakeLists.txt +8 -0
  62. data/vendor/libgit2/deps/llhttp/LICENSE-MIT +22 -0
  63. data/vendor/libgit2/deps/llhttp/api.c +510 -0
  64. data/vendor/libgit2/deps/llhttp/http.c +170 -0
  65. data/vendor/libgit2/deps/llhttp/llhttp.c +10168 -0
  66. data/vendor/libgit2/deps/llhttp/llhttp.h +897 -0
  67. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +33 -31
  68. data/vendor/libgit2/deps/ntlmclient/crypt_builtin_md4.c +311 -0
  69. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +2 -1
  70. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -20
  71. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +7 -5
  72. data/vendor/libgit2/deps/ntlmclient/ntlm.c +25 -25
  73. data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
  74. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
  75. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +5 -4
  76. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +2 -1
  77. data/vendor/libgit2/deps/ntlmclient/utf8.h +1176 -721
  78. data/vendor/libgit2/deps/ntlmclient/util.h +11 -0
  79. data/vendor/libgit2/deps/pcre/CMakeLists.txt +89 -88
  80. data/vendor/libgit2/deps/pcre/LICENCE +5 -5
  81. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  82. data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
  83. data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
  84. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  85. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
  86. data/vendor/libgit2/deps/xdiff/git-xdiff.h +56 -0
  87. data/vendor/libgit2/{src → deps}/xdiff/xdiff.h +15 -15
  88. data/vendor/libgit2/{src → deps}/xdiff/xdiffi.c +152 -125
  89. data/vendor/libgit2/{src → deps}/xdiff/xdiffi.h +2 -4
  90. data/vendor/libgit2/{src → deps}/xdiff/xemit.c +26 -10
  91. data/vendor/libgit2/{src → deps}/xdiff/xhistogram.c +92 -94
  92. data/vendor/libgit2/{src → deps}/xdiff/xinclude.h +1 -12
  93. data/vendor/libgit2/{src → deps}/xdiff/xmacros.h +18 -1
  94. data/vendor/libgit2/{src → deps}/xdiff/xmerge.c +126 -137
  95. data/vendor/libgit2/{src → deps}/xdiff/xpatience.c +26 -46
  96. data/vendor/libgit2/{src → deps}/xdiff/xprepare.c +24 -46
  97. data/vendor/libgit2/{src → deps}/xdiff/xutils.c +36 -8
  98. data/vendor/libgit2/{src → deps}/xdiff/xutils.h +2 -1
  99. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -1
  100. data/vendor/libgit2/deps/zlib/LICENSE +22 -0
  101. data/vendor/libgit2/deps/zlib/adler32.c +7 -22
  102. data/vendor/libgit2/deps/zlib/crc32.c +931 -317
  103. data/vendor/libgit2/deps/zlib/crc32.h +9441 -436
  104. data/vendor/libgit2/deps/zlib/deflate.c +428 -453
  105. data/vendor/libgit2/deps/zlib/deflate.h +51 -23
  106. data/vendor/libgit2/deps/zlib/gzguts.h +15 -19
  107. data/vendor/libgit2/deps/zlib/infback.c +19 -31
  108. data/vendor/libgit2/deps/zlib/inffast.c +15 -18
  109. data/vendor/libgit2/deps/zlib/inffast.h +1 -1
  110. data/vendor/libgit2/deps/zlib/inflate.c +75 -110
  111. data/vendor/libgit2/deps/zlib/inflate.h +3 -2
  112. data/vendor/libgit2/deps/zlib/inftrees.c +6 -11
  113. data/vendor/libgit2/deps/zlib/inftrees.h +6 -6
  114. data/vendor/libgit2/deps/zlib/trees.c +294 -380
  115. data/vendor/libgit2/deps/zlib/zconf.h +23 -14
  116. data/vendor/libgit2/deps/zlib/zlib.h +310 -284
  117. data/vendor/libgit2/deps/zlib/zutil.c +20 -46
  118. data/vendor/libgit2/deps/zlib/zutil.h +24 -41
  119. data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
  120. data/vendor/libgit2/include/git2/apply.h +43 -8
  121. data/vendor/libgit2/include/git2/attr.h +28 -6
  122. data/vendor/libgit2/include/git2/blame.h +137 -29
  123. data/vendor/libgit2/include/git2/blob.h +85 -29
  124. data/vendor/libgit2/include/git2/branch.h +25 -16
  125. data/vendor/libgit2/include/git2/buffer.h +24 -82
  126. data/vendor/libgit2/include/git2/cert.h +4 -3
  127. data/vendor/libgit2/include/git2/checkout.h +88 -34
  128. data/vendor/libgit2/include/git2/cherrypick.h +10 -3
  129. data/vendor/libgit2/include/git2/clone.h +28 -12
  130. data/vendor/libgit2/include/git2/commit.h +134 -3
  131. data/vendor/libgit2/include/git2/common.h +172 -59
  132. data/vendor/libgit2/include/git2/config.h +118 -32
  133. data/vendor/libgit2/include/git2/credential.h +32 -3
  134. data/vendor/libgit2/include/git2/credential_helpers.h +2 -0
  135. data/vendor/libgit2/include/git2/deprecated.h +141 -3
  136. data/vendor/libgit2/include/git2/describe.h +20 -3
  137. data/vendor/libgit2/include/git2/diff.h +95 -19
  138. data/vendor/libgit2/include/git2/email.h +10 -30
  139. data/vendor/libgit2/include/git2/errors.h +51 -61
  140. data/vendor/libgit2/include/git2/experimental.h +20 -0
  141. data/vendor/libgit2/include/git2/filter.h +21 -9
  142. data/vendor/libgit2/include/git2/global.h +8 -1
  143. data/vendor/libgit2/include/git2/graph.h +4 -2
  144. data/vendor/libgit2/include/git2/ignore.h +11 -1
  145. data/vendor/libgit2/include/git2/index.h +111 -11
  146. data/vendor/libgit2/include/git2/indexer.h +67 -2
  147. data/vendor/libgit2/include/git2/mailmap.h +7 -1
  148. data/vendor/libgit2/include/git2/merge.h +70 -5
  149. data/vendor/libgit2/include/git2/message.h +4 -2
  150. data/vendor/libgit2/include/git2/net.h +3 -1
  151. data/vendor/libgit2/include/git2/notes.h +9 -6
  152. data/vendor/libgit2/include/git2/object.h +57 -7
  153. data/vendor/libgit2/include/git2/odb.h +156 -33
  154. data/vendor/libgit2/include/git2/odb_backend.h +132 -16
  155. data/vendor/libgit2/include/git2/oid.h +116 -17
  156. data/vendor/libgit2/include/git2/oidarray.h +7 -1
  157. data/vendor/libgit2/include/git2/pack.h +37 -9
  158. data/vendor/libgit2/include/git2/patch.h +10 -3
  159. data/vendor/libgit2/include/git2/pathspec.h +10 -1
  160. data/vendor/libgit2/include/git2/proxy.h +11 -1
  161. data/vendor/libgit2/include/git2/rebase.h +18 -7
  162. data/vendor/libgit2/include/git2/refdb.h +5 -2
  163. data/vendor/libgit2/include/git2/reflog.h +4 -3
  164. data/vendor/libgit2/include/git2/refs.h +11 -8
  165. data/vendor/libgit2/include/git2/refspec.h +14 -4
  166. data/vendor/libgit2/include/git2/remote.h +295 -54
  167. data/vendor/libgit2/include/git2/repository.h +95 -25
  168. data/vendor/libgit2/include/git2/reset.h +18 -5
  169. data/vendor/libgit2/include/git2/revert.h +9 -4
  170. data/vendor/libgit2/include/git2/revparse.h +4 -4
  171. data/vendor/libgit2/include/git2/revwalk.h +7 -3
  172. data/vendor/libgit2/include/git2/signature.h +47 -2
  173. data/vendor/libgit2/include/git2/stash.h +78 -10
  174. data/vendor/libgit2/include/git2/status.h +24 -11
  175. data/vendor/libgit2/include/git2/stdint.h +87 -85
  176. data/vendor/libgit2/include/git2/strarray.h +2 -16
  177. data/vendor/libgit2/include/git2/submodule.h +27 -11
  178. data/vendor/libgit2/include/git2/sys/alloc.h +12 -34
  179. data/vendor/libgit2/include/git2/sys/commit.h +77 -3
  180. data/vendor/libgit2/include/git2/sys/commit_graph.h +110 -59
  181. data/vendor/libgit2/include/git2/sys/config.h +80 -4
  182. data/vendor/libgit2/include/git2/sys/credential.h +4 -3
  183. data/vendor/libgit2/include/git2/sys/diff.h +21 -1
  184. data/vendor/libgit2/include/git2/sys/email.h +7 -0
  185. data/vendor/libgit2/include/git2/sys/errors.h +76 -0
  186. data/vendor/libgit2/include/git2/sys/filter.h +66 -3
  187. data/vendor/libgit2/include/git2/sys/hashsig.h +11 -0
  188. data/vendor/libgit2/include/git2/sys/index.h +3 -2
  189. data/vendor/libgit2/include/git2/sys/mempack.h +32 -2
  190. data/vendor/libgit2/include/git2/sys/merge.h +55 -7
  191. data/vendor/libgit2/include/git2/sys/midx.h +47 -4
  192. data/vendor/libgit2/include/git2/sys/odb_backend.h +10 -9
  193. data/vendor/libgit2/include/git2/sys/openssl.h +8 -1
  194. data/vendor/libgit2/include/git2/sys/path.h +12 -1
  195. data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -36
  196. data/vendor/libgit2/include/git2/sys/refs.h +3 -2
  197. data/vendor/libgit2/include/git2/sys/remote.h +53 -0
  198. data/vendor/libgit2/include/git2/sys/repository.h +63 -3
  199. data/vendor/libgit2/include/git2/sys/stream.h +26 -3
  200. data/vendor/libgit2/include/git2/sys/transport.h +87 -41
  201. data/vendor/libgit2/include/git2/tag.h +4 -1
  202. data/vendor/libgit2/include/git2/trace.h +9 -3
  203. data/vendor/libgit2/include/git2/transaction.h +3 -2
  204. data/vendor/libgit2/include/git2/transport.h +11 -3
  205. data/vendor/libgit2/include/git2/tree.h +20 -8
  206. data/vendor/libgit2/include/git2/types.h +26 -10
  207. data/vendor/libgit2/include/git2/version.h +63 -6
  208. data/vendor/libgit2/include/git2/worktree.h +30 -8
  209. data/vendor/libgit2/include/git2.h +1 -0
  210. data/vendor/libgit2/src/CMakeLists.txt +203 -420
  211. data/vendor/libgit2/src/README.md +12 -0
  212. data/vendor/libgit2/src/cli/CMakeLists.txt +56 -0
  213. data/vendor/libgit2/src/cli/README.md +26 -0
  214. data/vendor/libgit2/src/{branch.h → cli/cmd.c} +10 -8
  215. data/vendor/libgit2/src/cli/cmd.h +37 -0
  216. data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
  217. data/vendor/libgit2/src/cli/cmd_cat_file.c +202 -0
  218. data/vendor/libgit2/src/cli/cmd_clone.c +190 -0
  219. data/vendor/libgit2/src/cli/cmd_config.c +241 -0
  220. data/vendor/libgit2/src/cli/cmd_hash_object.c +152 -0
  221. data/vendor/libgit2/src/cli/cmd_help.c +85 -0
  222. data/vendor/libgit2/src/cli/cmd_index_pack.c +114 -0
  223. data/vendor/libgit2/src/cli/cmd_init.c +102 -0
  224. data/vendor/libgit2/src/cli/common.c +168 -0
  225. data/vendor/libgit2/src/cli/common.h +63 -0
  226. data/vendor/libgit2/src/cli/error.h +51 -0
  227. data/vendor/libgit2/src/cli/main.c +134 -0
  228. data/vendor/libgit2/src/cli/opt.c +695 -0
  229. data/vendor/libgit2/src/cli/opt.h +367 -0
  230. data/vendor/libgit2/src/cli/opt_usage.c +263 -0
  231. data/vendor/libgit2/src/cli/opt_usage.h +40 -0
  232. data/vendor/libgit2/src/cli/progress.c +395 -0
  233. data/vendor/libgit2/src/cli/progress.h +129 -0
  234. data/vendor/libgit2/src/cli/sighandler.h +20 -0
  235. data/vendor/libgit2/src/cli/unix/sighandler.c +37 -0
  236. data/vendor/libgit2/src/cli/win32/precompiled.h +3 -0
  237. data/vendor/libgit2/src/cli/win32/sighandler.c +37 -0
  238. data/vendor/libgit2/src/libgit2/CMakeLists.txt +140 -0
  239. data/vendor/libgit2/src/{annotated_commit.c → libgit2/annotated_commit.c} +2 -2
  240. data/vendor/libgit2/src/{annotated_commit.h → libgit2/annotated_commit.h} +2 -2
  241. data/vendor/libgit2/src/{apply.c → libgit2/apply.c} +32 -34
  242. data/vendor/libgit2/src/{apply.h → libgit2/apply.h} +2 -2
  243. data/vendor/libgit2/src/{attr.c → libgit2/attr.c} +48 -31
  244. data/vendor/libgit2/src/{attr_file.c → libgit2/attr_file.c} +25 -20
  245. data/vendor/libgit2/src/{attr_file.h → libgit2/attr_file.h} +6 -4
  246. data/vendor/libgit2/src/{attrcache.c → libgit2/attrcache.c} +87 -46
  247. data/vendor/libgit2/src/{attrcache.h → libgit2/attrcache.h} +5 -9
  248. data/vendor/libgit2/src/{blame.c → libgit2/blame.c} +152 -57
  249. data/vendor/libgit2/src/{blame.h → libgit2/blame.h} +1 -0
  250. data/vendor/libgit2/src/{blame_git.c → libgit2/blame_git.c} +1 -2
  251. data/vendor/libgit2/src/{blob.c → libgit2/blob.c} +38 -29
  252. data/vendor/libgit2/src/{blob.h → libgit2/blob.h} +3 -3
  253. data/vendor/libgit2/src/{branch.c → libgit2/branch.c} +164 -118
  254. data/vendor/libgit2/src/libgit2/branch.h +31 -0
  255. data/vendor/libgit2/src/libgit2/buf.c +126 -0
  256. data/vendor/libgit2/src/libgit2/buf.h +50 -0
  257. data/vendor/libgit2/src/{cache.c → libgit2/cache.c} +22 -17
  258. data/vendor/libgit2/src/{cache.h → libgit2/cache.h} +7 -9
  259. data/vendor/libgit2/src/{checkout.c → libgit2/checkout.c} +107 -91
  260. data/vendor/libgit2/src/{checkout.h → libgit2/checkout.h} +0 -2
  261. data/vendor/libgit2/src/{cherrypick.c → libgit2/cherrypick.c} +14 -15
  262. data/vendor/libgit2/src/{clone.c → libgit2/clone.c} +254 -203
  263. data/vendor/libgit2/src/{clone.h → libgit2/clone.h} +4 -1
  264. data/vendor/libgit2/src/{commit.c → libgit2/commit.c} +296 -77
  265. data/vendor/libgit2/src/libgit2/commit.h +87 -0
  266. data/vendor/libgit2/src/{commit_graph.c → libgit2/commit_graph.c} +246 -135
  267. data/vendor/libgit2/src/{commit_graph.h → libgit2/commit_graph.h} +33 -8
  268. data/vendor/libgit2/src/{commit_list.c → libgit2/commit_list.c} +17 -7
  269. data/vendor/libgit2/src/{commit_list.h → libgit2/commit_list.h} +1 -0
  270. data/vendor/libgit2/src/libgit2/common.h +55 -0
  271. data/vendor/libgit2/src/{config.c → libgit2/config.c} +490 -360
  272. data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
  273. data/vendor/libgit2/src/{config.h → libgit2/config.h} +24 -6
  274. data/vendor/libgit2/src/{config_backend.h → libgit2/config_backend.h} +8 -10
  275. data/vendor/libgit2/src/{config_cache.c → libgit2/config_cache.c} +4 -5
  276. data/vendor/libgit2/src/{config_file.c → libgit2/config_file.c} +212 -183
  277. data/vendor/libgit2/src/libgit2/config_list.c +285 -0
  278. data/vendor/libgit2/src/libgit2/config_list.h +32 -0
  279. data/vendor/libgit2/src/libgit2/config_mem.c +374 -0
  280. data/vendor/libgit2/src/{config_parse.c → libgit2/config_parse.c} +37 -32
  281. data/vendor/libgit2/src/{config_snapshot.c → libgit2/config_snapshot.c} +24 -31
  282. data/vendor/libgit2/src/{crlf.c → libgit2/crlf.c} +24 -21
  283. data/vendor/libgit2/src/{describe.c → libgit2/describe.c} +62 -51
  284. data/vendor/libgit2/src/{diff.c → libgit2/diff.c} +44 -14
  285. data/vendor/libgit2/src/{diff.h → libgit2/diff.h} +8 -10
  286. data/vendor/libgit2/src/{diff_driver.c → libgit2/diff_driver.c} +46 -55
  287. data/vendor/libgit2/src/{diff_driver.h → libgit2/diff_driver.h} +5 -5
  288. data/vendor/libgit2/src/{diff_file.c → libgit2/diff_file.c} +45 -27
  289. data/vendor/libgit2/src/{diff_generate.c → libgit2/diff_generate.c} +70 -20
  290. data/vendor/libgit2/src/{diff_generate.h → libgit2/diff_generate.h} +5 -3
  291. data/vendor/libgit2/src/{diff_parse.c → libgit2/diff_parse.c} +22 -6
  292. data/vendor/libgit2/src/{diff_print.c → libgit2/diff_print.c} +192 -105
  293. data/vendor/libgit2/src/{diff_stats.c → libgit2/diff_stats.c} +40 -29
  294. data/vendor/libgit2/src/libgit2/diff_stats.h +18 -0
  295. data/vendor/libgit2/src/{diff_tform.c → libgit2/diff_tform.c} +49 -16
  296. data/vendor/libgit2/src/{diff_xdiff.c → libgit2/diff_xdiff.c} +4 -8
  297. data/vendor/libgit2/src/{diff_xdiff.h → libgit2/diff_xdiff.h} +1 -1
  298. data/vendor/libgit2/src/{email.c → libgit2/email.c} +58 -40
  299. data/vendor/libgit2/src/{email.h → libgit2/email.h} +1 -1
  300. data/vendor/libgit2/src/{transports/ssh.h → libgit2/experimental.h.in} +3 -4
  301. data/vendor/libgit2/src/{fetch.c → libgit2/fetch.c} +105 -30
  302. data/vendor/libgit2/src/{fetch.h → libgit2/fetch.h} +1 -3
  303. data/vendor/libgit2/src/{fetchhead.c → libgit2/fetchhead.c} +30 -28
  304. data/vendor/libgit2/src/{filter.c → libgit2/filter.c} +132 -58
  305. data/vendor/libgit2/src/{filter.h → libgit2/filter.h} +26 -5
  306. data/vendor/libgit2/src/{win32 → libgit2}/git2.rc +3 -3
  307. data/vendor/libgit2/src/libgit2/grafts.c +270 -0
  308. data/vendor/libgit2/src/libgit2/grafts.h +35 -0
  309. data/vendor/libgit2/src/{graph.c → libgit2/graph.c} +1 -1
  310. data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
  311. data/vendor/libgit2/src/{ident.c → libgit2/ident.c} +20 -20
  312. data/vendor/libgit2/src/{ignore.c → libgit2/ignore.c} +44 -39
  313. data/vendor/libgit2/src/{ignore.h → libgit2/ignore.h} +2 -2
  314. data/vendor/libgit2/src/{index.c → libgit2/index.c} +460 -276
  315. data/vendor/libgit2/src/{index.h → libgit2/index.h} +21 -5
  316. data/vendor/libgit2/src/libgit2/index_map.c +95 -0
  317. data/vendor/libgit2/src/libgit2/index_map.h +28 -0
  318. data/vendor/libgit2/src/{indexer.c → libgit2/indexer.c} +208 -124
  319. data/vendor/libgit2/src/{iterator.c → libgit2/iterator.c} +102 -71
  320. data/vendor/libgit2/src/{iterator.h → libgit2/iterator.h} +8 -5
  321. data/vendor/libgit2/src/libgit2/libgit2.c +268 -0
  322. data/vendor/libgit2/src/{mailmap.c → libgit2/mailmap.c} +39 -37
  323. data/vendor/libgit2/src/{merge.c → libgit2/merge.c} +83 -73
  324. data/vendor/libgit2/src/{merge.h → libgit2/merge.h} +1 -14
  325. data/vendor/libgit2/src/{merge_driver.c → libgit2/merge_driver.c} +4 -4
  326. data/vendor/libgit2/src/{merge_file.c → libgit2/merge_file.c} +13 -5
  327. data/vendor/libgit2/src/{message.c → libgit2/message.c} +21 -10
  328. data/vendor/libgit2/src/{midx.c → libgit2/midx.c} +174 -112
  329. data/vendor/libgit2/src/{midx.h → libgit2/midx.h} +17 -6
  330. data/vendor/libgit2/src/{mwindow.c → libgit2/mwindow.c} +53 -57
  331. data/vendor/libgit2/src/{mwindow.h → libgit2/mwindow.h} +9 -2
  332. data/vendor/libgit2/src/{notes.c → libgit2/notes.c} +29 -37
  333. data/vendor/libgit2/src/{object.c → libgit2/object.c} +166 -35
  334. data/vendor/libgit2/src/{object.h → libgit2/object.h} +17 -2
  335. data/vendor/libgit2/src/{odb.c → libgit2/odb.c} +261 -88
  336. data/vendor/libgit2/src/{odb.h → libgit2/odb.h} +44 -5
  337. data/vendor/libgit2/src/{odb_loose.c → libgit2/odb_loose.c} +192 -134
  338. data/vendor/libgit2/src/{odb_mempack.c → libgit2/odb_mempack.c} +67 -22
  339. data/vendor/libgit2/src/{odb_pack.c → libgit2/odb_pack.c} +162 -89
  340. data/vendor/libgit2/src/{oid.c → libgit2/oid.c} +171 -92
  341. data/vendor/libgit2/src/libgit2/oid.h +284 -0
  342. data/vendor/libgit2/src/libgit2/oidarray.c +89 -0
  343. data/vendor/libgit2/src/{oidarray.h → libgit2/oidarray.h} +5 -1
  344. data/vendor/libgit2/src/{pack-objects.c → libgit2/pack-objects.c} +126 -66
  345. data/vendor/libgit2/src/{pack-objects.h → libgit2/pack-objects.h} +28 -12
  346. data/vendor/libgit2/src/{pack.c → libgit2/pack.c} +146 -111
  347. data/vendor/libgit2/src/{pack.h → libgit2/pack.h} +45 -25
  348. data/vendor/libgit2/src/{parse.c → libgit2/parse.c} +8 -4
  349. data/vendor/libgit2/src/{parse.h → libgit2/parse.h} +1 -1
  350. data/vendor/libgit2/src/{patch.c → libgit2/patch.c} +3 -3
  351. data/vendor/libgit2/src/{patch.h → libgit2/patch.h} +8 -1
  352. data/vendor/libgit2/src/{patch_generate.c → libgit2/patch_generate.c} +51 -16
  353. data/vendor/libgit2/src/{patch_generate.h → libgit2/patch_generate.h} +5 -5
  354. data/vendor/libgit2/src/{patch_parse.c → libgit2/patch_parse.c} +42 -34
  355. data/vendor/libgit2/src/libgit2/path.c +375 -0
  356. data/vendor/libgit2/src/libgit2/path.h +68 -0
  357. data/vendor/libgit2/src/{pathspec.c → libgit2/pathspec.c} +7 -7
  358. data/vendor/libgit2/src/{pathspec.h → libgit2/pathspec.h} +2 -2
  359. data/vendor/libgit2/src/{proxy.c → libgit2/proxy.c} +4 -1
  360. data/vendor/libgit2/src/{proxy.h → libgit2/proxy.h} +1 -1
  361. data/vendor/libgit2/src/{push.c → libgit2/push.c} +116 -60
  362. data/vendor/libgit2/src/{push.h → libgit2/push.h} +5 -16
  363. data/vendor/libgit2/src/{reader.c → libgit2/reader.c} +9 -9
  364. data/vendor/libgit2/src/{reader.h → libgit2/reader.h} +2 -2
  365. data/vendor/libgit2/src/{rebase.c → libgit2/rebase.c} +147 -147
  366. data/vendor/libgit2/src/{refdb_fs.c → libgit2/refdb_fs.c} +639 -254
  367. data/vendor/libgit2/src/{reflog.c → libgit2/reflog.c} +8 -7
  368. data/vendor/libgit2/src/{reflog.h → libgit2/reflog.h} +3 -2
  369. data/vendor/libgit2/src/{refs.c → libgit2/refs.c} +67 -39
  370. data/vendor/libgit2/src/{refs.h → libgit2/refs.h} +8 -3
  371. data/vendor/libgit2/src/{refspec.c → libgit2/refspec.c} +60 -38
  372. data/vendor/libgit2/src/{refspec.h → libgit2/refspec.h} +13 -2
  373. data/vendor/libgit2/src/{remote.c → libgit2/remote.c} +821 -454
  374. data/vendor/libgit2/src/libgit2/remote.h +101 -0
  375. data/vendor/libgit2/src/{repository.c → libgit2/repository.c} +1377 -594
  376. data/vendor/libgit2/src/{repository.h → libgit2/repository.h} +43 -12
  377. data/vendor/libgit2/src/{reset.c → libgit2/reset.c} +8 -5
  378. data/vendor/libgit2/src/{revert.c → libgit2/revert.c} +18 -22
  379. data/vendor/libgit2/src/{revparse.c → libgit2/revparse.c} +76 -44
  380. data/vendor/libgit2/src/{revwalk.c → libgit2/revwalk.c} +48 -19
  381. data/vendor/libgit2/src/{revwalk.h → libgit2/revwalk.h} +3 -3
  382. data/vendor/libgit2/src/{libgit2.c → libgit2/settings.c} +162 -95
  383. data/vendor/libgit2/src/{settings.h → libgit2/settings.h} +6 -2
  384. data/vendor/libgit2/src/{signature.c → libgit2/signature.c} +144 -21
  385. data/vendor/libgit2/src/{signature.h → libgit2/signature.h} +1 -2
  386. data/vendor/libgit2/src/{stash.c → libgit2/stash.c} +243 -68
  387. data/vendor/libgit2/src/{status.c → libgit2/status.c} +5 -2
  388. data/vendor/libgit2/src/{strarray.c → libgit2/strarray.c} +1 -0
  389. data/vendor/libgit2/src/libgit2/strarray.h +25 -0
  390. data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.c +62 -67
  391. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.c +41 -24
  392. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.h +2 -0
  393. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.c +11 -3
  394. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.h +6 -3
  395. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  396. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  397. data/vendor/libgit2/src/libgit2/streams/socket.c +428 -0
  398. data/vendor/libgit2/src/{streams → libgit2/streams}/socket.h +3 -1
  399. data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.c +79 -19
  400. data/vendor/libgit2/src/{streams → libgit2/streams}/tls.c +5 -0
  401. data/vendor/libgit2/src/{submodule.c → libgit2/submodule.c} +279 -220
  402. data/vendor/libgit2/src/{submodule.h → libgit2/submodule.h} +10 -11
  403. data/vendor/libgit2/src/libgit2/sysdir.c +650 -0
  404. data/vendor/libgit2/src/{sysdir.h → libgit2/sysdir.h} +55 -18
  405. data/vendor/libgit2/src/{tag.c → libgit2/tag.c} +74 -43
  406. data/vendor/libgit2/src/{tag.h → libgit2/tag.h} +2 -2
  407. data/vendor/libgit2/src/{trace.c → libgit2/trace.c} +1 -14
  408. data/vendor/libgit2/src/{trace.h → libgit2/trace.h} +5 -22
  409. data/vendor/libgit2/src/{trailer.c → libgit2/trailer.c} +7 -7
  410. data/vendor/libgit2/src/{transaction.c → libgit2/transaction.c} +27 -21
  411. data/vendor/libgit2/src/{transaction.h → libgit2/transaction.h} +4 -1
  412. data/vendor/libgit2/src/{transport.c → libgit2/transport.c} +14 -11
  413. data/vendor/libgit2/src/{transports → libgit2/transports}/auth.c +7 -9
  414. data/vendor/libgit2/src/{transports → libgit2/transports}/auth.h +3 -5
  415. data/vendor/libgit2/src/{transports/auth_negotiate.c → libgit2/transports/auth_gssapi.c} +44 -45
  416. data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.h +1 -1
  417. data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.h +1 -2
  418. data/vendor/libgit2/src/{transports/auth_ntlm.c → libgit2/transports/auth_ntlmclient.c} +22 -22
  419. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  420. data/vendor/libgit2/src/{transports → libgit2/transports}/credential.c +1 -1
  421. data/vendor/libgit2/src/{transports → libgit2/transports}/git.c +16 -19
  422. data/vendor/libgit2/src/{transports → libgit2/transports}/http.c +49 -24
  423. data/vendor/libgit2/src/{transports → libgit2/transports}/http.h +0 -11
  424. data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.c +188 -134
  425. data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.h +10 -0
  426. data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
  427. data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
  428. data/vendor/libgit2/src/{transports → libgit2/transports}/local.c +159 -127
  429. data/vendor/libgit2/src/{transports → libgit2/transports}/smart.c +142 -165
  430. data/vendor/libgit2/src/{transports → libgit2/transports}/smart.h +56 -36
  431. data/vendor/libgit2/src/{transports → libgit2/transports}/smart_pkt.c +307 -74
  432. data/vendor/libgit2/src/{transports → libgit2/transports}/smart_protocol.c +297 -97
  433. data/vendor/libgit2/src/libgit2/transports/ssh.c +85 -0
  434. data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +347 -0
  435. data/vendor/libgit2/src/libgit2/transports/ssh_exec.h +26 -0
  436. data/vendor/libgit2/src/{transports/ssh.c → libgit2/transports/ssh_libssh2.c} +414 -268
  437. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
  438. data/vendor/libgit2/src/{transports → libgit2/transports}/winhttp.c +101 -75
  439. data/vendor/libgit2/src/{tree-cache.c → libgit2/tree-cache.c} +30 -20
  440. data/vendor/libgit2/src/{tree-cache.h → libgit2/tree-cache.h} +7 -5
  441. data/vendor/libgit2/src/{tree.c → libgit2/tree.c} +128 -110
  442. data/vendor/libgit2/src/{tree.h → libgit2/tree.h} +7 -6
  443. data/vendor/libgit2/src/{worktree.c → libgit2/worktree.c} +160 -121
  444. data/vendor/libgit2/src/{worktree.h → libgit2/worktree.h} +1 -1
  445. data/vendor/libgit2/src/util/CMakeLists.txt +77 -0
  446. data/vendor/libgit2/src/{alloc.c → util/alloc.c} +69 -7
  447. data/vendor/libgit2/src/util/alloc.h +65 -0
  448. data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
  449. data/vendor/libgit2/src/util/allocators/debugalloc.h +17 -0
  450. data/vendor/libgit2/src/util/allocators/failalloc.c +32 -0
  451. data/vendor/libgit2/src/util/allocators/failalloc.h +17 -0
  452. data/vendor/libgit2/src/util/allocators/stdalloc.c +37 -0
  453. data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.h +1 -1
  454. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +50 -0
  455. data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.h +1 -1
  456. data/vendor/libgit2/src/{array.h → util/array.h} +25 -19
  457. data/vendor/libgit2/src/{assert_safe.h → util/assert_safe.h} +16 -0
  458. data/vendor/libgit2/src/{cc-compat.h → util/cc-compat.h} +5 -1
  459. data/vendor/libgit2/src/util/ctype_compat.h +70 -0
  460. data/vendor/libgit2/src/{date.c → util/date.c} +35 -33
  461. data/vendor/libgit2/src/util/date.h +45 -0
  462. data/vendor/libgit2/src/util/errors.c +401 -0
  463. data/vendor/libgit2/src/{errors.h → util/errors.h} +22 -19
  464. data/vendor/libgit2/src/{filebuf.c → util/filebuf.c} +35 -30
  465. data/vendor/libgit2/src/{filebuf.h → util/filebuf.h} +21 -8
  466. data/vendor/libgit2/src/{path.c → util/fs_path.c} +591 -615
  467. data/vendor/libgit2/src/{path.h → util/fs_path.h} +257 -181
  468. data/vendor/libgit2/src/{futils.c → util/futils.c} +144 -95
  469. data/vendor/libgit2/src/{futils.h → util/futils.h} +40 -18
  470. data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +33 -2
  471. data/vendor/libgit2/src/{common.h → util/git2_util.h} +26 -59
  472. data/vendor/libgit2/src/util/hash/builtin.c +53 -0
  473. data/vendor/libgit2/src/{hash/sha1/openssl.h → util/hash/builtin.h} +6 -6
  474. data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.c +3 -3
  475. data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.h +3 -3
  476. data/vendor/libgit2/src/util/hash/common_crypto.c +112 -0
  477. data/vendor/libgit2/src/{hash/sha1 → util/hash}/common_crypto.h +11 -3
  478. data/vendor/libgit2/src/util/hash/mbedtls.c +92 -0
  479. data/vendor/libgit2/src/{hash/sha1 → util/hash}/mbedtls.h +14 -4
  480. data/vendor/libgit2/src/util/hash/openssl.c +347 -0
  481. data/vendor/libgit2/src/util/hash/openssl.h +61 -0
  482. data/vendor/libgit2/src/util/hash/rfc6234/sha.h +243 -0
  483. data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +601 -0
  484. data/vendor/libgit2/src/util/hash/sha.h +73 -0
  485. data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.c +1 -1
  486. data/vendor/libgit2/src/util/hash/win32.c +549 -0
  487. data/vendor/libgit2/src/util/hash/win32.h +60 -0
  488. data/vendor/libgit2/src/util/hash.c +158 -0
  489. data/vendor/libgit2/src/util/hash.h +61 -0
  490. data/vendor/libgit2/src/util/hashmap.h +424 -0
  491. data/vendor/libgit2/src/util/hashmap_str.h +43 -0
  492. data/vendor/libgit2/src/{integer.h → util/integer.h} +3 -1
  493. data/vendor/libgit2/src/{map.h → util/map.h} +1 -1
  494. data/vendor/libgit2/src/util/net.c +1160 -0
  495. data/vendor/libgit2/src/{net.h → util/net.h} +45 -4
  496. data/vendor/libgit2/src/{pool.c → util/pool.c} +1 -1
  497. data/vendor/libgit2/src/{pool.h → util/pool.h} +6 -1
  498. data/vendor/libgit2/src/{posix.c → util/posix.c} +57 -3
  499. data/vendor/libgit2/src/{posix.h → util/posix.h} +26 -1
  500. data/vendor/libgit2/src/{pqueue.h → util/pqueue.h} +3 -3
  501. data/vendor/libgit2/src/util/process.h +222 -0
  502. data/vendor/libgit2/src/util/rand.c +230 -0
  503. data/vendor/libgit2/src/util/rand.h +37 -0
  504. data/vendor/libgit2/src/{regexp.c → util/regexp.c} +5 -5
  505. data/vendor/libgit2/src/{regexp.h → util/regexp.h} +1 -1
  506. data/vendor/libgit2/src/{runtime.c → util/runtime.c} +1 -1
  507. data/vendor/libgit2/src/{runtime.h → util/runtime.h} +1 -1
  508. data/vendor/libgit2/src/{sortedcache.c → util/sortedcache.c} +15 -14
  509. data/vendor/libgit2/src/{sortedcache.h → util/sortedcache.h} +5 -5
  510. data/vendor/libgit2/src/util/staticstr.h +66 -0
  511. data/vendor/libgit2/src/{buffer.c → util/str.c} +159 -153
  512. data/vendor/libgit2/src/util/str.h +357 -0
  513. data/vendor/libgit2/src/util/strlist.c +108 -0
  514. data/vendor/libgit2/src/util/strlist.h +36 -0
  515. data/vendor/libgit2/src/{thread.c → util/thread.c} +1 -1
  516. data/vendor/libgit2/src/{thread.h → util/thread.h} +23 -22
  517. data/vendor/libgit2/src/{tsort.c → util/tsort.c} +1 -1
  518. data/vendor/libgit2/src/{unix → util/unix}/map.c +1 -3
  519. data/vendor/libgit2/src/{unix → util/unix}/posix.h +1 -6
  520. data/vendor/libgit2/src/util/unix/process.c +629 -0
  521. data/vendor/libgit2/src/{unix → util/unix}/realpath.c +24 -8
  522. data/vendor/libgit2/src/{utf8.c → util/utf8.c} +1 -1
  523. data/vendor/libgit2/src/{utf8.h → util/utf8.h} +1 -1
  524. data/vendor/libgit2/src/{util.c → util/util.c} +24 -19
  525. data/vendor/libgit2/src/{util.h → util/util.h} +30 -81
  526. data/vendor/libgit2/src/{varint.h → util/varint.h} +1 -1
  527. data/vendor/libgit2/src/{vector.c → util/vector.c} +3 -3
  528. data/vendor/libgit2/src/{vector.h → util/vector.h} +4 -4
  529. data/vendor/libgit2/src/{wildmatch.h → util/wildmatch.h} +1 -1
  530. data/vendor/libgit2/src/{win32 → util/win32}/dir.h +1 -1
  531. data/vendor/libgit2/src/{win32 → util/win32}/error.c +1 -1
  532. data/vendor/libgit2/src/{win32 → util/win32}/error.h +1 -1
  533. data/vendor/libgit2/src/{win32 → util/win32}/map.c +1 -1
  534. data/vendor/libgit2/src/{win32 → util/win32}/path_w32.c +148 -17
  535. data/vendor/libgit2/src/{win32 → util/win32}/path_w32.h +3 -1
  536. data/vendor/libgit2/src/{win32 → util/win32}/posix.h +1 -2
  537. data/vendor/libgit2/src/{win32 → util/win32}/posix_w32.c +42 -35
  538. data/vendor/libgit2/src/util/win32/precompiled.c +1 -0
  539. data/vendor/libgit2/src/{win32 → util/win32}/precompiled.h +1 -1
  540. data/vendor/libgit2/src/util/win32/process.c +506 -0
  541. data/vendor/libgit2/src/{win32 → util/win32}/thread.h +1 -1
  542. data/vendor/libgit2/src/util/win32/utf-conv.c +144 -0
  543. data/vendor/libgit2/src/util/win32/utf-conv.h +127 -0
  544. data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.c +2 -3
  545. data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.h +3 -4
  546. data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.c +1 -1
  547. data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.h +1 -1
  548. data/vendor/libgit2/src/{win32 → util/win32}/w32_util.c +1 -1
  549. data/vendor/libgit2/src/{win32 → util/win32}/w32_util.h +1 -1
  550. data/vendor/libgit2/src/{zstream.c → util/zstream.c} +5 -5
  551. data/vendor/libgit2/src/{zstream.h → util/zstream.h} +5 -5
  552. metadata +431 -362
  553. data/vendor/libgit2/cmake/FindIconv.cmake +0 -45
  554. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -6
  555. data/vendor/libgit2/deps/http-parser/COPYING +0 -23
  556. data/vendor/libgit2/deps/http-parser/http_parser.c +0 -2182
  557. data/vendor/libgit2/deps/http-parser/http_parser.h +0 -305
  558. data/vendor/libgit2/deps/zlib/COPYING +0 -27
  559. data/vendor/libgit2/include/git2/sys/reflog.h +0 -21
  560. data/vendor/libgit2/src/alloc.h +0 -40
  561. data/vendor/libgit2/src/allocators/failalloc.c +0 -92
  562. data/vendor/libgit2/src/allocators/failalloc.h +0 -23
  563. data/vendor/libgit2/src/allocators/stdalloc.c +0 -150
  564. data/vendor/libgit2/src/allocators/win32_leakcheck.c +0 -118
  565. data/vendor/libgit2/src/buffer.h +0 -374
  566. data/vendor/libgit2/src/commit.h +0 -46
  567. data/vendor/libgit2/src/config_entries.c +0 -237
  568. data/vendor/libgit2/src/config_entries.h +0 -24
  569. data/vendor/libgit2/src/config_mem.c +0 -220
  570. data/vendor/libgit2/src/errors.c +0 -238
  571. data/vendor/libgit2/src/hash/sha1/common_crypto.c +0 -57
  572. data/vendor/libgit2/src/hash/sha1/generic.c +0 -300
  573. data/vendor/libgit2/src/hash/sha1/generic.h +0 -19
  574. data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
  575. data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
  576. data/vendor/libgit2/src/hash/sha1/win32.c +0 -333
  577. data/vendor/libgit2/src/hash/sha1/win32.h +0 -128
  578. data/vendor/libgit2/src/hash/sha1.h +0 -38
  579. data/vendor/libgit2/src/hash.c +0 -110
  580. data/vendor/libgit2/src/hash.h +0 -46
  581. data/vendor/libgit2/src/idxmap.c +0 -157
  582. data/vendor/libgit2/src/idxmap.h +0 -177
  583. data/vendor/libgit2/src/khash.h +0 -615
  584. data/vendor/libgit2/src/libgit2.h +0 -15
  585. data/vendor/libgit2/src/message.h +0 -17
  586. data/vendor/libgit2/src/net.c +0 -540
  587. data/vendor/libgit2/src/netops.c +0 -125
  588. data/vendor/libgit2/src/netops.h +0 -68
  589. data/vendor/libgit2/src/offmap.c +0 -101
  590. data/vendor/libgit2/src/offmap.h +0 -133
  591. data/vendor/libgit2/src/oid.h +0 -51
  592. data/vendor/libgit2/src/oidarray.c +0 -43
  593. data/vendor/libgit2/src/oidmap.c +0 -107
  594. data/vendor/libgit2/src/oidmap.h +0 -128
  595. data/vendor/libgit2/src/remote.h +0 -55
  596. data/vendor/libgit2/src/streams/socket.c +0 -239
  597. data/vendor/libgit2/src/strmap.c +0 -100
  598. data/vendor/libgit2/src/strmap.h +0 -131
  599. data/vendor/libgit2/src/sysdir.c +0 -347
  600. data/vendor/libgit2/src/threadstate.c +0 -84
  601. data/vendor/libgit2/src/threadstate.h +0 -24
  602. data/vendor/libgit2/src/win32/findfile.c +0 -230
  603. data/vendor/libgit2/src/win32/findfile.h +0 -19
  604. data/vendor/libgit2/src/win32/utf-conv.c +0 -146
  605. data/vendor/libgit2/src/win32/utf-conv.h +0 -60
  606. /data/vendor/libgit2/{src → deps}/xdiff/xemit.h +0 -0
  607. /data/vendor/libgit2/{src → deps}/xdiff/xprepare.h +0 -0
  608. /data/vendor/libgit2/{src → deps}/xdiff/xtypes.h +0 -0
  609. /data/vendor/libgit2/src/{win32 → cli/win32}/precompiled.c +0 -0
  610. /data/vendor/libgit2/src/{attr.h → libgit2/attr.h} +0 -0
  611. /data/vendor/libgit2/src/{blame_git.h → libgit2/blame_git.h} +0 -0
  612. /data/vendor/libgit2/src/{config_parse.h → libgit2/config_parse.h} +0 -0
  613. /data/vendor/libgit2/src/{delta.c → libgit2/delta.c} +0 -0
  614. /data/vendor/libgit2/src/{delta.h → libgit2/delta.h} +0 -0
  615. /data/vendor/libgit2/src/{diff_file.h → libgit2/diff_file.h} +0 -0
  616. /data/vendor/libgit2/src/{diff_parse.h → libgit2/diff_parse.h} +0 -0
  617. /data/vendor/libgit2/src/{diff_tform.h → libgit2/diff_tform.h} +0 -0
  618. /data/vendor/libgit2/src/{fetchhead.h → libgit2/fetchhead.h} +0 -0
  619. /data/vendor/libgit2/src/{hashsig.c → libgit2/hashsig.c} +0 -0
  620. /data/vendor/libgit2/src/{indexer.h → libgit2/indexer.h} +0 -0
  621. /data/vendor/libgit2/src/{mailmap.h → libgit2/mailmap.h} +0 -0
  622. /data/vendor/libgit2/src/{merge_driver.h → libgit2/merge_driver.h} +0 -0
  623. /data/vendor/libgit2/src/{notes.h → libgit2/notes.h} +0 -0
  624. /data/vendor/libgit2/src/{object_api.c → libgit2/object_api.c} +0 -0
  625. /data/vendor/libgit2/src/{patch_parse.h → libgit2/patch_parse.h} +0 -0
  626. /data/vendor/libgit2/src/{refdb.c → libgit2/refdb.c} +0 -0
  627. /data/vendor/libgit2/src/{refdb.h → libgit2/refdb.h} +0 -0
  628. /data/vendor/libgit2/src/{repo_template.h → libgit2/repo_template.h} +0 -0
  629. /data/vendor/libgit2/src/{status.h → libgit2/status.h} +0 -0
  630. /data/vendor/libgit2/src/{stream.h → libgit2/stream.h} +0 -0
  631. /data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.h +0 -0
  632. /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.c +0 -0
  633. /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.h +0 -0
  634. /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.c +0 -0
  635. /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.h +0 -0
  636. /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.h +0 -0
  637. /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.h +0 -0
  638. /data/vendor/libgit2/src/{transports → libgit2/transports}/credential_helpers.c +0 -0
  639. /data/vendor/libgit2/src/{userdiff.h → libgit2/userdiff.h} +0 -0
  640. /data/vendor/libgit2/src/{bitvec.h → util/bitvec.h} +0 -0
  641. /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.h +0 -0
  642. /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.c +0 -0
  643. /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.h +0 -0
  644. /data/vendor/libgit2/src/{pqueue.c → util/pqueue.c} +0 -0
  645. /data/vendor/libgit2/src/{strnlen.h → util/strnlen.h} +0 -0
  646. /data/vendor/libgit2/src/{unix → util/unix}/pthread.h +0 -0
  647. /data/vendor/libgit2/src/{varint.c → util/varint.c} +0 -0
  648. /data/vendor/libgit2/src/{wildmatch.c → util/wildmatch.c} +0 -0
  649. /data/vendor/libgit2/src/{win32 → util/win32}/dir.c +0 -0
  650. /data/vendor/libgit2/src/{win32 → util/win32}/mingw-compat.h +0 -0
  651. /data/vendor/libgit2/src/{win32 → util/win32}/msvc-compat.h +0 -0
  652. /data/vendor/libgit2/src/{win32 → util/win32}/reparse.h +0 -0
  653. /data/vendor/libgit2/src/{win32 → util/win32}/thread.c +0 -0
  654. /data/vendor/libgit2/src/{win32 → util/win32}/version.h +0 -0
  655. /data/vendor/libgit2/src/{win32 → util/win32}/w32_common.h +0 -0
  656. /data/vendor/libgit2/src/{win32 → util/win32}/win32-compat.h +0 -0
@@ -17,9 +17,10 @@
17
17
  #include "pathspec.h"
18
18
  #include "ignore.h"
19
19
  #include "blob.h"
20
- #include "idxmap.h"
21
20
  #include "diff.h"
22
21
  #include "varint.h"
22
+ #include "path.h"
23
+ #include "index_map.h"
23
24
 
24
25
  #include "git2/odb.h"
25
26
  #include "git2/oid.h"
@@ -31,9 +32,6 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
31
32
  unsigned int flags,
32
33
  git_index_matched_path_cb cb, void *payload);
33
34
 
34
- #define minimal_entry_size (offsetof(struct entry_short, path))
35
-
36
- static const size_t INDEX_FOOTER_SIZE = GIT_OID_RAWSZ;
37
35
  static const size_t INDEX_HEADER_SIZE = 12;
38
36
 
39
37
  static const unsigned int INDEX_VERSION_NUMBER_DEFAULT = 2;
@@ -65,7 +63,7 @@ struct entry_time {
65
63
  uint32_t nanoseconds;
66
64
  };
67
65
 
68
- struct entry_short {
66
+ struct entry_common {
69
67
  struct entry_time ctime;
70
68
  struct entry_time mtime;
71
69
  uint32_t dev;
@@ -74,25 +72,35 @@ struct entry_short {
74
72
  uint32_t uid;
75
73
  uint32_t gid;
76
74
  uint32_t file_size;
77
- git_oid oid;
78
- uint16_t flags;
79
- char path[1]; /* arbitrary length */
80
75
  };
81
76
 
82
- struct entry_long {
83
- struct entry_time ctime;
84
- struct entry_time mtime;
85
- uint32_t dev;
86
- uint32_t ino;
87
- uint32_t mode;
88
- uint32_t uid;
89
- uint32_t gid;
90
- uint32_t file_size;
91
- git_oid oid;
92
- uint16_t flags;
93
- uint16_t flags_extended;
94
- char path[1]; /* arbitrary length */
95
- };
77
+ #define entry_short(oid_size) \
78
+ struct { \
79
+ struct entry_common common; \
80
+ unsigned char oid[oid_size]; \
81
+ uint16_t flags; \
82
+ char path[1]; /* arbitrary length */ \
83
+ }
84
+
85
+ #define entry_long(oid_size) \
86
+ struct { \
87
+ struct entry_common common; \
88
+ unsigned char oid[oid_size]; \
89
+ uint16_t flags; \
90
+ uint16_t flags_extended; \
91
+ char path[1]; /* arbitrary length */ \
92
+ }
93
+
94
+ typedef entry_short(GIT_OID_SHA1_SIZE) index_entry_short_sha1;
95
+ typedef entry_long(GIT_OID_SHA1_SIZE) index_entry_long_sha1;
96
+
97
+ #ifdef GIT_EXPERIMENTAL_SHA256
98
+ typedef entry_short(GIT_OID_SHA256_SIZE) index_entry_short_sha256;
99
+ typedef entry_long(GIT_OID_SHA256_SIZE) index_entry_long_sha256;
100
+ #endif
101
+
102
+ #undef entry_short
103
+ #undef entry_long
96
104
 
97
105
  struct entry_srch_key {
98
106
  const char *path;
@@ -115,40 +123,16 @@ struct reuc_entry_internal {
115
123
  bool git_index__enforce_unsaved_safety = false;
116
124
 
117
125
  /* local declarations */
118
- static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size);
126
+ static int read_extension(size_t *read_len, git_index *index, size_t checksum_size, const char *buffer, size_t buffer_size);
119
127
  static int read_header(struct index_header *dest, const void *buffer);
120
128
 
121
129
  static int parse_index(git_index *index, const char *buffer, size_t buffer_size);
122
130
  static bool is_index_extended(git_index *index);
123
- static int write_index(git_oid *checksum, git_index *index, git_filebuf *file);
131
+ static int write_index(unsigned char checksum[GIT_HASH_MAX_SIZE], size_t *checksum_size, git_index *index, git_filebuf *file);
124
132
 
125
133
  static void index_entry_free(git_index_entry *entry);
126
134
  static void index_entry_reuc_free(git_index_reuc_entry *reuc);
127
135
 
128
- GIT_INLINE(int) index_map_set(git_idxmap *map, git_index_entry *e, bool ignore_case)
129
- {
130
- if (ignore_case)
131
- return git_idxmap_icase_set((git_idxmap_icase *) map, e, e);
132
- else
133
- return git_idxmap_set(map, e, e);
134
- }
135
-
136
- GIT_INLINE(int) index_map_delete(git_idxmap *map, git_index_entry *e, bool ignore_case)
137
- {
138
- if (ignore_case)
139
- return git_idxmap_icase_delete((git_idxmap_icase *) map, e);
140
- else
141
- return git_idxmap_delete(map, e);
142
- }
143
-
144
- GIT_INLINE(int) index_map_resize(git_idxmap *map, size_t count, bool ignore_case)
145
- {
146
- if (ignore_case)
147
- return git_idxmap_icase_resize((git_idxmap_icase *) map, count);
148
- else
149
- return git_idxmap_resize(map, count);
150
- }
151
-
152
136
  int git_index_entry_srch(const void *key, const void *array_member)
153
137
  {
154
138
  const struct entry_srch_key *srch_key = key;
@@ -380,6 +364,7 @@ GIT_INLINE(int) index_find(
380
364
  void git_index__set_ignore_case(git_index *index, bool ignore_case)
381
365
  {
382
366
  index->ignore_case = ignore_case;
367
+ index->entries_map.ignore_case = ignore_case;
383
368
 
384
369
  if (ignore_case) {
385
370
  index->entries_cmp_path = git__strcasecmp_cb;
@@ -401,7 +386,10 @@ void git_index__set_ignore_case(git_index *index, bool ignore_case)
401
386
  git_vector_sort(&index->reuc);
402
387
  }
403
388
 
404
- int git_index_open(git_index **index_out, const char *index_path)
389
+ int git_index__open(
390
+ git_index **index_out,
391
+ const char *index_path,
392
+ git_oid_t oid_type)
405
393
  {
406
394
  git_index *index;
407
395
  int error = -1;
@@ -411,6 +399,9 @@ int git_index_open(git_index **index_out, const char *index_path)
411
399
  index = git__calloc(1, sizeof(git_index));
412
400
  GIT_ERROR_CHECK_ALLOC(index);
413
401
 
402
+ GIT_ASSERT_ARG(git_oid_type_is_valid(oid_type));
403
+ index->oid_type = oid_type;
404
+
414
405
  if (git_pool_init(&index->tree_pool, 1) < 0)
415
406
  goto fail;
416
407
 
@@ -420,12 +411,11 @@ int git_index_open(git_index **index_out, const char *index_path)
420
411
  goto fail;
421
412
 
422
413
  /* Check if index file is stored on disk already */
423
- if (git_path_exists(index->index_file_path) == true)
414
+ if (git_fs_path_exists(index->index_file_path) == true)
424
415
  index->on_disk = 1;
425
416
  }
426
417
 
427
418
  if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 ||
428
- git_idxmap_new(&index->entries_map) < 0 ||
429
419
  git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
430
420
  git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
431
421
  git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
@@ -451,10 +441,39 @@ fail:
451
441
  return error;
452
442
  }
453
443
 
444
+ #ifdef GIT_EXPERIMENTAL_SHA256
445
+ int git_index_open(
446
+ git_index **index_out,
447
+ const char *index_path,
448
+ const git_index_options *opts)
449
+ {
450
+ return git_index__open(index_out, index_path,
451
+ opts && opts->oid_type ? opts->oid_type : GIT_OID_DEFAULT);
452
+ }
453
+ #else
454
+ int git_index_open(git_index **index_out, const char *index_path)
455
+ {
456
+ return git_index__open(index_out, index_path, GIT_OID_SHA1);
457
+ }
458
+ #endif
459
+
460
+ int git_index__new(git_index **out, git_oid_t oid_type)
461
+ {
462
+ return git_index__open(out, NULL, oid_type);
463
+ }
464
+
465
+ #ifdef GIT_EXPERIMENTAL_SHA256
466
+ int git_index_new(git_index **out, const git_index_options *opts)
467
+ {
468
+ return git_index__new(out,
469
+ opts && opts->oid_type ? opts->oid_type : GIT_OID_DEFAULT);
470
+ }
471
+ #else
454
472
  int git_index_new(git_index **out)
455
473
  {
456
- return git_index_open(out, NULL);
474
+ return git_index__new(out, GIT_OID_SHA1);
457
475
  }
476
+ #endif
458
477
 
459
478
  static void index_free(git_index *index)
460
479
  {
@@ -465,11 +484,11 @@ static void index_free(git_index *index)
465
484
  return;
466
485
 
467
486
  git_index_clear(index);
468
- git_idxmap_free(index->entries_map);
469
- git_vector_free(&index->entries);
470
- git_vector_free(&index->names);
471
- git_vector_free(&index->reuc);
472
- git_vector_free(&index->deleted);
487
+ git_index_entrymap_dispose(&index->entries_map);
488
+ git_vector_dispose(&index->entries);
489
+ git_vector_dispose(&index->names);
490
+ git_vector_dispose(&index->reuc);
491
+ git_vector_dispose(&index->deleted);
473
492
 
474
493
  git__free(index->index_file_path);
475
494
 
@@ -510,7 +529,7 @@ static int index_remove_entry(git_index *index, size_t pos)
510
529
 
511
530
  if (entry != NULL) {
512
531
  git_tree_cache_invalidate_path(index->tree, entry->path);
513
- index_map_delete(index->entries_map, entry, index->ignore_case);
532
+ git_index_entrymap_remove(&index->entries_map, entry);
514
533
  }
515
534
 
516
535
  error = git_vector_remove(&index->entries, pos);
@@ -538,7 +557,8 @@ int git_index_clear(git_index *index)
538
557
  index->tree = NULL;
539
558
  git_pool_clear(&index->tree_pool);
540
559
 
541
- git_idxmap_clear(index->entries_map);
560
+ git_index_entrymap_clear(&index->entries_map);
561
+
542
562
  while (!error && index->entries.length > 0)
543
563
  error = index_remove_entry(index, index->entries.length - 1);
544
564
 
@@ -606,10 +626,12 @@ int git_index_caps(const git_index *index)
606
626
  (index->no_symlinks ? GIT_INDEX_CAPABILITY_NO_SYMLINKS : 0));
607
627
  }
608
628
 
629
+ #ifndef GIT_DEPRECATE_HARD
609
630
  const git_oid *git_index_checksum(git_index *index)
610
631
  {
611
- return &index->checksum;
632
+ return (git_oid *)index->checksum;
612
633
  }
634
+ #endif
613
635
 
614
636
  /**
615
637
  * Returns 1 for changed, 0 for not changed and <0 for errors
@@ -618,37 +640,38 @@ static int compare_checksum(git_index *index)
618
640
  {
619
641
  int fd;
620
642
  ssize_t bytes_read;
621
- git_oid checksum = {{ 0 }};
643
+ unsigned char checksum[GIT_HASH_MAX_SIZE];
644
+ size_t checksum_size = git_oid_size(index->oid_type);
622
645
 
623
646
  if ((fd = p_open(index->index_file_path, O_RDONLY)) < 0)
624
647
  return fd;
625
648
 
626
- if (p_lseek(fd, -20, SEEK_END) < 0) {
649
+ if (p_lseek(fd, (0 - (ssize_t)checksum_size), SEEK_END) < 0) {
627
650
  p_close(fd);
628
651
  git_error_set(GIT_ERROR_OS, "failed to seek to end of file");
629
652
  return -1;
630
653
  }
631
654
 
632
- bytes_read = p_read(fd, &checksum, GIT_OID_RAWSZ);
655
+ bytes_read = p_read(fd, checksum, checksum_size);
633
656
  p_close(fd);
634
657
 
635
- if (bytes_read < 0)
658
+ if (bytes_read < (ssize_t)checksum_size)
636
659
  return -1;
637
660
 
638
- return !!git_oid_cmp(&checksum, &index->checksum);
661
+ return !!memcmp(checksum, index->checksum, checksum_size);
639
662
  }
640
663
 
641
664
  int git_index_read(git_index *index, int force)
642
665
  {
643
666
  int error = 0, updated;
644
- git_buf buffer = GIT_BUF_INIT;
667
+ git_str buffer = GIT_STR_INIT;
645
668
  git_futils_filestamp stamp = index->stamp;
646
669
 
647
670
  if (!index->index_file_path)
648
671
  return create_index_error(-1,
649
672
  "failed to read index: The index is in-memory only");
650
673
 
651
- index->on_disk = git_path_exists(index->index_file_path);
674
+ index->on_disk = git_fs_path_exists(index->index_file_path);
652
675
 
653
676
  if (!index->on_disk) {
654
677
  if (force && (error = git_index_clear(index)) < 0)
@@ -687,7 +710,7 @@ int git_index_read(git_index *index, int force)
687
710
  index->dirty = 0;
688
711
  }
689
712
 
690
- git_buf_dispose(&buffer);
713
+ git_str_dispose(&buffer);
691
714
  return error;
692
715
  }
693
716
 
@@ -702,16 +725,6 @@ int git_index_read_safely(git_index *index)
702
725
  return git_index_read(index, false);
703
726
  }
704
727
 
705
- int git_index__changed_relative_to(
706
- git_index *index, const git_oid *checksum)
707
- {
708
- /* attempt to update index (ignoring errors) */
709
- if (git_index_read(index, false) < 0)
710
- git_error_clear();
711
-
712
- return !!git_oid_cmp(&index->checksum, checksum);
713
- }
714
-
715
728
  static bool is_racy_entry(git_index *index, const git_index_entry *entry)
716
729
  {
717
730
  /* Git special-cases submodules in the check */
@@ -756,8 +769,10 @@ static int truncate_racily_clean(git_index *index)
756
769
  diff_opts.pathspec.count = paths.length;
757
770
  diff_opts.pathspec.strings = (char **)paths.contents;
758
771
 
759
- if ((error = git_diff_index_to_workdir(&diff, INDEX_OWNER(index), index, &diff_opts)) < 0)
772
+ if ((error = git_diff_index_to_workdir(&diff, INDEX_OWNER(index), index, &diff_opts)) < 0) {
773
+ git_vector_dispose(&paths);
760
774
  return error;
775
+ }
761
776
 
762
777
  git_vector_foreach(&diff->deltas, i, delta) {
763
778
  entry = (git_index_entry *)git_index_get_bypath(index, delta->old_file.path, 0);
@@ -773,7 +788,7 @@ static int truncate_racily_clean(git_index *index)
773
788
 
774
789
  done:
775
790
  git_diff_free(diff);
776
- git_vector_free(&paths);
791
+ git_vector_dispose(&paths);
777
792
  return 0;
778
793
  }
779
794
 
@@ -874,14 +889,9 @@ const git_index_entry *git_index_get_bypath(
874
889
  key.path = path;
875
890
  GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
876
891
 
877
- if (index->ignore_case)
878
- value = git_idxmap_icase_get((git_idxmap_icase *) index->entries_map, &key);
879
- else
880
- value = git_idxmap_get(index->entries_map, &key);
881
-
882
- if (!value) {
883
- git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
884
- return NULL;
892
+ if (git_index_entrymap_get(&value, &index->entries_map, &key) != 0) {
893
+ git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
894
+ return NULL;
885
895
  }
886
896
 
887
897
  return value;
@@ -944,7 +954,7 @@ static int index_entry_create(
944
954
  if (st)
945
955
  mode = st->st_mode;
946
956
 
947
- if (!git_path_validate(repo, path, mode, path_valid_flags)) {
957
+ if (!git_path_is_valid(repo, path, mode, path_valid_flags)) {
948
958
  git_error_set(GIT_ERROR_INDEX, "invalid path: '%s'", path);
949
959
  return -1;
950
960
  }
@@ -969,7 +979,7 @@ static int index_entry_init(
969
979
  {
970
980
  int error = 0;
971
981
  git_index_entry *entry = NULL;
972
- git_buf path = GIT_BUF_INIT;
982
+ git_str path = GIT_STR_INIT;
973
983
  struct stat st;
974
984
  git_oid oid;
975
985
  git_repository *repo;
@@ -991,8 +1001,8 @@ static int index_entry_init(
991
1001
  if (git_repository_workdir_path(&path, repo, rel_path) < 0)
992
1002
  return -1;
993
1003
 
994
- error = git_path_lstat(path.ptr, &st);
995
- git_buf_dispose(&path);
1004
+ error = git_fs_path_lstat(path.ptr, &st);
1005
+ git_str_dispose(&path);
996
1006
 
997
1007
  if (error < 0)
998
1008
  return error;
@@ -1155,10 +1165,13 @@ static int has_dir_name(git_index *index,
1155
1165
  size_t len, pos;
1156
1166
 
1157
1167
  for (;;) {
1158
- if (*--slash == '/')
1159
- break;
1168
+ slash--;
1169
+
1160
1170
  if (slash <= entry->path)
1161
1171
  return 0;
1172
+
1173
+ if (*slash == '/')
1174
+ break;
1162
1175
  }
1163
1176
  len = slash - name;
1164
1177
 
@@ -1420,7 +1433,7 @@ static int index_insert(
1420
1433
  * check for dups, this is actually cheaper in the long run.)
1421
1434
  */
1422
1435
  if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0 ||
1423
- (error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1436
+ (error = git_index_entrymap_put(&index->entries_map, entry)) < 0)
1424
1437
  goto out;
1425
1438
  }
1426
1439
 
@@ -1525,7 +1538,7 @@ int git_index_add_from_buffer(
1525
1538
  static int add_repo_as_submodule(git_index_entry **out, git_index *index, const char *path)
1526
1539
  {
1527
1540
  git_repository *sub;
1528
- git_buf abspath = GIT_BUF_INIT;
1541
+ git_str abspath = GIT_STR_INIT;
1529
1542
  git_repository *repo = INDEX_OWNER(index);
1530
1543
  git_reference *head;
1531
1544
  git_index_entry *entry;
@@ -1556,7 +1569,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
1556
1569
 
1557
1570
  git_reference_free(head);
1558
1571
  git_repository_free(sub);
1559
- git_buf_dispose(&abspath);
1572
+ git_str_dispose(&abspath);
1560
1573
 
1561
1574
  *out = entry;
1562
1575
  return 0;
@@ -1579,15 +1592,17 @@ int git_index_add_bypath(git_index *index, const char *path)
1579
1592
 
1580
1593
  if (ret == GIT_EDIRECTORY) {
1581
1594
  git_submodule *sm;
1582
- git_error_state err;
1595
+ git_error *last_error;
1583
1596
 
1584
- git_error_state_capture(&err, ret);
1597
+ git_error_save(&last_error);
1585
1598
 
1586
1599
  ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path);
1587
- if (ret == GIT_ENOTFOUND)
1588
- return git_error_state_restore(&err);
1600
+ if (ret == GIT_ENOTFOUND) {
1601
+ git_error_restore(last_error);
1602
+ return GIT_EDIRECTORY;
1603
+ }
1589
1604
 
1590
- git_error_state_free(&err);
1605
+ git_error_free(last_error);
1591
1606
 
1592
1607
  /*
1593
1608
  * EEXISTS means that there is a repository at that path, but it's not known
@@ -1647,8 +1662,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
1647
1662
  return 0;
1648
1663
 
1649
1664
  if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
1650
- index_map_resize(index->entries_map, (size_t)(source_entries->length * 1.3),
1651
- index->ignore_case) < 0)
1665
+ git_index_entrymap_resize(&index->entries_map, (size_t)(source_entries->length * 1.3)) < 0)
1652
1666
  return -1;
1653
1667
 
1654
1668
  git_vector_foreach(source_entries, i, source_entry) {
@@ -1661,10 +1675,8 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
1661
1675
  entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
1662
1676
  entry->mode = git_index__create_mode(entry->mode);
1663
1677
 
1664
- if ((error = git_vector_insert(&index->entries, entry)) < 0)
1665
- break;
1666
-
1667
- if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
1678
+ if ((error = git_vector_insert(&index->entries, entry)) < 0 ||
1679
+ (error = git_index_entrymap_put(&index->entries_map, entry)) < 0)
1668
1680
  break;
1669
1681
 
1670
1682
  index->dirty = 1;
@@ -1707,7 +1719,7 @@ int git_index_remove(git_index *index, const char *path, int stage)
1707
1719
  remove_key.path = path;
1708
1720
  GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
1709
1721
 
1710
- index_map_delete(index->entries_map, &remove_key, index->ignore_case);
1722
+ git_index_entrymap_remove(&index->entries_map, &remove_key);
1711
1723
 
1712
1724
  if (index_find(&position, index, path, 0, stage) < 0) {
1713
1725
  git_error_set(
@@ -1722,13 +1734,13 @@ int git_index_remove(git_index *index, const char *path, int stage)
1722
1734
 
1723
1735
  int git_index_remove_directory(git_index *index, const char *dir, int stage)
1724
1736
  {
1725
- git_buf pfx = GIT_BUF_INIT;
1737
+ git_str pfx = GIT_STR_INIT;
1726
1738
  int error = 0;
1727
1739
  size_t pos;
1728
1740
  git_index_entry *entry;
1729
1741
 
1730
- if (!(error = git_buf_sets(&pfx, dir)) &&
1731
- !(error = git_path_to_dir(&pfx)))
1742
+ if (!(error = git_str_sets(&pfx, dir)) &&
1743
+ !(error = git_fs_path_to_dir(&pfx)))
1732
1744
  index_find(&pos, index, pfx.ptr, pfx.size, GIT_INDEX_STAGE_ANY);
1733
1745
 
1734
1746
  while (!error) {
@@ -1746,7 +1758,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
1746
1758
  /* removed entry at 'pos' so we don't need to increment */
1747
1759
  }
1748
1760
 
1749
- git_buf_dispose(&pfx);
1761
+ git_str_dispose(&pfx);
1750
1762
 
1751
1763
  return error;
1752
1764
  }
@@ -2313,6 +2325,7 @@ static int index_error_invalid(const char *message)
2313
2325
  static int read_reuc(git_index *index, const char *buffer, size_t size)
2314
2326
  {
2315
2327
  const char *endptr;
2328
+ size_t oid_size = git_oid_size(index->oid_type);
2316
2329
  size_t len;
2317
2330
  int i;
2318
2331
 
@@ -2361,14 +2374,16 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
2361
2374
  for (i = 0; i < 3; i++) {
2362
2375
  if (!lost->mode[i])
2363
2376
  continue;
2364
- if (size < 20) {
2377
+ if (size < oid_size) {
2365
2378
  index_entry_reuc_free(lost);
2366
2379
  return index_error_invalid("reading reuc entry oid");
2367
2380
  }
2368
2381
 
2369
- git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer);
2370
- size -= 20;
2371
- buffer += 20;
2382
+ if (git_oid__fromraw(&lost->oid[i], (const unsigned char *) buffer, index->oid_type) < 0)
2383
+ return -1;
2384
+
2385
+ size -= oid_size;
2386
+ buffer += oid_size;
2372
2387
  }
2373
2388
 
2374
2389
  /* entry was read successfully - insert into reuc vector */
@@ -2438,70 +2453,157 @@ out_err:
2438
2453
  return 0;
2439
2454
  }
2440
2455
 
2441
- static size_t index_entry_size(size_t path_len, size_t varint_len, uint32_t flags)
2456
+ GIT_INLINE(size_t) index_entry_path_offset(
2457
+ git_oid_t oid_type,
2458
+ uint32_t flags)
2442
2459
  {
2460
+ if (oid_type == GIT_OID_SHA1)
2461
+ return (flags & GIT_INDEX_ENTRY_EXTENDED) ?
2462
+ offsetof(index_entry_long_sha1, path) :
2463
+ offsetof(index_entry_short_sha1, path);
2464
+
2465
+ #ifdef GIT_EXPERIMENTAL_SHA256
2466
+ else if (oid_type == GIT_OID_SHA256)
2467
+ return (flags & GIT_INDEX_ENTRY_EXTENDED) ?
2468
+ offsetof(index_entry_long_sha256, path) :
2469
+ offsetof(index_entry_short_sha256, path);
2470
+ #endif
2471
+
2472
+ git_error_set(GIT_ERROR_INTERNAL, "invalid oid type");
2473
+ return 0;
2474
+ }
2475
+
2476
+ GIT_INLINE(size_t) index_entry_flags_offset(git_oid_t oid_type)
2477
+ {
2478
+ if (oid_type == GIT_OID_SHA1)
2479
+ return offsetof(index_entry_long_sha1, flags_extended);
2480
+
2481
+ #ifdef GIT_EXPERIMENTAL_SHA256
2482
+ else if (oid_type == GIT_OID_SHA256)
2483
+ return offsetof(index_entry_long_sha256, flags_extended);
2484
+ #endif
2485
+
2486
+ git_error_set(GIT_ERROR_INTERNAL, "invalid oid type");
2487
+ return 0;
2488
+ }
2489
+
2490
+ static size_t index_entry_size(
2491
+ size_t path_len,
2492
+ size_t varint_len,
2493
+ git_oid_t oid_type,
2494
+ uint32_t flags)
2495
+ {
2496
+ size_t offset, size;
2497
+
2498
+ if (!(offset = index_entry_path_offset(oid_type, flags)))
2499
+ return 0;
2500
+
2443
2501
  if (varint_len) {
2444
- if (flags & GIT_INDEX_ENTRY_EXTENDED)
2445
- return offsetof(struct entry_long, path) + path_len + 1 + varint_len;
2446
- else
2447
- return offsetof(struct entry_short, path) + path_len + 1 + varint_len;
2502
+ if (GIT_ADD_SIZET_OVERFLOW(&size, offset, path_len) ||
2503
+ GIT_ADD_SIZET_OVERFLOW(&size, size, 1) ||
2504
+ GIT_ADD_SIZET_OVERFLOW(&size, size, varint_len))
2505
+ return 0;
2448
2506
  } else {
2449
- #define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7)
2450
- if (flags & GIT_INDEX_ENTRY_EXTENDED)
2451
- return entry_size(struct entry_long, path_len);
2452
- else
2453
- return entry_size(struct entry_short, path_len);
2454
- #undef entry_size
2507
+ if (GIT_ADD_SIZET_OVERFLOW(&size, offset, path_len) ||
2508
+ GIT_ADD_SIZET_OVERFLOW(&size, size, 8))
2509
+ return 0;
2510
+
2511
+ size &= ~7;
2455
2512
  }
2513
+
2514
+ return size;
2456
2515
  }
2457
2516
 
2458
2517
  static int read_entry(
2459
2518
  git_index_entry **out,
2460
2519
  size_t *out_size,
2461
2520
  git_index *index,
2521
+ size_t checksum_size,
2462
2522
  const void *buffer,
2463
2523
  size_t buffer_size,
2464
2524
  const char *last)
2465
2525
  {
2466
- size_t path_length, entry_size;
2526
+ size_t path_length, path_offset, entry_size;
2467
2527
  const char *path_ptr;
2468
- struct entry_short source;
2528
+ struct entry_common *source_common;
2529
+ index_entry_short_sha1 source_sha1;
2530
+ #ifdef GIT_EXPERIMENTAL_SHA256
2531
+ index_entry_short_sha256 source_sha256;
2532
+ #endif
2469
2533
  git_index_entry entry = {{0}};
2470
2534
  bool compressed = index->version >= INDEX_VERSION_NUMBER_COMP;
2471
2535
  char *tmp_path = NULL;
2472
2536
 
2473
- if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size)
2537
+ size_t minimal_entry_size = index_entry_path_offset(index->oid_type, 0);
2538
+
2539
+ if (checksum_size + minimal_entry_size > buffer_size)
2474
2540
  return -1;
2475
2541
 
2476
2542
  /* buffer is not guaranteed to be aligned */
2477
- memcpy(&source, buffer, sizeof(struct entry_short));
2478
-
2479
- entry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds);
2480
- entry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds);
2481
- entry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds);
2482
- entry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds);
2483
- entry.dev = ntohl(source.dev);
2484
- entry.ino = ntohl(source.ino);
2485
- entry.mode = ntohl(source.mode);
2486
- entry.uid = ntohl(source.uid);
2487
- entry.gid = ntohl(source.gid);
2488
- entry.file_size = ntohl(source.file_size);
2489
- git_oid_cpy(&entry.id, &source.oid);
2490
- entry.flags = ntohs(source.flags);
2543
+ switch (index->oid_type) {
2544
+ case GIT_OID_SHA1:
2545
+ source_common = &source_sha1.common;
2546
+ memcpy(&source_sha1, buffer, sizeof(source_sha1));
2547
+ break;
2548
+ #ifdef GIT_EXPERIMENTAL_SHA256
2549
+ case GIT_OID_SHA256:
2550
+ source_common = &source_sha256.common;
2551
+ memcpy(&source_sha256, buffer, sizeof(source_sha256));
2552
+ break;
2553
+ #endif
2554
+ default:
2555
+ GIT_ASSERT(!"invalid oid type");
2556
+ }
2557
+
2558
+ entry.ctime.seconds = (git_time_t)ntohl(source_common->ctime.seconds);
2559
+ entry.ctime.nanoseconds = ntohl(source_common->ctime.nanoseconds);
2560
+ entry.mtime.seconds = (git_time_t)ntohl(source_common->mtime.seconds);
2561
+ entry.mtime.nanoseconds = ntohl(source_common->mtime.nanoseconds);
2562
+ entry.dev = ntohl(source_common->dev);
2563
+ entry.ino = ntohl(source_common->ino);
2564
+ entry.mode = ntohl(source_common->mode);
2565
+ entry.uid = ntohl(source_common->uid);
2566
+ entry.gid = ntohl(source_common->gid);
2567
+ entry.file_size = ntohl(source_common->file_size);
2568
+
2569
+ switch (index->oid_type) {
2570
+ case GIT_OID_SHA1:
2571
+ if (git_oid__fromraw(&entry.id, source_sha1.oid,
2572
+ GIT_OID_SHA1) < 0)
2573
+ return -1;
2574
+ entry.flags = ntohs(source_sha1.flags);
2575
+ break;
2576
+ #ifdef GIT_EXPERIMENTAL_SHA256
2577
+ case GIT_OID_SHA256:
2578
+ if (git_oid__fromraw(&entry.id, source_sha256.oid,
2579
+ GIT_OID_SHA256) < 0)
2580
+ return -1;
2581
+ entry.flags = ntohs(source_sha256.flags);
2582
+ break;
2583
+ #endif
2584
+ default:
2585
+ GIT_ASSERT(!"invalid oid type");
2586
+ }
2587
+
2588
+ if (!(path_offset = index_entry_path_offset(index->oid_type, entry.flags)))
2589
+ return -1;
2590
+
2491
2591
 
2492
2592
  if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
2493
2593
  uint16_t flags_raw;
2494
2594
  size_t flags_offset;
2495
2595
 
2496
- flags_offset = offsetof(struct entry_long, flags_extended);
2497
- memcpy(&flags_raw, (const char *) buffer + flags_offset,
2498
- sizeof(flags_raw));
2596
+ if (!(flags_offset = index_entry_flags_offset(index->oid_type)))
2597
+ return -1;
2598
+
2599
+ memcpy(&flags_raw, (const char *)buffer + flags_offset, sizeof(flags_raw));
2499
2600
  flags_raw = ntohs(flags_raw);
2500
2601
 
2501
2602
  memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw));
2502
- path_ptr = (const char *) buffer + offsetof(struct entry_long, path);
2503
- } else
2504
- path_ptr = (const char *) buffer + offsetof(struct entry_short, path);
2603
+ path_ptr = (const char *)buffer + path_offset;
2604
+ } else {
2605
+ path_ptr = (const char *)buffer + path_offset;
2606
+ }
2505
2607
 
2506
2608
  if (!compressed) {
2507
2609
  path_length = entry.flags & GIT_INDEX_ENTRY_NAMEMASK;
@@ -2513,12 +2615,12 @@ static int read_entry(
2513
2615
 
2514
2616
  path_end = memchr(path_ptr, '\0', buffer_size);
2515
2617
  if (path_end == NULL)
2516
- return -1;
2618
+ return index_error_invalid("invalid path name");
2517
2619
 
2518
2620
  path_length = path_end - path_ptr;
2519
2621
  }
2520
2622
 
2521
- entry_size = index_entry_size(path_length, 0, entry.flags);
2623
+ entry_size = index_entry_size(path_length, 0, index->oid_type, entry.flags);
2522
2624
  entry.path = (char *)path_ptr;
2523
2625
  } else {
2524
2626
  size_t varint_len, last_len, prefix_len, suffix_len, path_len;
@@ -2544,15 +2646,18 @@ static int read_entry(
2544
2646
 
2545
2647
  memcpy(tmp_path, last, prefix_len);
2546
2648
  memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1);
2547
- entry_size = index_entry_size(suffix_len, varint_len, entry.flags);
2649
+
2650
+ entry_size = index_entry_size(suffix_len, varint_len, index->oid_type, entry.flags);
2548
2651
  entry.path = tmp_path;
2549
2652
  }
2550
2653
 
2551
2654
  if (entry_size == 0)
2552
2655
  return -1;
2553
2656
 
2554
- if (INDEX_FOOTER_SIZE + entry_size > buffer_size)
2657
+ if (checksum_size + entry_size > buffer_size) {
2658
+ git_error_set(GIT_ERROR_INTERNAL, "invalid index checksum");
2555
2659
  return -1;
2660
+ }
2556
2661
 
2557
2662
  if (index_entry_dup(out, index, &entry) < 0) {
2558
2663
  git__free(tmp_path);
@@ -2581,7 +2686,7 @@ static int read_header(struct index_header *dest, const void *buffer)
2581
2686
  return 0;
2582
2687
  }
2583
2688
 
2584
- static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size)
2689
+ static int read_extension(size_t *read_len, git_index *index, size_t checksum_size, const char *buffer, size_t buffer_size)
2585
2690
  {
2586
2691
  struct index_extension dest;
2587
2692
  size_t total_size;
@@ -2594,7 +2699,7 @@ static int read_extension(size_t *read_len, git_index *index, const char *buffer
2594
2699
 
2595
2700
  if (dest.extension_size > total_size ||
2596
2701
  buffer_size < total_size ||
2597
- buffer_size - total_size < INDEX_FOOTER_SIZE) {
2702
+ buffer_size - total_size < checksum_size) {
2598
2703
  index_error_invalid("extension is truncated");
2599
2704
  return -1;
2600
2705
  }
@@ -2603,7 +2708,7 @@ static int read_extension(size_t *read_len, git_index *index, const char *buffer
2603
2708
  if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
2604
2709
  /* tree cache */
2605
2710
  if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
2606
- if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0)
2711
+ if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, index->oid_type, &index->tree_pool) < 0)
2607
2712
  return -1;
2608
2713
  } else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
2609
2714
  if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
@@ -2631,7 +2736,9 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2631
2736
  int error = 0;
2632
2737
  unsigned int i;
2633
2738
  struct index_header header = { 0 };
2634
- git_oid checksum_calculated, checksum_expected;
2739
+ unsigned char checksum[GIT_HASH_MAX_SIZE];
2740
+ unsigned char zero_checksum[GIT_HASH_MAX_SIZE] = { 0 };
2741
+ size_t checksum_size = git_hash_size(git_oid_algorithm(index->oid_type));
2635
2742
  const char *last = NULL;
2636
2743
  const char *empty = "";
2637
2744
 
@@ -2643,12 +2750,15 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2643
2750
  buffer_size -= _increase;\
2644
2751
  }
2645
2752
 
2646
- if (buffer_size < INDEX_HEADER_SIZE + INDEX_FOOTER_SIZE)
2753
+ if (buffer_size < INDEX_HEADER_SIZE + checksum_size)
2647
2754
  return index_error_invalid("insufficient buffer space");
2648
2755
 
2649
- /* Precalculate the SHA1 of the files's contents -- we'll match it to
2650
- * the provided SHA1 in the footer */
2651
- git_hash_buf(&checksum_calculated, buffer, buffer_size - INDEX_FOOTER_SIZE);
2756
+ /*
2757
+ * Precalculate the hash of the files's contents -- we'll match
2758
+ * it to the provided checksum in the footer.
2759
+ */
2760
+ git_hash_buf(checksum, buffer, buffer_size - checksum_size,
2761
+ git_oid_algorithm(index->oid_type));
2652
2762
 
2653
2763
  /* Parse header */
2654
2764
  if ((error = read_header(&header, buffer)) < 0)
@@ -2662,15 +2772,15 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2662
2772
 
2663
2773
  GIT_ASSERT(!index->entries.length);
2664
2774
 
2665
- if ((error = index_map_resize(index->entries_map, header.entry_count, index->ignore_case)) < 0)
2775
+ if ((error = git_index_entrymap_resize(&index->entries_map, header.entry_count)) < 0)
2666
2776
  return error;
2667
2777
 
2668
2778
  /* Parse all the entries */
2669
- for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
2779
+ for (i = 0; i < header.entry_count && buffer_size > checksum_size; ++i) {
2670
2780
  git_index_entry *entry = NULL;
2671
2781
  size_t entry_size;
2672
2782
 
2673
- if ((error = read_entry(&entry, &entry_size, index, buffer, buffer_size, last)) < 0) {
2783
+ if ((error = read_entry(&entry, &entry_size, index, checksum_size, buffer, buffer_size, last)) < 0) {
2674
2784
  error = index_error_invalid("invalid entry");
2675
2785
  goto done;
2676
2786
  }
@@ -2680,7 +2790,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2680
2790
  goto done;
2681
2791
  }
2682
2792
 
2683
- if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0) {
2793
+ if ((error = git_index_entrymap_put(&index->entries_map, entry)) < 0) {
2684
2794
  index_entry_free(entry);
2685
2795
  goto done;
2686
2796
  }
@@ -2698,32 +2808,36 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
2698
2808
  }
2699
2809
 
2700
2810
  /* There's still space for some extensions! */
2701
- while (buffer_size > INDEX_FOOTER_SIZE) {
2811
+ while (buffer_size > checksum_size) {
2702
2812
  size_t extension_size;
2703
2813
 
2704
- if ((error = read_extension(&extension_size, index, buffer, buffer_size)) < 0) {
2814
+ if ((error = read_extension(&extension_size, index, checksum_size, buffer, buffer_size)) < 0) {
2705
2815
  goto done;
2706
2816
  }
2707
2817
 
2708
2818
  seek_forward(extension_size);
2709
2819
  }
2710
2820
 
2711
- if (buffer_size != INDEX_FOOTER_SIZE) {
2821
+ if (buffer_size != checksum_size) {
2712
2822
  error = index_error_invalid(
2713
2823
  "buffer size does not match index footer size");
2714
2824
  goto done;
2715
2825
  }
2716
2826
 
2717
- /* 160-bit SHA-1 over the content of the index file before this checksum. */
2718
- git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer);
2719
-
2720
- if (git_oid__cmp(&checksum_calculated, &checksum_expected) != 0) {
2827
+ /*
2828
+ * SHA-1 or SHA-256 (depending on the repository's object format)
2829
+ * over the content of the index file before this checksum.
2830
+ * Note: checksum may be 0 if the index was written by a client
2831
+ * where index.skipHash was set to true.
2832
+ */
2833
+ if (memcmp(zero_checksum, buffer, checksum_size) != 0 &&
2834
+ memcmp(checksum, buffer, checksum_size) != 0) {
2721
2835
  error = index_error_invalid(
2722
2836
  "calculated checksum does not match expected");
2723
2837
  goto done;
2724
2838
  }
2725
2839
 
2726
- git_oid_cpy(&index->checksum, &checksum_calculated);
2840
+ memcpy(index->checksum, checksum, checksum_size);
2727
2841
 
2728
2842
  #undef seek_forward
2729
2843
 
@@ -2756,16 +2870,40 @@ static bool is_index_extended(git_index *index)
2756
2870
  return (extended > 0);
2757
2871
  }
2758
2872
 
2759
- static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const char *last)
2873
+ static int write_disk_entry(
2874
+ git_index *index,
2875
+ git_filebuf *file,
2876
+ git_index_entry *entry,
2877
+ const char *last)
2760
2878
  {
2761
2879
  void *mem = NULL;
2762
- struct entry_short ondisk;
2763
- size_t path_len, disk_size;
2880
+ struct entry_common *ondisk_common;
2881
+ size_t path_len, path_offset, disk_size;
2764
2882
  int varint_len = 0;
2765
2883
  char *path;
2766
2884
  const char *path_start = entry->path;
2767
2885
  size_t same_len = 0;
2768
2886
 
2887
+ index_entry_short_sha1 ondisk_sha1;
2888
+ index_entry_long_sha1 ondisk_ext_sha1;
2889
+ #ifdef GIT_EXPERIMENTAL_SHA256
2890
+ index_entry_short_sha256 ondisk_sha256;
2891
+ index_entry_long_sha256 ondisk_ext_sha256;
2892
+ #endif
2893
+
2894
+ switch (index->oid_type) {
2895
+ case GIT_OID_SHA1:
2896
+ ondisk_common = &ondisk_sha1.common;
2897
+ break;
2898
+ #ifdef GIT_EXPERIMENTAL_SHA256
2899
+ case GIT_OID_SHA256:
2900
+ ondisk_common = &ondisk_sha256.common;
2901
+ break;
2902
+ #endif
2903
+ default:
2904
+ GIT_ASSERT(!"invalid oid type");
2905
+ }
2906
+
2769
2907
  path_len = ((struct entry_internal *)entry)->pathlen;
2770
2908
 
2771
2909
  if (last) {
@@ -2782,9 +2920,9 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2782
2920
  varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
2783
2921
  }
2784
2922
 
2785
- disk_size = index_entry_size(path_len, varint_len, entry->flags);
2923
+ disk_size = index_entry_size(path_len, varint_len, index->oid_type, entry->flags);
2786
2924
 
2787
- if (git_filebuf_reserve(file, &mem, disk_size) < 0)
2925
+ if (!disk_size || git_filebuf_reserve(file, &mem, disk_size) < 0)
2788
2926
  return -1;
2789
2927
 
2790
2928
  memset(mem, 0x0, disk_size);
@@ -2799,37 +2937,77 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
2799
2937
  *
2800
2938
  * In 2038 I will be either too dead or too rich to care about this
2801
2939
  */
2802
- ondisk.ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
2803
- ondisk.mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
2804
- ondisk.ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
2805
- ondisk.mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
2806
- ondisk.dev = htonl(entry->dev);
2807
- ondisk.ino = htonl(entry->ino);
2808
- ondisk.mode = htonl(entry->mode);
2809
- ondisk.uid = htonl(entry->uid);
2810
- ondisk.gid = htonl(entry->gid);
2811
- ondisk.file_size = htonl((uint32_t)entry->file_size);
2812
-
2813
- git_oid_cpy(&ondisk.oid, &entry->id);
2940
+ ondisk_common->ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
2941
+ ondisk_common->mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
2942
+ ondisk_common->ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
2943
+ ondisk_common->mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
2944
+ ondisk_common->dev = htonl(entry->dev);
2945
+ ondisk_common->ino = htonl(entry->ino);
2946
+ ondisk_common->mode = htonl(entry->mode);
2947
+ ondisk_common->uid = htonl(entry->uid);
2948
+ ondisk_common->gid = htonl(entry->gid);
2949
+ ondisk_common->file_size = htonl((uint32_t)entry->file_size);
2950
+
2951
+ switch (index->oid_type) {
2952
+ case GIT_OID_SHA1:
2953
+ git_oid_raw_cpy(ondisk_sha1.oid, entry->id.id, GIT_OID_SHA1_SIZE);
2954
+ ondisk_sha1.flags = htons(entry->flags);
2955
+ break;
2956
+ #ifdef GIT_EXPERIMENTAL_SHA256
2957
+ case GIT_OID_SHA256:
2958
+ git_oid_raw_cpy(ondisk_sha256.oid, entry->id.id, GIT_OID_SHA256_SIZE);
2959
+ ondisk_sha256.flags = htons(entry->flags);
2960
+ break;
2961
+ #endif
2962
+ default:
2963
+ GIT_ASSERT(!"invalid oid type");
2964
+ }
2814
2965
 
2815
- ondisk.flags = htons(entry->flags);
2966
+ path_offset = index_entry_path_offset(index->oid_type, entry->flags);
2816
2967
 
2817
2968
  if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
2818
- const size_t path_offset = offsetof(struct entry_long, path);
2819
- struct entry_long ondisk_ext;
2820
- memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
2821
- ondisk_ext.flags_extended = htons(entry->flags_extended &
2969
+ struct entry_common *ondisk_ext;
2970
+ uint16_t flags_extended = htons(entry->flags_extended &
2822
2971
  GIT_INDEX_ENTRY_EXTENDED_FLAGS);
2823
- memcpy(mem, &ondisk_ext, path_offset);
2824
- path = (char *)mem + path_offset;
2825
- disk_size -= path_offset;
2972
+
2973
+ switch (index->oid_type) {
2974
+ case GIT_OID_SHA1:
2975
+ memcpy(&ondisk_ext_sha1, &ondisk_sha1,
2976
+ sizeof(index_entry_short_sha1));
2977
+ ondisk_ext_sha1.flags_extended = flags_extended;
2978
+ ondisk_ext = &ondisk_ext_sha1.common;
2979
+ break;
2980
+ #ifdef GIT_EXPERIMENTAL_SHA256
2981
+ case GIT_OID_SHA256:
2982
+ memcpy(&ondisk_ext_sha256, &ondisk_sha256,
2983
+ sizeof(index_entry_short_sha256));
2984
+ ondisk_ext_sha256.flags_extended = flags_extended;
2985
+ ondisk_ext = &ondisk_ext_sha256.common;
2986
+ break;
2987
+ #endif
2988
+ default:
2989
+ GIT_ASSERT(!"invalid oid type");
2990
+ }
2991
+
2992
+ memcpy(mem, ondisk_ext, path_offset);
2826
2993
  } else {
2827
- const size_t path_offset = offsetof(struct entry_short, path);
2828
- memcpy(mem, &ondisk, path_offset);
2829
- path = (char *)mem + path_offset;
2830
- disk_size -= path_offset;
2994
+ switch (index->oid_type) {
2995
+ case GIT_OID_SHA1:
2996
+ memcpy(mem, &ondisk_sha1, path_offset);
2997
+ break;
2998
+ #ifdef GIT_EXPERIMENTAL_SHA256
2999
+ case GIT_OID_SHA256:
3000
+ memcpy(mem, &ondisk_sha256, path_offset);
3001
+ break;
3002
+ #endif
3003
+ default:
3004
+ GIT_ASSERT(!"invalid oid type");
3005
+ }
2831
3006
  }
2832
3007
 
3008
+ path = (char *)mem + path_offset;
3009
+ disk_size -= path_offset;
3010
+
2833
3011
  if (last) {
2834
3012
  varint_len = git_encode_varint((unsigned char *) path,
2835
3013
  disk_size, strlen(last) - same_len);
@@ -2881,18 +3059,18 @@ static int write_entries(git_index *index, git_filebuf *file)
2881
3059
  last = "";
2882
3060
 
2883
3061
  git_vector_foreach(entries, i, entry) {
2884
- if ((error = write_disk_entry(file, entry, last)) < 0)
3062
+ if ((error = write_disk_entry(index, file, entry, last)) < 0)
2885
3063
  break;
2886
3064
  if (index->version >= INDEX_VERSION_NUMBER_COMP)
2887
3065
  last = entry->path;
2888
3066
  }
2889
3067
 
2890
3068
  done:
2891
- git_vector_free(&case_sorted);
3069
+ git_vector_dispose(&case_sorted);
2892
3070
  return error;
2893
3071
  }
2894
3072
 
2895
- static int write_extension(git_filebuf *file, struct index_extension *header, git_buf *data)
3073
+ static int write_extension(git_filebuf *file, struct index_extension *header, git_str *data)
2896
3074
  {
2897
3075
  struct index_extension ondisk;
2898
3076
 
@@ -2904,30 +3082,30 @@ static int write_extension(git_filebuf *file, struct index_extension *header, gi
2904
3082
  return git_filebuf_write(file, data->ptr, data->size);
2905
3083
  }
2906
3084
 
2907
- static int create_name_extension_data(git_buf *name_buf, git_index_name_entry *conflict_name)
3085
+ static int create_name_extension_data(git_str *name_buf, git_index_name_entry *conflict_name)
2908
3086
  {
2909
3087
  int error = 0;
2910
3088
 
2911
3089
  if (conflict_name->ancestor == NULL)
2912
- error = git_buf_put(name_buf, "\0", 1);
3090
+ error = git_str_put(name_buf, "\0", 1);
2913
3091
  else
2914
- error = git_buf_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1);
3092
+ error = git_str_put(name_buf, conflict_name->ancestor, strlen(conflict_name->ancestor) + 1);
2915
3093
 
2916
3094
  if (error != 0)
2917
3095
  goto on_error;
2918
3096
 
2919
3097
  if (conflict_name->ours == NULL)
2920
- error = git_buf_put(name_buf, "\0", 1);
3098
+ error = git_str_put(name_buf, "\0", 1);
2921
3099
  else
2922
- error = git_buf_put(name_buf, conflict_name->ours, strlen(conflict_name->ours) + 1);
3100
+ error = git_str_put(name_buf, conflict_name->ours, strlen(conflict_name->ours) + 1);
2923
3101
 
2924
3102
  if (error != 0)
2925
3103
  goto on_error;
2926
3104
 
2927
3105
  if (conflict_name->theirs == NULL)
2928
- error = git_buf_put(name_buf, "\0", 1);
3106
+ error = git_str_put(name_buf, "\0", 1);
2929
3107
  else
2930
- error = git_buf_put(name_buf, conflict_name->theirs, strlen(conflict_name->theirs) + 1);
3108
+ error = git_str_put(name_buf, conflict_name->theirs, strlen(conflict_name->theirs) + 1);
2931
3109
 
2932
3110
  on_error:
2933
3111
  return error;
@@ -2935,7 +3113,7 @@ on_error:
2935
3113
 
2936
3114
  static int write_name_extension(git_index *index, git_filebuf *file)
2937
3115
  {
2938
- git_buf name_buf = GIT_BUF_INIT;
3116
+ git_str name_buf = GIT_STR_INIT;
2939
3117
  git_vector *out = &index->names;
2940
3118
  git_index_name_entry *conflict_name;
2941
3119
  struct index_extension extension;
@@ -2953,28 +3131,29 @@ static int write_name_extension(git_index *index, git_filebuf *file)
2953
3131
 
2954
3132
  error = write_extension(file, &extension, &name_buf);
2955
3133
 
2956
- git_buf_dispose(&name_buf);
3134
+ git_str_dispose(&name_buf);
2957
3135
 
2958
3136
  done:
2959
3137
  return error;
2960
3138
  }
2961
3139
 
2962
- static int create_reuc_extension_data(git_buf *reuc_buf, git_index_reuc_entry *reuc)
3140
+ static int create_reuc_extension_data(git_str *reuc_buf, git_index *index, git_index_reuc_entry *reuc)
2963
3141
  {
3142
+ size_t oid_size = git_oid_size(index->oid_type);
2964
3143
  int i;
2965
3144
  int error = 0;
2966
3145
 
2967
- if ((error = git_buf_put(reuc_buf, reuc->path, strlen(reuc->path) + 1)) < 0)
3146
+ if ((error = git_str_put(reuc_buf, reuc->path, strlen(reuc->path) + 1)) < 0)
2968
3147
  return error;
2969
3148
 
2970
3149
  for (i = 0; i < 3; i++) {
2971
- if ((error = git_buf_printf(reuc_buf, "%o", reuc->mode[i])) < 0 ||
2972
- (error = git_buf_put(reuc_buf, "\0", 1)) < 0)
3150
+ if ((error = git_str_printf(reuc_buf, "%o", reuc->mode[i])) < 0 ||
3151
+ (error = git_str_put(reuc_buf, "\0", 1)) < 0)
2973
3152
  return error;
2974
3153
  }
2975
3154
 
2976
3155
  for (i = 0; i < 3; i++) {
2977
- if (reuc->mode[i] && (error = git_buf_put(reuc_buf, (char *)&reuc->oid[i].id, GIT_OID_RAWSZ)) < 0)
3156
+ if (reuc->mode[i] && (error = git_str_put(reuc_buf, (char *)&reuc->oid[i].id, oid_size)) < 0)
2978
3157
  return error;
2979
3158
  }
2980
3159
 
@@ -2983,7 +3162,7 @@ static int create_reuc_extension_data(git_buf *reuc_buf, git_index_reuc_entry *r
2983
3162
 
2984
3163
  static int write_reuc_extension(git_index *index, git_filebuf *file)
2985
3164
  {
2986
- git_buf reuc_buf = GIT_BUF_INIT;
3165
+ git_str reuc_buf = GIT_STR_INIT;
2987
3166
  git_vector *out = &index->reuc;
2988
3167
  git_index_reuc_entry *reuc;
2989
3168
  struct index_extension extension;
@@ -2991,7 +3170,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
2991
3170
  int error = 0;
2992
3171
 
2993
3172
  git_vector_foreach(out, i, reuc) {
2994
- if ((error = create_reuc_extension_data(&reuc_buf, reuc)) < 0)
3173
+ if ((error = create_reuc_extension_data(&reuc_buf, index, reuc)) < 0)
2995
3174
  goto done;
2996
3175
  }
2997
3176
 
@@ -3001,7 +3180,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
3001
3180
 
3002
3181
  error = write_extension(file, &extension, &reuc_buf);
3003
3182
 
3004
- git_buf_dispose(&reuc_buf);
3183
+ git_str_dispose(&reuc_buf);
3005
3184
 
3006
3185
  done:
3007
3186
  return error;
@@ -3010,7 +3189,7 @@ done:
3010
3189
  static int write_tree_extension(git_index *index, git_filebuf *file)
3011
3190
  {
3012
3191
  struct index_extension extension;
3013
- git_buf buf = GIT_BUF_INIT;
3192
+ git_str buf = GIT_STR_INIT;
3014
3193
  int error;
3015
3194
 
3016
3195
  if (index->tree == NULL)
@@ -3025,7 +3204,7 @@ static int write_tree_extension(git_index *index, git_filebuf *file)
3025
3204
 
3026
3205
  error = write_extension(file, &extension, &buf);
3027
3206
 
3028
- git_buf_dispose(&buf);
3207
+ git_str_dispose(&buf);
3029
3208
 
3030
3209
  return error;
3031
3210
  }
@@ -3039,9 +3218,12 @@ static void clear_uptodate(git_index *index)
3039
3218
  entry->flags_extended &= ~GIT_INDEX_ENTRY_UPTODATE;
3040
3219
  }
3041
3220
 
3042
- static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
3221
+ static int write_index(
3222
+ unsigned char checksum[GIT_HASH_MAX_SIZE],
3223
+ size_t *checksum_size,
3224
+ git_index *index,
3225
+ git_filebuf *file)
3043
3226
  {
3044
- git_oid hash_final;
3045
3227
  struct index_header header;
3046
3228
  bool is_extended;
3047
3229
  uint32_t index_version_number;
@@ -3049,6 +3231,10 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
3049
3231
  GIT_ASSERT_ARG(index);
3050
3232
  GIT_ASSERT_ARG(file);
3051
3233
 
3234
+ GIT_ASSERT(index->oid_type);
3235
+
3236
+ *checksum_size = git_hash_size(git_oid_algorithm(index->oid_type));
3237
+
3052
3238
  if (index->version <= INDEX_VERSION_NUMBER_EXT) {
3053
3239
  is_extended = is_index_extended(index);
3054
3240
  index_version_number = is_extended ? INDEX_VERSION_NUMBER_EXT : INDEX_VERSION_NUMBER_LB;
@@ -3079,11 +3265,10 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
3079
3265
  return -1;
3080
3266
 
3081
3267
  /* get out the hash for all the contents we've appended to the file */
3082
- git_filebuf_hash(&hash_final, file);
3083
- git_oid_cpy(checksum, &hash_final);
3268
+ git_filebuf_hash(checksum, file);
3084
3269
 
3085
3270
  /* write it at the end of the file */
3086
- if (git_filebuf_write(file, hash_final.id, GIT_OID_RAWSZ) < 0)
3271
+ if (git_filebuf_write(file, checksum, *checksum_size) < 0)
3087
3272
  return -1;
3088
3273
 
3089
3274
  /* file entries are no longer up to date */
@@ -3115,13 +3300,13 @@ static int read_tree_cb(
3115
3300
  {
3116
3301
  read_tree_data *data = payload;
3117
3302
  git_index_entry *entry = NULL, *old_entry;
3118
- git_buf path = GIT_BUF_INIT;
3303
+ git_str path = GIT_STR_INIT;
3119
3304
  size_t pos;
3120
3305
 
3121
3306
  if (git_tree_entry__is_tree(tentry))
3122
3307
  return 0;
3123
3308
 
3124
- if (git_buf_joinpath(&path, root, tentry->filename) < 0)
3309
+ if (git_str_joinpath(&path, root, tentry->filename) < 0)
3125
3310
  return -1;
3126
3311
 
3127
3312
  if (index_entry_create(&entry, INDEX_OWNER(data->index), path.ptr, NULL, false) < 0)
@@ -3143,7 +3328,7 @@ static int read_tree_cb(
3143
3328
  }
3144
3329
 
3145
3330
  index_entry_adjust_namemask(entry, path.size);
3146
- git_buf_dispose(&path);
3331
+ git_str_dispose(&path);
3147
3332
 
3148
3333
  if (git_vector_insert(data->new_entries, entry) < 0) {
3149
3334
  index_entry_free(entry);
@@ -3157,14 +3342,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3157
3342
  {
3158
3343
  int error = 0;
3159
3344
  git_vector entries = GIT_VECTOR_INIT;
3160
- git_idxmap *entries_map;
3345
+ git_index_entrymap entries_map = GIT_INDEX_ENTRYMAP_INIT;
3161
3346
  read_tree_data data;
3162
3347
  size_t i;
3163
3348
  git_index_entry *e;
3164
3349
 
3165
- if (git_idxmap_new(&entries_map) < 0)
3166
- return -1;
3167
-
3168
3350
  git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
3169
3351
 
3170
3352
  data.index = index;
@@ -3180,11 +3362,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3180
3362
  if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
3181
3363
  goto cleanup;
3182
3364
 
3183
- if ((error = index_map_resize(entries_map, entries.length, index->ignore_case)) < 0)
3365
+ if ((error = git_index_entrymap_resize(&entries_map, entries.length)) < 0)
3184
3366
  goto cleanup;
3185
3367
 
3186
3368
  git_vector_foreach(&entries, i, e) {
3187
- if ((error = index_map_set(entries_map, e, index->ignore_case)) < 0) {
3369
+ if ((error = git_index_entrymap_put(&entries_map, e)) < 0) {
3188
3370
  git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
3189
3371
  return error;
3190
3372
  }
@@ -3194,22 +3376,22 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
3194
3376
 
3195
3377
  git_vector_sort(&entries);
3196
3378
 
3197
- if ((error = git_index_clear(index)) < 0) {
3198
- /* well, this isn't good */;
3199
- } else {
3200
- git_vector_swap(&entries, &index->entries);
3201
- entries_map = git_atomic_swap(index->entries_map, entries_map);
3202
- }
3379
+ if ((error = git_index_clear(index)) < 0)
3380
+ goto cleanup;
3381
+
3382
+ git_vector_swap(&entries, &index->entries);
3383
+ git_index_entrymap_swap(&entries_map, &index->entries_map);
3203
3384
 
3204
3385
  index->dirty = 1;
3205
3386
 
3206
3387
  cleanup:
3207
- git_vector_free(&entries);
3208
- git_idxmap_free(entries_map);
3388
+ git_vector_dispose(&entries);
3389
+ git_index_entrymap_dispose(&entries_map);
3390
+
3209
3391
  if (error < 0)
3210
3392
  return error;
3211
3393
 
3212
- error = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool);
3394
+ error = git_tree_cache_read_tree(&index->tree, tree, index->oid_type, &index->tree_pool);
3213
3395
 
3214
3396
  return error;
3215
3397
  }
@@ -3221,7 +3403,7 @@ static int git_index_read_iterator(
3221
3403
  {
3222
3404
  git_vector new_entries = GIT_VECTOR_INIT,
3223
3405
  remove_entries = GIT_VECTOR_INIT;
3224
- git_idxmap *new_entries_map = NULL;
3406
+ git_index_entrymap new_entries_map = GIT_INDEX_ENTRYMAP_INIT;
3225
3407
  git_iterator *index_iterator = NULL;
3226
3408
  git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT;
3227
3409
  const git_index_entry *old_entry, *new_entry;
@@ -3232,12 +3414,11 @@ static int git_index_read_iterator(
3232
3414
  GIT_ASSERT((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
3233
3415
 
3234
3416
  if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
3235
- (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
3236
- (error = git_idxmap_new(&new_entries_map)) < 0)
3417
+ (error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0)
3237
3418
  goto done;
3238
3419
 
3239
- if (new_length_hint && (error = index_map_resize(new_entries_map, new_length_hint,
3240
- index->ignore_case)) < 0)
3420
+ if (new_length_hint &&
3421
+ (error = git_index_entrymap_resize(&new_entries_map, new_length_hint)) < 0)
3241
3422
  goto done;
3242
3423
 
3243
3424
  opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
@@ -3302,8 +3483,7 @@ static int git_index_read_iterator(
3302
3483
 
3303
3484
  if (add_entry) {
3304
3485
  if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
3305
- error = index_map_set(new_entries_map, add_entry,
3306
- index->ignore_case);
3486
+ error = git_index_entrymap_put(&new_entries_map, add_entry);
3307
3487
  }
3308
3488
 
3309
3489
  if (remove_entry && error >= 0)
@@ -3332,7 +3512,7 @@ static int git_index_read_iterator(
3332
3512
  goto done;
3333
3513
 
3334
3514
  git_vector_swap(&new_entries, &index->entries);
3335
- new_entries_map = git_atomic_swap(index->entries_map, new_entries_map);
3515
+ git_index_entrymap_swap(&index->entries_map, &new_entries_map);
3336
3516
 
3337
3517
  git_vector_foreach(&remove_entries, i, entry) {
3338
3518
  if (index->tree)
@@ -3347,9 +3527,9 @@ static int git_index_read_iterator(
3347
3527
  error = 0;
3348
3528
 
3349
3529
  done:
3350
- git_idxmap_free(new_entries_map);
3351
- git_vector_free(&new_entries);
3352
- git_vector_free(&remove_entries);
3530
+ git_index_entrymap_dispose(&new_entries_map);
3531
+ git_vector_dispose(&new_entries);
3532
+ git_vector_dispose(&remove_entries);
3353
3533
  git_iterator_free(index_iterator);
3354
3534
  return error;
3355
3535
  }
@@ -3385,7 +3565,7 @@ enum {
3385
3565
  INDEX_ACTION_NONE = 0,
3386
3566
  INDEX_ACTION_UPDATE = 1,
3387
3567
  INDEX_ACTION_REMOVE = 2,
3388
- INDEX_ACTION_ADDALL = 3,
3568
+ INDEX_ACTION_ADDALL = 3
3389
3569
  };
3390
3570
 
3391
3571
  int git_index_add_all(
@@ -3397,7 +3577,6 @@ int git_index_add_all(
3397
3577
  {
3398
3578
  int error;
3399
3579
  git_repository *repo;
3400
- git_iterator *wditer = NULL;
3401
3580
  git_pathspec ps;
3402
3581
  bool no_fnmatch = (flags & GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH) != 0;
3403
3582
 
@@ -3423,7 +3602,6 @@ int git_index_add_all(
3423
3602
  git_error_set_after_callback(error);
3424
3603
 
3425
3604
  cleanup:
3426
- git_iterator_free(wditer);
3427
3605
  git_pathspec__clear(&ps);
3428
3606
 
3429
3607
  return error;
@@ -3498,7 +3676,7 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
3498
3676
  }
3499
3677
 
3500
3678
  /*
3501
- * We do the matching ourselves intead of passing the list to
3679
+ * We do the matching ourselves instead of passing the list to
3502
3680
  * diff because we want to tell the callback which one
3503
3681
  * matched, which we do not know if we ask diff to filter for us.
3504
3682
  */
@@ -3511,7 +3689,8 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
3511
3689
  GIT_DIFF_RECURSE_UNTRACKED_DIRS;
3512
3690
 
3513
3691
  if (flags == GIT_INDEX_ADD_FORCE)
3514
- opts.flags |= GIT_DIFF_INCLUDE_IGNORED;
3692
+ opts.flags |= GIT_DIFF_INCLUDE_IGNORED |
3693
+ GIT_DIFF_RECURSE_IGNORED_DIRS;
3515
3694
  }
3516
3695
 
3517
3696
  if ((error = git_diff_index_to_workdir(&diff, repo, index, &opts)) < 0)
@@ -3540,7 +3719,7 @@ static int index_apply_to_all(
3540
3719
  size_t i;
3541
3720
  git_pathspec ps;
3542
3721
  const char *match;
3543
- git_buf path = GIT_BUF_INIT;
3722
+ git_str path = GIT_STR_INIT;
3544
3723
 
3545
3724
  GIT_ASSERT_ARG(index);
3546
3725
 
@@ -3569,7 +3748,7 @@ static int index_apply_to_all(
3569
3748
  }
3570
3749
 
3571
3750
  /* index manipulation may alter entry, so don't depend on it */
3572
- if ((error = git_buf_sets(&path, entry->path)) < 0)
3751
+ if ((error = git_str_sets(&path, entry->path)) < 0)
3573
3752
  break;
3574
3753
 
3575
3754
  switch (action) {
@@ -3598,7 +3777,7 @@ static int index_apply_to_all(
3598
3777
  }
3599
3778
  }
3600
3779
 
3601
- git_buf_dispose(&path);
3780
+ git_str_dispose(&path);
3602
3781
  git_pathspec__clear(&ps);
3603
3782
 
3604
3783
  return error;
@@ -3651,7 +3830,7 @@ int git_index_snapshot_new(git_vector *snap, git_index *index)
3651
3830
 
3652
3831
  void git_index_snapshot_release(git_vector *snap, git_index *index)
3653
3832
  {
3654
- git_vector_free(snap);
3833
+ git_vector_dispose(snap);
3655
3834
 
3656
3835
  git_atomic32_dec(&index->readers);
3657
3836
 
@@ -3669,19 +3848,23 @@ int git_indexwriter_init(
3669
3848
  git_indexwriter *writer,
3670
3849
  git_index *index)
3671
3850
  {
3672
- int error;
3851
+ int filebuf_hash, error;
3673
3852
 
3674
3853
  GIT_REFCOUNT_INC(index);
3675
3854
 
3676
3855
  writer->index = index;
3677
3856
 
3857
+ filebuf_hash = git_filebuf_hash_flags(git_oid_algorithm(index->oid_type));
3858
+ GIT_ASSERT(filebuf_hash);
3859
+
3678
3860
  if (!index->index_file_path)
3679
3861
  return create_index_error(-1,
3680
3862
  "failed to write index: The index is in-memory only");
3681
3863
 
3682
- if ((error = git_filebuf_open(
3683
- &writer->file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) {
3684
-
3864
+ if ((error = git_filebuf_open(&writer->file,
3865
+ index->index_file_path,
3866
+ git_filebuf_hash_flags(filebuf_hash),
3867
+ GIT_INDEX_FILE_MODE)) < 0) {
3685
3868
  if (error == GIT_ELOCKED)
3686
3869
  git_error_set(GIT_ERROR_INDEX, "the index is locked; this might be due to a concurrent or crashed process");
3687
3870
 
@@ -3713,8 +3896,9 @@ int git_indexwriter_init_for_operation(
3713
3896
 
3714
3897
  int git_indexwriter_commit(git_indexwriter *writer)
3715
3898
  {
3899
+ unsigned char checksum[GIT_HASH_MAX_SIZE];
3900
+ size_t checksum_size;
3716
3901
  int error;
3717
- git_oid checksum = {{ 0 }};
3718
3902
 
3719
3903
  if (!writer->should_write)
3720
3904
  return 0;
@@ -3722,7 +3906,7 @@ int git_indexwriter_commit(git_indexwriter *writer)
3722
3906
  git_vector_sort(&writer->index->entries);
3723
3907
  git_vector_sort(&writer->index->reuc);
3724
3908
 
3725
- if ((error = write_index(&checksum, writer->index, &writer->file)) < 0) {
3909
+ if ((error = write_index(checksum, &checksum_size, writer->index, &writer->file)) < 0) {
3726
3910
  git_indexwriter_cleanup(writer);
3727
3911
  return error;
3728
3912
  }
@@ -3738,7 +3922,7 @@ int git_indexwriter_commit(git_indexwriter *writer)
3738
3922
 
3739
3923
  writer->index->dirty = 0;
3740
3924
  writer->index->on_disk = 1;
3741
- git_oid_cpy(&writer->index->checksum, &checksum);
3925
+ memcpy(writer->index->checksum, checksum, checksum_size);
3742
3926
 
3743
3927
  git_index_free(writer->index);
3744
3928
  writer->index = NULL;