rugged 0.27.7 → 0.27.10

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 (409) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +1 -0
  4. data/vendor/libgit2/CMakeLists.txt +99 -51
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  7. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
  8. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
  9. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +9 -8
  10. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  11. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  12. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  13. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
  14. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  15. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  16. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  17. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  18. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  19. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  20. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  21. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  22. data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
  23. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
  24. data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
  25. data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
  26. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
  27. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
  28. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
  29. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
  30. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
  31. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
  32. data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
  33. data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
  34. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
  35. data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
  36. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
  37. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
  38. data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
  39. data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
  40. data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
  42. data/vendor/libgit2/deps/pcre/COPYING +5 -0
  43. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  44. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
  45. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  46. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
  47. data/vendor/libgit2/deps/pcre/config.h.in +57 -0
  48. data/vendor/libgit2/deps/pcre/pcre.h +641 -0
  49. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
  50. data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
  51. data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
  52. data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
  53. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
  54. data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
  55. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
  56. data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
  57. data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
  58. data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
  59. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
  60. data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
  61. data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
  62. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
  63. data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
  64. data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
  65. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
  66. data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
  67. data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
  68. data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
  69. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
  70. data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
  71. data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
  72. data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
  73. data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
  74. data/vendor/libgit2/deps/pcre/ucp.h +224 -0
  75. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  76. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  77. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  78. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  79. data/vendor/libgit2/deps/zlib/adler32.c +0 -7
  80. data/vendor/libgit2/deps/zlib/crc32.c +0 -7
  81. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  82. data/vendor/libgit2/include/git2/apply.h +149 -0
  83. data/vendor/libgit2/include/git2/attr.h +20 -13
  84. data/vendor/libgit2/include/git2/blame.h +4 -4
  85. data/vendor/libgit2/include/git2/blob.h +44 -12
  86. data/vendor/libgit2/include/git2/buffer.h +20 -26
  87. data/vendor/libgit2/include/git2/cert.h +135 -0
  88. data/vendor/libgit2/include/git2/checkout.h +53 -21
  89. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  90. data/vendor/libgit2/include/git2/clone.h +5 -5
  91. data/vendor/libgit2/include/git2/commit.h +25 -3
  92. data/vendor/libgit2/include/git2/common.h +35 -10
  93. data/vendor/libgit2/include/git2/config.h +29 -19
  94. data/vendor/libgit2/include/git2/cred.h +308 -0
  95. data/vendor/libgit2/include/git2/deprecated.h +493 -0
  96. data/vendor/libgit2/include/git2/describe.h +4 -4
  97. data/vendor/libgit2/include/git2/diff.h +177 -135
  98. data/vendor/libgit2/include/git2/errors.h +53 -46
  99. data/vendor/libgit2/include/git2/filter.h +8 -0
  100. data/vendor/libgit2/include/git2/index.h +74 -52
  101. data/vendor/libgit2/include/git2/indexer.h +76 -6
  102. data/vendor/libgit2/include/git2/merge.h +25 -10
  103. data/vendor/libgit2/include/git2/net.h +0 -5
  104. data/vendor/libgit2/include/git2/notes.h +1 -1
  105. data/vendor/libgit2/include/git2/object.h +17 -29
  106. data/vendor/libgit2/include/git2/odb.h +12 -11
  107. data/vendor/libgit2/include/git2/odb_backend.h +10 -9
  108. data/vendor/libgit2/include/git2/oid.h +2 -2
  109. data/vendor/libgit2/include/git2/pack.h +14 -3
  110. data/vendor/libgit2/include/git2/proxy.h +5 -3
  111. data/vendor/libgit2/include/git2/rebase.h +46 -2
  112. data/vendor/libgit2/include/git2/refs.h +34 -16
  113. data/vendor/libgit2/include/git2/remote.h +111 -14
  114. data/vendor/libgit2/include/git2/repository.h +69 -34
  115. data/vendor/libgit2/include/git2/revert.h +1 -1
  116. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  117. data/vendor/libgit2/include/git2/signature.h +2 -2
  118. data/vendor/libgit2/include/git2/stash.h +5 -5
  119. data/vendor/libgit2/include/git2/status.h +26 -17
  120. data/vendor/libgit2/include/git2/submodule.h +23 -6
  121. data/vendor/libgit2/include/git2/sys/alloc.h +18 -18
  122. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  123. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  124. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  125. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  126. data/vendor/libgit2/include/git2/sys/merge.h +3 -3
  127. data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -22
  128. data/vendor/libgit2/include/git2/sys/path.h +14 -5
  129. data/vendor/libgit2/include/git2/sys/refdb_backend.h +76 -40
  130. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  131. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  132. data/vendor/libgit2/include/git2/sys/transport.h +129 -83
  133. data/vendor/libgit2/include/git2/tag.h +13 -4
  134. data/vendor/libgit2/include/git2/trace.h +2 -2
  135. data/vendor/libgit2/include/git2/transport.h +11 -311
  136. data/vendor/libgit2/include/git2/tree.h +4 -4
  137. data/vendor/libgit2/include/git2/types.h +25 -106
  138. data/vendor/libgit2/include/git2/version.h +3 -3
  139. data/vendor/libgit2/include/git2/worktree.h +5 -5
  140. data/vendor/libgit2/include/git2.h +4 -0
  141. data/vendor/libgit2/src/CMakeLists.txt +104 -235
  142. data/vendor/libgit2/src/alloc.c +14 -18
  143. data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +7 -8
  144. data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
  145. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  146. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  147. data/vendor/libgit2/src/annotated_commit.c +18 -11
  148. data/vendor/libgit2/src/apply.c +535 -28
  149. data/vendor/libgit2/src/apply.h +3 -1
  150. data/vendor/libgit2/src/array.h +2 -2
  151. data/vendor/libgit2/src/attr.c +77 -71
  152. data/vendor/libgit2/src/attr_file.c +203 -117
  153. data/vendor/libgit2/src/attr_file.h +9 -9
  154. data/vendor/libgit2/src/attrcache.c +49 -51
  155. data/vendor/libgit2/src/attrcache.h +2 -1
  156. data/vendor/libgit2/src/blame.c +38 -18
  157. data/vendor/libgit2/src/blame.h +1 -1
  158. data/vendor/libgit2/src/blame_git.c +29 -15
  159. data/vendor/libgit2/src/blob.c +123 -37
  160. data/vendor/libgit2/src/blob.h +19 -2
  161. data/vendor/libgit2/src/branch.c +47 -23
  162. data/vendor/libgit2/src/buf_text.c +7 -6
  163. data/vendor/libgit2/src/buffer.c +60 -53
  164. data/vendor/libgit2/src/cache.c +38 -45
  165. data/vendor/libgit2/src/cache.h +3 -3
  166. data/vendor/libgit2/src/cc-compat.h +20 -3
  167. data/vendor/libgit2/src/checkout.c +77 -67
  168. data/vendor/libgit2/src/cherrypick.c +12 -6
  169. data/vendor/libgit2/src/clone.c +36 -14
  170. data/vendor/libgit2/src/clone.h +4 -0
  171. data/vendor/libgit2/src/commit.c +103 -48
  172. data/vendor/libgit2/src/commit.h +7 -0
  173. data/vendor/libgit2/src/commit_list.c +36 -78
  174. data/vendor/libgit2/src/commit_list.h +2 -2
  175. data/vendor/libgit2/src/common.h +24 -90
  176. data/vendor/libgit2/src/config.c +203 -176
  177. data/vendor/libgit2/src/config.h +8 -20
  178. data/vendor/libgit2/src/config_backend.h +96 -0
  179. data/vendor/libgit2/src/config_cache.c +41 -35
  180. data/vendor/libgit2/src/config_entries.c +229 -0
  181. data/vendor/libgit2/src/config_entries.h +24 -0
  182. data/vendor/libgit2/src/config_file.c +422 -680
  183. data/vendor/libgit2/src/config_mem.c +220 -0
  184. data/vendor/libgit2/src/config_parse.c +96 -68
  185. data/vendor/libgit2/src/config_parse.h +15 -14
  186. data/vendor/libgit2/src/config_snapshot.c +206 -0
  187. data/vendor/libgit2/src/crlf.c +219 -196
  188. data/vendor/libgit2/src/delta.c +25 -18
  189. data/vendor/libgit2/src/describe.c +42 -41
  190. data/vendor/libgit2/src/diff.c +52 -67
  191. data/vendor/libgit2/src/diff.h +2 -1
  192. data/vendor/libgit2/src/diff_driver.c +44 -46
  193. data/vendor/libgit2/src/diff_file.c +16 -14
  194. data/vendor/libgit2/src/diff_file.h +1 -1
  195. data/vendor/libgit2/src/diff_generate.c +158 -103
  196. data/vendor/libgit2/src/diff_generate.h +3 -3
  197. data/vendor/libgit2/src/diff_parse.c +4 -4
  198. data/vendor/libgit2/src/diff_print.c +34 -22
  199. data/vendor/libgit2/src/diff_stats.c +22 -7
  200. data/vendor/libgit2/src/diff_tform.c +18 -16
  201. data/vendor/libgit2/src/diff_xdiff.c +3 -3
  202. data/vendor/libgit2/src/errors.c +51 -39
  203. data/vendor/libgit2/src/errors.h +81 -0
  204. data/vendor/libgit2/src/features.h.in +9 -3
  205. data/vendor/libgit2/src/fetch.c +8 -3
  206. data/vendor/libgit2/src/fetchhead.c +12 -12
  207. data/vendor/libgit2/src/filebuf.c +28 -32
  208. data/vendor/libgit2/src/filebuf.h +2 -2
  209. data/vendor/libgit2/src/filter.c +47 -33
  210. data/vendor/libgit2/src/filter.h +0 -10
  211. data/vendor/libgit2/src/{fileops.c → futils.c} +70 -63
  212. data/vendor/libgit2/src/{fileops.h → futils.h} +6 -6
  213. data/vendor/libgit2/src/global.c +35 -55
  214. data/vendor/libgit2/src/global.h +0 -2
  215. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +48 -0
  216. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  217. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +17 -17
  218. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  219. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  220. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -10
  221. data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
  222. data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -7
  223. data/vendor/libgit2/src/hash/sha1/openssl.c +59 -0
  224. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  225. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  226. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +47 -37
  227. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  228. data/vendor/libgit2/src/hash/sha1.h +38 -0
  229. data/vendor/libgit2/src/hash.c +61 -0
  230. data/vendor/libgit2/src/hash.h +20 -21
  231. data/vendor/libgit2/src/hashsig.c +5 -5
  232. data/vendor/libgit2/src/idxmap.c +107 -61
  233. data/vendor/libgit2/src/idxmap.h +153 -31
  234. data/vendor/libgit2/src/ignore.c +38 -42
  235. data/vendor/libgit2/src/index.c +264 -199
  236. data/vendor/libgit2/src/index.h +7 -1
  237. data/vendor/libgit2/src/indexer.c +338 -167
  238. data/vendor/libgit2/src/integer.h +71 -26
  239. data/vendor/libgit2/src/iterator.c +134 -62
  240. data/vendor/libgit2/src/iterator.h +15 -0
  241. data/vendor/libgit2/src/mailmap.c +8 -8
  242. data/vendor/libgit2/src/map.h +1 -1
  243. data/vendor/libgit2/src/merge.c +137 -93
  244. data/vendor/libgit2/src/merge_driver.c +11 -11
  245. data/vendor/libgit2/src/merge_file.c +2 -2
  246. data/vendor/libgit2/src/mwindow.c +24 -29
  247. data/vendor/libgit2/src/mwindow.h +4 -4
  248. data/vendor/libgit2/src/net.c +184 -0
  249. data/vendor/libgit2/src/net.h +36 -0
  250. data/vendor/libgit2/src/netops.c +55 -156
  251. data/vendor/libgit2/src/netops.h +3 -23
  252. data/vendor/libgit2/src/notes.c +14 -9
  253. data/vendor/libgit2/src/object.c +120 -69
  254. data/vendor/libgit2/src/object.h +22 -9
  255. data/vendor/libgit2/src/object_api.c +8 -8
  256. data/vendor/libgit2/src/odb.c +111 -88
  257. data/vendor/libgit2/src/odb.h +8 -7
  258. data/vendor/libgit2/src/odb_loose.c +58 -47
  259. data/vendor/libgit2/src/odb_mempack.c +21 -34
  260. data/vendor/libgit2/src/odb_pack.c +17 -13
  261. data/vendor/libgit2/src/offmap.c +53 -35
  262. data/vendor/libgit2/src/offmap.h +108 -21
  263. data/vendor/libgit2/src/oid.c +12 -7
  264. data/vendor/libgit2/src/oidmap.c +49 -47
  265. data/vendor/libgit2/src/oidmap.h +101 -24
  266. data/vendor/libgit2/src/pack-objects.c +87 -86
  267. data/vendor/libgit2/src/pack-objects.h +2 -8
  268. data/vendor/libgit2/src/pack.c +94 -96
  269. data/vendor/libgit2/src/pack.h +16 -18
  270. data/vendor/libgit2/src/parse.c +17 -4
  271. data/vendor/libgit2/src/parse.h +3 -3
  272. data/vendor/libgit2/src/patch.c +3 -3
  273. data/vendor/libgit2/src/patch_generate.c +18 -18
  274. data/vendor/libgit2/src/patch_parse.c +147 -79
  275. data/vendor/libgit2/src/path.c +207 -62
  276. data/vendor/libgit2/src/path.h +14 -0
  277. data/vendor/libgit2/src/pathspec.c +18 -18
  278. data/vendor/libgit2/src/pool.c +26 -22
  279. data/vendor/libgit2/src/pool.h +7 -7
  280. data/vendor/libgit2/src/posix.c +10 -10
  281. data/vendor/libgit2/src/posix.h +12 -1
  282. data/vendor/libgit2/src/proxy.c +8 -3
  283. data/vendor/libgit2/src/push.c +35 -29
  284. data/vendor/libgit2/src/push.h +2 -1
  285. data/vendor/libgit2/src/reader.c +265 -0
  286. data/vendor/libgit2/src/reader.h +107 -0
  287. data/vendor/libgit2/src/rebase.c +97 -38
  288. data/vendor/libgit2/src/refdb.c +15 -3
  289. data/vendor/libgit2/src/refdb_fs.c +318 -222
  290. data/vendor/libgit2/src/reflog.c +13 -15
  291. data/vendor/libgit2/src/refs.c +122 -89
  292. data/vendor/libgit2/src/refs.h +5 -3
  293. data/vendor/libgit2/src/refspec.c +27 -33
  294. data/vendor/libgit2/src/regexp.c +221 -0
  295. data/vendor/libgit2/src/regexp.h +97 -0
  296. data/vendor/libgit2/src/remote.c +229 -178
  297. data/vendor/libgit2/src/remote.h +11 -2
  298. data/vendor/libgit2/src/repository.c +227 -172
  299. data/vendor/libgit2/src/repository.h +52 -40
  300. data/vendor/libgit2/src/reset.c +7 -7
  301. data/vendor/libgit2/src/revert.c +11 -6
  302. data/vendor/libgit2/src/revparse.c +46 -46
  303. data/vendor/libgit2/src/revwalk.c +89 -54
  304. data/vendor/libgit2/src/revwalk.h +20 -0
  305. data/vendor/libgit2/src/settings.c +22 -9
  306. data/vendor/libgit2/src/signature.c +15 -13
  307. data/vendor/libgit2/src/sortedcache.c +22 -36
  308. data/vendor/libgit2/src/sortedcache.h +1 -1
  309. data/vendor/libgit2/src/stash.c +56 -76
  310. data/vendor/libgit2/src/status.c +27 -21
  311. data/vendor/libgit2/src/stream.h +17 -2
  312. data/vendor/libgit2/src/streams/mbedtls.c +100 -80
  313. data/vendor/libgit2/src/streams/mbedtls.h +5 -2
  314. data/vendor/libgit2/src/streams/openssl.c +93 -81
  315. data/vendor/libgit2/src/streams/openssl.h +5 -2
  316. data/vendor/libgit2/src/streams/registry.c +118 -0
  317. data/vendor/libgit2/src/streams/registry.h +19 -0
  318. data/vendor/libgit2/src/streams/socket.c +55 -30
  319. data/vendor/libgit2/src/streams/stransport.c +57 -32
  320. data/vendor/libgit2/src/streams/stransport.h +5 -0
  321. data/vendor/libgit2/src/streams/tls.c +48 -20
  322. data/vendor/libgit2/src/streams/tls.h +12 -4
  323. data/vendor/libgit2/src/strmap.c +47 -74
  324. data/vendor/libgit2/src/strmap.h +108 -33
  325. data/vendor/libgit2/src/submodule.c +190 -169
  326. data/vendor/libgit2/src/submodule.h +1 -1
  327. data/vendor/libgit2/src/sysdir.c +25 -15
  328. data/vendor/libgit2/src/tag.c +39 -26
  329. data/vendor/libgit2/src/tag.h +2 -1
  330. data/vendor/libgit2/src/trace.c +2 -2
  331. data/vendor/libgit2/src/trace.h +2 -2
  332. data/vendor/libgit2/src/trailer.c +46 -32
  333. data/vendor/libgit2/src/transaction.c +30 -29
  334. data/vendor/libgit2/src/transport.c +3 -3
  335. data/vendor/libgit2/src/transports/auth.c +14 -10
  336. data/vendor/libgit2/src/transports/auth.h +10 -3
  337. data/vendor/libgit2/src/transports/auth_negotiate.c +31 -16
  338. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  339. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  340. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  341. data/vendor/libgit2/src/transports/cred.c +24 -24
  342. data/vendor/libgit2/src/transports/git.c +25 -30
  343. data/vendor/libgit2/src/transports/http.c +871 -335
  344. data/vendor/libgit2/src/transports/http.h +2 -0
  345. data/vendor/libgit2/src/transports/local.c +28 -28
  346. data/vendor/libgit2/src/transports/smart.c +64 -46
  347. data/vendor/libgit2/src/transports/smart.h +5 -6
  348. data/vendor/libgit2/src/transports/smart_pkt.c +162 -151
  349. data/vendor/libgit2/src/transports/smart_protocol.c +64 -94
  350. data/vendor/libgit2/src/transports/ssh.c +76 -65
  351. data/vendor/libgit2/src/transports/winhttp.c +328 -319
  352. data/vendor/libgit2/src/tree-cache.c +21 -14
  353. data/vendor/libgit2/src/tree.c +119 -112
  354. data/vendor/libgit2/src/tree.h +1 -0
  355. data/vendor/libgit2/src/unix/map.c +3 -3
  356. data/vendor/libgit2/src/unix/posix.h +1 -11
  357. data/vendor/libgit2/src/userdiff.h +3 -1
  358. data/vendor/libgit2/src/util.c +154 -93
  359. data/vendor/libgit2/src/util.h +19 -23
  360. data/vendor/libgit2/src/vector.c +15 -10
  361. data/vendor/libgit2/src/wildmatch.c +320 -0
  362. data/vendor/libgit2/src/wildmatch.h +23 -0
  363. data/vendor/libgit2/src/win32/dir.c +3 -3
  364. data/vendor/libgit2/src/win32/findfile.c +1 -1
  365. data/vendor/libgit2/src/win32/map.c +9 -11
  366. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  367. data/vendor/libgit2/src/win32/path_w32.c +113 -9
  368. data/vendor/libgit2/src/win32/path_w32.h +18 -29
  369. data/vendor/libgit2/src/win32/posix.h +1 -4
  370. data/vendor/libgit2/src/win32/posix_w32.c +69 -44
  371. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  372. data/vendor/libgit2/src/win32/thread.c +5 -10
  373. data/vendor/libgit2/src/win32/w32_buffer.c +9 -5
  374. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  375. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -95
  376. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
  377. data/vendor/libgit2/src/win32/w32_stack.c +6 -11
  378. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  379. data/vendor/libgit2/src/win32/w32_util.c +27 -64
  380. data/vendor/libgit2/src/win32/w32_util.h +5 -49
  381. data/vendor/libgit2/src/worktree.c +44 -30
  382. data/vendor/libgit2/src/xdiff/xdiffi.c +5 -5
  383. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  384. data/vendor/libgit2/src/xdiff/xmerge.c +27 -15
  385. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  386. data/vendor/libgit2/src/zstream.c +4 -4
  387. metadata +115 -38
  388. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  389. data/vendor/libgit2/deps/regex/config.h +0 -7
  390. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  391. data/vendor/libgit2/deps/regex/regex.c +0 -92
  392. data/vendor/libgit2/deps/regex/regex.h +0 -582
  393. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  394. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  395. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  396. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  397. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  398. data/vendor/libgit2/libgit2.pc.in +0 -13
  399. data/vendor/libgit2/src/config_file.h +0 -73
  400. data/vendor/libgit2/src/fnmatch.c +0 -248
  401. data/vendor/libgit2/src/fnmatch.h +0 -48
  402. data/vendor/libgit2/src/hash/hash_collisiondetect.h +0 -47
  403. data/vendor/libgit2/src/hash/hash_openssl.h +0 -59
  404. data/vendor/libgit2/src/streams/curl.c +0 -385
  405. data/vendor/libgit2/src/streams/curl.h +0 -17
  406. /data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  407. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  408. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  409. /data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
@@ -10,18 +10,24 @@
10
10
  #include "git2/indexer.h"
11
11
  #include "git2/object.h"
12
12
 
13
+ #include "commit.h"
14
+ #include "tree.h"
15
+ #include "tag.h"
13
16
  #include "pack.h"
14
17
  #include "mwindow.h"
15
18
  #include "posix.h"
16
19
  #include "pack.h"
17
20
  #include "filebuf.h"
18
21
  #include "oid.h"
22
+ #include "oidarray.h"
19
23
  #include "oidmap.h"
20
24
  #include "zstream.h"
21
25
  #include "object.h"
22
26
 
23
27
  extern git_mutex git__mwindow_mutex;
24
28
 
29
+ size_t git_indexer__max_objects = UINT32_MAX;
30
+
25
31
  #define UINT31_MAX (0x7FFFFFFF)
26
32
 
27
33
  struct entry {
@@ -36,12 +42,15 @@ struct git_indexer {
36
42
  pack_committed :1,
37
43
  have_stream :1,
38
44
  have_delta :1,
39
- do_fsync :1;
45
+ do_fsync :1,
46
+ do_verify :1;
40
47
  struct git_pack_header hdr;
41
48
  struct git_pack_file *pack;
42
49
  unsigned int mode;
43
- git_off_t off;
44
- git_off_t entry_start;
50
+ off64_t off;
51
+ off64_t entry_start;
52
+ git_object_t entry_type;
53
+ git_buf entry_data;
45
54
  git_packfile_stream stream;
46
55
  size_t nr_objects;
47
56
  git_vector objects;
@@ -49,10 +58,13 @@ struct git_indexer {
49
58
  unsigned int fanout[256];
50
59
  git_hash_ctx hash_ctx;
51
60
  git_oid hash;
52
- git_transfer_progress_cb progress_cb;
61
+ git_indexer_progress_cb progress_cb;
53
62
  void *progress_payload;
54
63
  char objbuf[8*1024];
55
64
 
65
+ /* OIDs referenced from pack objects. Used for verification. */
66
+ git_oidmap *expected_oids;
67
+
56
68
  /* Needed to look up objects which we want to inject to fix a thin pack */
57
69
  git_odb *odb;
58
70
 
@@ -63,7 +75,7 @@ struct git_indexer {
63
75
  };
64
76
 
65
77
  struct delta_info {
66
- git_off_t delta_off;
78
+ off64_t delta_off;
67
79
  };
68
80
 
69
81
  const git_oid *git_indexer_hash(const git_indexer *idx)
@@ -84,12 +96,12 @@ static int parse_header(struct git_pack_header *hdr, struct git_pack_file *pack)
84
96
 
85
97
  /* Verify we recognize this pack file format. */
86
98
  if (hdr->hdr_signature != ntohl(PACK_SIGNATURE)) {
87
- giterr_set(GITERR_INDEXER, "wrong pack signature");
99
+ git_error_set(GIT_ERROR_INDEXER, "wrong pack signature");
88
100
  return -1;
89
101
  }
90
102
 
91
103
  if (!pack_version_ok(hdr->hdr_version)) {
92
- giterr_set(GITERR_INDEXER, "wrong pack version");
104
+ git_error_set(GIT_ERROR_INDEXER, "wrong pack version");
93
105
  return -1;
94
106
  }
95
107
 
@@ -104,27 +116,48 @@ static int objects_cmp(const void *a, const void *b)
104
116
  return git_oid__cmp(&entrya->oid, &entryb->oid);
105
117
  }
106
118
 
119
+ int git_indexer_options_init(git_indexer_options *opts, unsigned int version)
120
+ {
121
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(
122
+ opts, version, git_indexer_options, GIT_INDEXER_OPTIONS_INIT);
123
+ return 0;
124
+ }
125
+
126
+ int git_indexer_init_options(git_indexer_options *opts, unsigned int version)
127
+ {
128
+ return git_indexer_options_init(opts, version);
129
+ }
130
+
107
131
  int git_indexer_new(
108
132
  git_indexer **out,
109
133
  const char *prefix,
110
134
  unsigned int mode,
111
135
  git_odb *odb,
112
- git_transfer_progress_cb progress_cb,
113
- void *progress_payload)
136
+ git_indexer_options *in_opts)
114
137
  {
138
+ git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT;
115
139
  git_indexer *idx;
116
140
  git_buf path = GIT_BUF_INIT, tmp_path = GIT_BUF_INIT;
117
141
  static const char suff[] = "/pack";
118
142
  int error, fd = -1;
119
143
 
144
+ if (in_opts)
145
+ memcpy(&opts, in_opts, sizeof(opts));
146
+
120
147
  idx = git__calloc(1, sizeof(git_indexer));
121
- GITERR_CHECK_ALLOC(idx);
148
+ GIT_ERROR_CHECK_ALLOC(idx);
122
149
  idx->odb = odb;
123
- idx->progress_cb = progress_cb;
124
- idx->progress_payload = progress_payload;
150
+ idx->progress_cb = opts.progress_cb;
151
+ idx->progress_payload = opts.progress_cb_payload;
125
152
  idx->mode = mode ? mode : GIT_PACK_FILE_MODE;
126
153
  git_hash_ctx_init(&idx->hash_ctx);
127
154
  git_hash_ctx_init(&idx->trailer);
155
+ git_buf_init(&idx->entry_data, 0);
156
+
157
+ if ((error = git_oidmap_new(&idx->expected_oids)) < 0)
158
+ goto cleanup;
159
+
160
+ idx->do_verify = opts.verify;
128
161
 
129
162
  if (git_repository__fsync_gitdir)
130
163
  idx->do_fsync = 1;
@@ -178,7 +211,7 @@ static int store_delta(git_indexer *idx)
178
211
  struct delta_info *delta;
179
212
 
180
213
  delta = git__calloc(1, sizeof(struct delta_info));
181
- GITERR_CHECK_ALLOC(delta);
214
+ GIT_ERROR_CHECK_ALLOC(delta);
182
215
  delta->delta_off = idx->entry_start;
183
216
 
184
217
  if (git_vector_insert(&idx->deltas, delta) < 0)
@@ -187,7 +220,7 @@ static int store_delta(git_indexer *idx)
187
220
  return 0;
188
221
  }
189
222
 
190
- static int hash_header(git_hash_ctx *ctx, git_off_t len, git_otype type)
223
+ static int hash_header(git_hash_ctx *ctx, off64_t len, git_object_t type)
191
224
  {
192
225
  char buffer[64];
193
226
  size_t hdrlen;
@@ -210,6 +243,9 @@ static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream)
210
243
  if ((read = git_packfile_stream_read(stream, idx->objbuf, sizeof(idx->objbuf))) < 0)
211
244
  break;
212
245
 
246
+ if (idx->do_verify)
247
+ git_buf_put(&idx->entry_data, idx->objbuf, read);
248
+
213
249
  git_hash_update(&idx->hash_ctx, idx->objbuf, read);
214
250
  } while (read > 0);
215
251
 
@@ -220,16 +256,16 @@ static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream)
220
256
  }
221
257
 
222
258
  /* In order to create the packfile stream, we need to skip over the delta base description */
223
- static int advance_delta_offset(git_indexer *idx, git_otype type)
259
+ static int advance_delta_offset(git_indexer *idx, git_object_t type)
224
260
  {
225
261
  git_mwindow *w = NULL;
226
262
 
227
- assert(type == GIT_OBJ_REF_DELTA || type == GIT_OBJ_OFS_DELTA);
263
+ assert(type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA);
228
264
 
229
- if (type == GIT_OBJ_REF_DELTA) {
265
+ if (type == GIT_OBJECT_REF_DELTA) {
230
266
  idx->off += GIT_OID_RAWSZ;
231
267
  } else {
232
- git_off_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
268
+ off64_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
233
269
  git_mwindow_close(&w);
234
270
  if (base_off < 0)
235
271
  return (int)base_off;
@@ -255,7 +291,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
255
291
  return 0;
256
292
  }
257
293
 
258
- static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start, git_off_t size)
294
+ static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, off64_t start, off64_t size)
259
295
  {
260
296
  void *ptr;
261
297
  uint32_t crc;
@@ -279,21 +315,114 @@ static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start,
279
315
  return 0;
280
316
  }
281
317
 
318
+ static int add_expected_oid(git_indexer *idx, const git_oid *oid)
319
+ {
320
+ /*
321
+ * If we know about that object because it is stored in our ODB or
322
+ * because we have already processed it as part of our pack file, we do
323
+ * not have to expect it.
324
+ */
325
+ if ((!idx->odb || !git_odb_exists(idx->odb, oid)) &&
326
+ !git_oidmap_exists(idx->pack->idx_cache, oid) &&
327
+ !git_oidmap_exists(idx->expected_oids, oid)) {
328
+ git_oid *dup = git__malloc(sizeof(*oid));
329
+ GIT_ERROR_CHECK_ALLOC(dup);
330
+ git_oid_cpy(dup, oid);
331
+ return git_oidmap_set(idx->expected_oids, dup, dup);
332
+ }
333
+
334
+ return 0;
335
+ }
336
+
337
+ static int check_object_connectivity(git_indexer *idx, const git_rawobj *obj)
338
+ {
339
+ git_object *object;
340
+ git_oid *expected;
341
+ int error;
342
+
343
+ if (obj->type != GIT_OBJECT_BLOB &&
344
+ obj->type != GIT_OBJECT_TREE &&
345
+ obj->type != GIT_OBJECT_COMMIT &&
346
+ obj->type != GIT_OBJECT_TAG)
347
+ return 0;
348
+
349
+ if ((error = git_object__from_raw(&object, obj->data, obj->len, obj->type)) < 0)
350
+ goto out;
351
+
352
+ if ((expected = git_oidmap_get(idx->expected_oids, &object->cached.oid)) != NULL) {
353
+ git_oidmap_delete(idx->expected_oids, &object->cached.oid);
354
+ git__free(expected);
355
+ }
356
+
357
+ /*
358
+ * Check whether this is a known object. If so, we can just continue as
359
+ * we assume that the ODB has a complete graph.
360
+ */
361
+ if (idx->odb && git_odb_exists(idx->odb, &object->cached.oid))
362
+ return 0;
363
+
364
+ switch (obj->type) {
365
+ case GIT_OBJECT_TREE:
366
+ {
367
+ git_tree *tree = (git_tree *) object;
368
+ git_tree_entry *entry;
369
+ size_t i;
370
+
371
+ git_array_foreach(tree->entries, i, entry)
372
+ if (add_expected_oid(idx, entry->oid) < 0)
373
+ goto out;
374
+
375
+ break;
376
+ }
377
+ case GIT_OBJECT_COMMIT:
378
+ {
379
+ git_commit *commit = (git_commit *) object;
380
+ git_oid *parent_oid;
381
+ size_t i;
382
+
383
+ git_array_foreach(commit->parent_ids, i, parent_oid)
384
+ if (add_expected_oid(idx, parent_oid) < 0)
385
+ goto out;
386
+
387
+ if (add_expected_oid(idx, &commit->tree_id) < 0)
388
+ goto out;
389
+
390
+ break;
391
+ }
392
+ case GIT_OBJECT_TAG:
393
+ {
394
+ git_tag *tag = (git_tag *) object;
395
+
396
+ if (add_expected_oid(idx, &tag->target) < 0)
397
+ goto out;
398
+
399
+ break;
400
+ }
401
+ case GIT_OBJECT_BLOB:
402
+ default:
403
+ break;
404
+ }
405
+
406
+ out:
407
+ git_object_free(object);
408
+
409
+ return error;
410
+ }
411
+
282
412
  static int store_object(git_indexer *idx)
283
413
  {
284
414
  int i, error;
285
- khiter_t k;
286
415
  git_oid oid;
287
416
  struct entry *entry;
288
- git_off_t entry_size;
417
+ off64_t entry_size;
289
418
  struct git_pack_entry *pentry;
290
- git_off_t entry_start = idx->entry_start;
419
+ off64_t entry_start = idx->entry_start;
291
420
 
292
421
  entry = git__calloc(1, sizeof(*entry));
293
- GITERR_CHECK_ALLOC(entry);
422
+ GIT_ERROR_CHECK_ALLOC(entry);
294
423
 
295
424
  pentry = git__calloc(1, sizeof(struct git_pack_entry));
296
- GITERR_CHECK_ALLOC(pentry);
425
+ GIT_ERROR_CHECK_ALLOC(pentry);
297
426
 
298
427
  git_hash_final(&oid, &idx->hash_ctx);
299
428
  entry_size = idx->off - entry_start;
@@ -304,25 +433,32 @@ static int store_object(git_indexer *idx)
304
433
  entry->offset = (uint32_t)entry_start;
305
434
  }
306
435
 
436
+ if (idx->do_verify) {
437
+ git_rawobj rawobj = {
438
+ idx->entry_data.ptr,
439
+ idx->entry_data.size,
440
+ idx->entry_type
441
+ };
442
+
443
+ if ((error = check_object_connectivity(idx, &rawobj)) < 0)
444
+ goto on_error;
445
+ }
446
+
307
447
  git_oid_cpy(&pentry->sha1, &oid);
308
448
  pentry->offset = entry_start;
309
449
 
310
- k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error);
311
- if (error == -1) {
450
+ if (git_oidmap_exists(idx->pack->idx_cache, &pentry->sha1)) {
451
+ git_error_set(GIT_ERROR_INDEXER, "duplicate object %s found in pack", git_oid_tostr_s(&pentry->sha1));
312
452
  git__free(pentry);
313
- giterr_set_oom();
314
453
  goto on_error;
315
454
  }
316
455
 
317
- if (error == 0) {
318
- giterr_set(GITERR_INDEXER, "duplicate object %s found in pack", git_oid_tostr_s(&pentry->sha1));
456
+ if ((error = git_oidmap_set(idx->pack->idx_cache, &pentry->sha1, pentry)) < 0) {
319
457
  git__free(pentry);
458
+ git_error_set_oom();
320
459
  goto on_error;
321
460
  }
322
461
 
323
-
324
- git_oidmap_set_value_at(idx->pack->idx_cache, k, pentry);
325
-
326
462
  git_oid_cpy(&entry->oid, &oid);
327
463
 
328
464
  if (crc_object(&entry->crc, &idx->pack->mwf, entry_start, entry_size) < 0)
@@ -349,10 +485,9 @@ GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
349
485
  return git_oidmap_exists(idx->pack->idx_cache, id);
350
486
  }
351
487
 
352
- static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
488
+ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, off64_t entry_start)
353
489
  {
354
- int i, error;
355
- khiter_t k;
490
+ int i;
356
491
 
357
492
  if (entry_start > UINT31_MAX) {
358
493
  entry->offset = UINT32_MAX;
@@ -362,15 +497,13 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
362
497
  }
363
498
 
364
499
  pentry->offset = entry_start;
365
- k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error);
366
500
 
367
- if (error <= 0) {
368
- giterr_set(GITERR_INDEXER, "cannot insert object into pack");
501
+ if (git_oidmap_exists(idx->pack->idx_cache, &pentry->sha1) ||
502
+ git_oidmap_set(idx->pack->idx_cache, &pentry->sha1, pentry) < 0) {
503
+ git_error_set(GIT_ERROR_INDEXER, "cannot insert object into pack");
369
504
  return -1;
370
505
  }
371
506
 
372
- git_oidmap_set_value_at(idx->pack->idx_cache, k, pentry);
373
-
374
507
  /* Add the object to the list */
375
508
  if (git_vector_insert(&idx->objects, entry) < 0)
376
509
  return -1;
@@ -382,7 +515,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
382
515
  return 0;
383
516
  }
384
517
 
385
- static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_start)
518
+ static int hash_and_save(git_indexer *idx, git_rawobj *obj, off64_t entry_start)
386
519
  {
387
520
  git_oid oid;
388
521
  size_t entry_size;
@@ -390,15 +523,15 @@ static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_star
390
523
  struct git_pack_entry *pentry = NULL;
391
524
 
392
525
  entry = git__calloc(1, sizeof(*entry));
393
- GITERR_CHECK_ALLOC(entry);
526
+ GIT_ERROR_CHECK_ALLOC(entry);
394
527
 
395
528
  if (git_odb__hashobj(&oid, obj) < 0) {
396
- giterr_set(GITERR_INDEXER, "failed to hash object");
529
+ git_error_set(GIT_ERROR_INDEXER, "failed to hash object");
397
530
  goto on_error;
398
531
  }
399
532
 
400
533
  pentry = git__calloc(1, sizeof(struct git_pack_entry));
401
- GITERR_CHECK_ALLOC(pentry);
534
+ GIT_ERROR_CHECK_ALLOC(pentry);
402
535
 
403
536
  git_oid_cpy(&pentry->sha1, &oid);
404
537
  git_oid_cpy(&entry->oid, &oid);
@@ -417,10 +550,10 @@ on_error:
417
550
  return -1;
418
551
  }
419
552
 
420
- static int do_progress_callback(git_indexer *idx, git_transfer_progress *stats)
553
+ static int do_progress_callback(git_indexer *idx, git_indexer_progress *stats)
421
554
  {
422
555
  if (idx->progress_cb)
423
- return giterr_set_after_callback_function(
556
+ return git_error_set_after_callback_function(
424
557
  idx->progress_cb(stats, idx->progress_payload),
425
558
  "indexer progress");
426
559
  return 0;
@@ -463,12 +596,12 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
463
596
  idx->inbuf_len += size - to_expell;
464
597
  }
465
598
 
466
- static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size)
599
+ static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
467
600
  {
468
601
  git_file fd = idx->pack->mwf.fd;
469
602
  size_t mmap_alignment;
470
603
  size_t page_offset;
471
- git_off_t page_start;
604
+ off64_t page_start;
472
605
  unsigned char *map_data;
473
606
  git_map map;
474
607
  int error;
@@ -494,11 +627,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
494
627
 
495
628
  static int append_to_pack(git_indexer *idx, const void *data, size_t size)
496
629
  {
497
- git_off_t new_size;
630
+ off64_t new_size;
498
631
  size_t mmap_alignment;
499
632
  size_t page_offset;
500
- git_off_t page_start;
501
- git_off_t current_size = idx->pack->mwf.size;
633
+ off64_t page_start;
634
+ off64_t current_size = idx->pack->mwf.size;
502
635
  int fd = idx->pack->mwf.fd;
503
636
  int error;
504
637
 
@@ -518,24 +651,110 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
518
651
 
519
652
  if (p_lseek(fd, page_start + mmap_alignment - 1, SEEK_SET) < 0 ||
520
653
  p_write(idx->pack->mwf.fd, data, 1) < 0) {
521
- giterr_set(GITERR_OS, "cannot extend packfile '%s'", idx->pack->pack_name);
654
+ git_error_set(GIT_ERROR_OS, "cannot extend packfile '%s'", idx->pack->pack_name);
522
655
  return -1;
523
656
  }
524
657
 
525
658
  return write_at(idx, data, idx->pack->mwf.size, size);
526
659
  }
527
660
 
528
- int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_transfer_progress *stats)
661
+ static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
662
+ {
663
+ git_packfile_stream *stream = &idx->stream;
664
+ off64_t entry_start = idx->off;
665
+ size_t entry_size;
666
+ git_object_t type;
667
+ git_mwindow *w = NULL;
668
+ int error;
669
+
670
+ if (idx->pack->mwf.size <= idx->off + 20)
671
+ return GIT_EBUFS;
672
+
673
+ if (!idx->have_stream) {
674
+ error = git_packfile_unpack_header(&entry_size, &type, &idx->pack->mwf, &w, &idx->off);
675
+ if (error == GIT_EBUFS) {
676
+ idx->off = entry_start;
677
+ return error;
678
+ }
679
+ if (error < 0)
680
+ return error;
681
+
682
+ git_mwindow_close(&w);
683
+ idx->entry_start = entry_start;
684
+ git_hash_init(&idx->hash_ctx);
685
+ git_buf_clear(&idx->entry_data);
686
+
687
+ if (type == GIT_OBJECT_REF_DELTA || type == GIT_OBJECT_OFS_DELTA) {
688
+ error = advance_delta_offset(idx, type);
689
+ if (error == GIT_EBUFS) {
690
+ idx->off = entry_start;
691
+ return error;
692
+ }
693
+ if (error < 0)
694
+ return error;
695
+
696
+ idx->have_delta = 1;
697
+ } else {
698
+ idx->have_delta = 0;
699
+
700
+ error = hash_header(&idx->hash_ctx, entry_size, type);
701
+ if (error < 0)
702
+ return error;
703
+ }
704
+
705
+ idx->have_stream = 1;
706
+ idx->entry_type = type;
707
+
708
+ error = git_packfile_stream_open(stream, idx->pack, idx->off);
709
+ if (error < 0)
710
+ return error;
711
+ }
712
+
713
+ if (idx->have_delta) {
714
+ error = read_object_stream(idx, stream);
715
+ } else {
716
+ error = hash_object_stream(idx, stream);
717
+ }
718
+
719
+ idx->off = stream->curpos;
720
+ if (error == GIT_EBUFS)
721
+ return error;
722
+
723
+ /* We want to free the stream reasorces no matter what here */
724
+ idx->have_stream = 0;
725
+ git_packfile_stream_dispose(stream);
726
+
727
+ if (error < 0)
728
+ return error;
729
+
730
+ if (idx->have_delta) {
731
+ error = store_delta(idx);
732
+ } else {
733
+ error = store_object(idx);
734
+ }
735
+
736
+ if (error < 0)
737
+ return error;
738
+
739
+ if (!idx->have_delta) {
740
+ stats->indexed_objects++;
741
+ }
742
+ stats->received_objects++;
743
+
744
+ if ((error = do_progress_callback(idx, stats)) != 0)
745
+ return error;
746
+
747
+ return 0;
748
+ }
749
+
750
+ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats)
529
751
  {
530
752
  int error = -1;
531
- size_t processed;
532
753
  struct git_pack_header *hdr = &idx->hdr;
533
754
  git_mwindow_file *mwf = &idx->pack->mwf;
534
755
 
535
756
  assert(idx && data && stats);
536
757
 
537
- processed = stats->indexed_objects;
538
-
539
758
  if ((error = append_to_pack(idx, data, size)) < 0)
540
759
  return error;
541
760
 
@@ -557,15 +776,15 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
557
776
  idx->nr_objects = ntohl(hdr->hdr_entries);
558
777
  idx->off = sizeof(struct git_pack_header);
559
778
 
560
- /* for now, limit to 2^32 objects */
561
- assert(idx->nr_objects == (size_t)((unsigned int)idx->nr_objects));
562
- if (idx->nr_objects == (size_t)((unsigned int)idx->nr_objects))
779
+ if (idx->nr_objects <= git_indexer__max_objects) {
563
780
  total_objects = (unsigned int)idx->nr_objects;
564
- else
565
- total_objects = UINT_MAX;
781
+ } else {
782
+ git_error_set(GIT_ERROR_INDEXER, "too many objects");
783
+ return -1;
784
+ }
566
785
 
567
- idx->pack->idx_cache = git_oidmap_alloc();
568
- GITERR_CHECK_ALLOC(idx->pack->idx_cache);
786
+ if (git_oidmap_new(&idx->pack->idx_cache) < 0)
787
+ return -1;
569
788
 
570
789
  idx->pack->has_cache = 1;
571
790
  if (git_vector_init(&idx->objects, total_objects, objects_cmp) < 0)
@@ -578,7 +797,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
578
797
  stats->local_objects = 0;
579
798
  stats->total_deltas = 0;
580
799
  stats->indexed_deltas = 0;
581
- processed = stats->indexed_objects = 0;
800
+ stats->indexed_objects = 0;
582
801
  stats->total_objects = total_objects;
583
802
 
584
803
  if ((error = do_progress_callback(idx, stats)) != 0)
@@ -590,87 +809,13 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
590
809
  /* As the file grows any windows we try to use will be out of date */
591
810
  git_mwindow_free_all(mwf);
592
811
 
593
- while (processed < idx->nr_objects) {
594
- git_packfile_stream *stream = &idx->stream;
595
- git_off_t entry_start = idx->off;
596
- size_t entry_size;
597
- git_otype type;
598
- git_mwindow *w = NULL;
599
-
600
- if (idx->pack->mwf.size <= idx->off + 20)
601
- return 0;
602
-
603
- if (!idx->have_stream) {
604
- error = git_packfile_unpack_header(&entry_size, &type, mwf, &w, &idx->off);
605
- if (error == GIT_EBUFS) {
606
- idx->off = entry_start;
607
- return 0;
608
- }
609
- if (error < 0)
610
- goto on_error;
611
-
612
- git_mwindow_close(&w);
613
- idx->entry_start = entry_start;
614
- git_hash_init(&idx->hash_ctx);
615
-
616
- if (type == GIT_OBJ_REF_DELTA || type == GIT_OBJ_OFS_DELTA) {
617
- error = advance_delta_offset(idx, type);
618
- if (error == GIT_EBUFS) {
619
- idx->off = entry_start;
620
- return 0;
621
- }
622
- if (error < 0)
623
- goto on_error;
624
-
625
- idx->have_delta = 1;
626
- } else {
627
- idx->have_delta = 0;
628
-
629
- error = hash_header(&idx->hash_ctx, entry_size, type);
630
- if (error < 0)
631
- goto on_error;
632
- }
633
-
634
- idx->have_stream = 1;
635
-
636
- error = git_packfile_stream_open(stream, idx->pack, idx->off);
637
- if (error < 0)
812
+ while (stats->indexed_objects < idx->nr_objects) {
813
+ if ((error = read_stream_object(idx, stats)) != 0) {
814
+ if (error == GIT_EBUFS)
815
+ break;
816
+ else
638
817
  goto on_error;
639
818
  }
640
-
641
- if (idx->have_delta) {
642
- error = read_object_stream(idx, stream);
643
- } else {
644
- error = hash_object_stream(idx, stream);
645
- }
646
-
647
- idx->off = stream->curpos;
648
- if (error == GIT_EBUFS)
649
- return 0;
650
-
651
- /* We want to free the stream reasorces no matter what here */
652
- idx->have_stream = 0;
653
- git_packfile_stream_dispose(stream);
654
-
655
- if (error < 0)
656
- goto on_error;
657
-
658
- if (idx->have_delta) {
659
- error = store_delta(idx);
660
- } else {
661
- error = store_object(idx);
662
- }
663
-
664
- if (error < 0)
665
- goto on_error;
666
-
667
- if (!idx->have_delta) {
668
- stats->indexed_objects = (unsigned int)++processed;
669
- }
670
- stats->received_objects++;
671
-
672
- if ((error = do_progress_callback(idx, stats)) != 0)
673
- goto on_error;
674
819
  }
675
820
 
676
821
  return 0;
@@ -720,7 +865,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
720
865
  git_oid foo = {{0}};
721
866
  unsigned char hdr[64];
722
867
  git_buf buf = GIT_BUF_INIT;
723
- git_off_t entry_start;
868
+ off64_t entry_start;
724
869
  const void *data;
725
870
  size_t len, hdr_len;
726
871
  int error;
@@ -729,7 +874,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
729
874
  entry_start = idx->pack->mwf.size;
730
875
 
731
876
  if (git_odb_read(&obj, idx->odb, id) < 0) {
732
- giterr_set(GITERR_INDEXER, "missing delta bases");
877
+ git_error_set(GIT_ERROR_INDEXER, "missing delta bases");
733
878
  return -1;
734
879
  }
735
880
 
@@ -737,7 +882,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
737
882
  len = git_odb_object_size(obj);
738
883
 
739
884
  entry = git__calloc(1, sizeof(*entry));
740
- GITERR_CHECK_ALLOC(entry);
885
+ GIT_ERROR_CHECK_ALLOC(entry);
741
886
 
742
887
  entry->crc = crc32(0L, Z_NULL, 0);
743
888
 
@@ -768,7 +913,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
768
913
  idx->pack->mwf.size += GIT_OID_RAWSZ;
769
914
 
770
915
  pentry = git__calloc(1, sizeof(struct git_pack_entry));
771
- GITERR_CHECK_ALLOC(pentry);
916
+ GIT_ERROR_CHECK_ALLOC(pentry);
772
917
 
773
918
  git_oid_cpy(&pentry->sha1, id);
774
919
  git_oid_cpy(&entry->oid, id);
@@ -786,15 +931,15 @@ cleanup:
786
931
  return error;
787
932
  }
788
933
 
789
- static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
934
+ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
790
935
  {
791
936
  int error, found_ref_delta = 0;
792
937
  unsigned int i;
793
938
  struct delta_info *delta;
794
939
  size_t size;
795
- git_otype type;
940
+ git_object_t type;
796
941
  git_mwindow *w = NULL;
797
- git_off_t curpos = 0;
942
+ off64_t curpos = 0;
798
943
  unsigned char *base_info;
799
944
  unsigned int left = 0;
800
945
  git_oid base;
@@ -802,7 +947,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
802
947
  assert(git_vector_length(&idx->deltas) > 0);
803
948
 
804
949
  if (idx->odb == NULL) {
805
- giterr_set(GITERR_INDEXER, "cannot fix a thin pack without an ODB");
950
+ git_error_set(GIT_ERROR_INDEXER, "cannot fix a thin pack without an ODB");
806
951
  return -1;
807
952
  }
808
953
 
@@ -816,21 +961,21 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
816
961
  if (error < 0)
817
962
  return error;
818
963
 
819
- if (type == GIT_OBJ_REF_DELTA) {
964
+ if (type == GIT_OBJECT_REF_DELTA) {
820
965
  found_ref_delta = 1;
821
966
  break;
822
967
  }
823
968
  }
824
969
 
825
970
  if (!found_ref_delta) {
826
- giterr_set(GITERR_INDEXER, "no REF_DELTA found, cannot inject object");
971
+ git_error_set(GIT_ERROR_INDEXER, "no REF_DELTA found, cannot inject object");
827
972
  return -1;
828
973
  }
829
974
 
830
975
  /* curpos now points to the base information, which is an OID */
831
976
  base_info = git_mwindow_open(&idx->pack->mwf, &w, curpos, GIT_OID_RAWSZ, &left);
832
977
  if (base_info == NULL) {
833
- giterr_set(GITERR_INDEXER, "failed to map delta information");
978
+ git_error_set(GIT_ERROR_INDEXER, "failed to map delta information");
834
979
  return -1;
835
980
  }
836
981
 
@@ -848,7 +993,7 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
848
993
  return 0;
849
994
  }
850
995
 
851
- static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
996
+ static int resolve_deltas(git_indexer *idx, git_indexer_progress *stats)
852
997
  {
853
998
  unsigned int i;
854
999
  int error;
@@ -859,7 +1004,7 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
859
1004
  progressed = 0;
860
1005
  non_null = 0;
861
1006
  git_vector_foreach(&idx->deltas, i, delta) {
862
- git_rawobj obj = {NULL};
1007
+ git_rawobj obj = {0};
863
1008
 
864
1009
  if (!delta)
865
1010
  continue;
@@ -874,6 +1019,10 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
874
1019
  return -1;
875
1020
  }
876
1021
 
1022
+ if (idx->do_verify && check_object_connectivity(idx, &obj) < 0)
1023
+ /* TODO: error? continue? */
1024
+ continue;
1025
+
877
1026
  if (hash_and_save(idx, &obj, delta->delta_off) < 0)
878
1027
  continue;
879
1028
 
@@ -901,11 +1050,11 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
901
1050
  return 0;
902
1051
  }
903
1052
 
904
- static int update_header_and_rehash(git_indexer *idx, git_transfer_progress *stats)
1053
+ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stats)
905
1054
  {
906
1055
  void *ptr;
907
1056
  size_t chunk = 1024*1024;
908
- git_off_t hashed = 0;
1057
+ off64_t hashed = 0;
909
1058
  git_mwindow *w = NULL;
910
1059
  git_mwindow_file *mwf;
911
1060
  unsigned int left;
@@ -942,7 +1091,7 @@ static int update_header_and_rehash(git_indexer *idx, git_transfer_progress *sta
942
1091
  return 0;
943
1092
  }
944
1093
 
945
- int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
1094
+ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats)
946
1095
  {
947
1096
  git_mwindow *w = NULL;
948
1097
  unsigned int i, long_offsets = 0, left;
@@ -955,17 +1104,17 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
955
1104
  void *packfile_trailer;
956
1105
 
957
1106
  if (!idx->parsed_header) {
958
- giterr_set(GITERR_INDEXER, "incomplete pack header");
1107
+ git_error_set(GIT_ERROR_INDEXER, "incomplete pack header");
959
1108
  return -1;
960
1109
  }
961
1110
 
962
1111
  /* Test for this before resolve_deltas(), as it plays with idx->off */
963
1112
  if (idx->off + 20 < idx->pack->mwf.size) {
964
- giterr_set(GITERR_INDEXER, "unexpected data at the end of the pack");
1113
+ git_error_set(GIT_ERROR_INDEXER, "unexpected data at the end of the pack");
965
1114
  return -1;
966
1115
  }
967
1116
  if (idx->off + 20 > idx->pack->mwf.size) {
968
- giterr_set(GITERR_INDEXER, "missing trailer at the end of the pack");
1117
+ git_error_set(GIT_ERROR_INDEXER, "missing trailer at the end of the pack");
969
1118
  return -1;
970
1119
  }
971
1120
 
@@ -981,7 +1130,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
981
1130
 
982
1131
  git_hash_final(&trailer_hash, &idx->trailer);
983
1132
  if (git_oid_cmp(&file_hash, &trailer_hash)) {
984
- giterr_set(GITERR_INDEXER, "packfile trailer mismatch");
1133
+ git_error_set(GIT_ERROR_INDEXER, "packfile trailer mismatch");
985
1134
  return -1;
986
1135
  }
987
1136
 
@@ -992,7 +1141,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
992
1141
  return error;
993
1142
 
994
1143
  if (stats->indexed_objects != stats->total_objects) {
995
- giterr_set(GITERR_INDEXER, "early EOF");
1144
+ git_error_set(GIT_ERROR_INDEXER, "early EOF");
996
1145
  return -1;
997
1146
  }
998
1147
 
@@ -1004,6 +1153,18 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
1004
1153
  write_at(idx, &trailer_hash, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ);
1005
1154
  }
1006
1155
 
1156
+ /*
1157
+ * Is the resulting graph fully connected or are we still
1158
+ * missing some objects? In the second case, we can
1159
+ * bail out due to an incomplete and thus corrupt
1160
+ * packfile.
1161
+ */
1162
+ if (git_oidmap_size(idx->expected_oids) > 0) {
1163
+ git_error_set(GIT_ERROR_INDEXER, "packfile is missing %"PRIuZ" objects",
1164
+ git_oidmap_size(idx->expected_oids));
1165
+ return -1;
1166
+ }
1167
+
1007
1168
  git_vector_sort(&idx->objects);
1008
1169
 
1009
1170
  /* Use the trailer hash as the pack file name to ensure
@@ -1090,18 +1251,18 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
1090
1251
 
1091
1252
  /* Truncate file to undo rounding up to next page_size in append_to_pack */
1092
1253
  if (p_ftruncate(idx->pack->mwf.fd, idx->pack->mwf.size) < 0) {
1093
- giterr_set(GITERR_OS, "failed to truncate pack file '%s'", idx->pack->pack_name);
1254
+ git_error_set(GIT_ERROR_OS, "failed to truncate pack file '%s'", idx->pack->pack_name);
1094
1255
  return -1;
1095
1256
  }
1096
1257
 
1097
1258
  if (idx->do_fsync && p_fsync(idx->pack->mwf.fd) < 0) {
1098
- giterr_set(GITERR_OS, "failed to fsync packfile");
1259
+ git_error_set(GIT_ERROR_OS, "failed to fsync packfile");
1099
1260
  goto on_error;
1100
1261
  }
1101
1262
 
1102
1263
  /* We need to close the descriptor here so Windows doesn't choke on commit_at */
1103
1264
  if (p_close(idx->pack->mwf.fd) < 0) {
1104
- giterr_set(GITERR_OS, "failed to close packfile");
1265
+ git_error_set(GIT_ERROR_OS, "failed to close packfile");
1105
1266
  goto on_error;
1106
1267
  }
1107
1268
 
@@ -1133,6 +1294,10 @@ on_error:
1133
1294
 
1134
1295
  void git_indexer_free(git_indexer *idx)
1135
1296
  {
1297
+ const git_oid *key;
1298
+ git_oid *value;
1299
+ size_t iter;
1300
+
1136
1301
  if (idx == NULL)
1137
1302
  return;
1138
1303
 
@@ -1160,7 +1325,13 @@ void git_indexer_free(git_indexer *idx)
1160
1325
  git_mutex_unlock(&git__mwindow_mutex);
1161
1326
  }
1162
1327
 
1328
+ iter = 0;
1329
+ while (git_oidmap_iterate((void **) &value, idx->expected_oids, &iter, &key) == 0)
1330
+ git__free(value);
1331
+
1163
1332
  git_hash_ctx_cleanup(&idx->trailer);
1164
1333
  git_hash_ctx_cleanup(&idx->hash_ctx);
1334
+ git_buf_dispose(&idx->entry_data);
1335
+ git_oidmap_free(idx->expected_oids);
1165
1336
  git__free(idx);
1166
1337
  }