rugged 0.27.9 → 0.27.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (420) 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 +98 -54
  5. data/vendor/libgit2/COPYING +28 -0
  6. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  7. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +9 -8
  8. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  9. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  10. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
  11. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
  12. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
  13. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  14. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
  15. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  16. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
  17. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
  18. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
  19. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
  20. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  21. data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -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.h +5 -0
  82. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  83. data/vendor/libgit2/include/git2/apply.h +149 -0
  84. data/vendor/libgit2/include/git2/attr.h +38 -20
  85. data/vendor/libgit2/include/git2/blame.h +42 -25
  86. data/vendor/libgit2/include/git2/blob.h +45 -13
  87. data/vendor/libgit2/include/git2/branch.h +1 -1
  88. data/vendor/libgit2/include/git2/buffer.h +22 -16
  89. data/vendor/libgit2/include/git2/cert.h +135 -0
  90. data/vendor/libgit2/include/git2/checkout.h +65 -32
  91. data/vendor/libgit2/include/git2/cherrypick.h +9 -7
  92. data/vendor/libgit2/include/git2/clone.h +12 -10
  93. data/vendor/libgit2/include/git2/commit.h +53 -3
  94. data/vendor/libgit2/include/git2/common.h +60 -8
  95. data/vendor/libgit2/include/git2/config.h +30 -19
  96. data/vendor/libgit2/include/git2/cred.h +308 -0
  97. data/vendor/libgit2/include/git2/deprecated.h +493 -0
  98. data/vendor/libgit2/include/git2/describe.h +32 -9
  99. data/vendor/libgit2/include/git2/diff.h +208 -156
  100. data/vendor/libgit2/include/git2/errors.h +54 -46
  101. data/vendor/libgit2/include/git2/filter.h +8 -0
  102. data/vendor/libgit2/include/git2/ignore.h +2 -2
  103. data/vendor/libgit2/include/git2/index.h +74 -52
  104. data/vendor/libgit2/include/git2/indexer.h +76 -6
  105. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  106. data/vendor/libgit2/include/git2/merge.h +35 -18
  107. data/vendor/libgit2/include/git2/net.h +0 -5
  108. data/vendor/libgit2/include/git2/notes.h +1 -1
  109. data/vendor/libgit2/include/git2/object.h +17 -29
  110. data/vendor/libgit2/include/git2/odb.h +12 -11
  111. data/vendor/libgit2/include/git2/odb_backend.h +10 -9
  112. data/vendor/libgit2/include/git2/oid.h +2 -2
  113. data/vendor/libgit2/include/git2/pack.h +14 -3
  114. data/vendor/libgit2/include/git2/proxy.h +14 -8
  115. data/vendor/libgit2/include/git2/rebase.h +53 -6
  116. data/vendor/libgit2/include/git2/refs.h +33 -15
  117. data/vendor/libgit2/include/git2/refspec.h +17 -0
  118. data/vendor/libgit2/include/git2/remote.h +123 -24
  119. data/vendor/libgit2/include/git2/repository.h +76 -39
  120. data/vendor/libgit2/include/git2/revert.h +6 -4
  121. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  122. data/vendor/libgit2/include/git2/signature.h +2 -2
  123. data/vendor/libgit2/include/git2/stash.h +15 -12
  124. data/vendor/libgit2/include/git2/status.h +33 -20
  125. data/vendor/libgit2/include/git2/submodule.h +30 -12
  126. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  127. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  128. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  129. data/vendor/libgit2/include/git2/sys/cred.h +90 -0
  130. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  131. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  132. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  133. data/vendor/libgit2/include/git2/sys/merge.h +9 -4
  134. data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -22
  135. data/vendor/libgit2/include/git2/sys/path.h +64 -0
  136. data/vendor/libgit2/include/git2/sys/refdb_backend.h +76 -40
  137. data/vendor/libgit2/include/git2/sys/repository.h +5 -1
  138. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  139. data/vendor/libgit2/include/git2/sys/transport.h +129 -83
  140. data/vendor/libgit2/include/git2/tag.h +13 -4
  141. data/vendor/libgit2/include/git2/trace.h +2 -2
  142. data/vendor/libgit2/include/git2/transaction.h +1 -0
  143. data/vendor/libgit2/include/git2/transport.h +11 -311
  144. data/vendor/libgit2/include/git2/tree.h +4 -4
  145. data/vendor/libgit2/include/git2/types.h +33 -111
  146. data/vendor/libgit2/include/git2/version.h +4 -4
  147. data/vendor/libgit2/include/git2/worktree.h +48 -13
  148. data/vendor/libgit2/src/CMakeLists.txt +96 -164
  149. data/vendor/libgit2/src/alloc.c +43 -0
  150. data/vendor/libgit2/src/alloc.h +40 -0
  151. data/vendor/libgit2/src/allocators/stdalloc.c +119 -0
  152. data/vendor/libgit2/src/{streams/curl.h → allocators/stdalloc.h} +5 -5
  153. data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
  154. data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
  155. data/vendor/libgit2/src/annotated_commit.c +15 -8
  156. data/vendor/libgit2/src/apply.c +537 -31
  157. data/vendor/libgit2/src/apply.h +3 -1
  158. data/vendor/libgit2/src/array.h +2 -2
  159. data/vendor/libgit2/src/attr.c +81 -75
  160. data/vendor/libgit2/src/attr_file.c +207 -121
  161. data/vendor/libgit2/src/attr_file.h +9 -9
  162. data/vendor/libgit2/src/attrcache.c +51 -53
  163. data/vendor/libgit2/src/attrcache.h +2 -1
  164. data/vendor/libgit2/src/blame.c +47 -20
  165. data/vendor/libgit2/src/blame.h +2 -1
  166. data/vendor/libgit2/src/blame_git.c +37 -20
  167. data/vendor/libgit2/src/blob.c +128 -42
  168. data/vendor/libgit2/src/blob.h +19 -2
  169. data/vendor/libgit2/src/branch.c +67 -43
  170. data/vendor/libgit2/src/buf_text.c +7 -6
  171. data/vendor/libgit2/src/buffer.c +69 -57
  172. data/vendor/libgit2/src/buffer.h +1 -1
  173. data/vendor/libgit2/src/cache.c +38 -45
  174. data/vendor/libgit2/src/cache.h +3 -3
  175. data/vendor/libgit2/src/cc-compat.h +20 -3
  176. data/vendor/libgit2/src/checkout.c +109 -90
  177. data/vendor/libgit2/src/cherrypick.c +15 -9
  178. data/vendor/libgit2/src/clone.c +49 -27
  179. data/vendor/libgit2/src/clone.h +4 -0
  180. data/vendor/libgit2/src/commit.c +117 -49
  181. data/vendor/libgit2/src/commit.h +7 -0
  182. data/vendor/libgit2/src/commit_list.c +30 -78
  183. data/vendor/libgit2/src/commit_list.h +2 -2
  184. data/vendor/libgit2/src/common.h +27 -91
  185. data/vendor/libgit2/src/config.c +194 -176
  186. data/vendor/libgit2/src/config.h +8 -20
  187. data/vendor/libgit2/src/config_backend.h +96 -0
  188. data/vendor/libgit2/src/config_cache.c +41 -35
  189. data/vendor/libgit2/src/config_entries.c +229 -0
  190. data/vendor/libgit2/src/config_entries.h +24 -0
  191. data/vendor/libgit2/src/config_file.c +439 -753
  192. data/vendor/libgit2/src/config_mem.c +220 -0
  193. data/vendor/libgit2/src/config_parse.c +114 -63
  194. data/vendor/libgit2/src/config_parse.h +17 -16
  195. data/vendor/libgit2/src/config_snapshot.c +206 -0
  196. data/vendor/libgit2/src/crlf.c +219 -190
  197. data/vendor/libgit2/src/delta.c +25 -18
  198. data/vendor/libgit2/src/describe.c +42 -41
  199. data/vendor/libgit2/src/diff.c +53 -68
  200. data/vendor/libgit2/src/diff.h +2 -1
  201. data/vendor/libgit2/src/diff_driver.c +47 -49
  202. data/vendor/libgit2/src/diff_file.c +19 -17
  203. data/vendor/libgit2/src/diff_file.h +1 -1
  204. data/vendor/libgit2/src/diff_generate.c +162 -106
  205. data/vendor/libgit2/src/diff_generate.h +3 -3
  206. data/vendor/libgit2/src/diff_parse.c +4 -4
  207. data/vendor/libgit2/src/diff_print.c +42 -30
  208. data/vendor/libgit2/src/diff_stats.c +22 -7
  209. data/vendor/libgit2/src/diff_tform.c +16 -16
  210. data/vendor/libgit2/src/diff_xdiff.c +15 -3
  211. data/vendor/libgit2/src/errors.c +51 -39
  212. data/vendor/libgit2/src/errors.h +81 -0
  213. data/vendor/libgit2/src/features.h.in +11 -3
  214. data/vendor/libgit2/src/fetch.c +10 -5
  215. data/vendor/libgit2/src/fetchhead.c +17 -17
  216. data/vendor/libgit2/src/filebuf.c +32 -36
  217. data/vendor/libgit2/src/filebuf.h +2 -2
  218. data/vendor/libgit2/src/filter.c +46 -38
  219. data/vendor/libgit2/src/filter.h +0 -10
  220. data/vendor/libgit2/src/{fileops.c → futils.c} +80 -73
  221. data/vendor/libgit2/src/{fileops.h → futils.h} +6 -6
  222. data/vendor/libgit2/src/global.c +48 -63
  223. data/vendor/libgit2/src/global.h +0 -2
  224. data/vendor/libgit2/src/hash.c +61 -0
  225. data/vendor/libgit2/src/hash.h +20 -19
  226. data/vendor/libgit2/src/hash/sha1.h +38 -0
  227. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +48 -0
  228. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
  229. data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +17 -17
  230. data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
  231. data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
  232. data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -10
  233. data/vendor/libgit2/src/hash/sha1/mbedtls.c +46 -0
  234. data/vendor/libgit2/src/hash/sha1/mbedtls.h +19 -0
  235. data/vendor/libgit2/src/hash/sha1/openssl.c +59 -0
  236. data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
  237. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
  238. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
  239. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
  240. data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
  241. data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +47 -37
  242. data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
  243. data/vendor/libgit2/src/hashsig.c +5 -5
  244. data/vendor/libgit2/src/idxmap.c +107 -61
  245. data/vendor/libgit2/src/idxmap.h +153 -31
  246. data/vendor/libgit2/src/ignore.c +43 -47
  247. data/vendor/libgit2/src/index.c +337 -232
  248. data/vendor/libgit2/src/index.h +17 -1
  249. data/vendor/libgit2/src/indexer.c +346 -175
  250. data/vendor/libgit2/src/integer.h +71 -26
  251. data/vendor/libgit2/src/iterator.c +142 -70
  252. data/vendor/libgit2/src/iterator.h +15 -0
  253. data/vendor/libgit2/src/khash.h +3 -1
  254. data/vendor/libgit2/src/mailmap.c +485 -0
  255. data/vendor/libgit2/src/mailmap.h +35 -0
  256. data/vendor/libgit2/src/map.h +1 -1
  257. data/vendor/libgit2/src/merge.c +144 -100
  258. data/vendor/libgit2/src/merge_driver.c +11 -11
  259. data/vendor/libgit2/src/merge_file.c +2 -2
  260. data/vendor/libgit2/src/mwindow.c +24 -29
  261. data/vendor/libgit2/src/mwindow.h +4 -4
  262. data/vendor/libgit2/src/net.c +184 -0
  263. data/vendor/libgit2/src/net.h +36 -0
  264. data/vendor/libgit2/src/netops.c +55 -156
  265. data/vendor/libgit2/src/netops.h +3 -23
  266. data/vendor/libgit2/src/notes.c +16 -11
  267. data/vendor/libgit2/src/object.c +120 -69
  268. data/vendor/libgit2/src/object.h +22 -9
  269. data/vendor/libgit2/src/object_api.c +8 -8
  270. data/vendor/libgit2/src/odb.c +116 -93
  271. data/vendor/libgit2/src/odb.h +8 -7
  272. data/vendor/libgit2/src/odb_loose.c +62 -55
  273. data/vendor/libgit2/src/odb_mempack.c +21 -34
  274. data/vendor/libgit2/src/odb_pack.c +18 -14
  275. data/vendor/libgit2/src/offmap.c +53 -35
  276. data/vendor/libgit2/src/offmap.h +108 -21
  277. data/vendor/libgit2/src/oid.c +12 -7
  278. data/vendor/libgit2/src/oidmap.c +49 -47
  279. data/vendor/libgit2/src/oidmap.h +101 -24
  280. data/vendor/libgit2/src/pack-objects.c +88 -87
  281. data/vendor/libgit2/src/pack-objects.h +2 -8
  282. data/vendor/libgit2/src/pack.c +99 -101
  283. data/vendor/libgit2/src/pack.h +17 -19
  284. data/vendor/libgit2/src/parse.c +10 -0
  285. data/vendor/libgit2/src/parse.h +3 -3
  286. data/vendor/libgit2/src/patch.c +4 -4
  287. data/vendor/libgit2/src/patch_generate.c +20 -20
  288. data/vendor/libgit2/src/patch_parse.c +151 -63
  289. data/vendor/libgit2/src/path.c +169 -125
  290. data/vendor/libgit2/src/path.h +3 -71
  291. data/vendor/libgit2/src/pathspec.c +19 -19
  292. data/vendor/libgit2/src/pool.c +26 -22
  293. data/vendor/libgit2/src/pool.h +7 -7
  294. data/vendor/libgit2/src/posix.c +10 -10
  295. data/vendor/libgit2/src/posix.h +12 -1
  296. data/vendor/libgit2/src/proxy.c +8 -3
  297. data/vendor/libgit2/src/push.c +37 -31
  298. data/vendor/libgit2/src/push.h +2 -1
  299. data/vendor/libgit2/src/reader.c +265 -0
  300. data/vendor/libgit2/src/reader.h +107 -0
  301. data/vendor/libgit2/src/rebase.c +115 -59
  302. data/vendor/libgit2/src/refdb.c +15 -3
  303. data/vendor/libgit2/src/refdb_fs.c +381 -254
  304. data/vendor/libgit2/src/reflog.c +13 -15
  305. data/vendor/libgit2/src/refs.c +118 -88
  306. data/vendor/libgit2/src/refs.h +5 -3
  307. data/vendor/libgit2/src/refspec.c +56 -37
  308. data/vendor/libgit2/src/refspec.h +1 -1
  309. data/vendor/libgit2/src/regexp.c +221 -0
  310. data/vendor/libgit2/src/regexp.h +97 -0
  311. data/vendor/libgit2/src/remote.c +266 -215
  312. data/vendor/libgit2/src/remote.h +11 -2
  313. data/vendor/libgit2/src/repository.c +280 -225
  314. data/vendor/libgit2/src/repository.h +52 -40
  315. data/vendor/libgit2/src/reset.c +8 -8
  316. data/vendor/libgit2/src/revert.c +14 -9
  317. data/vendor/libgit2/src/revparse.c +47 -48
  318. data/vendor/libgit2/src/revwalk.c +120 -57
  319. data/vendor/libgit2/src/revwalk.h +22 -1
  320. data/vendor/libgit2/src/settings.c +47 -10
  321. data/vendor/libgit2/src/signature.c +11 -11
  322. data/vendor/libgit2/src/sortedcache.c +22 -36
  323. data/vendor/libgit2/src/sortedcache.h +1 -1
  324. data/vendor/libgit2/src/stash.c +125 -99
  325. data/vendor/libgit2/src/status.c +28 -22
  326. data/vendor/libgit2/src/stream.h +17 -2
  327. data/vendor/libgit2/src/streams/mbedtls.c +483 -0
  328. data/vendor/libgit2/src/streams/mbedtls.h +23 -0
  329. data/vendor/libgit2/src/streams/openssl.c +224 -114
  330. data/vendor/libgit2/src/streams/openssl.h +4 -108
  331. data/vendor/libgit2/src/streams/registry.c +118 -0
  332. data/vendor/libgit2/src/streams/registry.h +19 -0
  333. data/vendor/libgit2/src/streams/socket.c +55 -30
  334. data/vendor/libgit2/src/streams/stransport.c +57 -32
  335. data/vendor/libgit2/src/streams/stransport.h +5 -0
  336. data/vendor/libgit2/src/streams/tls.c +50 -19
  337. data/vendor/libgit2/src/streams/tls.h +12 -4
  338. data/vendor/libgit2/src/strmap.c +47 -74
  339. data/vendor/libgit2/src/strmap.h +108 -33
  340. data/vendor/libgit2/src/submodule.c +272 -216
  341. data/vendor/libgit2/src/submodule.h +1 -1
  342. data/vendor/libgit2/src/sysdir.c +29 -19
  343. data/vendor/libgit2/src/tag.c +41 -28
  344. data/vendor/libgit2/src/tag.h +2 -1
  345. data/vendor/libgit2/src/trace.c +2 -2
  346. data/vendor/libgit2/src/trace.h +3 -3
  347. data/vendor/libgit2/src/trailer.c +52 -38
  348. data/vendor/libgit2/src/transaction.c +30 -29
  349. data/vendor/libgit2/src/transport.c +5 -5
  350. data/vendor/libgit2/src/transports/auth.c +15 -11
  351. data/vendor/libgit2/src/transports/auth.h +10 -3
  352. data/vendor/libgit2/src/transports/auth_negotiate.c +33 -18
  353. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  354. data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
  355. data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
  356. data/vendor/libgit2/src/transports/cred.c +24 -24
  357. data/vendor/libgit2/src/transports/git.c +26 -31
  358. data/vendor/libgit2/src/transports/http.c +881 -348
  359. data/vendor/libgit2/src/transports/http.h +2 -0
  360. data/vendor/libgit2/src/transports/local.c +35 -35
  361. data/vendor/libgit2/src/transports/smart.c +70 -47
  362. data/vendor/libgit2/src/transports/smart.h +3 -4
  363. data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
  364. data/vendor/libgit2/src/transports/smart_protocol.c +96 -116
  365. data/vendor/libgit2/src/transports/ssh.c +77 -66
  366. data/vendor/libgit2/src/transports/winhttp.c +318 -314
  367. data/vendor/libgit2/src/tree-cache.c +19 -12
  368. data/vendor/libgit2/src/tree.c +103 -142
  369. data/vendor/libgit2/src/tree.h +1 -12
  370. data/vendor/libgit2/src/unix/map.c +3 -3
  371. data/vendor/libgit2/src/unix/posix.h +1 -11
  372. data/vendor/libgit2/src/userdiff.h +3 -1
  373. data/vendor/libgit2/src/util.c +70 -56
  374. data/vendor/libgit2/src/util.h +28 -156
  375. data/vendor/libgit2/src/vector.c +4 -4
  376. data/vendor/libgit2/src/wildmatch.c +320 -0
  377. data/vendor/libgit2/src/wildmatch.h +23 -0
  378. data/vendor/libgit2/src/win32/dir.c +3 -3
  379. data/vendor/libgit2/src/win32/findfile.c +3 -3
  380. data/vendor/libgit2/src/win32/map.c +9 -11
  381. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  382. data/vendor/libgit2/src/win32/path_w32.c +113 -9
  383. data/vendor/libgit2/src/win32/path_w32.h +18 -29
  384. data/vendor/libgit2/src/win32/posix.h +1 -4
  385. data/vendor/libgit2/src/win32/posix_w32.c +70 -45
  386. data/vendor/libgit2/src/win32/precompiled.h +0 -2
  387. data/vendor/libgit2/src/win32/thread.c +5 -10
  388. data/vendor/libgit2/src/win32/w32_buffer.c +9 -5
  389. data/vendor/libgit2/src/win32/w32_common.h +39 -0
  390. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +3 -2
  391. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +26 -75
  392. data/vendor/libgit2/src/win32/w32_stack.c +6 -11
  393. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  394. data/vendor/libgit2/src/win32/w32_util.c +27 -64
  395. data/vendor/libgit2/src/win32/w32_util.h +5 -49
  396. data/vendor/libgit2/src/worktree.c +95 -60
  397. data/vendor/libgit2/src/worktree.h +2 -0
  398. data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
  399. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  400. data/vendor/libgit2/src/xdiff/xmerge.c +27 -15
  401. data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
  402. data/vendor/libgit2/src/zstream.c +4 -4
  403. metadata +122 -33
  404. data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
  405. data/vendor/libgit2/deps/regex/config.h +0 -7
  406. data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
  407. data/vendor/libgit2/deps/regex/regex.c +0 -92
  408. data/vendor/libgit2/deps/regex/regex.h +0 -582
  409. data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
  410. data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
  411. data/vendor/libgit2/deps/regex/regexec.c +0 -4369
  412. data/vendor/libgit2/include/git2/inttypes.h +0 -309
  413. data/vendor/libgit2/include/git2/sys/time.h +0 -31
  414. data/vendor/libgit2/libgit2.pc.in +0 -13
  415. data/vendor/libgit2/src/config_file.h +0 -73
  416. data/vendor/libgit2/src/fnmatch.c +0 -248
  417. data/vendor/libgit2/src/fnmatch.h +0 -48
  418. data/vendor/libgit2/src/hash/hash_collisiondetect.h +0 -47
  419. data/vendor/libgit2/src/hash/hash_openssl.h +0 -59
  420. data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -57,7 +57,8 @@ extern int git_diff_delta__format_file_header(
57
57
  const git_diff_delta *delta,
58
58
  const char *oldpfx,
59
59
  const char *newpfx,
60
- int oid_strlen);
60
+ int oid_strlen,
61
+ bool print_index);
61
62
 
62
63
  extern int git_diff_delta__cmp(const void *a, const void *b);
63
64
  extern int git_diff_delta__casecmp(const void *a, const void *b);
@@ -9,11 +9,13 @@
9
9
 
10
10
  #include "git2/attr.h"
11
11
 
12
+ #include "common.h"
12
13
  #include "diff.h"
13
14
  #include "strmap.h"
14
15
  #include "map.h"
15
16
  #include "buf_text.h"
16
17
  #include "config.h"
18
+ #include "regexp.h"
17
19
  #include "repository.h"
18
20
 
19
21
  typedef enum {
@@ -24,7 +26,7 @@ typedef enum {
24
26
  } git_diff_driver_t;
25
27
 
26
28
  typedef struct {
27
- regex_t re;
29
+ git_regexp re;
28
30
  int flags;
29
31
  } git_diff_driver_pattern;
30
32
 
@@ -38,7 +40,7 @@ struct git_diff_driver {
38
40
  uint32_t binary_flags;
39
41
  uint32_t other_flags;
40
42
  git_array_t(git_diff_driver_pattern) fn_patterns;
41
- regex_t word_pattern;
43
+ git_regexp word_pattern;
42
44
  char name[GIT_FLEX_ARRAY];
43
45
  };
44
46
 
@@ -63,7 +65,7 @@ git_diff_driver_registry *git_diff_driver_registry_new(void)
63
65
  if (!reg)
64
66
  return NULL;
65
67
 
66
- if (git_strmap_alloc(&reg->drivers) < 0) {
68
+ if (git_strmap_new(&reg->drivers) < 0) {
67
69
  git_diff_driver_registry_free(reg);
68
70
  return NULL;
69
71
  }
@@ -112,7 +114,7 @@ static int diff_driver_add_patterns(
112
114
  if (error < 0)
113
115
  break;
114
116
 
115
- if ((error = p_regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
117
+ if ((error = git_regexp_compile(&pat->re, buf.ptr, regex_flags)) != 0) {
116
118
  /*
117
119
  * TODO: issue a warning
118
120
  */
@@ -121,7 +123,7 @@ static int diff_driver_add_patterns(
121
123
 
122
124
  if (error && pat != NULL)
123
125
  (void)git_array_pop(drv->fn_patterns); /* release last item */
124
- git_buf_free(&buf);
126
+ git_buf_dispose(&buf);
125
127
 
126
128
  /* We want to ignore bad patterns, so return success regardless */
127
129
  return 0;
@@ -129,7 +131,7 @@ static int diff_driver_add_patterns(
129
131
 
130
132
  static int diff_driver_xfuncname(const git_config_entry *entry, void *payload)
131
133
  {
132
- return diff_driver_add_patterns(payload, entry->value, REG_EXTENDED);
134
+ return diff_driver_add_patterns(payload, entry->value, 0);
133
135
  }
134
136
 
135
137
  static int diff_driver_funcname(const git_config_entry *entry, void *payload)
@@ -149,7 +151,7 @@ static git_diff_driver_registry *git_repository_driver_registry(
149
151
  }
150
152
 
151
153
  if (!repo->diff_drivers)
152
- giterr_set(GITERR_REPOSITORY, "unable to create diff driver registry");
154
+ git_error_set(GIT_ERROR_REPOSITORY, "unable to create diff driver registry");
153
155
 
154
156
  return repo->diff_drivers;
155
157
  }
@@ -162,11 +164,11 @@ static int diff_driver_alloc(
162
164
  namelen = strlen(name),
163
165
  alloclen;
164
166
 
165
- GITERR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
166
- GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
167
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
168
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
167
169
 
168
170
  driver = git__calloc(1, alloclen);
169
- GITERR_CHECK_ALLOC(driver);
171
+ GIT_ERROR_CHECK_ALLOC(driver);
170
172
 
171
173
  memcpy(driver->name, name, namelen);
172
174
 
@@ -183,9 +185,9 @@ static int git_diff_driver_builtin(
183
185
  git_diff_driver_registry *reg,
184
186
  const char *driver_name)
185
187
  {
186
- int error = 0;
187
188
  git_diff_driver_definition *ddef = NULL;
188
189
  git_diff_driver *drv = NULL;
190
+ int error = 0;
189
191
  size_t idx;
190
192
 
191
193
  for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
@@ -204,20 +206,15 @@ static int git_diff_driver_builtin(
204
206
 
205
207
  if (ddef->fns &&
206
208
  (error = diff_driver_add_patterns(
207
- drv, ddef->fns, ddef->flags | REG_EXTENDED)) < 0)
209
+ drv, ddef->fns, ddef->flags)) < 0)
208
210
  goto done;
209
211
 
210
212
  if (ddef->words &&
211
- (error = p_regcomp(
212
- &drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED)))
213
- {
214
- error = giterr_set_regex(&drv->word_pattern, error);
213
+ (error = git_regexp_compile(&drv->word_pattern, ddef->words, ddef->flags)) < 0)
215
214
  goto done;
216
- }
217
215
 
218
- git_strmap_insert(reg->drivers, drv->name, drv, &error);
219
- if (error > 0)
220
- error = 0;
216
+ if ((error = git_strmap_set(reg->drivers, drv->name, drv)) < 0)
217
+ goto done;
221
218
 
222
219
  done:
223
220
  if (error && drv)
@@ -233,9 +230,8 @@ static int git_diff_driver_load(
233
230
  {
234
231
  int error = 0;
235
232
  git_diff_driver_registry *reg;
236
- git_diff_driver *drv = NULL;
233
+ git_diff_driver *drv;
237
234
  size_t namelen;
238
- khiter_t pos;
239
235
  git_config *cfg = NULL;
240
236
  git_buf name = GIT_BUF_INIT;
241
237
  git_config_entry *ce = NULL;
@@ -244,9 +240,8 @@ static int git_diff_driver_load(
244
240
  if ((reg = git_repository_driver_registry(repo)) == NULL)
245
241
  return -1;
246
242
 
247
- pos = git_strmap_lookup_index(reg->drivers, driver_name);
248
- if (git_strmap_valid_index(reg->drivers, pos)) {
249
- *out = git_strmap_value_at(reg->drivers, pos);
243
+ if ((drv = git_strmap_get(reg->drivers, driver_name)) != NULL) {
244
+ *out = drv;
250
245
  return 0;
251
246
  }
252
247
 
@@ -257,7 +252,7 @@ static int git_diff_driver_load(
257
252
 
258
253
  /* if you can't read config for repo, just use default driver */
259
254
  if (git_repository_config_snapshot(&cfg, repo) < 0) {
260
- giterr_clear();
255
+ git_error_clear();
261
256
  goto done;
262
257
  }
263
258
 
@@ -283,21 +278,25 @@ static int git_diff_driver_load(
283
278
  /* TODO: warn if diff.<name>.command or diff.<name>.textconv are set */
284
279
 
285
280
  git_buf_truncate(&name, namelen + strlen("diff.."));
286
- git_buf_put(&name, "xfuncname", strlen("xfuncname"));
281
+ if ((error = git_buf_PUTS(&name, "xfuncname")) < 0)
282
+ goto done;
283
+
287
284
  if ((error = git_config_get_multivar_foreach(
288
285
  cfg, name.ptr, NULL, diff_driver_xfuncname, drv)) < 0) {
289
286
  if (error != GIT_ENOTFOUND)
290
287
  goto done;
291
- giterr_clear(); /* no diff.<driver>.xfuncname, so just continue */
288
+ git_error_clear(); /* no diff.<driver>.xfuncname, so just continue */
292
289
  }
293
290
 
294
291
  git_buf_truncate(&name, namelen + strlen("diff.."));
295
- git_buf_put(&name, "funcname", strlen("funcname"));
292
+ if ((error = git_buf_PUTS(&name, "funcname")) < 0)
293
+ goto done;
294
+
296
295
  if ((error = git_config_get_multivar_foreach(
297
296
  cfg, name.ptr, NULL, diff_driver_funcname, drv)) < 0) {
298
297
  if (error != GIT_ENOTFOUND)
299
298
  goto done;
300
- giterr_clear(); /* no diff.<driver>.funcname, so just continue */
299
+ git_error_clear(); /* no diff.<driver>.funcname, so just continue */
301
300
  }
302
301
 
303
302
  /* if we found any patterns, set driver type to use correct callback */
@@ -307,16 +306,17 @@ static int git_diff_driver_load(
307
306
  }
308
307
 
309
308
  git_buf_truncate(&name, namelen + strlen("diff.."));
310
- git_buf_put(&name, "wordregex", strlen("wordregex"));
309
+ if ((error = git_buf_PUTS(&name, "wordregex")) < 0)
310
+ goto done;
311
+
311
312
  if ((error = git_config__lookup_entry(&ce, cfg, name.ptr, false)) < 0)
312
313
  goto done;
313
314
  if (!ce || !ce->value)
314
315
  /* no diff.<driver>.wordregex, so just continue */;
315
- else if (!(error = p_regcomp(&drv->word_pattern, ce->value, REG_EXTENDED)))
316
+ else if (!(error = git_regexp_compile(&drv->word_pattern, ce->value, 0)))
316
317
  found_driver = true;
317
318
  else {
318
319
  /* TODO: warn about bad regex instead of failure */
319
- error = giterr_set_regex(&drv->word_pattern, error);
320
320
  goto done;
321
321
  }
322
322
 
@@ -329,16 +329,14 @@ static int git_diff_driver_load(
329
329
  goto done;
330
330
 
331
331
  /* store driver in registry */
332
- git_strmap_insert(reg->drivers, drv->name, drv, &error);
333
- if (error < 0)
332
+ if ((error = git_strmap_set(reg->drivers, drv->name, drv)) < 0)
334
333
  goto done;
335
- error = 0;
336
334
 
337
335
  *out = drv;
338
336
 
339
337
  done:
340
338
  git_config_entry_free(ce);
341
- git_buf_free(&name);
339
+ git_buf_dispose(&name);
342
340
  git_config_free(cfg);
343
341
 
344
342
  if (!*out) {
@@ -369,18 +367,18 @@ int git_diff_driver_lookup(
369
367
  attrsession, 0, path, 1, attrs)) < 0)
370
368
  /* return error below */;
371
369
 
372
- else if (GIT_ATTR_UNSPECIFIED(values[0]))
370
+ else if (GIT_ATTR_IS_UNSPECIFIED(values[0]))
373
371
  /* just use the auto value */;
374
- else if (GIT_ATTR_FALSE(values[0]))
372
+ else if (GIT_ATTR_IS_FALSE(values[0]))
375
373
  *out = &global_drivers[DIFF_DRIVER_BINARY];
376
- else if (GIT_ATTR_TRUE(values[0]))
374
+ else if (GIT_ATTR_IS_TRUE(values[0]))
377
375
  *out = &global_drivers[DIFF_DRIVER_TEXT];
378
376
 
379
377
  /* otherwise look for driver information in config and build driver */
380
378
  else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) {
381
379
  if (error == GIT_ENOTFOUND) {
382
380
  error = 0;
383
- giterr_clear();
381
+ git_error_clear();
384
382
  }
385
383
  }
386
384
 
@@ -398,10 +396,10 @@ void git_diff_driver_free(git_diff_driver *driver)
398
396
  return;
399
397
 
400
398
  for (i = 0; i < git_array_size(driver->fn_patterns); ++i)
401
- regfree(& git_array_get(driver->fn_patterns, i)->re);
399
+ git_regexp_dispose(& git_array_get(driver->fn_patterns, i)->re);
402
400
  git_array_clear(driver->fn_patterns);
403
401
 
404
- regfree(&driver->word_pattern);
402
+ git_regexp_dispose(&driver->word_pattern);
405
403
 
406
404
  git__free(driver);
407
405
  }
@@ -449,19 +447,19 @@ static int diff_context_line__pattern_match(
449
447
  git_diff_driver *driver, git_buf *line)
450
448
  {
451
449
  size_t i, maxi = git_array_size(driver->fn_patterns);
452
- regmatch_t pmatch[2];
450
+ git_regmatch pmatch[2];
453
451
 
454
452
  for (i = 0; i < maxi; ++i) {
455
453
  git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i);
456
454
 
457
- if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) {
455
+ if (!git_regexp_search(&pat->re, line->ptr, 2, pmatch)) {
458
456
  if (pat->flags & REG_NEGATE)
459
457
  return false;
460
458
 
461
459
  /* use pmatch data to trim line data */
462
- i = (pmatch[1].rm_so >= 0) ? 1 : 0;
463
- git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so);
464
- git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so);
460
+ i = (pmatch[1].start >= 0) ? 1 : 0;
461
+ git_buf_consume(line, git_buf_cstr(line) + pmatch[i].start);
462
+ git_buf_truncate(line, pmatch[i].end - pmatch[i].start);
465
463
  git_buf_rtrim(line);
466
464
 
467
465
  return true;
@@ -516,7 +514,7 @@ void git_diff_find_context_init(
516
514
  void git_diff_find_context_clear(git_diff_find_context_payload *payload)
517
515
  {
518
516
  if (payload) {
519
- git_buf_free(&payload->line);
517
+ git_buf_dispose(&payload->line);
520
518
  payload->driver = NULL;
521
519
  }
522
520
  }
@@ -12,7 +12,7 @@
12
12
  #include "diff.h"
13
13
  #include "diff_generate.h"
14
14
  #include "odb.h"
15
- #include "fileops.h"
15
+ #include "futils.h"
16
16
  #include "filter.h"
17
17
 
18
18
  #define DIFF_MAX_FILESIZE 0x20000000
@@ -62,7 +62,7 @@ static int diff_file_content_init_common(
62
62
  git_diff_driver_update_options(&fc->opts_flags, fc->driver);
63
63
 
64
64
  /* make sure file is conceivable mmap-able */
65
- if ((git_off_t)((size_t)fc->file->size) != fc->file->size)
65
+ if ((size_t)fc->file->size != fc->file->size)
66
66
  fc->file->flags |= GIT_DIFF_FLAG_BINARY;
67
67
  /* check if user is forcing text diff the file */
68
68
  else if (fc->opts_flags & GIT_DIFF_FORCE_TEXT) {
@@ -161,7 +161,7 @@ int git_diff_file_content__init_from_src(
161
161
  fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
162
162
  } else {
163
163
  fc->file->size = src->buflen;
164
- git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB);
164
+ git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB);
165
165
  fc->file->id_abbrev = GIT_OID_HEXSZ;
166
166
 
167
167
  fc->map.len = src->buflen;
@@ -188,7 +188,7 @@ static int diff_file_content_commit_to_str(
188
188
  if ((error = git_submodule_lookup(&sm, fc->repo, fc->file->path)) < 0) {
189
189
  /* GIT_EEXISTS means a "submodule" that has not been git added */
190
190
  if (error == GIT_EEXISTS) {
191
- giterr_clear();
191
+ git_error_clear();
192
192
  error = 0;
193
193
  }
194
194
  return error;
@@ -232,7 +232,7 @@ static int diff_file_content_load_blob(
232
232
  int error = 0;
233
233
  git_odb_object *odb_obj = NULL;
234
234
 
235
- if (git_oid_iszero(&fc->file->id))
235
+ if (git_oid_is_zero(&fc->file->id))
236
236
  return 0;
237
237
 
238
238
  if (fc->file->mode == GIT_FILEMODE_COMMIT)
@@ -251,7 +251,7 @@ static int diff_file_content_load_blob(
251
251
 
252
252
  if (odb_obj != NULL) {
253
253
  error = git_object__from_odb_object(
254
- (git_object **)&fc->blob, fc->repo, odb_obj, GIT_OBJ_BLOB);
254
+ (git_object **)&fc->blob, fc->repo, odb_obj, GIT_OBJECT_BLOB);
255
255
  git_odb_object_free(odb_obj);
256
256
  } else {
257
257
  error = git_blob_lookup(
@@ -280,7 +280,7 @@ static int diff_file_content_load_workdir_symlink_fake(
280
280
  fc->map.data = git_buf_detach(&target);
281
281
  fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
282
282
 
283
- git_buf_free(&target);
283
+ git_buf_dispose(&target);
284
284
  return error;
285
285
  }
286
286
 
@@ -290,8 +290,8 @@ static int diff_file_content_load_workdir_symlink(
290
290
  ssize_t alloc_len, read_len;
291
291
  int symlink_supported, error;
292
292
 
293
- if ((error = git_repository__cvar(
294
- &symlink_supported, fc->repo, GIT_CVAR_SYMLINKS)) < 0)
293
+ if ((error = git_repository__configmap_lookup(
294
+ &symlink_supported, fc->repo, GIT_CONFIGMAP_SYMLINKS)) < 0)
295
295
  return -1;
296
296
 
297
297
  if (!symlink_supported)
@@ -303,13 +303,13 @@ static int diff_file_content_load_workdir_symlink(
303
303
  alloc_len = (ssize_t)(fc->file->size * 2) + 1;
304
304
 
305
305
  fc->map.data = git__calloc(alloc_len, sizeof(char));
306
- GITERR_CHECK_ALLOC(fc->map.data);
306
+ GIT_ERROR_CHECK_ALLOC(fc->map.data);
307
307
 
308
308
  fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
309
309
 
310
310
  read_len = p_readlink(git_buf_cstr(path), fc->map.data, alloc_len);
311
311
  if (read_len < 0) {
312
- giterr_set(GITERR_OS, "failed to read symlink '%s'", fc->file->path);
312
+ git_error_set(GIT_ERROR_OS, "failed to read symlink '%s'", fc->file->path);
313
313
  return -1;
314
314
  }
315
315
 
@@ -330,8 +330,10 @@ static int diff_file_content_load_workdir_file(
330
330
  if (fd < 0)
331
331
  return fd;
332
332
 
333
- if (!fc->file->size &&
334
- !(fc->file->size = git_futils_filesize(fd)))
333
+ if (!fc->file->size)
334
+ error = git_futils_filesize(&fc->file->size, fd);
335
+
336
+ if (error < 0 || !fc->file->size)
335
337
  goto cleanup;
336
338
 
337
339
  if ((diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0 &&
@@ -352,7 +354,7 @@ static int diff_file_content_load_workdir_file(
352
354
  }
353
355
 
354
356
  /* if mmap failed, fall through to try readbuffer below */
355
- giterr_clear();
357
+ git_error_clear();
356
358
  }
357
359
 
358
360
  if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
@@ -361,7 +363,7 @@ static int diff_file_content_load_workdir_file(
361
363
  error = git_filter_list_apply_to_data(&out, fl, &raw);
362
364
 
363
365
  if (out.ptr != raw.ptr)
364
- git_buf_free(&raw);
366
+ git_buf_dispose(&raw);
365
367
 
366
368
  if (!error) {
367
369
  fc->map.len = out.size;
@@ -402,11 +404,11 @@ static int diff_file_content_load_workdir(
402
404
  /* once data is loaded, update OID if we didn't have it previously */
403
405
  if (!error && (fc->file->flags & GIT_DIFF_FLAG_VALID_ID) == 0) {
404
406
  error = git_odb_hash(
405
- &fc->file->id, fc->map.data, fc->map.len, GIT_OBJ_BLOB);
407
+ &fc->file->id, fc->map.data, fc->map.len, GIT_OBJECT_BLOB);
406
408
  fc->file->flags |= GIT_DIFF_FLAG_VALID_ID;
407
409
  }
408
410
 
409
- git_buf_free(&path);
411
+ git_buf_dispose(&path);
410
412
  return error;
411
413
  }
412
414
 
@@ -20,7 +20,7 @@ typedef struct {
20
20
  git_diff_driver *driver;
21
21
  uint32_t flags;
22
22
  uint32_t opts_flags;
23
- git_off_t opts_max_size;
23
+ git_object_size_t opts_max_size;
24
24
  git_iterator_type_t src;
25
25
  const git_blob *blob;
26
26
  git_map map;
@@ -9,7 +9,7 @@
9
9
 
10
10
  #include "diff.h"
11
11
  #include "patch_generate.h"
12
- #include "fileops.h"
12
+ #include "futils.h"
13
13
  #include "config.h"
14
14
  #include "attr_file.h"
15
15
  #include "filter.h"
@@ -81,7 +81,7 @@ static int diff_insert_delta(
81
81
  if (error > 0) /* positive value means to skip this delta */
82
82
  return 0;
83
83
  else /* negative value means to cancel diff */
84
- return giterr_set_after_callback_function(error, "git_diff");
84
+ return git_error_set_after_callback_function(error, "git_diff");
85
85
  }
86
86
  }
87
87
 
@@ -138,7 +138,7 @@ static int diff_delta__from_one(
138
138
  if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE))
139
139
  has_old = !has_old;
140
140
 
141
- if ((entry->flags & GIT_IDXENTRY_VALID) != 0)
141
+ if ((entry->flags & GIT_INDEX_ENTRY_VALID) != 0)
142
142
  return 0;
143
143
 
144
144
  if (status == GIT_DELTA_IGNORED &&
@@ -157,7 +157,7 @@ static int diff_delta__from_one(
157
157
  return 0;
158
158
 
159
159
  delta = diff_delta__alloc(diff, status, entry->path);
160
- GITERR_CHECK_ALLOC(delta);
160
+ GIT_ERROR_CHECK_ALLOC(delta);
161
161
 
162
162
  /* This fn is just for single-sided diffs */
163
163
  assert(status != GIT_DELTA_MODIFIED);
@@ -179,7 +179,7 @@ static int diff_delta__from_one(
179
179
 
180
180
  delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
181
181
 
182
- if (has_old || !git_oid_iszero(&delta->new_file.id))
182
+ if (has_old || !git_oid_is_zero(&delta->new_file.id))
183
183
  delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
184
184
 
185
185
  return diff_insert_delta(diff, delta, matched_pathspec);
@@ -220,7 +220,7 @@ static int diff_delta__from_two(
220
220
  }
221
221
 
222
222
  delta = diff_delta__alloc(diff, status, canonical_path);
223
- GITERR_CHECK_ALLOC(delta);
223
+ GIT_ERROR_CHECK_ALLOC(delta);
224
224
  delta->nfiles = 2;
225
225
 
226
226
  if (!git_index_entry_is_conflict(old_entry)) {
@@ -240,7 +240,7 @@ static int diff_delta__from_two(
240
240
  delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
241
241
  delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS;
242
242
 
243
- if (!git_oid_iszero(&new_entry->id))
243
+ if (!git_oid_is_zero(&new_entry->id))
244
244
  delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;
245
245
  }
246
246
 
@@ -273,7 +273,8 @@ static git_diff_delta *diff_delta__last_for_item(
273
273
  break;
274
274
  case GIT_DELTA_MODIFIED:
275
275
  if (git_oid__cmp(&delta->old_file.id, &item->id) == 0 ||
276
- git_oid__cmp(&delta->new_file.id, &item->id) == 0)
276
+ (delta->new_file.mode == item->mode &&
277
+ git_oid__cmp(&delta->new_file.id, &item->id) == 0))
277
278
  return delta;
278
279
  break;
279
280
  default:
@@ -471,17 +472,17 @@ static int diff_generated_apply_options(
471
472
  if ((val = git_repository_config_snapshot(&cfg, repo)) < 0)
472
473
  return val;
473
474
 
474
- if (!git_config__cvar(&val, cfg, GIT_CVAR_SYMLINKS) && val)
475
+ if (!git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_SYMLINKS) && val)
475
476
  diff->diffcaps |= GIT_DIFFCAPS_HAS_SYMLINKS;
476
477
 
477
- if (!git_config__cvar(&val, cfg, GIT_CVAR_IGNORESTAT) && val)
478
+ if (!git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_IGNORESTAT) && val)
478
479
  diff->diffcaps |= GIT_DIFFCAPS_IGNORE_STAT;
479
480
 
480
481
  if ((diff->base.opts.flags & GIT_DIFF_IGNORE_FILEMODE) == 0 &&
481
- !git_config__cvar(&val, cfg, GIT_CVAR_FILEMODE) && val)
482
+ !git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_FILEMODE) && val)
482
483
  diff->diffcaps |= GIT_DIFFCAPS_TRUST_MODE_BITS;
483
484
 
484
- if (!git_config__cvar(&val, cfg, GIT_CVAR_TRUSTCTIME) && val)
485
+ if (!git_config__configmap_lookup(&val, cfg, GIT_CONFIGMAP_TRUSTCTIME) && val)
485
486
  diff->diffcaps |= GIT_DIFFCAPS_TRUST_CTIME;
486
487
 
487
488
  /* Don't set GIT_DIFFCAPS_USE_DEV - compile time option in core git */
@@ -516,7 +517,7 @@ static int diff_generated_apply_options(
516
517
 
517
518
  if (entry && git_submodule_parse_ignore(
518
519
  &diff->base.opts.ignore_submodules, entry->value) < 0)
519
- giterr_clear();
520
+ git_error_clear();
520
521
  git_config_entry_free(entry);
521
522
  }
522
523
 
@@ -559,13 +560,18 @@ int git_diff__oid_for_file(
559
560
  git_diff *diff,
560
561
  const char *path,
561
562
  uint16_t mode,
562
- git_off_t size)
563
+ git_object_size_t size)
563
564
  {
564
565
  git_index_entry entry;
565
566
 
567
+ if (size > UINT32_MAX) {
568
+ git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'", path);
569
+ return -1;
570
+ }
571
+
566
572
  memset(&entry, 0, sizeof(entry));
567
573
  entry.mode = mode;
568
- entry.file_size = size;
574
+ entry.file_size = (uint32_t)size;
569
575
  entry.path = (char *)path;
570
576
 
571
577
  return git_diff__oid_for_entry(out, diff, &entry, mode, NULL);
@@ -600,7 +606,7 @@ int git_diff__oid_for_entry(
600
606
 
601
607
  if (p_stat(full_path.ptr, &st) < 0) {
602
608
  error = git_path_set_error(errno, entry.path, "stat");
603
- git_buf_free(&full_path);
609
+ git_buf_dispose(&full_path);
604
610
  return error;
605
611
  }
606
612
 
@@ -621,13 +627,13 @@ int git_diff__oid_for_entry(
621
627
  /* if submodule lookup failed probably just in an intermediate
622
628
  * state where some init hasn't happened, so ignore the error
623
629
  */
624
- giterr_clear();
630
+ git_error_clear();
625
631
  }
626
632
  } else if (S_ISLNK(mode)) {
627
633
  error = git_odb__hashlink(out, full_path.ptr);
628
634
  diff->base.perf.oid_calculations++;
629
635
  } else if (!git__is_sizet(entry.file_size)) {
630
- giterr_set(GITERR_OS, "file size overflow (for 32-bits) on '%s'",
636
+ git_error_set(GIT_ERROR_NOMEMORY, "file size overflow (for 32-bits) on '%s'",
631
637
  entry.path);
632
638
  error = -1;
633
639
  } else if (!(error = git_filter_list_load(&fl,
@@ -639,7 +645,7 @@ int git_diff__oid_for_entry(
639
645
  error = fd;
640
646
  else {
641
647
  error = git_odb__hashfd_filtered(
642
- out, fd, (size_t)entry.file_size, GIT_OBJ_BLOB, fl);
648
+ out, fd, (size_t)entry.file_size, GIT_OBJECT_BLOB, fl);
643
649
  p_close(fd);
644
650
  diff->base.perf.oid_calculations++;
645
651
  }
@@ -663,7 +669,7 @@ int git_diff__oid_for_entry(
663
669
  }
664
670
  }
665
671
 
666
- git_buf_free(&full_path);
672
+ git_buf_dispose(&full_path);
667
673
  return error;
668
674
  }
669
675
 
@@ -699,7 +705,7 @@ static int maybe_modified_submodule(
699
705
 
700
706
  /* GIT_EEXISTS means dir with .git in it was found - ignore it */
701
707
  if (error == GIT_EEXISTS) {
702
- giterr_clear();
708
+ git_error_clear();
703
709
  error = 0;
704
710
  }
705
711
  return error;
@@ -763,11 +769,11 @@ static int maybe_modified(
763
769
  status = GIT_DELTA_CONFLICTED;
764
770
 
765
771
  /* support "assume unchanged" (poorly, b/c we still stat everything) */
766
- } else if ((oitem->flags & GIT_IDXENTRY_VALID) != 0) {
772
+ } else if ((oitem->flags & GIT_INDEX_ENTRY_VALID) != 0) {
767
773
  status = GIT_DELTA_UNMODIFIED;
768
774
 
769
775
  /* support "skip worktree" index bit */
770
- } else if ((oitem->flags_extended & GIT_IDXENTRY_SKIP_WORKTREE) != 0) {
776
+ } else if ((oitem->flags_extended & GIT_INDEX_ENTRY_SKIP_WORKTREE) != 0) {
771
777
  status = GIT_DELTA_UNMODIFIED;
772
778
 
773
779
  /* if basic type of file changed, then split into delete and add */
@@ -791,13 +797,13 @@ static int maybe_modified(
791
797
  /* if oids and modes match (and are valid), then file is unmodified */
792
798
  } else if (git_oid_equal(&oitem->id, &nitem->id) &&
793
799
  omode == nmode &&
794
- !git_oid_iszero(&oitem->id)) {
800
+ !git_oid_is_zero(&oitem->id)) {
795
801
  status = GIT_DELTA_UNMODIFIED;
796
802
 
797
803
  /* if we have an unknown OID and a workdir iterator, then check some
798
804
  * circumstances that can accelerate things or need special handling
799
805
  */
800
- } else if (git_oid_iszero(&nitem->id) && new_is_workdir) {
806
+ } else if (git_oid_is_zero(&nitem->id) && new_is_workdir) {
801
807
  bool use_ctime =
802
808
  ((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0);
803
809
  git_index *index = git_iterator_index(info->new_iter);
@@ -837,7 +843,7 @@ static int maybe_modified(
837
843
  /* if we got here and decided that the files are modified, but we
838
844
  * haven't calculated the OID of the new item, then calculate it now
839
845
  */
840
- if (modified_uncertain && git_oid_iszero(&nitem->id)) {
846
+ if (modified_uncertain && git_oid_is_zero(&nitem->id)) {
841
847
  const git_oid *update_check =
842
848
  DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) && omode == nmode ?
843
849
  &oitem->id : NULL;
@@ -871,7 +877,7 @@ static int maybe_modified(
871
877
 
872
878
  return diff_delta__from_two(
873
879
  diff, status, oitem, omode, nitem, nmode,
874
- git_oid_iszero(&noid) ? NULL : &noid, matched_pathspec);
880
+ git_oid_is_zero(&noid) ? NULL : &noid, matched_pathspec);
875
881
  }
876
882
 
877
883
  static bool entry_is_prefixed(
@@ -1059,7 +1065,7 @@ static int handle_unmatched_new_item(
1059
1065
 
1060
1066
  /* if directory is empty, can't advance into it, so skip it */
1061
1067
  if (error == GIT_ENOTFOUND) {
1062
- giterr_clear();
1068
+ git_error_clear();
1063
1069
  error = iterator_advance(&info->nitem, info->new_iter);
1064
1070
  }
1065
1071
 
@@ -1081,7 +1087,7 @@ static int handle_unmatched_new_item(
1081
1087
  else if (nitem->mode == GIT_FILEMODE_COMMIT) {
1082
1088
  /* ignore things that are not actual submodules */
1083
1089
  if (git_submodule_lookup(NULL, info->repo, nitem->path) != 0) {
1084
- giterr_clear();
1090
+ git_error_clear();
1085
1091
  delta_type = GIT_DELTA_IGNORED;
1086
1092
 
1087
1093
  /* if this contains a tracked item, treat as normal TREE */
@@ -1090,7 +1096,7 @@ static int handle_unmatched_new_item(
1090
1096
  if (error != GIT_ENOTFOUND)
1091
1097
  return error;
1092
1098
 
1093
- giterr_clear();
1099
+ git_error_clear();
1094
1100
  return iterator_advance(&info->nitem, info->new_iter);
1095
1101
  }
1096
1102
  }
@@ -1191,7 +1197,7 @@ int git_diff__from_iterators(
1191
1197
  *out = NULL;
1192
1198
 
1193
1199
  diff = diff_generated_alloc(repo, old_iter, new_iter);
1194
- GITERR_CHECK_ALLOC(diff);
1200
+ GIT_ERROR_CHECK_ALLOC(diff);
1195
1201
 
1196
1202
  info.repo = repo;
1197
1203
  info.old_iter = old_iter;
@@ -1256,29 +1262,31 @@ cleanup:
1256
1262
  return error;
1257
1263
  }
1258
1264
 
1259
- #define DIFF_FROM_ITERATORS(MAKE_FIRST, FLAGS_FIRST, MAKE_SECOND, FLAGS_SECOND) do { \
1260
- git_iterator *a = NULL, *b = NULL; \
1261
- char *pfx = (opts && !(opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) ? \
1262
- git_pathspec_prefix(&opts->pathspec) : NULL; \
1263
- git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT, \
1264
- b_opts = GIT_ITERATOR_OPTIONS_INIT; \
1265
- a_opts.flags = FLAGS_FIRST; \
1266
- a_opts.start = pfx; \
1267
- a_opts.end = pfx; \
1268
- b_opts.flags = FLAGS_SECOND; \
1269
- b_opts.start = pfx; \
1270
- b_opts.end = pfx; \
1271
- GITERR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options"); \
1272
- if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) { \
1273
- a_opts.pathlist.strings = opts->pathspec.strings; \
1274
- a_opts.pathlist.count = opts->pathspec.count; \
1275
- b_opts.pathlist.strings = opts->pathspec.strings; \
1276
- b_opts.pathlist.count = opts->pathspec.count; \
1277
- } \
1278
- if (!error && !(error = MAKE_FIRST) && !(error = MAKE_SECOND)) \
1279
- error = git_diff__from_iterators(&diff, repo, a, b, opts); \
1280
- git__free(pfx); git_iterator_free(a); git_iterator_free(b); \
1281
- } while (0)
1265
+ static int diff_prepare_iterator_opts(char **prefix, git_iterator_options *a, int aflags,
1266
+ git_iterator_options *b, int bflags,
1267
+ const git_diff_options *opts)
1268
+ {
1269
+ GIT_ERROR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options");
1270
+
1271
+ *prefix = NULL;
1272
+
1273
+ if (opts && (opts->flags & GIT_DIFF_DISABLE_PATHSPEC_MATCH)) {
1274
+ a->pathlist.strings = opts->pathspec.strings;
1275
+ a->pathlist.count = opts->pathspec.count;
1276
+ b->pathlist.strings = opts->pathspec.strings;
1277
+ b->pathlist.count = opts->pathspec.count;
1278
+ } else if (opts) {
1279
+ *prefix = git_pathspec_prefix(&opts->pathspec);
1280
+ GIT_ERROR_CHECK_ALLOC(prefix);
1281
+ }
1282
+
1283
+ a->flags = aflags;
1284
+ b->flags = bflags;
1285
+ a->start = b->start = *prefix;
1286
+ a->end = b->end = *prefix;
1287
+
1288
+ return 0;
1289
+ }
1282
1290
 
1283
1291
  int git_diff_tree_to_tree(
1284
1292
  git_diff **out,
@@ -1287,8 +1295,12 @@ int git_diff_tree_to_tree(
1287
1295
  git_tree *new_tree,
1288
1296
  const git_diff_options *opts)
1289
1297
  {
1290
- git_diff *diff = NULL;
1291
1298
  git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE;
1299
+ git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT,
1300
+ b_opts = GIT_ITERATOR_OPTIONS_INIT;
1301
+ git_iterator *a = NULL, *b = NULL;
1302
+ git_diff *diff = NULL;
1303
+ char *prefix = NULL;
1292
1304
  int error = 0;
1293
1305
 
1294
1306
  assert(out && repo);
@@ -1302,13 +1314,19 @@ int git_diff_tree_to_tree(
1302
1314
  if (opts && (opts->flags & GIT_DIFF_IGNORE_CASE) != 0)
1303
1315
  iflag = GIT_ITERATOR_IGNORE_CASE;
1304
1316
 
1305
- DIFF_FROM_ITERATORS(
1306
- git_iterator_for_tree(&a, old_tree, &a_opts), iflag,
1307
- git_iterator_for_tree(&b, new_tree, &b_opts), iflag
1308
- );
1317
+ if ((error = diff_prepare_iterator_opts(&prefix, &a_opts, iflag, &b_opts, iflag, opts)) < 0 ||
1318
+ (error = git_iterator_for_tree(&a, old_tree, &a_opts)) < 0 ||
1319
+ (error = git_iterator_for_tree(&b, new_tree, &b_opts)) < 0 ||
1320
+ (error = git_diff__from_iterators(&diff, repo, a, b, opts)) < 0)
1321
+ goto out;
1309
1322
 
1310
- if (!error)
1311
- *out = diff;
1323
+ *out = diff;
1324
+ diff = NULL;
1325
+ out:
1326
+ git_iterator_free(a);
1327
+ git_iterator_free(b);
1328
+ git_diff_free(diff);
1329
+ git__free(prefix);
1312
1330
 
1313
1331
  return error;
1314
1332
  }
@@ -1319,7 +1337,7 @@ static int diff_load_index(git_index **index, git_repository *repo)
1319
1337
 
1320
1338
  /* reload the repository index when user did not pass one in */
1321
1339
  if (!error && git_index_read(*index, false) < 0)
1322
- giterr_clear();
1340
+ git_error_clear();
1323
1341
 
1324
1342
  return error;
1325
1343
  }
@@ -1331,9 +1349,13 @@ int git_diff_tree_to_index(
1331
1349
  git_index *index,
1332
1350
  const git_diff_options *opts)
1333
1351
  {
1334
- git_diff *diff = NULL;
1335
1352
  git_iterator_flag_t iflag = GIT_ITERATOR_DONT_IGNORE_CASE |
1336
1353
  GIT_ITERATOR_INCLUDE_CONFLICTS;
1354
+ git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT,
1355
+ b_opts = GIT_ITERATOR_OPTIONS_INIT;
1356
+ git_iterator *a = NULL, *b = NULL;
1357
+ git_diff *diff = NULL;
1358
+ char *prefix = NULL;
1337
1359
  bool index_ignore_case = false;
1338
1360
  int error = 0;
1339
1361
 
@@ -1346,17 +1368,23 @@ int git_diff_tree_to_index(
1346
1368
 
1347
1369
  index_ignore_case = index->ignore_case;
1348
1370
 
1349
- DIFF_FROM_ITERATORS(
1350
- git_iterator_for_tree(&a, old_tree, &a_opts), iflag,
1351
- git_iterator_for_index(&b, repo, index, &b_opts), iflag
1352
- );
1371
+ if ((error = diff_prepare_iterator_opts(&prefix, &a_opts, iflag, &b_opts, iflag, opts)) < 0 ||
1372
+ (error = git_iterator_for_tree(&a, old_tree, &a_opts)) < 0 ||
1373
+ (error = git_iterator_for_index(&b, repo, index, &b_opts)) < 0 ||
1374
+ (error = git_diff__from_iterators(&diff, repo, a, b, opts)) < 0)
1375
+ goto out;
1353
1376
 
1354
1377
  /* if index is in case-insensitive order, re-sort deltas to match */
1355
- if (!error && index_ignore_case)
1378
+ if (index_ignore_case)
1356
1379
  git_diff__set_ignore_case(diff, true);
1357
1380
 
1358
- if (!error)
1359
- *out = diff;
1381
+ *out = diff;
1382
+ diff = NULL;
1383
+ out:
1384
+ git_iterator_free(a);
1385
+ git_iterator_free(b);
1386
+ git_diff_free(diff);
1387
+ git__free(prefix);
1360
1388
 
1361
1389
  return error;
1362
1390
  }
@@ -1367,7 +1395,11 @@ int git_diff_index_to_workdir(
1367
1395
  git_index *index,
1368
1396
  const git_diff_options *opts)
1369
1397
  {
1398
+ git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT,
1399
+ b_opts = GIT_ITERATOR_OPTIONS_INIT;
1400
+ git_iterator *a = NULL, *b = NULL;
1370
1401
  git_diff *diff = NULL;
1402
+ char *prefix = NULL;
1371
1403
  int error = 0;
1372
1404
 
1373
1405
  assert(out && repo);
@@ -1377,20 +1409,24 @@ int git_diff_index_to_workdir(
1377
1409
  if (!index && (error = diff_load_index(&index, repo)) < 0)
1378
1410
  return error;
1379
1411
 
1380
- DIFF_FROM_ITERATORS(
1381
- git_iterator_for_index(&a, repo, index, &a_opts),
1382
- GIT_ITERATOR_INCLUDE_CONFLICTS,
1383
-
1384
- git_iterator_for_workdir(&b, repo, index, NULL, &b_opts),
1385
- GIT_ITERATOR_DONT_AUTOEXPAND
1386
- );
1387
-
1388
- if (!error && (diff->opts.flags & GIT_DIFF_UPDATE_INDEX) != 0 &&
1389
- ((git_diff_generated *)diff)->index_updated)
1390
- error = git_index_write(index);
1391
-
1392
- if (!error)
1393
- *out = diff;
1412
+ if ((error = diff_prepare_iterator_opts(&prefix, &a_opts, GIT_ITERATOR_INCLUDE_CONFLICTS,
1413
+ &b_opts, GIT_ITERATOR_DONT_AUTOEXPAND, opts)) < 0 ||
1414
+ (error = git_iterator_for_index(&a, repo, index, &a_opts)) < 0 ||
1415
+ (error = git_iterator_for_workdir(&b, repo, index, NULL, &b_opts)) < 0 ||
1416
+ (error = git_diff__from_iterators(&diff, repo, a, b, opts)) < 0)
1417
+ goto out;
1418
+
1419
+ if ((diff->opts.flags & GIT_DIFF_UPDATE_INDEX) && ((git_diff_generated *)diff)->index_updated)
1420
+ if ((error = git_index_write(index)) < 0)
1421
+ goto out;
1422
+
1423
+ *out = diff;
1424
+ diff = NULL;
1425
+ out:
1426
+ git_iterator_free(a);
1427
+ git_iterator_free(b);
1428
+ git_diff_free(diff);
1429
+ git__free(prefix);
1394
1430
 
1395
1431
  return error;
1396
1432
  }
@@ -1401,24 +1437,33 @@ int git_diff_tree_to_workdir(
1401
1437
  git_tree *old_tree,
1402
1438
  const git_diff_options *opts)
1403
1439
  {
1440
+ git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT,
1441
+ b_opts = GIT_ITERATOR_OPTIONS_INIT;
1442
+ git_iterator *a = NULL, *b = NULL;
1404
1443
  git_diff *diff = NULL;
1444
+ char *prefix = NULL;
1405
1445
  git_index *index;
1406
- int error = 0;
1446
+ int error;
1407
1447
 
1408
1448
  assert(out && repo);
1409
1449
 
1410
1450
  *out = NULL;
1411
1451
 
1412
- if ((error = git_repository_index__weakptr(&index, repo)))
1413
- return error;
1414
-
1415
- DIFF_FROM_ITERATORS(
1416
- git_iterator_for_tree(&a, old_tree, &a_opts), 0,
1417
- git_iterator_for_workdir(&b, repo, index, old_tree, &b_opts), GIT_ITERATOR_DONT_AUTOEXPAND
1418
- );
1419
-
1420
- if (!error)
1421
- *out = diff;
1452
+ if ((error = diff_prepare_iterator_opts(&prefix, &a_opts, 0,
1453
+ &b_opts, GIT_ITERATOR_DONT_AUTOEXPAND, opts) < 0) ||
1454
+ (error = git_repository_index__weakptr(&index, repo)) < 0 ||
1455
+ (error = git_iterator_for_tree(&a, old_tree, &a_opts)) < 0 ||
1456
+ (error = git_iterator_for_workdir(&b, repo, index, old_tree, &b_opts)) < 0 ||
1457
+ (error = git_diff__from_iterators(&diff, repo, a, b, opts)) < 0)
1458
+ goto out;
1459
+
1460
+ *out = diff;
1461
+ diff = NULL;
1462
+ out:
1463
+ git_iterator_free(a);
1464
+ git_iterator_free(b);
1465
+ git_diff_free(diff);
1466
+ git__free(prefix);
1422
1467
 
1423
1468
  return error;
1424
1469
  }
@@ -1462,24 +1507,35 @@ int git_diff_index_to_index(
1462
1507
  git_index *new_index,
1463
1508
  const git_diff_options *opts)
1464
1509
  {
1465
- git_diff *diff;
1466
- int error = 0;
1510
+ git_iterator_options a_opts = GIT_ITERATOR_OPTIONS_INIT,
1511
+ b_opts = GIT_ITERATOR_OPTIONS_INIT;
1512
+ git_iterator *a = NULL, *b = NULL;
1513
+ git_diff *diff = NULL;
1514
+ char *prefix = NULL;
1515
+ int error;
1467
1516
 
1468
1517
  assert(out && old_index && new_index);
1469
1518
 
1470
1519
  *out = NULL;
1471
1520
 
1472
- DIFF_FROM_ITERATORS(
1473
- git_iterator_for_index(&a, repo, old_index, &a_opts), GIT_ITERATOR_DONT_IGNORE_CASE,
1474
- git_iterator_for_index(&b, repo, new_index, &b_opts), GIT_ITERATOR_DONT_IGNORE_CASE
1475
- );
1521
+ if ((error = diff_prepare_iterator_opts(&prefix, &a_opts, GIT_ITERATOR_DONT_IGNORE_CASE,
1522
+ &b_opts, GIT_ITERATOR_DONT_IGNORE_CASE, opts) < 0) ||
1523
+ (error = git_iterator_for_index(&a, repo, old_index, &a_opts)) < 0 ||
1524
+ (error = git_iterator_for_index(&b, repo, new_index, &b_opts)) < 0 ||
1525
+ (error = git_diff__from_iterators(&diff, repo, a, b, opts)) < 0)
1526
+ goto out;
1476
1527
 
1477
1528
  /* if index is in case-insensitive order, re-sort deltas to match */
1478
- if (!error && (old_index->ignore_case || new_index->ignore_case))
1529
+ if (old_index->ignore_case || new_index->ignore_case)
1479
1530
  git_diff__set_ignore_case(diff, true);
1480
1531
 
1481
- if (!error)
1482
- *out = diff;
1532
+ *out = diff;
1533
+ diff = NULL;
1534
+ out:
1535
+ git_iterator_free(a);
1536
+ git_iterator_free(b);
1537
+ git_diff_free(diff);
1538
+ git__free(prefix);
1483
1539
 
1484
1540
  return error;
1485
1541
  }
@@ -1551,7 +1607,7 @@ int git_diff__paired_foreach(
1551
1607
  }
1552
1608
 
1553
1609
  if ((error = cb(h2i, i2w, payload)) != 0) {
1554
- giterr_set_after_callback(error);
1610
+ git_error_set_after_callback(error);
1555
1611
  break;
1556
1612
  }
1557
1613
  }
@@ -1590,7 +1646,7 @@ int git_diff__commit(
1590
1646
  char commit_oidstr[GIT_OID_HEXSZ + 1];
1591
1647
 
1592
1648
  error = -1;
1593
- giterr_set(GITERR_INVALID, "commit %s is a merge commit",
1649
+ git_error_set(GIT_ERROR_INVALID, "commit %s is a merge commit",
1594
1650
  git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit)));
1595
1651
  goto on_error;
1596
1652
  }