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
@@ -43,7 +43,7 @@ static int mark_parents(git_revwalk *walk, git_commit_list_node *one,
43
43
  return 0;
44
44
  }
45
45
 
46
- if (git_pqueue_init(&list, 0, 2, git_commit_list_time_cmp) < 0)
46
+ if (git_pqueue_init(&list, 0, 2, git_commit_list_generation_cmp) < 0)
47
47
  return -1;
48
48
 
49
49
  if (git_commit_list_parse(walk, one) < 0)
@@ -176,19 +176,74 @@ on_error:
176
176
 
177
177
  int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const git_oid *ancestor)
178
178
  {
179
- git_oid merge_base;
180
- int error;
181
-
182
179
  if (git_oid_equal(commit, ancestor))
183
180
  return 0;
184
181
 
185
- error = git_merge_base(&merge_base, repo, commit, ancestor);
186
- /* No merge-base found, it's not a descendant */
187
- if (error == GIT_ENOTFOUND)
182
+ return git_graph_reachable_from_any(repo, ancestor, commit, 1);
183
+ }
184
+
185
+ int git_graph_reachable_from_any(
186
+ git_repository *repo,
187
+ const git_oid *commit_id,
188
+ const git_oid descendant_array[],
189
+ size_t length)
190
+ {
191
+ git_revwalk *walk = NULL;
192
+ git_vector list;
193
+ git_commit_list *result = NULL;
194
+ git_commit_list_node *commit;
195
+ size_t i;
196
+ uint32_t minimum_generation = 0xffffffff;
197
+ int error = 0;
198
+
199
+ if (!length)
188
200
  return 0;
189
201
 
190
- if (error < 0)
202
+ for (i = 0; i < length; ++i) {
203
+ if (git_oid_equal(commit_id, &descendant_array[i]))
204
+ return 1;
205
+ }
206
+
207
+ if ((error = git_vector_init(&list, length + 1, NULL)) < 0)
191
208
  return error;
192
209
 
193
- return git_oid_equal(&merge_base, ancestor);
210
+ if ((error = git_revwalk_new(&walk, repo)) < 0)
211
+ goto done;
212
+
213
+ for (i = 0; i < length; i++) {
214
+ commit = git_revwalk__commit_lookup(walk, &descendant_array[i]);
215
+ if (commit == NULL) {
216
+ error = -1;
217
+ goto done;
218
+ }
219
+
220
+ git_vector_insert(&list, commit);
221
+ if (minimum_generation > commit->generation)
222
+ minimum_generation = commit->generation;
223
+ }
224
+
225
+ commit = git_revwalk__commit_lookup(walk, commit_id);
226
+ if (commit == NULL) {
227
+ error = -1;
228
+ goto done;
229
+ }
230
+
231
+ if (minimum_generation > commit->generation)
232
+ minimum_generation = commit->generation;
233
+
234
+ if ((error = git_merge__bases_many(&result, walk, commit, &list, minimum_generation)) < 0)
235
+ goto done;
236
+
237
+ if (result) {
238
+ error = git_oid_equal(commit_id, &result->item->oid);
239
+ } else {
240
+ /* No merge-base found, it's not a descendant */
241
+ error = 0;
242
+ }
243
+
244
+ done:
245
+ git_commit_list_free(&result);
246
+ git_vector_free(&list);
247
+ git_revwalk_free(walk);
248
+ return error;
194
249
  }
@@ -24,22 +24,22 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
24
24
 
25
25
  int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
26
26
  {
27
- assert(ctx);
27
+ GIT_ASSERT_ARG(ctx);
28
28
  SHA1DCInit(&ctx->c);
29
29
  return 0;
30
30
  }
31
31
 
32
32
  int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
33
33
  {
34
- assert(ctx);
34
+ GIT_ASSERT_ARG(ctx);
35
35
  SHA1DCUpdate(&ctx->c, data, len);
36
36
  return 0;
37
37
  }
38
38
 
39
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
39
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
40
40
  {
41
- assert(ctx);
42
- if (SHA1DCFinal(out->id, &ctx->c)) {
41
+ GIT_ASSERT_ARG(ctx);
42
+ if (SHA1DCFinal(out, &ctx->c)) {
43
43
  git_error_set(GIT_ERROR_SHA1, "SHA1 collision attack detected");
44
44
  return -1;
45
45
  }
@@ -26,7 +26,7 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
26
26
 
27
27
  int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
28
28
  {
29
- assert(ctx);
29
+ GIT_ASSERT_ARG(ctx);
30
30
  CC_SHA1_Init(&ctx->c);
31
31
  return 0;
32
32
  }
@@ -35,7 +35,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *_data, size_t len)
35
35
  {
36
36
  const unsigned char *data = _data;
37
37
 
38
- assert(ctx);
38
+ GIT_ASSERT_ARG(ctx);
39
39
 
40
40
  while (len > 0) {
41
41
  CC_LONG chunk = (len > CC_LONG_MAX) ? CC_LONG_MAX : (CC_LONG)len;
@@ -49,9 +49,9 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *_data, size_t len)
49
49
  return 0;
50
50
  }
51
51
 
52
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
52
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
53
53
  {
54
- assert(ctx);
55
- CC_SHA1_Final(out->id, &ctx->c);
54
+ GIT_ASSERT_ARG(ctx);
55
+ CC_SHA1_Final(out, &ctx->c);
56
56
  return 0;
57
57
  }
@@ -278,7 +278,7 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
278
278
  return 0;
279
279
  }
280
280
 
281
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
281
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
282
282
  {
283
283
  static const unsigned char pad[64] = { 0x80 };
284
284
  unsigned int padlen[2];
@@ -294,7 +294,7 @@ int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
294
294
 
295
295
  /* Output hash */
296
296
  for (i = 0; i < 5; i++)
297
- put_be32(out->id + i*4, ctx->H[i]);
297
+ put_be32(out + i*4, ctx->H[i]);
298
298
 
299
299
  return 0;
300
300
  }
@@ -11,7 +11,7 @@
11
11
  #include "hash/sha1.h"
12
12
 
13
13
  struct git_hash_sha1_ctx {
14
- unsigned long long size;
14
+ uint64_t size;
15
15
  unsigned int H[5];
16
16
  unsigned int W[16];
17
17
  };
@@ -19,28 +19,28 @@ int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
19
19
 
20
20
  void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
21
21
  {
22
- assert(ctx);
23
- mbedtls_sha1_free(&ctx->c);
22
+ if (ctx)
23
+ mbedtls_sha1_free(&ctx->c);
24
24
  }
25
25
 
26
26
  int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
27
27
  {
28
- assert(ctx);
29
- mbedtls_sha1_init(&ctx->c);
30
- mbedtls_sha1_starts(&ctx->c);
31
- return 0;
28
+ GIT_ASSERT_ARG(ctx);
29
+ mbedtls_sha1_init(&ctx->c);
30
+ mbedtls_sha1_starts(&ctx->c);
31
+ return 0;
32
32
  }
33
33
 
34
34
  int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
35
35
  {
36
- assert(ctx);
37
- mbedtls_sha1_update(&ctx->c, data, len);
38
- return 0;
36
+ GIT_ASSERT_ARG(ctx);
37
+ mbedtls_sha1_update(&ctx->c, data, len);
38
+ return 0;
39
39
  }
40
40
 
41
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
41
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
42
42
  {
43
- assert(ctx);
44
- mbedtls_sha1_finish(&ctx->c, out->id);
45
- return 0;
43
+ GIT_ASSERT_ARG(ctx);
44
+ mbedtls_sha1_finish(&ctx->c, out);
45
+ return 0;
46
46
  }
@@ -24,7 +24,7 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
24
24
 
25
25
  int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
26
26
  {
27
- assert(ctx);
27
+ GIT_ASSERT_ARG(ctx);
28
28
 
29
29
  if (SHA1_Init(&ctx->c) != 1) {
30
30
  git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to initialize hash context");
@@ -36,7 +36,7 @@ int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
36
36
 
37
37
  int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
38
38
  {
39
- assert(ctx);
39
+ GIT_ASSERT_ARG(ctx);
40
40
 
41
41
  if (SHA1_Update(&ctx->c, data, len) != 1) {
42
42
  git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to update hash");
@@ -46,11 +46,11 @@ int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
46
46
  return 0;
47
47
  }
48
48
 
49
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
49
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
50
50
  {
51
- assert(ctx);
51
+ GIT_ASSERT_ARG(ctx);
52
52
 
53
- if (SHA1_Final(out->id, &ctx->c) != 1) {
53
+ if (SHA1_Final(out, &ctx->c) != 1) {
54
54
  git_error_set(GIT_ERROR_SHA1, "hash_openssl: failed to finalize hash");
55
55
  return -1;
56
56
  }
@@ -10,10 +10,8 @@
10
10
  #include <memory.h>
11
11
  #include <stdio.h>
12
12
  #include <stdlib.h>
13
- #ifdef __unix__
14
13
  #include <sys/types.h> /* make sure macros like _BIG_ENDIAN visible */
15
14
  #endif
16
- #endif
17
15
 
18
16
  #ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C
19
17
  #include SHA1DC_CUSTOM_INCLUDE_SHA1_C
@@ -72,7 +70,7 @@
72
70
  /* Not under GCC-alike or glibc */
73
71
  #elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN)
74
72
  /*
75
- * *BSD and newlib (embeded linux, cygwin, etc).
73
+ * *BSD and newlib (embedded linux, cygwin, etc).
76
74
  * the defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) part prevents
77
75
  * this condition from matching with Solaris/sparc.
78
76
  * (Solaris defines only one endian macro)
@@ -1712,7 +1710,7 @@ static void sha1_recompression_step(uint32_t step, uint32_t ihvin[5], uint32_t i
1712
1710
 
1713
1711
 
1714
1712
 
1715
- static void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
1713
+ static void sha1_process(SHA1_CTX *ctx, const uint32_t block[16])
1716
1714
  {
1717
1715
  unsigned i, j;
1718
1716
  uint32_t ubc_dv_mask[DVMASKSIZE] = { 0xFFFFFFFF };
@@ -1764,7 +1762,7 @@ static void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
1764
1762
  }
1765
1763
  }
1766
1764
 
1767
- void SHA1DCInit(SHA1_CTX* ctx)
1765
+ void SHA1DCInit(SHA1_CTX *ctx)
1768
1766
  {
1769
1767
  ctx->total = 0;
1770
1768
  ctx->ihv[0] = 0x67452301;
@@ -1780,7 +1778,7 @@ void SHA1DCInit(SHA1_CTX* ctx)
1780
1778
  ctx->callback = NULL;
1781
1779
  }
1782
1780
 
1783
- void SHA1DCSetSafeHash(SHA1_CTX* ctx, int safehash)
1781
+ void SHA1DCSetSafeHash(SHA1_CTX *ctx, int safehash)
1784
1782
  {
1785
1783
  if (safehash)
1786
1784
  ctx->safe_hash = 1;
@@ -1789,7 +1787,7 @@ void SHA1DCSetSafeHash(SHA1_CTX* ctx, int safehash)
1789
1787
  }
1790
1788
 
1791
1789
 
1792
- void SHA1DCSetUseUBC(SHA1_CTX* ctx, int ubc_check)
1790
+ void SHA1DCSetUseUBC(SHA1_CTX *ctx, int ubc_check)
1793
1791
  {
1794
1792
  if (ubc_check)
1795
1793
  ctx->ubc_check = 1;
@@ -1797,7 +1795,7 @@ void SHA1DCSetUseUBC(SHA1_CTX* ctx, int ubc_check)
1797
1795
  ctx->ubc_check = 0;
1798
1796
  }
1799
1797
 
1800
- void SHA1DCSetUseDetectColl(SHA1_CTX* ctx, int detect_coll)
1798
+ void SHA1DCSetUseDetectColl(SHA1_CTX *ctx, int detect_coll)
1801
1799
  {
1802
1800
  if (detect_coll)
1803
1801
  ctx->detect_coll = 1;
@@ -1805,7 +1803,7 @@ void SHA1DCSetUseDetectColl(SHA1_CTX* ctx, int detect_coll)
1805
1803
  ctx->detect_coll = 0;
1806
1804
  }
1807
1805
 
1808
- void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX* ctx, int reduced_round_coll)
1806
+ void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX *ctx, int reduced_round_coll)
1809
1807
  {
1810
1808
  if (reduced_round_coll)
1811
1809
  ctx->reduced_round_coll = 1;
@@ -1813,12 +1811,12 @@ void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX* ctx, int reduced_round_coll)
1813
1811
  ctx->reduced_round_coll = 0;
1814
1812
  }
1815
1813
 
1816
- void SHA1DCSetCallback(SHA1_CTX* ctx, collision_block_callback callback)
1814
+ void SHA1DCSetCallback(SHA1_CTX *ctx, collision_block_callback callback)
1817
1815
  {
1818
1816
  ctx->callback = callback;
1819
1817
  }
1820
1818
 
1821
- void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)
1819
+ void SHA1DCUpdate(SHA1_CTX *ctx, const char *buf, size_t len)
1822
1820
  {
1823
1821
  unsigned left, fill;
1824
1822
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  #include "win32.h"
9
9
 
10
- #include "global.h"
10
+ #include "runtime.h"
11
11
 
12
12
  #include <wincrypt.h>
13
13
  #include <strsafe.h>
@@ -129,7 +129,8 @@ int git_hash_sha1_global_init(void)
129
129
  if ((error = hash_cng_prov_init()) < 0)
130
130
  error = hash_cryptoapi_prov_init();
131
131
 
132
- git__on_shutdown(sha1_shutdown);
132
+ if (!error)
133
+ error = git_runtime_shutdown_register(sha1_shutdown);
133
134
 
134
135
  return error;
135
136
  }
@@ -163,7 +164,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_sha1_ctx *ctx, const void *_data,
163
164
  {
164
165
  const BYTE *data = (BYTE *)_data;
165
166
 
166
- assert(ctx->ctx.cryptoapi.valid);
167
+ GIT_ASSERT(ctx->ctx.cryptoapi.valid);
167
168
 
168
169
  while (len > 0) {
169
170
  DWORD chunk = (len > MAXDWORD) ? MAXDWORD : (DWORD)len;
@@ -180,14 +181,14 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_sha1_ctx *ctx, const void *_data,
180
181
  return 0;
181
182
  }
182
183
 
183
- GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_sha1_ctx *ctx)
184
+ GIT_INLINE(int) hash_cryptoapi_final(unsigned char *out, git_hash_sha1_ctx *ctx)
184
185
  {
185
- DWORD len = 20;
186
+ DWORD len = GIT_HASH_SHA1_SIZE;
186
187
  int error = 0;
187
188
 
188
- assert(ctx->ctx.cryptoapi.valid);
189
+ GIT_ASSERT(ctx->ctx.cryptoapi.valid);
189
190
 
190
- if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) {
191
+ if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out, &len, 0)) {
191
192
  git_error_set(GIT_ERROR_OS, "legacy hash data could not be finished");
192
193
  error = -1;
193
194
  }
@@ -261,9 +262,9 @@ GIT_INLINE(int) hash_cng_update(git_hash_sha1_ctx *ctx, const void *_data, size_
261
262
  return 0;
262
263
  }
263
264
 
264
- GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_sha1_ctx *ctx)
265
+ GIT_INLINE(int) hash_cng_final(unsigned char *out, git_hash_sha1_ctx *ctx)
265
266
  {
266
- if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) {
267
+ if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out, GIT_HASH_SHA1_SIZE, 0) < 0) {
267
268
  git_error_set(GIT_ERROR_OS, "hash could not be finished");
268
269
  return -1;
269
270
  }
@@ -285,7 +286,7 @@ int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
285
286
  {
286
287
  int error = 0;
287
288
 
288
- assert(ctx);
289
+ GIT_ASSERT_ARG(ctx);
289
290
 
290
291
  /*
291
292
  * When compiled with GIT_THREADS, the global hash_prov data is
@@ -302,27 +303,30 @@ int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx)
302
303
 
303
304
  int git_hash_sha1_init(git_hash_sha1_ctx *ctx)
304
305
  {
305
- assert(ctx && ctx->type);
306
+ GIT_ASSERT_ARG(ctx);
307
+ GIT_ASSERT_ARG(ctx->type);
306
308
  return (ctx->type == CNG) ? hash_cng_init(ctx) : hash_cryptoapi_init(ctx);
307
309
  }
308
310
 
309
311
  int git_hash_sha1_update(git_hash_sha1_ctx *ctx, const void *data, size_t len)
310
312
  {
311
- assert(ctx && ctx->type);
313
+ GIT_ASSERT_ARG(ctx);
314
+ GIT_ASSERT_ARG(ctx->type);
312
315
  return (ctx->type == CNG) ? hash_cng_update(ctx, data, len) : hash_cryptoapi_update(ctx, data, len);
313
316
  }
314
317
 
315
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *ctx)
318
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *ctx)
316
319
  {
317
- assert(ctx && ctx->type);
320
+ GIT_ASSERT_ARG(ctx);
321
+ GIT_ASSERT_ARG(ctx->type);
318
322
  return (ctx->type == CNG) ? hash_cng_final(out, ctx) : hash_cryptoapi_final(out, ctx);
319
323
  }
320
324
 
321
325
  void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx)
322
326
  {
323
- assert(ctx);
324
-
325
- if (ctx->type == CNG)
327
+ if (!ctx)
328
+ return;
329
+ else if (ctx->type == CNG)
326
330
  hash_ctx_cng_cleanup(ctx);
327
331
  else if(ctx->type == CRYPTOAPI)
328
332
  hash_ctx_cryptoapi_cleanup(ctx);
@@ -26,6 +26,8 @@ typedef struct git_hash_sha1_ctx git_hash_sha1_ctx;
26
26
  # include "sha1/generic.h"
27
27
  #endif
28
28
 
29
+ #define GIT_HASH_SHA1_SIZE 20
30
+
29
31
  int git_hash_sha1_global_init(void);
30
32
 
31
33
  int git_hash_sha1_ctx_init(git_hash_sha1_ctx *ctx);
@@ -33,6 +35,6 @@ void git_hash_sha1_ctx_cleanup(git_hash_sha1_ctx *ctx);
33
35
 
34
36
  int git_hash_sha1_init(git_hash_sha1_ctx *c);
35
37
  int git_hash_sha1_update(git_hash_sha1_ctx *c, const void *data, size_t len);
36
- int git_hash_sha1_final(git_oid *out, git_hash_sha1_ctx *c);
38
+ int git_hash_sha1_final(unsigned char *out, git_hash_sha1_ctx *c);
37
39
 
38
40
  #endif
@@ -12,85 +12,104 @@ int git_hash_global_init(void)
12
12
  return git_hash_sha1_global_init();
13
13
  }
14
14
 
15
- int git_hash_ctx_init(git_hash_ctx *ctx)
15
+ int git_hash_ctx_init(git_hash_ctx *ctx, git_hash_algorithm_t algorithm)
16
16
  {
17
17
  int error;
18
18
 
19
- if ((error = git_hash_sha1_ctx_init(&ctx->sha1)) < 0)
20
- return error;
21
-
22
- ctx->algo = GIT_HASH_ALGO_SHA1;
19
+ switch (algorithm) {
20
+ case GIT_HASH_ALGORITHM_SHA1:
21
+ error = git_hash_sha1_ctx_init(&ctx->ctx.sha1);
22
+ break;
23
+ default:
24
+ git_error_set(GIT_ERROR_INTERNAL, "unknown hash algorithm");
25
+ error = -1;
26
+ }
23
27
 
24
- return 0;
28
+ ctx->algorithm = algorithm;
29
+ return error;
25
30
  }
26
31
 
27
32
  void git_hash_ctx_cleanup(git_hash_ctx *ctx)
28
33
  {
29
- switch (ctx->algo) {
30
- case GIT_HASH_ALGO_SHA1:
31
- git_hash_sha1_ctx_cleanup(&ctx->sha1);
32
- return;
33
- default:
34
- assert(0);
34
+ switch (ctx->algorithm) {
35
+ case GIT_HASH_ALGORITHM_SHA1:
36
+ git_hash_sha1_ctx_cleanup(&ctx->ctx.sha1);
37
+ return;
38
+ default:
39
+ /* unreachable */ ;
35
40
  }
36
41
  }
37
42
 
38
43
  int git_hash_init(git_hash_ctx *ctx)
39
44
  {
40
- switch (ctx->algo) {
41
- case GIT_HASH_ALGO_SHA1:
42
- return git_hash_sha1_init(&ctx->sha1);
43
- default:
44
- assert(0);
45
- return -1;
45
+ switch (ctx->algorithm) {
46
+ case GIT_HASH_ALGORITHM_SHA1:
47
+ return git_hash_sha1_init(&ctx->ctx.sha1);
48
+ default:
49
+ /* unreachable */ ;
46
50
  }
51
+
52
+ git_error_set(GIT_ERROR_INTERNAL, "unknown hash algorithm");
53
+ return -1;
47
54
  }
48
55
 
49
56
  int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
50
57
  {
51
- switch (ctx->algo) {
52
- case GIT_HASH_ALGO_SHA1:
53
- return git_hash_sha1_update(&ctx->sha1, data, len);
54
- default:
55
- assert(0);
56
- return -1;
58
+ switch (ctx->algorithm) {
59
+ case GIT_HASH_ALGORITHM_SHA1:
60
+ return git_hash_sha1_update(&ctx->ctx.sha1, data, len);
61
+ default:
62
+ /* unreachable */ ;
57
63
  }
64
+
65
+ git_error_set(GIT_ERROR_INTERNAL, "unknown hash algorithm");
66
+ return -1;
58
67
  }
59
68
 
60
- int git_hash_final(git_oid *out, git_hash_ctx *ctx)
69
+ int git_hash_final(unsigned char *out, git_hash_ctx *ctx)
61
70
  {
62
- switch (ctx->algo) {
63
- case GIT_HASH_ALGO_SHA1:
64
- return git_hash_sha1_final(out, &ctx->sha1);
65
- default:
66
- assert(0);
67
- return -1;
71
+ switch (ctx->algorithm) {
72
+ case GIT_HASH_ALGORITHM_SHA1:
73
+ return git_hash_sha1_final(out, &ctx->ctx.sha1);
74
+ default:
75
+ /* unreachable */ ;
68
76
  }
77
+
78
+ git_error_set(GIT_ERROR_INTERNAL, "unknown hash algorithm");
79
+ return -1;
69
80
  }
70
81
 
71
- int git_hash_buf(git_oid *out, const void *data, size_t len)
82
+ int git_hash_buf(
83
+ unsigned char *out,
84
+ const void *data,
85
+ size_t len,
86
+ git_hash_algorithm_t algorithm)
72
87
  {
73
88
  git_hash_ctx ctx;
74
89
  int error = 0;
75
90
 
76
- if (git_hash_ctx_init(&ctx) < 0)
91
+ if (git_hash_ctx_init(&ctx, algorithm) < 0)
77
92
  return -1;
78
93
 
79
94
  if ((error = git_hash_update(&ctx, data, len)) >= 0)
80
95
  error = git_hash_final(out, &ctx);
81
96
 
82
97
  git_hash_ctx_cleanup(&ctx);
83
-
98
+
84
99
  return error;
85
100
  }
86
101
 
87
- int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n)
102
+ int git_hash_vec(
103
+ unsigned char *out,
104
+ git_str_vec *vec,
105
+ size_t n,
106
+ git_hash_algorithm_t algorithm)
88
107
  {
89
108
  git_hash_ctx ctx;
90
109
  size_t i;
91
110
  int error = 0;
92
111
 
93
- if (git_hash_ctx_init(&ctx) < 0)
112
+ if (git_hash_ctx_init(&ctx, algorithm) < 0)
94
113
  return -1;
95
114
 
96
115
  for (i = 0; i < n; i++) {
@@ -105,3 +124,19 @@ done:
105
124
 
106
125
  return error;
107
126
  }
127
+
128
+ int git_hash_fmt(char *out, unsigned char *hash, size_t hash_len)
129
+ {
130
+ static char hex[] = "0123456789abcdef";
131
+ char *str = out;
132
+ size_t i;
133
+
134
+ for (i = 0; i < hash_len; i++) {
135
+ *str++ = hex[hash[i] >> 4];
136
+ *str++ = hex[hash[i] & 0x0f];
137
+ }
138
+
139
+ *str++ = '\0';
140
+
141
+ return 0;
142
+ }
@@ -10,37 +10,37 @@
10
10
 
11
11
  #include "common.h"
12
12
 
13
- #include "git2/oid.h"
13
+ #include "hash/sha1.h"
14
14
 
15
15
  typedef struct {
16
16
  void *data;
17
17
  size_t len;
18
- } git_buf_vec;
18
+ } git_str_vec;
19
19
 
20
20
  typedef enum {
21
- GIT_HASH_ALGO_UNKNOWN = 0,
22
- GIT_HASH_ALGO_SHA1,
23
- } git_hash_algo_t;
24
-
25
- #include "hash/sha1.h"
21
+ GIT_HASH_ALGORITHM_NONE = 0,
22
+ GIT_HASH_ALGORITHM_SHA1
23
+ } git_hash_algorithm_t;
26
24
 
27
25
  typedef struct git_hash_ctx {
28
26
  union {
29
27
  git_hash_sha1_ctx sha1;
30
- };
31
- git_hash_algo_t algo;
28
+ } ctx;
29
+ git_hash_algorithm_t algorithm;
32
30
  } git_hash_ctx;
33
31
 
34
32
  int git_hash_global_init(void);
35
33
 
36
- int git_hash_ctx_init(git_hash_ctx *ctx);
34
+ int git_hash_ctx_init(git_hash_ctx *ctx, git_hash_algorithm_t algorithm);
37
35
  void git_hash_ctx_cleanup(git_hash_ctx *ctx);
38
36
 
39
37
  int git_hash_init(git_hash_ctx *c);
40
38
  int git_hash_update(git_hash_ctx *c, const void *data, size_t len);
41
- int git_hash_final(git_oid *out, git_hash_ctx *c);
39
+ int git_hash_final(unsigned char *out, git_hash_ctx *c);
40
+
41
+ int git_hash_buf(unsigned char *out, const void *data, size_t len, git_hash_algorithm_t algorithm);
42
+ int git_hash_vec(unsigned char *out, git_str_vec *vec, size_t n, git_hash_algorithm_t algorithm);
42
43
 
43
- int git_hash_buf(git_oid *out, const void *data, size_t len);
44
- int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n);
44
+ int git_hash_fmt(char *out, unsigned char *hash, size_t hash_len);
45
45
 
46
46
  #endif