rugged 1.1.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (407) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/extconf.rb +2 -2
  5. data/ext/rugged/rugged.c +7 -4
  6. data/ext/rugged/rugged_config.c +7 -2
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +17 -0
  9. data/ext/rugged/rugged_repo.c +3 -3
  10. data/lib/rugged/repository.rb +2 -2
  11. data/lib/rugged/version.rb +1 -1
  12. data/vendor/libgit2/CMakeLists.txt +103 -271
  13. data/vendor/libgit2/COPYING +149 -24
  14. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  15. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  16. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  17. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  19. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  20. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  21. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  22. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  23. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  24. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  25. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  26. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  27. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  30. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  31. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  32. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  33. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  34. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  35. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
  36. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
  37. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  38. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  39. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  40. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  41. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  42. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
  43. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  44. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  45. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  46. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  47. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  48. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  49. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  50. data/vendor/libgit2/deps/ntlmclient/ntlm.c +154 -122
  51. data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
  52. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
  53. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  54. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  55. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  56. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  57. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  58. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  59. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  60. data/vendor/libgit2/include/git2/apply.h +16 -2
  61. data/vendor/libgit2/include/git2/attr.h +106 -2
  62. data/vendor/libgit2/include/git2/blame.h +97 -43
  63. data/vendor/libgit2/include/git2/blob.h +33 -2
  64. data/vendor/libgit2/include/git2/branch.h +27 -0
  65. data/vendor/libgit2/include/git2/buffer.h +18 -78
  66. data/vendor/libgit2/include/git2/cert.h +43 -6
  67. data/vendor/libgit2/include/git2/checkout.h +32 -13
  68. data/vendor/libgit2/include/git2/clone.h +4 -4
  69. data/vendor/libgit2/include/git2/commit.h +37 -19
  70. data/vendor/libgit2/include/git2/common.h +46 -5
  71. data/vendor/libgit2/include/git2/config.h +19 -3
  72. data/vendor/libgit2/include/git2/credential.h +2 -1
  73. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  74. data/vendor/libgit2/include/git2/deprecated.h +326 -6
  75. data/vendor/libgit2/include/git2/describe.h +7 -2
  76. data/vendor/libgit2/include/git2/diff.h +50 -121
  77. data/vendor/libgit2/include/git2/email.h +127 -0
  78. data/vendor/libgit2/include/git2/errors.h +7 -6
  79. data/vendor/libgit2/include/git2/filter.h +69 -18
  80. data/vendor/libgit2/include/git2/graph.h +21 -2
  81. data/vendor/libgit2/include/git2/ignore.h +1 -1
  82. data/vendor/libgit2/include/git2/index.h +13 -7
  83. data/vendor/libgit2/include/git2/indexer.h +19 -0
  84. data/vendor/libgit2/include/git2/merge.h +23 -3
  85. data/vendor/libgit2/include/git2/message.h +2 -0
  86. data/vendor/libgit2/include/git2/notes.h +2 -2
  87. data/vendor/libgit2/include/git2/object.h +23 -0
  88. data/vendor/libgit2/include/git2/odb.h +65 -6
  89. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  90. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  91. data/vendor/libgit2/include/git2/pack.h +24 -8
  92. data/vendor/libgit2/include/git2/patch.h +16 -0
  93. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  94. data/vendor/libgit2/include/git2/proxy.h +1 -1
  95. data/vendor/libgit2/include/git2/rebase.h +34 -2
  96. data/vendor/libgit2/include/git2/refdb.h +3 -0
  97. data/vendor/libgit2/include/git2/reflog.h +1 -1
  98. data/vendor/libgit2/include/git2/refs.h +8 -4
  99. data/vendor/libgit2/include/git2/remote.h +246 -46
  100. data/vendor/libgit2/include/git2/repository.h +25 -18
  101. data/vendor/libgit2/include/git2/reset.h +2 -2
  102. data/vendor/libgit2/include/git2/revparse.h +5 -5
  103. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  104. data/vendor/libgit2/include/git2/signature.h +1 -1
  105. data/vendor/libgit2/include/git2/stash.h +4 -4
  106. data/vendor/libgit2/include/git2/status.h +124 -62
  107. data/vendor/libgit2/include/git2/stdint.h +3 -3
  108. data/vendor/libgit2/include/git2/submodule.h +16 -2
  109. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  110. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  111. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  112. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  113. data/vendor/libgit2/include/git2/sys/odb_backend.h +9 -5
  114. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  115. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  116. data/vendor/libgit2/include/git2/sys/transport.h +26 -34
  117. data/vendor/libgit2/include/git2/tag.h +13 -0
  118. data/vendor/libgit2/include/git2/tree.h +4 -17
  119. data/vendor/libgit2/include/git2/types.h +16 -7
  120. data/vendor/libgit2/include/git2/version.h +4 -4
  121. data/vendor/libgit2/include/git2/worktree.h +13 -2
  122. data/vendor/libgit2/include/git2.h +1 -0
  123. data/vendor/libgit2/src/CMakeLists.txt +192 -290
  124. data/vendor/libgit2/src/alloc.c +21 -8
  125. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  126. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  127. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  128. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  129. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  130. data/vendor/libgit2/src/annotated_commit.c +21 -9
  131. data/vendor/libgit2/src/annotated_commit.h +1 -1
  132. data/vendor/libgit2/src/apply.c +34 -25
  133. data/vendor/libgit2/src/apply.h +2 -2
  134. data/vendor/libgit2/src/array.h +11 -11
  135. data/vendor/libgit2/src/attr.c +204 -82
  136. data/vendor/libgit2/src/attr_file.c +105 -52
  137. data/vendor/libgit2/src/attr_file.h +36 -15
  138. data/vendor/libgit2/src/attrcache.c +55 -45
  139. data/vendor/libgit2/src/attrcache.h +4 -5
  140. data/vendor/libgit2/src/blame.c +15 -9
  141. data/vendor/libgit2/src/blame_git.c +2 -2
  142. data/vendor/libgit2/src/blob.c +76 -52
  143. data/vendor/libgit2/src/blob.h +1 -1
  144. data/vendor/libgit2/src/branch.c +203 -110
  145. data/vendor/libgit2/src/branch.h +15 -3
  146. data/vendor/libgit2/src/buf.c +126 -0
  147. data/vendor/libgit2/src/buf.h +50 -0
  148. data/vendor/libgit2/src/cache.c +2 -2
  149. data/vendor/libgit2/src/cache.h +7 -7
  150. data/vendor/libgit2/src/cc-compat.h +11 -9
  151. data/vendor/libgit2/src/checkout.c +118 -91
  152. data/vendor/libgit2/src/cherrypick.c +16 -12
  153. data/vendor/libgit2/src/clone.c +97 -103
  154. data/vendor/libgit2/src/commit.c +167 -84
  155. data/vendor/libgit2/src/commit.h +24 -1
  156. data/vendor/libgit2/src/commit_graph.c +1224 -0
  157. data/vendor/libgit2/src/commit_graph.h +169 -0
  158. data/vendor/libgit2/src/commit_list.c +48 -3
  159. data/vendor/libgit2/src/commit_list.h +2 -0
  160. data/vendor/libgit2/src/common.h +35 -5
  161. data/vendor/libgit2/src/config.c +119 -64
  162. data/vendor/libgit2/src/config.h +15 -2
  163. data/vendor/libgit2/src/config_cache.c +5 -3
  164. data/vendor/libgit2/src/config_file.c +120 -100
  165. data/vendor/libgit2/src/config_mem.c +9 -9
  166. data/vendor/libgit2/src/config_parse.c +29 -27
  167. data/vendor/libgit2/src/crlf.c +36 -23
  168. data/vendor/libgit2/src/date.c +13 -19
  169. data/vendor/libgit2/src/date.h +33 -0
  170. data/vendor/libgit2/src/delta.c +1 -1
  171. data/vendor/libgit2/src/describe.c +32 -21
  172. data/vendor/libgit2/src/diff.c +71 -183
  173. data/vendor/libgit2/src/diff.h +2 -4
  174. data/vendor/libgit2/src/diff_driver.c +53 -51
  175. data/vendor/libgit2/src/diff_driver.h +3 -3
  176. data/vendor/libgit2/src/diff_file.c +31 -26
  177. data/vendor/libgit2/src/diff_generate.c +76 -23
  178. data/vendor/libgit2/src/diff_generate.h +5 -3
  179. data/vendor/libgit2/src/diff_print.c +120 -95
  180. data/vendor/libgit2/src/diff_stats.c +47 -34
  181. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  182. data/vendor/libgit2/src/diff_tform.c +18 -16
  183. data/vendor/libgit2/src/diff_xdiff.c +7 -10
  184. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  185. data/vendor/libgit2/src/email.c +315 -0
  186. data/vendor/libgit2/src/email.h +25 -0
  187. data/vendor/libgit2/src/errors.c +37 -32
  188. data/vendor/libgit2/src/features.h.in +11 -2
  189. data/vendor/libgit2/src/fetch.c +77 -26
  190. data/vendor/libgit2/src/fetch.h +1 -1
  191. data/vendor/libgit2/src/fetchhead.c +27 -23
  192. data/vendor/libgit2/src/filebuf.c +36 -34
  193. data/vendor/libgit2/src/filebuf.h +1 -1
  194. data/vendor/libgit2/src/filter.c +278 -132
  195. data/vendor/libgit2/src/filter.h +46 -6
  196. data/vendor/libgit2/src/fs_path.c +2071 -0
  197. data/vendor/libgit2/src/fs_path.h +772 -0
  198. data/vendor/libgit2/src/futils.c +96 -90
  199. data/vendor/libgit2/src/futils.h +27 -15
  200. data/vendor/libgit2/src/graph.c +64 -9
  201. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
  202. data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
  203. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  204. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  205. data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
  206. data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
  207. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
  208. data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
  209. data/vendor/libgit2/src/hash/sha1.h +3 -1
  210. data/vendor/libgit2/src/hash.c +71 -36
  211. data/vendor/libgit2/src/hash.h +13 -13
  212. data/vendor/libgit2/src/hashsig.c +23 -10
  213. data/vendor/libgit2/src/ident.c +30 -20
  214. data/vendor/libgit2/src/ignore.c +63 -46
  215. data/vendor/libgit2/src/ignore.h +2 -2
  216. data/vendor/libgit2/src/index.c +184 -149
  217. data/vendor/libgit2/src/index.h +7 -4
  218. data/vendor/libgit2/src/indexer.c +143 -89
  219. data/vendor/libgit2/src/integer.h +64 -2
  220. data/vendor/libgit2/src/iterator.c +93 -73
  221. data/vendor/libgit2/src/iterator.h +6 -6
  222. data/vendor/libgit2/src/khash.h +3 -12
  223. data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
  224. data/vendor/libgit2/src/libgit2.h +15 -0
  225. data/vendor/libgit2/src/mailmap.c +60 -45
  226. data/vendor/libgit2/src/map.h +3 -3
  227. data/vendor/libgit2/src/merge.c +104 -61
  228. data/vendor/libgit2/src/merge.h +3 -15
  229. data/vendor/libgit2/src/merge_driver.c +21 -15
  230. data/vendor/libgit2/src/merge_file.c +24 -6
  231. data/vendor/libgit2/src/message.c +21 -8
  232. data/vendor/libgit2/src/midx.c +501 -18
  233. data/vendor/libgit2/src/midx.h +29 -2
  234. data/vendor/libgit2/src/mwindow.c +103 -59
  235. data/vendor/libgit2/src/mwindow.h +3 -3
  236. data/vendor/libgit2/src/net.c +405 -71
  237. data/vendor/libgit2/src/net.h +26 -5
  238. data/vendor/libgit2/src/netops.c +7 -5
  239. data/vendor/libgit2/src/netops.h +3 -3
  240. data/vendor/libgit2/src/notes.c +40 -49
  241. data/vendor/libgit2/src/object.c +68 -20
  242. data/vendor/libgit2/src/object.h +1 -1
  243. data/vendor/libgit2/src/odb.c +320 -80
  244. data/vendor/libgit2/src/odb.h +17 -3
  245. data/vendor/libgit2/src/odb_loose.c +96 -86
  246. data/vendor/libgit2/src/odb_mempack.c +19 -6
  247. data/vendor/libgit2/src/odb_pack.c +402 -125
  248. data/vendor/libgit2/src/oid.c +16 -8
  249. data/vendor/libgit2/src/oid.h +15 -0
  250. data/vendor/libgit2/src/oidarray.c +10 -1
  251. data/vendor/libgit2/src/pack-objects.c +90 -69
  252. data/vendor/libgit2/src/pack-objects.h +11 -6
  253. data/vendor/libgit2/src/pack.c +337 -127
  254. data/vendor/libgit2/src/pack.h +25 -7
  255. data/vendor/libgit2/src/patch.c +17 -10
  256. data/vendor/libgit2/src/patch.h +1 -0
  257. data/vendor/libgit2/src/patch_generate.c +29 -13
  258. data/vendor/libgit2/src/patch_generate.h +5 -5
  259. data/vendor/libgit2/src/patch_parse.c +26 -25
  260. data/vendor/libgit2/src/path.c +86 -1768
  261. data/vendor/libgit2/src/path.h +39 -635
  262. data/vendor/libgit2/src/pathspec.c +12 -12
  263. data/vendor/libgit2/src/pathspec.h +2 -2
  264. data/vendor/libgit2/src/pool.c +13 -7
  265. data/vendor/libgit2/src/posix.c +14 -6
  266. data/vendor/libgit2/src/posix.h +1 -0
  267. data/vendor/libgit2/src/pqueue.h +1 -1
  268. data/vendor/libgit2/src/proxy.c +4 -1
  269. data/vendor/libgit2/src/proxy.h +1 -1
  270. data/vendor/libgit2/src/push.c +30 -35
  271. data/vendor/libgit2/src/push.h +4 -16
  272. data/vendor/libgit2/src/rand.c +226 -0
  273. data/vendor/libgit2/src/rand.h +37 -0
  274. data/vendor/libgit2/src/reader.c +18 -14
  275. data/vendor/libgit2/src/reader.h +2 -2
  276. data/vendor/libgit2/src/rebase.c +177 -132
  277. data/vendor/libgit2/src/refdb.c +30 -13
  278. data/vendor/libgit2/src/refdb_fs.c +548 -222
  279. data/vendor/libgit2/src/reflog.c +19 -14
  280. data/vendor/libgit2/src/refs.c +107 -72
  281. data/vendor/libgit2/src/refs.h +2 -2
  282. data/vendor/libgit2/src/refspec.c +53 -38
  283. data/vendor/libgit2/src/refspec.h +5 -2
  284. data/vendor/libgit2/src/regexp.c +1 -1
  285. data/vendor/libgit2/src/remote.c +960 -486
  286. data/vendor/libgit2/src/remote.h +16 -10
  287. data/vendor/libgit2/src/repository.c +702 -422
  288. data/vendor/libgit2/src/repository.h +26 -8
  289. data/vendor/libgit2/src/reset.c +16 -12
  290. data/vendor/libgit2/src/revert.c +16 -12
  291. data/vendor/libgit2/src/revparse.c +66 -48
  292. data/vendor/libgit2/src/revwalk.c +39 -22
  293. data/vendor/libgit2/src/runtime.c +162 -0
  294. data/vendor/libgit2/src/runtime.h +62 -0
  295. data/vendor/libgit2/src/settings.h +11 -0
  296. data/vendor/libgit2/src/signature.c +18 -11
  297. data/vendor/libgit2/src/signature.h +1 -1
  298. data/vendor/libgit2/src/sortedcache.c +1 -1
  299. data/vendor/libgit2/src/sortedcache.h +10 -8
  300. data/vendor/libgit2/src/stash.c +39 -38
  301. data/vendor/libgit2/src/status.c +11 -5
  302. data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
  303. data/vendor/libgit2/src/str.h +357 -0
  304. data/vendor/libgit2/src/strarray.c +2 -1
  305. data/vendor/libgit2/src/streams/mbedtls.c +22 -23
  306. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  307. data/vendor/libgit2/src/streams/openssl.c +101 -201
  308. data/vendor/libgit2/src/streams/openssl.h +9 -1
  309. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  310. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  311. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  312. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  313. data/vendor/libgit2/src/streams/registry.c +5 -6
  314. data/vendor/libgit2/src/streams/socket.c +6 -2
  315. data/vendor/libgit2/src/streams/stransport.c +6 -3
  316. data/vendor/libgit2/src/streams/tls.c +5 -3
  317. data/vendor/libgit2/src/submodule.c +290 -212
  318. data/vendor/libgit2/src/submodule.h +10 -10
  319. data/vendor/libgit2/src/sysdir.c +70 -56
  320. data/vendor/libgit2/src/sysdir.h +15 -10
  321. data/vendor/libgit2/src/tag.c +72 -34
  322. data/vendor/libgit2/src/thread.c +140 -0
  323. data/vendor/libgit2/src/thread.h +479 -0
  324. data/vendor/libgit2/src/threadstate.c +84 -0
  325. data/vendor/libgit2/src/threadstate.h +24 -0
  326. data/vendor/libgit2/src/trace.c +3 -16
  327. data/vendor/libgit2/src/trace.h +17 -30
  328. data/vendor/libgit2/src/trailer.c +2 -2
  329. data/vendor/libgit2/src/transaction.c +20 -9
  330. data/vendor/libgit2/src/transport.c +13 -13
  331. data/vendor/libgit2/src/transports/auth.c +8 -10
  332. data/vendor/libgit2/src/transports/auth.h +2 -3
  333. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
  334. data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
  335. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  336. data/vendor/libgit2/src/transports/credential.c +15 -7
  337. data/vendor/libgit2/src/transports/git.c +10 -14
  338. data/vendor/libgit2/src/transports/http.c +56 -34
  339. data/vendor/libgit2/src/transports/http.h +3 -3
  340. data/vendor/libgit2/src/transports/httpclient.c +106 -79
  341. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  342. data/vendor/libgit2/src/transports/local.c +127 -119
  343. data/vendor/libgit2/src/transports/smart.c +61 -144
  344. data/vendor/libgit2/src/transports/smart.h +26 -32
  345. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  346. data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
  347. data/vendor/libgit2/src/transports/ssh.c +100 -131
  348. data/vendor/libgit2/src/transports/winhttp.c +86 -82
  349. data/vendor/libgit2/src/tree-cache.c +5 -5
  350. data/vendor/libgit2/src/tree-cache.h +2 -2
  351. data/vendor/libgit2/src/tree.c +150 -116
  352. data/vendor/libgit2/src/tree.h +1 -0
  353. data/vendor/libgit2/src/tsort.c +0 -2
  354. data/vendor/libgit2/src/unix/map.c +3 -3
  355. data/vendor/libgit2/src/unix/posix.h +1 -4
  356. data/vendor/libgit2/src/unix/pthread.h +2 -1
  357. data/vendor/libgit2/src/unix/realpath.c +0 -2
  358. data/vendor/libgit2/src/utf8.c +150 -0
  359. data/vendor/libgit2/src/utf8.h +52 -0
  360. data/vendor/libgit2/src/util.c +68 -144
  361. data/vendor/libgit2/src/util.h +36 -68
  362. data/vendor/libgit2/src/vector.c +23 -19
  363. data/vendor/libgit2/src/vector.h +5 -3
  364. data/vendor/libgit2/src/win32/findfile.c +172 -114
  365. data/vendor/libgit2/src/win32/findfile.h +7 -4
  366. data/vendor/libgit2/src/win32/map.c +1 -1
  367. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  368. data/vendor/libgit2/src/win32/path_w32.c +162 -33
  369. data/vendor/libgit2/src/win32/path_w32.h +2 -1
  370. data/vendor/libgit2/src/win32/posix.h +6 -7
  371. data/vendor/libgit2/src/win32/posix_w32.c +26 -33
  372. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  373. data/vendor/libgit2/src/win32/reparse.h +4 -4
  374. data/vendor/libgit2/src/win32/thread.c +24 -15
  375. data/vendor/libgit2/src/win32/thread.h +1 -1
  376. data/vendor/libgit2/src/win32/w32_buffer.c +5 -6
  377. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  378. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  379. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  380. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  381. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  382. data/vendor/libgit2/src/worktree.c +138 -105
  383. data/vendor/libgit2/src/worktree.h +1 -1
  384. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  385. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  386. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  387. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  388. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  389. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  390. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  391. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  392. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  393. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  394. data/vendor/libgit2/src/zstream.c +6 -6
  395. data/vendor/libgit2/src/zstream.h +4 -4
  396. metadata +60 -24
  397. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  398. data/vendor/libgit2/src/buf_text.c +0 -316
  399. data/vendor/libgit2/src/buf_text.h +0 -122
  400. data/vendor/libgit2/src/buffer.h +0 -222
  401. data/vendor/libgit2/src/global.c +0 -363
  402. data/vendor/libgit2/src/global.h +0 -41
  403. data/vendor/libgit2/src/thread-utils.c +0 -58
  404. data/vendor/libgit2/src/thread-utils.h +0 -369
  405. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  406. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  407. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -27,13 +27,13 @@ struct git_index {
27
27
 
28
28
  char *index_file_path;
29
29
  git_futils_filestamp stamp;
30
- git_oid checksum; /* checksum at the end of the file */
30
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
31
31
 
32
32
  git_vector entries;
33
33
  git_idxmap *entries_map;
34
34
 
35
35
  git_vector deleted; /* deleted entries if readers > 0 */
36
- git_atomic readers; /* number of active iterators */
36
+ git_atomic32 readers; /* number of active iterators */
37
37
 
38
38
  unsigned int on_disk:1;
39
39
  unsigned int ignore_case:1;
@@ -133,10 +133,13 @@ extern unsigned int git_index__create_mode(unsigned int mode);
133
133
 
134
134
  GIT_INLINE(const git_futils_filestamp *) git_index__filestamp(git_index *index)
135
135
  {
136
- return &index->stamp;
136
+ return &index->stamp;
137
137
  }
138
138
 
139
- extern int git_index__changed_relative_to(git_index *index, const git_oid *checksum);
139
+ GIT_INLINE(unsigned char *) git_index__checksum(git_index *index)
140
+ {
141
+ return index->checksum;
142
+ }
140
143
 
141
144
  /* Copy the current entries vector *and* increment the index refcount.
142
145
  * Call `git_index__release_snapshot` when done.
@@ -24,8 +24,6 @@
24
24
  #include "zstream.h"
25
25
  #include "object.h"
26
26
 
27
- extern git_mutex git__mwindow_mutex;
28
-
29
27
  size_t git_indexer__max_objects = UINT32_MAX;
30
28
 
31
29
  #define UINT31_MAX (0x7FFFFFFF)
@@ -50,14 +48,15 @@ struct git_indexer {
50
48
  off64_t off;
51
49
  off64_t entry_start;
52
50
  git_object_t entry_type;
53
- git_buf entry_data;
51
+ git_str entry_data;
54
52
  git_packfile_stream stream;
55
53
  size_t nr_objects;
56
54
  git_vector objects;
57
55
  git_vector deltas;
58
56
  unsigned int fanout[256];
59
57
  git_hash_ctx hash_ctx;
60
- git_oid hash;
58
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
59
+ char name[(GIT_HASH_SHA1_SIZE * 2) + 1];
61
60
  git_indexer_progress_cb progress_cb;
62
61
  void *progress_payload;
63
62
  char objbuf[8*1024];
@@ -78,9 +77,16 @@ struct delta_info {
78
77
  off64_t delta_off;
79
78
  };
80
79
 
80
+ #ifndef GIT_DEPRECATE_HARD
81
81
  const git_oid *git_indexer_hash(const git_indexer *idx)
82
82
  {
83
- return &idx->hash;
83
+ return (git_oid *)idx->checksum;
84
+ }
85
+ #endif
86
+
87
+ const char *git_indexer_name(const git_indexer *idx)
88
+ {
89
+ return idx->name;
84
90
  }
85
91
 
86
92
  static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack)
@@ -139,7 +145,7 @@ int git_indexer_new(
139
145
  {
140
146
  git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
141
147
  git_indexer *idx;
142
- git_buf path = GIT_BUF_INIT, tmp_path = GIT_BUF_INIT;
148
+ git_str path = GIT_STR_INIT, tmp_path = GIT_STR_INIT;
143
149
  static const char suff[] = "/pack";
144
150
  int error, fd = -1;
145
151
 
@@ -152,10 +158,10 @@ int git_indexer_new(
152
158
  idx->progress_cb = opts.progress_cb;
153
159
  idx->progress_payload = opts.progress_cb_payload;
154
160
  idx->mode = mode ? mode : GIT_PACK_FILE_MODE;
155
- git_buf_init(&idx->entry_data, 0);
161
+ git_str_init(&idx->entry_data, 0);
156
162
 
157
- if ((error = git_hash_ctx_init(&idx->hash_ctx)) < 0 ||
158
- (error = git_hash_ctx_init(&idx->trailer)) < 0 ||
163
+ if ((error = git_hash_ctx_init(&idx->hash_ctx, GIT_HASH_ALGORITHM_SHA1)) < 0 ||
164
+ (error = git_hash_ctx_init(&idx->trailer, GIT_HASH_ALGORITHM_SHA1)) < 0 ||
159
165
  (error = git_oidmap_new(&idx->expected_oids)) < 0)
160
166
  goto cleanup;
161
167
 
@@ -164,17 +170,17 @@ int git_indexer_new(
164
170
  if (git_repository__fsync_gitdir)
165
171
  idx->do_fsync = 1;
166
172
 
167
- error = git_buf_joinpath(&path, prefix, suff);
173
+ error = git_str_joinpath(&path, prefix, suff);
168
174
  if (error < 0)
169
175
  goto cleanup;
170
176
 
171
- fd = git_futils_mktmp(&tmp_path, git_buf_cstr(&path), idx->mode);
172
- git_buf_dispose(&path);
177
+ fd = git_futils_mktmp(&tmp_path, git_str_cstr(&path), idx->mode);
178
+ git_str_dispose(&path);
173
179
  if (fd < 0)
174
180
  goto cleanup;
175
181
 
176
- error = git_packfile_alloc(&idx->pack, git_buf_cstr(&tmp_path));
177
- git_buf_dispose(&tmp_path);
182
+ error = git_packfile_alloc(&idx->pack, git_str_cstr(&tmp_path));
183
+ git_str_dispose(&tmp_path);
178
184
 
179
185
  if (error < 0)
180
186
  goto cleanup;
@@ -190,14 +196,14 @@ cleanup:
190
196
  if (fd != -1)
191
197
  p_close(fd);
192
198
 
193
- if (git_buf_len(&tmp_path) > 0)
194
- p_unlink(git_buf_cstr(&tmp_path));
199
+ if (git_str_len(&tmp_path) > 0)
200
+ p_unlink(git_str_cstr(&tmp_path));
195
201
 
196
202
  if (idx->pack != NULL)
197
203
  p_unlink(idx->pack->pack_name);
198
204
 
199
- git_buf_dispose(&path);
200
- git_buf_dispose(&tmp_path);
205
+ git_str_dispose(&path);
206
+ git_str_dispose(&tmp_path);
201
207
  git__free(idx);
202
208
  return -1;
203
209
  }
@@ -239,14 +245,15 @@ static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream)
239
245
  {
240
246
  ssize_t read;
241
247
 
242
- assert(idx && stream);
248
+ GIT_ASSERT_ARG(idx);
249
+ GIT_ASSERT_ARG(stream);
243
250
 
244
251
  do {
245
252
  if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0)
246
253
  break;
247
254
 
248
255
  if (idx->do_verify)
249
- git_buf_put(&idx->entry_data, idx->objbuf, read);
256
+ git_str_put(&idx->entry_data, idx->objbuf, read);
250
257
 
251
258
  git_hash_update(&idx->hash_ctx, idx->objbuf, read);
252
259
  } while (read > 0);
@@ -262,7 +269,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
262
269
  {
263
270
  git_mwindow *w = NULL;
264
271
 
265
- assert(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
272
+ GIT_ASSERT_ARG(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
266
273
 
267
274
  if (type == GIT_OBJECT_REF_DELTA) {
268
275
  idx->off += GIT_OID_RAWSZ;
@@ -282,7 +289,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
282
289
  {
283
290
  ssize_t read;
284
291
 
285
- assert(stream);
292
+ GIT_ASSERT_ARG(stream);
286
293
 
287
294
  do {
288
295
  read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf));
@@ -341,7 +348,7 @@ static int check_object_connectivity(git_indexer *idx, const git_rawobj *obj)
341
348
  {
342
349
  git_object *object;
343
350
  git_oid *expected;
344
- int error;
351
+ int error = 0;
345
352
 
346
353
  if (obj->type != GIT_OBJECT_BLOB &&
347
354
  obj->type != GIT_OBJECT_TREE &&
@@ -349,8 +356,14 @@ static int check_object_connectivity(git_indexer *idx, const git_rawobj *obj)
349
356
  obj->type != GIT_OBJECT_TAG)
350
357
  return 0;
351
358
 
352
- if ((error = git_object__from_raw(&object, obj->data, obj->len, obj->type)) < 0)
359
+ if (git_object__from_raw(&object, obj->data, obj->len, obj->type) < 0) {
360
+ /*
361
+ * parse_raw returns EINVALID on invalid data; downgrade
362
+ * that to a normal -1 error code.
363
+ */
364
+ error = -1;
353
365
  goto out;
366
+ }
354
367
 
355
368
  if ((expected = git_oidmap_get(idx->expected_oids, &object->cached.oid)) != NULL) {
356
369
  git_oidmap_delete(idx->expected_oids, &object->cached.oid);
@@ -427,7 +440,7 @@ static int store_object(git_indexer *idx)
427
440
  pentry = git__calloc(1, sizeof(struct git_pack_entry));
428
441
  GIT_ERROR_CHECK_ALLOC(pentry);
429
442
 
430
- if (git_hash_final(&oid, &idx->hash_ctx)) {
443
+ if (git_hash_final(oid.id, &idx->hash_ctx)) {
431
444
  git__free(pentry);
432
445
  goto on_error;
433
446
  }
@@ -602,9 +615,10 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
602
615
  idx->inbuf_len += size - to_expell;
603
616
  }
604
617
 
618
+ #if defined(NO_MMAP) || !defined(GIT_WIN32)
619
+
605
620
  static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
606
621
  {
607
- #ifdef NO_MMAP
608
622
  size_t remaining_size = size;
609
623
  const char *ptr = (const char *)data;
610
624
 
@@ -620,7 +634,31 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
620
634
  offset += nb;
621
635
  remaining_size -= nb;
622
636
  }
637
+
638
+ return 0;
639
+ }
640
+
641
+ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
642
+ {
643
+ if (write_at(idx, data, idx->pack->mwf.size, size) < 0) {
644
+ git_error_set(GIT_ERROR_OS, "cannot extend packfile '%s'", idx->pack->pack_name);
645
+ return -1;
646
+ }
647
+
648
+ return 0;
649
+ }
650
+
623
651
  #else
652
+
653
+ /*
654
+ * Windows may keep different views to a networked file for the mmap- and
655
+ * open-accessed versions of a file, so any writes done through
656
+ * `write(2)`/`pwrite(2)` may not be reflected on the data that `mmap(2)` is
657
+ * able to read.
658
+ */
659
+
660
+ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
661
+ {
624
662
  git_file fd = idx->pack->mwf.fd;
625
663
  size_t mmap_alignment;
626
664
  size_t page_offset;
@@ -629,7 +667,8 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
629
667
  git_map map;
630
668
  int error;
631
669
 
632
- assert(data && size);
670
+ GIT_ASSERT_ARG(data);
671
+ GIT_ASSERT_ARG(size);
633
672
 
634
673
  if ((error = git__mmap_alignment(&mmap_alignment)) < 0)
635
674
  return error;
@@ -644,7 +683,6 @@ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t s
644
683
  map_data = (unsigned char *)map.data;
645
684
  memcpy(map_data + page_offset, data, size);
646
685
  p_munmap(&map);
647
- #endif
648
686
 
649
687
  return 0;
650
688
  }
@@ -680,6 +718,8 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
680
718
  return write_at(idx, data, idx->pack->mwf.size, size);
681
719
  }
682
720
 
721
+ #endif
722
+
683
723
  static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
684
724
  {
685
725
  git_packfile_stream *stream = &idx->stream;
@@ -693,7 +733,7 @@ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
693
733
  return GIT_EBUFS;
694
734
 
695
735
  if (!idx->have_stream) {
696
- error = git_packfile_unpack_header(&entry_size, &type, &idx->pack->mwf, &w, &idx->off);
736
+ error = git_packfile_unpack_header(&entry_size, &type, idx->pack, &w, &idx->off);
697
737
  if (error == GIT_EBUFS) {
698
738
  idx->off = entry_start;
699
739
  return error;
@@ -704,7 +744,7 @@ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
704
744
  git_mwindow_close(&w);
705
745
  idx->entry_start = entry_start;
706
746
  git_hash_init(&idx->hash_ctx);
707
- git_buf_clear(&idx->entry_data);
747
+ git_str_clear(&idx->entry_data);
708
748
 
709
749
  if (type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA) {
710
750
  error = advance_delta_offset(idx, type);
@@ -775,7 +815,9 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
775
815
  struct git_pack_header *hdr = &idx->hdr;
776
816
  git_mwindow_file *mwf = &idx->pack->mwf;
777
817
 
778
- assert(idx && data && stats);
818
+ GIT_ASSERT_ARG(idx);
819
+ GIT_ASSERT_ARG(data);
820
+ GIT_ASSERT_ARG(stats);
779
821
 
780
822
  if ((error = append_to_pack(idx, data, size)) < 0)
781
823
  return error;
@@ -829,7 +871,8 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_inde
829
871
  /* Now that we have data in the pack, let's try to parse it */
830
872
 
831
873
  /* As the file grows any windows we try to use will be out of date */
832
- git_mwindow_free_all(mwf);
874
+ if ((error = git_mwindow_free_all(mwf)) < 0)
875
+ goto on_error;
833
876
 
834
877
  while (stats->indexed_objects < idx->nr_objects) {
835
878
  if ((error = read_stream_object(idx, stats)) != 0) {
@@ -847,7 +890,7 @@ on_error:
847
890
  return error;
848
891
  }
849
892
 
850
- static int index_path(git_buf *path, git_indexer *idx, const char *suffix)
893
+ static int index_path(git_str *path, git_indexer *idx, const char *suffix)
851
894
  {
852
895
  const char prefix[] = "pack-";
853
896
  size_t slash = (size_t)path->size;
@@ -856,48 +899,50 @@ static int index_path(git_buf *path, git_indexer *idx, const char *suffix)
856
899
  while (slash > 0 && path->ptr[slash - 1] != '/')
857
900
  slash--;
858
901
 
859
- if (git_buf_grow(path, slash + 1 + strlen(prefix) +
902
+ if (git_str_grow(path, slash + 1 + strlen(prefix) +
860
903
  GIT_OID_HEXSZ + strlen(suffix) + 1) < 0)
861
904
  return -1;
862
905
 
863
- git_buf_truncate(path, slash);
864
- git_buf_puts(path, prefix);
865
- git_oid_fmt(path->ptr + git_buf_len(path), &idx->hash);
866
- path->size += GIT_OID_HEXSZ;
867
- git_buf_puts(path, suffix);
906
+ git_str_truncate(path, slash);
907
+ git_str_puts(path, prefix);
908
+ git_str_puts(path, idx->name);
909
+ git_str_puts(path, suffix);
868
910
 
869
- return git_buf_oom(path) ? -1 : 0;
911
+ return git_str_oom(path) ? -1 : 0;
870
912
  }
871
913
 
872
914
  /**
873
915
  * Rewind the packfile by the trailer, as we might need to fix the
874
916
  * packfile by injecting objects at the tail and must overwrite it.
875
917
  */
876
- static void seek_back_trailer(git_indexer *idx)
918
+ static int seek_back_trailer(git_indexer *idx)
877
919
  {
878
920
  idx->pack->mwf.size -= GIT_OID_RAWSZ;
879
- git_mwindow_free_all(&idx->pack->mwf);
921
+ return git_mwindow_free_all(&idx->pack->mwf);
880
922
  }
881
923
 
882
924
  static int inject_object(git_indexer *idx, git_oid *id)
883
925
  {
884
- git_odb_object *obj;
885
- struct entry *entry;
926
+ git_odb_object *obj = NULL;
927
+ struct entry *entry = NULL;
886
928
  struct git_pack_entry *pentry = NULL;
887
- git_oid foo = {{0}};
929
+ unsigned char empty_checksum[GIT_HASH_SHA1_SIZE] = {0};
888
930
  unsigned char hdr[64];
889
- git_buf buf = GIT_BUF_INIT;
931
+ git_str buf = GIT_STR_INIT;
890
932
  off64_t entry_start;
891
933
  const void *data;
892
934
  size_t len, hdr_len;
935
+ size_t checksum_size = GIT_HASH_SHA1_SIZE;
893
936
  int error;
894
937
 
895
- seek_back_trailer(idx);
938
+ if ((error = seek_back_trailer(idx)) < 0)
939
+ goto cleanup;
940
+
896
941
  entry_start = idx->pack->mwf.size;
897
942
 
898
- if (git_odb_read(&obj, idx->odb, id) < 0) {
943
+ if ((error = git_odb_read(&obj, idx->odb, id)) < 0) {
899
944
  git_error_set(GIT_ERROR_INDEXER, "missing delta bases");
900
- return -1;
945
+ goto cleanup;
901
946
  }
902
947
 
903
948
  data = git_odb_object_data(obj);
@@ -909,8 +954,8 @@ static int inject_object(git_indexer *idx, git_oid *id)
909
954
  entry->crc = crc32(0L, Z_NULL, 0);
910
955
 
911
956
  /* Write out the object header */
912
- hdr_len = git_packfile__object_header(hdr, len, git_odb_object_type(obj));
913
- if ((error = append_to_pack(idx, hdr, hdr_len)) < 0)
957
+ if ((error = git_packfile__object_header(&hdr_len, hdr, len, git_odb_object_type(obj))) < 0 ||
958
+ (error = append_to_pack(idx, hdr, hdr_len)) < 0)
914
959
  goto cleanup;
915
960
 
916
961
  idx->pack->mwf.size += hdr_len;
@@ -925,11 +970,11 @@ static int inject_object(git_indexer *idx, git_oid *id)
925
970
 
926
971
  idx->pack->mwf.size += buf.size;
927
972
  entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, (uInt)buf.size));
928
- git_buf_dispose(&buf);
973
+ git_str_dispose(&buf);
929
974
 
930
975
  /* Write a fake trailer so the pack functions play ball */
931
976
 
932
- if ((error = append_to_pack(idx, &foo, GIT_OID_RAWSZ)) < 0)
977
+ if ((error = append_to_pack(idx, empty_checksum, checksum_size)) < 0)
933
978
  goto cleanup;
934
979
 
935
980
  idx->pack->mwf.size += GIT_OID_RAWSZ;
@@ -966,7 +1011,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
966
1011
  unsigned int left = 0;
967
1012
  git_oid base;
968
1013
 
969
- assert(git_vector_length(&idx->deltas) > 0);
1014
+ GIT_ASSERT(git_vector_length(&idx->deltas) > 0);
970
1015
 
971
1016
  if (idx->odb == NULL) {
972
1017
  git_error_set(GIT_ERROR_INDEXER, "cannot fix a thin pack without an ODB");
@@ -979,7 +1024,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
979
1024
  continue;
980
1025
 
981
1026
  curpos = delta->delta_off;
982
- error = git_packfile_unpack_header(&size, &type, &idx->pack->mwf, &w, &curpos);
1027
+ error = git_packfile_unpack_header(&size, &type, idx->pack, &w, &curpos);
983
1028
  if (error < 0)
984
1029
  return error;
985
1030
 
@@ -1086,7 +1131,7 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
1086
1131
  git_hash_init(&idx->trailer);
1087
1132
 
1088
1133
 
1089
- /* Update the header to include the numer of local objects we injected */
1134
+ /* Update the header to include the number of local objects we injected */
1090
1135
  idx->hdr.hdr_entries = htonl(stats->total_objects + stats->local_objects);
1091
1136
  if (write_at(idx, &idx->hdr, 0, sizeof(struct git_pack_header)) < 0)
1092
1137
  return -1;
@@ -1097,7 +1142,9 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
1097
1142
  * hash_partially() keep the existing trailer out of the
1098
1143
  * calculation.
1099
1144
  */
1100
- git_mwindow_free_all(mwf);
1145
+ if (git_mwindow_free_all(mwf) < 0)
1146
+ return -1;
1147
+
1101
1148
  idx->inbuf_len = 0;
1102
1149
  while (hashed < mwf->size) {
1103
1150
  ptr = git_mwindow_open(mwf, &w, hashed, chunk, &left);
@@ -1119,11 +1166,13 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1119
1166
  unsigned int i, long_offsets = 0, left;
1120
1167
  int error;
1121
1168
  struct git_pack_idx_header hdr;
1122
- git_buf filename = GIT_BUF_INIT;
1169
+ git_str filename = GIT_STR_INIT;
1123
1170
  struct entry *entry;
1124
- git_oid trailer_hash, file_hash;
1171
+ unsigned char checksum[GIT_HASH_SHA1_SIZE];
1125
1172
  git_filebuf index_file = {0};
1126
1173
  void *packfile_trailer;
1174
+ size_t checksum_size = GIT_HASH_SHA1_SIZE;
1175
+ bool mismatch;
1127
1176
 
1128
1177
  if (!idx->parsed_header) {
1129
1178
  git_error_set(GIT_ERROR_INDEXER, "incomplete pack header");
@@ -1131,27 +1180,27 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1131
1180
  }
1132
1181
 
1133
1182
  /* Test for this before resolve_deltas(), as it plays with idx->off */
1134
- if (idx->off + 20 < idx->pack->mwf.size) {
1183
+ if (idx->off + (ssize_t)checksum_size < idx->pack->mwf.size) {
1135
1184
  git_error_set(GIT_ERROR_INDEXER, "unexpected data at the end of the pack");
1136
1185
  return -1;
1137
1186
  }
1138
- if (idx->off + 20 > idx->pack->mwf.size) {
1187
+ if (idx->off + (ssize_t)checksum_size > idx->pack->mwf.size) {
1139
1188
  git_error_set(GIT_ERROR_INDEXER, "missing trailer at the end of the pack");
1140
1189
  return -1;
1141
1190
  }
1142
1191
 
1143
- packfile_trailer = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left);
1192
+ packfile_trailer = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - checksum_size, checksum_size, &left);
1144
1193
  if (packfile_trailer == NULL) {
1145
1194
  git_mwindow_close(&w);
1146
1195
  goto on_error;
1147
1196
  }
1148
1197
 
1149
1198
  /* Compare the packfile trailer as it was sent to us and what we calculated */
1150
- git_oid_fromraw(&file_hash, packfile_trailer);
1199
+ git_hash_final(checksum, &idx->trailer);
1200
+ mismatch = !!memcmp(checksum, packfile_trailer, checksum_size);
1151
1201
  git_mwindow_close(&w);
1152
1202
 
1153
- git_hash_final(&trailer_hash, &idx->trailer);
1154
- if (git_oid_cmp(&file_hash, &trailer_hash)) {
1203
+ if (mismatch) {
1155
1204
  git_error_set(GIT_ERROR_INDEXER, "packfile trailer mismatch");
1156
1205
  return -1;
1157
1206
  }
@@ -1171,8 +1220,8 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1171
1220
  if (update_header_and_rehash(idx, stats) < 0)
1172
1221
  return -1;
1173
1222
 
1174
- git_hash_final(&trailer_hash, &idx->trailer);
1175
- write_at(idx, &trailer_hash, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ);
1223
+ git_hash_final(checksum, &idx->trailer);
1224
+ write_at(idx, checksum, idx->pack->mwf.size - checksum_size, checksum_size);
1176
1225
  }
1177
1226
 
1178
1227
  /*
@@ -1191,12 +1240,14 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1191
1240
 
1192
1241
  /* Use the trailer hash as the pack file name to ensure
1193
1242
  * files with different contents have different names */
1194
- git_oid_cpy(&idx->hash, &trailer_hash);
1243
+ memcpy(idx->checksum, checksum, checksum_size);
1244
+ if (git_hash_fmt(idx->name, checksum, checksum_size) < 0)
1245
+ return -1;
1195
1246
 
1196
- git_buf_sets(&filename, idx->pack->pack_name);
1197
- git_buf_shorten(&filename, strlen("pack"));
1198
- git_buf_puts(&filename, "idx");
1199
- if (git_buf_oom(&filename))
1247
+ git_str_sets(&filename, idx->pack->pack_name);
1248
+ git_str_shorten(&filename, strlen("pack"));
1249
+ git_str_puts(&filename, "idx");
1250
+ if (git_str_oom(&filename))
1200
1251
  return -1;
1201
1252
 
1202
1253
  if (git_filebuf_open(&index_file, filename.ptr,
@@ -1252,14 +1303,14 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1252
1303
  }
1253
1304
 
1254
1305
  /* Write out the packfile trailer to the index */
1255
- if (git_filebuf_write(&index_file, &trailer_hash, GIT_OID_RAWSZ) < 0)
1306
+ if (git_filebuf_write(&index_file, checksum, checksum_size) < 0)
1256
1307
  goto on_error;
1257
1308
 
1258
1309
  /* Write out the hash of the idx */
1259
- if (git_filebuf_hash(&trailer_hash, &index_file) < 0)
1310
+ if (git_filebuf_hash(checksum, &index_file) < 0)
1260
1311
  goto on_error;
1261
1312
 
1262
- git_filebuf_write(&index_file, &trailer_hash, sizeof(git_oid));
1313
+ git_filebuf_write(&index_file, checksum, checksum_size);
1263
1314
 
1264
1315
  /* Figure out what the final name should be */
1265
1316
  if (index_path(&filename, idx, ".idx") < 0)
@@ -1269,13 +1320,22 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1269
1320
  if (git_filebuf_commit_at(&index_file, filename.ptr) < 0)
1270
1321
  goto on_error;
1271
1322
 
1272
- git_mwindow_free_all(&idx->pack->mwf);
1323
+ if (git_mwindow_free_all(&idx->pack->mwf) < 0)
1324
+ goto on_error;
1273
1325
 
1274
- /* Truncate file to undo rounding up to next page_size in append_to_pack */
1326
+ #if !defined(NO_MMAP) && defined(GIT_WIN32)
1327
+ /*
1328
+ * Some non-Windows remote filesystems fail when truncating files if the
1329
+ * file permissions change after opening the file (done by p_mkstemp).
1330
+ *
1331
+ * Truncation is only needed when mmap is used to undo rounding up to next
1332
+ * page_size in append_to_pack.
1333
+ */
1275
1334
  if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
1276
1335
  git_error_set(GIT_ERROR_OS, "failed to truncate pack file '%s'", idx->pack->pack_name);
1277
1336
  return -1;
1278
1337
  }
1338
+ #endif
1279
1339
 
1280
1340
  if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) {
1281
1341
  git_error_set(GIT_ERROR_OS, "failed to fsync packfile");
@@ -1294,23 +1354,23 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
1294
1354
  goto on_error;
1295
1355
 
1296
1356
  /* And don't forget to rename the packfile to its new place. */
1297
- if (p_rename(idx->pack->pack_name, git_buf_cstr(&filename)) < 0)
1357
+ if (p_rename(idx->pack->pack_name, git_str_cstr(&filename)) < 0)
1298
1358
  goto on_error;
1299
1359
 
1300
1360
  /* And fsync the parent directory if we're asked to. */
1301
1361
  if (idx->do_fsync &&
1302
- git_futils_fsync_parent(git_buf_cstr(&filename)) < 0)
1362
+ git_futils_fsync_parent(git_str_cstr(&filename)) < 0)
1303
1363
  goto on_error;
1304
1364
 
1305
1365
  idx->pack_committed = 1;
1306
1366
 
1307
- git_buf_dispose(&filename);
1367
+ git_str_dispose(&filename);
1308
1368
  return 0;
1309
1369
 
1310
1370
  on_error:
1311
1371
  git_mwindow_free_all(&idx->pack->mwf);
1312
1372
  git_filebuf_cleanup(&index_file);
1313
- git_buf_dispose(&filename);
1373
+ git_str_dispose(&filename);
1314
1374
  return -1;
1315
1375
  }
1316
1376
 
@@ -1339,13 +1399,7 @@ void git_indexer_free(git_indexer *idx)
1339
1399
 
1340
1400
  git_vector_free_deep(&idx->deltas);
1341
1401
 
1342
- if (!git_mutex_lock(&git__mwindow_mutex)) {
1343
- if (!idx->pack_committed)
1344
- git_packfile_close(idx->pack, true);
1345
-
1346
- git_packfile_free(idx->pack);
1347
- git_mutex_unlock(&git__mwindow_mutex);
1348
- }
1402
+ git_packfile_free(idx->pack, !idx->pack_committed);
1349
1403
 
1350
1404
  iter = 0;
1351
1405
  while (git_oidmap_iterate((void **) &value, idx->expected_oids, &iter, &key) == 0)
@@ -1353,7 +1407,7 @@ void git_indexer_free(git_indexer *idx)
1353
1407
 
1354
1408
  git_hash_ctx_cleanup(&idx->trailer);
1355
1409
  git_hash_ctx_cleanup(&idx->hash_ctx);
1356
- git_buf_dispose(&idx->entry_data);
1410
+ git_str_dispose(&idx->entry_data);
1357
1411
  git_oidmap_free(idx->expected_oids);
1358
1412
  git__free(idx);
1359
1413
  }