rugged 1.7.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (361) 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 +23 -10
  5. data/vendor/libgit2/COPYING +195 -1
  6. data/vendor/libgit2/cmake/{FindIconv.cmake → FindIntlIconv.cmake} +6 -0
  7. data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
  8. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +1 -1
  9. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +23 -8
  10. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +17 -8
  11. data/vendor/libgit2/cmake/SelectHashes.cmake +28 -11
  12. data/vendor/libgit2/cmake/SelectRegex.cmake +6 -1
  13. data/vendor/libgit2/cmake/SelectSSH.cmake +22 -17
  14. data/vendor/libgit2/cmake/SelectZlib.cmake +4 -0
  15. data/vendor/libgit2/deps/llhttp/CMakeLists.txt +8 -0
  16. data/vendor/libgit2/deps/llhttp/LICENSE-MIT +22 -0
  17. data/vendor/libgit2/deps/llhttp/api.c +510 -0
  18. data/vendor/libgit2/deps/llhttp/http.c +170 -0
  19. data/vendor/libgit2/deps/llhttp/llhttp.c +10168 -0
  20. data/vendor/libgit2/deps/llhttp/llhttp.h +897 -0
  21. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +1 -1
  22. data/vendor/libgit2/deps/ntlmclient/crypt_builtin_md4.c +311 -0
  23. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +2 -1
  24. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -20
  25. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +4 -4
  26. data/vendor/libgit2/deps/ntlmclient/ntlm.c +21 -21
  27. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +5 -4
  28. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +2 -1
  29. data/vendor/libgit2/deps/ntlmclient/utf8.h +1176 -721
  30. data/vendor/libgit2/deps/ntlmclient/util.h +11 -0
  31. data/vendor/libgit2/deps/pcre/CMakeLists.txt +1 -0
  32. data/vendor/libgit2/deps/xdiff/xmerge.c +2 -2
  33. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -1
  34. data/vendor/libgit2/deps/zlib/LICENSE +22 -0
  35. data/vendor/libgit2/deps/zlib/adler32.c +5 -27
  36. data/vendor/libgit2/deps/zlib/crc32.c +94 -167
  37. data/vendor/libgit2/deps/zlib/deflate.c +358 -435
  38. data/vendor/libgit2/deps/zlib/deflate.h +41 -10
  39. data/vendor/libgit2/deps/zlib/gzguts.h +13 -18
  40. data/vendor/libgit2/deps/zlib/infback.c +17 -30
  41. data/vendor/libgit2/deps/zlib/inffast.c +1 -4
  42. data/vendor/libgit2/deps/zlib/inffast.h +1 -1
  43. data/vendor/libgit2/deps/zlib/inflate.c +36 -102
  44. data/vendor/libgit2/deps/zlib/inftrees.c +6 -11
  45. data/vendor/libgit2/deps/zlib/inftrees.h +6 -6
  46. data/vendor/libgit2/deps/zlib/trees.c +287 -352
  47. data/vendor/libgit2/deps/zlib/zconf.h +23 -14
  48. data/vendor/libgit2/deps/zlib/zlib.h +202 -202
  49. data/vendor/libgit2/deps/zlib/zutil.c +18 -44
  50. data/vendor/libgit2/deps/zlib/zutil.h +13 -33
  51. data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
  52. data/vendor/libgit2/include/git2/apply.h +27 -6
  53. data/vendor/libgit2/include/git2/attr.h +17 -4
  54. data/vendor/libgit2/include/git2/blame.h +133 -28
  55. data/vendor/libgit2/include/git2/blob.h +71 -28
  56. data/vendor/libgit2/include/git2/branch.h +22 -15
  57. data/vendor/libgit2/include/git2/buffer.h +6 -4
  58. data/vendor/libgit2/include/git2/cert.h +2 -1
  59. data/vendor/libgit2/include/git2/checkout.h +83 -32
  60. data/vendor/libgit2/include/git2/cherrypick.h +10 -3
  61. data/vendor/libgit2/include/git2/clone.h +25 -9
  62. data/vendor/libgit2/include/git2/commit.h +132 -3
  63. data/vendor/libgit2/include/git2/common.h +120 -63
  64. data/vendor/libgit2/include/git2/config.h +93 -23
  65. data/vendor/libgit2/include/git2/credential.h +30 -2
  66. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  67. data/vendor/libgit2/include/git2/deprecated.h +133 -3
  68. data/vendor/libgit2/include/git2/describe.h +13 -1
  69. data/vendor/libgit2/include/git2/diff.h +38 -8
  70. data/vendor/libgit2/include/git2/email.h +9 -29
  71. data/vendor/libgit2/include/git2/errors.h +46 -73
  72. data/vendor/libgit2/include/git2/filter.h +14 -7
  73. data/vendor/libgit2/include/git2/global.h +8 -1
  74. data/vendor/libgit2/include/git2/graph.h +3 -2
  75. data/vendor/libgit2/include/git2/ignore.h +10 -0
  76. data/vendor/libgit2/include/git2/index.h +99 -14
  77. data/vendor/libgit2/include/git2/indexer.h +21 -4
  78. data/vendor/libgit2/include/git2/mailmap.h +7 -1
  79. data/vendor/libgit2/include/git2/merge.h +46 -1
  80. data/vendor/libgit2/include/git2/message.h +2 -2
  81. data/vendor/libgit2/include/git2/net.h +3 -1
  82. data/vendor/libgit2/include/git2/notes.h +9 -6
  83. data/vendor/libgit2/include/git2/object.h +9 -8
  84. data/vendor/libgit2/include/git2/odb.h +91 -49
  85. data/vendor/libgit2/include/git2/odb_backend.h +80 -52
  86. data/vendor/libgit2/include/git2/oid.h +23 -24
  87. data/vendor/libgit2/include/git2/oidarray.h +7 -1
  88. data/vendor/libgit2/include/git2/pack.h +13 -1
  89. data/vendor/libgit2/include/git2/patch.h +2 -3
  90. data/vendor/libgit2/include/git2/pathspec.h +9 -0
  91. data/vendor/libgit2/include/git2/proxy.h +10 -0
  92. data/vendor/libgit2/include/git2/rebase.h +9 -6
  93. data/vendor/libgit2/include/git2/refdb.h +2 -2
  94. data/vendor/libgit2/include/git2/reflog.h +3 -2
  95. data/vendor/libgit2/include/git2/refs.h +9 -6
  96. data/vendor/libgit2/include/git2/refspec.h +14 -4
  97. data/vendor/libgit2/include/git2/remote.h +94 -18
  98. data/vendor/libgit2/include/git2/repository.h +57 -21
  99. data/vendor/libgit2/include/git2/reset.h +16 -3
  100. data/vendor/libgit2/include/git2/revert.h +9 -4
  101. data/vendor/libgit2/include/git2/revparse.h +3 -3
  102. data/vendor/libgit2/include/git2/revwalk.h +3 -2
  103. data/vendor/libgit2/include/git2/signature.h +46 -1
  104. data/vendor/libgit2/include/git2/stash.h +17 -3
  105. data/vendor/libgit2/include/git2/status.h +10 -6
  106. data/vendor/libgit2/include/git2/stdint.h +87 -85
  107. data/vendor/libgit2/include/git2/strarray.h +2 -3
  108. data/vendor/libgit2/include/git2/submodule.h +20 -9
  109. data/vendor/libgit2/include/git2/sys/alloc.h +12 -0
  110. data/vendor/libgit2/include/git2/sys/commit.h +77 -3
  111. data/vendor/libgit2/include/git2/sys/commit_graph.h +103 -62
  112. data/vendor/libgit2/include/git2/sys/config.h +80 -4
  113. data/vendor/libgit2/include/git2/sys/credential.h +4 -3
  114. data/vendor/libgit2/include/git2/sys/diff.h +21 -1
  115. data/vendor/libgit2/include/git2/sys/email.h +7 -0
  116. data/vendor/libgit2/include/git2/sys/errors.h +76 -0
  117. data/vendor/libgit2/include/git2/sys/filter.h +66 -3
  118. data/vendor/libgit2/include/git2/sys/hashsig.h +11 -0
  119. data/vendor/libgit2/include/git2/sys/index.h +3 -2
  120. data/vendor/libgit2/include/git2/sys/mempack.h +32 -2
  121. data/vendor/libgit2/include/git2/sys/merge.h +55 -7
  122. data/vendor/libgit2/include/git2/sys/midx.h +43 -4
  123. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -3
  124. data/vendor/libgit2/include/git2/sys/openssl.h +8 -1
  125. data/vendor/libgit2/include/git2/sys/path.h +12 -1
  126. data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -36
  127. data/vendor/libgit2/include/git2/sys/refs.h +3 -2
  128. data/vendor/libgit2/include/git2/sys/remote.h +8 -1
  129. data/vendor/libgit2/include/git2/sys/repository.h +63 -3
  130. data/vendor/libgit2/include/git2/sys/stream.h +11 -2
  131. data/vendor/libgit2/include/git2/sys/transport.h +24 -3
  132. data/vendor/libgit2/include/git2/tag.h +3 -1
  133. data/vendor/libgit2/include/git2/trace.h +9 -3
  134. data/vendor/libgit2/include/git2/transaction.h +3 -2
  135. data/vendor/libgit2/include/git2/transport.h +11 -3
  136. data/vendor/libgit2/include/git2/tree.h +16 -5
  137. data/vendor/libgit2/include/git2/types.h +19 -3
  138. data/vendor/libgit2/include/git2/version.h +44 -8
  139. data/vendor/libgit2/include/git2/worktree.h +16 -6
  140. data/vendor/libgit2/src/CMakeLists.txt +6 -4
  141. data/vendor/libgit2/src/cli/CMakeLists.txt +2 -2
  142. data/vendor/libgit2/src/cli/cmd.c +1 -1
  143. data/vendor/libgit2/src/cli/cmd.h +4 -0
  144. data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
  145. data/vendor/libgit2/src/cli/cmd_cat_file.c +6 -8
  146. data/vendor/libgit2/src/cli/cmd_clone.c +5 -7
  147. data/vendor/libgit2/src/cli/cmd_config.c +241 -0
  148. data/vendor/libgit2/src/cli/cmd_hash_object.c +6 -8
  149. data/vendor/libgit2/src/cli/cmd_help.c +6 -7
  150. data/vendor/libgit2/src/cli/cmd_index_pack.c +114 -0
  151. data/vendor/libgit2/src/cli/cmd_init.c +102 -0
  152. data/vendor/libgit2/src/cli/common.c +168 -0
  153. data/vendor/libgit2/src/cli/common.h +63 -0
  154. data/vendor/libgit2/src/cli/error.h +1 -1
  155. data/vendor/libgit2/src/cli/main.c +52 -24
  156. data/vendor/libgit2/src/cli/opt.c +29 -3
  157. data/vendor/libgit2/src/cli/opt.h +21 -3
  158. data/vendor/libgit2/src/cli/opt_usage.c +102 -33
  159. data/vendor/libgit2/src/cli/opt_usage.h +6 -1
  160. data/vendor/libgit2/src/cli/progress.c +51 -2
  161. data/vendor/libgit2/src/cli/progress.h +12 -0
  162. data/vendor/libgit2/src/cli/unix/sighandler.c +2 -1
  163. data/vendor/libgit2/src/cli/win32/precompiled.h +1 -1
  164. data/vendor/libgit2/src/cli/win32/sighandler.c +1 -1
  165. data/vendor/libgit2/src/libgit2/CMakeLists.txt +26 -8
  166. data/vendor/libgit2/src/libgit2/apply.c +10 -13
  167. data/vendor/libgit2/src/libgit2/attr.c +30 -13
  168. data/vendor/libgit2/src/libgit2/attr_file.c +7 -2
  169. data/vendor/libgit2/src/libgit2/attr_file.h +2 -0
  170. data/vendor/libgit2/src/libgit2/attrcache.c +69 -33
  171. data/vendor/libgit2/src/libgit2/attrcache.h +5 -9
  172. data/vendor/libgit2/src/libgit2/blame.c +130 -44
  173. data/vendor/libgit2/src/libgit2/blame.h +1 -0
  174. data/vendor/libgit2/src/libgit2/cache.c +22 -17
  175. data/vendor/libgit2/src/libgit2/cache.h +7 -9
  176. data/vendor/libgit2/src/libgit2/checkout.c +34 -24
  177. data/vendor/libgit2/src/libgit2/checkout.h +0 -2
  178. data/vendor/libgit2/src/libgit2/cherrypick.c +1 -2
  179. data/vendor/libgit2/src/libgit2/clone.c +186 -166
  180. data/vendor/libgit2/src/libgit2/clone.h +4 -1
  181. data/vendor/libgit2/src/libgit2/commit.c +92 -0
  182. data/vendor/libgit2/src/libgit2/commit_graph.c +67 -56
  183. data/vendor/libgit2/src/libgit2/commit_graph.h +1 -2
  184. data/vendor/libgit2/src/libgit2/config.c +389 -298
  185. data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
  186. data/vendor/libgit2/src/libgit2/config.h +9 -4
  187. data/vendor/libgit2/src/libgit2/config_backend.h +8 -10
  188. data/vendor/libgit2/src/libgit2/config_cache.c +4 -5
  189. data/vendor/libgit2/src/libgit2/config_file.c +99 -88
  190. data/vendor/libgit2/src/libgit2/config_list.c +285 -0
  191. data/vendor/libgit2/src/libgit2/config_list.h +32 -0
  192. data/vendor/libgit2/src/libgit2/config_mem.c +194 -40
  193. data/vendor/libgit2/src/libgit2/config_parse.c +10 -9
  194. data/vendor/libgit2/src/libgit2/config_snapshot.c +24 -31
  195. data/vendor/libgit2/src/libgit2/describe.c +24 -24
  196. data/vendor/libgit2/src/libgit2/diff.c +1 -1
  197. data/vendor/libgit2/src/libgit2/diff_driver.c +12 -19
  198. data/vendor/libgit2/src/libgit2/diff_driver.h +2 -2
  199. data/vendor/libgit2/src/libgit2/diff_generate.c +3 -3
  200. data/vendor/libgit2/src/libgit2/diff_parse.c +2 -2
  201. data/vendor/libgit2/src/libgit2/diff_print.c +65 -9
  202. data/vendor/libgit2/src/libgit2/diff_tform.c +36 -8
  203. data/vendor/libgit2/src/libgit2/email.c +1 -0
  204. data/vendor/libgit2/src/libgit2/fetch.c +5 -3
  205. data/vendor/libgit2/src/libgit2/filter.c +5 -5
  206. data/vendor/libgit2/src/libgit2/git2.rc +3 -3
  207. data/vendor/libgit2/src/libgit2/grafts.c +18 -20
  208. data/vendor/libgit2/src/libgit2/grafts.h +0 -1
  209. data/vendor/libgit2/src/libgit2/graph.c +1 -1
  210. data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
  211. data/vendor/libgit2/src/libgit2/ignore.c +9 -5
  212. data/vendor/libgit2/src/libgit2/index.c +68 -90
  213. data/vendor/libgit2/src/libgit2/index.h +2 -2
  214. data/vendor/libgit2/src/libgit2/index_map.c +95 -0
  215. data/vendor/libgit2/src/libgit2/index_map.h +28 -0
  216. data/vendor/libgit2/src/libgit2/indexer.c +34 -38
  217. data/vendor/libgit2/src/libgit2/iterator.c +14 -8
  218. data/vendor/libgit2/src/libgit2/libgit2.c +153 -368
  219. data/vendor/libgit2/src/libgit2/mailmap.c +1 -1
  220. data/vendor/libgit2/src/libgit2/merge.c +42 -37
  221. data/vendor/libgit2/src/libgit2/merge_driver.c +2 -2
  222. data/vendor/libgit2/src/libgit2/midx.c +28 -15
  223. data/vendor/libgit2/src/libgit2/mwindow.c +38 -45
  224. data/vendor/libgit2/src/libgit2/mwindow.h +4 -0
  225. data/vendor/libgit2/src/libgit2/object.c +6 -5
  226. data/vendor/libgit2/src/libgit2/odb.c +5 -4
  227. data/vendor/libgit2/src/libgit2/odb_mempack.c +49 -17
  228. data/vendor/libgit2/src/libgit2/odb_pack.c +13 -5
  229. data/vendor/libgit2/src/libgit2/oid.c +32 -5
  230. data/vendor/libgit2/src/libgit2/oid.h +11 -0
  231. data/vendor/libgit2/src/libgit2/pack-objects.c +58 -31
  232. data/vendor/libgit2/src/libgit2/pack-objects.h +12 -4
  233. data/vendor/libgit2/src/libgit2/pack.c +30 -24
  234. data/vendor/libgit2/src/libgit2/pack.h +15 -10
  235. data/vendor/libgit2/src/libgit2/patch_parse.c +2 -2
  236. data/vendor/libgit2/src/libgit2/path.c +1 -1
  237. data/vendor/libgit2/src/libgit2/pathspec.c +1 -1
  238. data/vendor/libgit2/src/libgit2/push.c +79 -28
  239. data/vendor/libgit2/src/libgit2/push.h +1 -0
  240. data/vendor/libgit2/src/libgit2/refdb_fs.c +128 -61
  241. data/vendor/libgit2/src/libgit2/reflog.c +1 -2
  242. data/vendor/libgit2/src/libgit2/reflog.h +2 -0
  243. data/vendor/libgit2/src/libgit2/refs.c +26 -7
  244. data/vendor/libgit2/src/libgit2/refs.h +6 -1
  245. data/vendor/libgit2/src/libgit2/refspec.c +28 -1
  246. data/vendor/libgit2/src/libgit2/refspec.h +8 -0
  247. data/vendor/libgit2/src/libgit2/remote.c +121 -61
  248. data/vendor/libgit2/src/libgit2/repository.c +231 -51
  249. data/vendor/libgit2/src/libgit2/repository.h +10 -6
  250. data/vendor/libgit2/src/libgit2/revert.c +1 -2
  251. data/vendor/libgit2/src/libgit2/revparse.c +2 -2
  252. data/vendor/libgit2/src/libgit2/revwalk.c +13 -10
  253. data/vendor/libgit2/src/libgit2/revwalk.h +3 -3
  254. data/vendor/libgit2/src/libgit2/settings.c +468 -0
  255. data/vendor/libgit2/src/libgit2/settings.h +6 -2
  256. data/vendor/libgit2/src/libgit2/signature.c +132 -15
  257. data/vendor/libgit2/src/libgit2/signature.h +0 -1
  258. data/vendor/libgit2/src/libgit2/status.c +1 -1
  259. data/vendor/libgit2/src/libgit2/streams/mbedtls.c +54 -60
  260. data/vendor/libgit2/src/libgit2/streams/openssl.c +32 -7
  261. data/vendor/libgit2/src/libgit2/streams/openssl.h +2 -0
  262. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +4 -0
  263. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.h +3 -0
  264. data/vendor/libgit2/src/libgit2/streams/stransport.c +39 -7
  265. data/vendor/libgit2/src/libgit2/submodule.c +106 -63
  266. data/vendor/libgit2/src/libgit2/submodule.h +6 -7
  267. data/vendor/libgit2/src/libgit2/tag.c +1 -1
  268. data/vendor/libgit2/src/libgit2/trailer.c +6 -6
  269. data/vendor/libgit2/src/libgit2/transaction.c +26 -20
  270. data/vendor/libgit2/src/libgit2/transaction.h +4 -1
  271. data/vendor/libgit2/src/libgit2/transport.c +4 -1
  272. data/vendor/libgit2/src/libgit2/transports/credential.c +1 -1
  273. data/vendor/libgit2/src/libgit2/transports/http.c +1 -2
  274. data/vendor/libgit2/src/libgit2/transports/http.h +0 -10
  275. data/vendor/libgit2/src/libgit2/transports/httpclient.c +112 -72
  276. data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
  277. data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
  278. data/vendor/libgit2/src/libgit2/transports/local.c +8 -7
  279. data/vendor/libgit2/src/libgit2/transports/smart.c +20 -8
  280. data/vendor/libgit2/src/libgit2/transports/smart.h +4 -2
  281. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +2 -2
  282. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +55 -10
  283. data/vendor/libgit2/src/libgit2/transports/ssh.c +41 -1103
  284. data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +347 -0
  285. data/vendor/libgit2/src/libgit2/transports/ssh_exec.h +26 -0
  286. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.c +1126 -0
  287. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
  288. data/vendor/libgit2/src/libgit2/transports/winhttp.c +35 -7
  289. data/vendor/libgit2/src/libgit2/tree.c +34 -26
  290. data/vendor/libgit2/src/libgit2/tree.h +3 -2
  291. data/vendor/libgit2/src/libgit2/worktree.c +14 -17
  292. data/vendor/libgit2/src/util/CMakeLists.txt +4 -6
  293. data/vendor/libgit2/src/util/alloc.c +4 -1
  294. data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
  295. data/vendor/libgit2/src/{cli/cli.h → util/allocators/debugalloc.h} +6 -9
  296. data/vendor/libgit2/src/util/allocators/stdalloc.c +0 -10
  297. data/vendor/libgit2/src/util/array.h +18 -17
  298. data/vendor/libgit2/src/util/cc-compat.h +2 -0
  299. data/vendor/libgit2/src/util/ctype_compat.h +70 -0
  300. data/vendor/libgit2/src/util/date.c +22 -14
  301. data/vendor/libgit2/src/util/date.h +12 -0
  302. data/vendor/libgit2/src/util/errors.c +401 -0
  303. data/vendor/libgit2/src/{libgit2 → util}/errors.h +21 -17
  304. data/vendor/libgit2/src/util/fs_path.c +15 -4
  305. data/vendor/libgit2/src/util/fs_path.h +23 -0
  306. data/vendor/libgit2/src/util/futils.c +6 -5
  307. data/vendor/libgit2/src/util/futils.h +13 -4
  308. data/vendor/libgit2/src/util/git2_features.h.in +12 -1
  309. data/vendor/libgit2/src/util/git2_util.h +6 -0
  310. data/vendor/libgit2/src/util/hash/openssl.c +152 -0
  311. data/vendor/libgit2/src/util/hash/openssl.h +17 -1
  312. data/vendor/libgit2/src/util/hash/sha.h +4 -1
  313. data/vendor/libgit2/src/util/hashmap.h +424 -0
  314. data/vendor/libgit2/src/util/hashmap_str.h +43 -0
  315. data/vendor/libgit2/src/util/integer.h +3 -1
  316. data/vendor/libgit2/src/util/net.c +13 -7
  317. data/vendor/libgit2/src/util/net.h +2 -0
  318. data/vendor/libgit2/src/util/pool.c +1 -1
  319. data/vendor/libgit2/src/util/pool.h +5 -0
  320. data/vendor/libgit2/src/util/pqueue.h +1 -1
  321. data/vendor/libgit2/src/util/process.h +222 -0
  322. data/vendor/libgit2/src/util/rand.c +1 -7
  323. data/vendor/libgit2/src/util/regexp.c +1 -1
  324. data/vendor/libgit2/src/util/sortedcache.c +14 -13
  325. data/vendor/libgit2/src/util/sortedcache.h +3 -3
  326. data/vendor/libgit2/src/util/str.c +2 -2
  327. data/vendor/libgit2/src/util/strlist.c +108 -0
  328. data/vendor/libgit2/src/util/strlist.h +36 -0
  329. data/vendor/libgit2/src/util/unix/posix.h +0 -2
  330. data/vendor/libgit2/src/util/unix/process.c +629 -0
  331. data/vendor/libgit2/src/util/unix/realpath.c +23 -5
  332. data/vendor/libgit2/src/util/util.c +2 -2
  333. data/vendor/libgit2/src/util/util.h +4 -38
  334. data/vendor/libgit2/src/util/vector.c +3 -3
  335. data/vendor/libgit2/src/util/vector.h +2 -2
  336. data/vendor/libgit2/src/util/win32/posix_w32.c +29 -6
  337. data/vendor/libgit2/src/util/win32/process.c +506 -0
  338. metadata +45 -28
  339. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -6
  340. data/vendor/libgit2/deps/http-parser/COPYING +0 -23
  341. data/vendor/libgit2/deps/http-parser/http_parser.c +0 -2182
  342. data/vendor/libgit2/deps/http-parser/http_parser.h +0 -305
  343. data/vendor/libgit2/deps/zlib/COPYING +0 -27
  344. data/vendor/libgit2/include/git2/sys/reflog.h +0 -21
  345. data/vendor/libgit2/src/libgit2/config_entries.c +0 -237
  346. data/vendor/libgit2/src/libgit2/config_entries.h +0 -24
  347. data/vendor/libgit2/src/libgit2/errors.c +0 -293
  348. data/vendor/libgit2/src/libgit2/idxmap.c +0 -157
  349. data/vendor/libgit2/src/libgit2/idxmap.h +0 -177
  350. data/vendor/libgit2/src/libgit2/libgit2.h +0 -15
  351. data/vendor/libgit2/src/libgit2/offmap.c +0 -101
  352. data/vendor/libgit2/src/libgit2/offmap.h +0 -133
  353. data/vendor/libgit2/src/libgit2/oidmap.c +0 -107
  354. data/vendor/libgit2/src/libgit2/oidmap.h +0 -128
  355. data/vendor/libgit2/src/libgit2/threadstate.c +0 -97
  356. data/vendor/libgit2/src/libgit2/threadstate.h +0 -22
  357. data/vendor/libgit2/src/libgit2/transports/ssh.h +0 -14
  358. data/vendor/libgit2/src/util/khash.h +0 -615
  359. data/vendor/libgit2/src/util/strmap.c +0 -100
  360. data/vendor/libgit2/src/util/strmap.h +0 -131
  361. /data/vendor/libgit2/cmake/{FindHTTPParser.cmake → FindHTTP_Parser.cmake} +0 -0
@@ -8,12 +8,12 @@
8
8
  #include "config_backend.h"
9
9
 
10
10
  #include "config.h"
11
- #include "config_entries.h"
11
+ #include "config_list.h"
12
12
 
13
13
  typedef struct {
14
14
  git_config_backend parent;
15
15
  git_mutex values_mutex;
16
- git_config_entries *entries;
16
+ git_config_list *config_list;
17
17
  git_config_backend *source;
18
18
  } config_snapshot_backend;
19
19
 
@@ -28,31 +28,27 @@ static int config_snapshot_iterator(
28
28
  struct git_config_backend *backend)
29
29
  {
30
30
  config_snapshot_backend *b = GIT_CONTAINER_OF(backend, config_snapshot_backend, parent);
31
- git_config_entries *entries = NULL;
31
+ git_config_list *config_list = NULL;
32
32
  int error;
33
33
 
34
- if ((error = git_config_entries_dup(&entries, b->entries)) < 0 ||
35
- (error = git_config_entries_iterator_new(iter, entries)) < 0)
34
+ if ((error = git_config_list_dup(&config_list, b->config_list)) < 0 ||
35
+ (error = git_config_list_iterator_new(iter, config_list)) < 0)
36
36
  goto out;
37
37
 
38
38
  out:
39
- /* Let iterator delete duplicated entries when it's done */
40
- git_config_entries_free(entries);
39
+ /* Let iterator delete duplicated config_list when it's done */
40
+ git_config_list_free(config_list);
41
41
  return error;
42
42
  }
43
43
 
44
- /* release the map containing the entry as an equivalent to freeing it */
45
- static void config_snapshot_entry_free(git_config_entry *entry)
46
- {
47
- git_config_entries *entries = (git_config_entries *) entry->payload;
48
- git_config_entries_free(entries);
49
- }
50
-
51
- static int config_snapshot_get(git_config_backend *cfg, const char *key, git_config_entry **out)
44
+ static int config_snapshot_get(
45
+ git_config_backend *cfg,
46
+ const char *key,
47
+ git_config_backend_entry **out)
52
48
  {
53
49
  config_snapshot_backend *b = GIT_CONTAINER_OF(cfg, config_snapshot_backend, parent);
54
- git_config_entries *entries = NULL;
55
- git_config_entry *entry;
50
+ git_config_list *config_list = NULL;
51
+ git_config_list_entry *entry;
56
52
  int error = 0;
57
53
 
58
54
  if (git_mutex_lock(&b->values_mutex) < 0) {
@@ -60,19 +56,16 @@ static int config_snapshot_get(git_config_backend *cfg, const char *key, git_con
60
56
  return -1;
61
57
  }
62
58
 
63
- entries = b->entries;
64
- git_config_entries_incref(entries);
59
+ config_list = b->config_list;
60
+ git_config_list_incref(config_list);
65
61
  git_mutex_unlock(&b->values_mutex);
66
62
 
67
- if ((error = (git_config_entries_get(&entry, entries, key))) < 0) {
68
- git_config_entries_free(entries);
63
+ if ((error = (git_config_list_get(&entry, config_list, key))) < 0) {
64
+ git_config_list_free(config_list);
69
65
  return error;
70
66
  }
71
67
 
72
- entry->free = config_snapshot_entry_free;
73
- entry->payload = entries;
74
- *out = entry;
75
-
68
+ *out = &entry->base;
76
69
  return 0;
77
70
  }
78
71
 
@@ -135,7 +128,7 @@ static void config_snapshot_free(git_config_backend *_backend)
135
128
  if (backend == NULL)
136
129
  return;
137
130
 
138
- git_config_entries_free(backend->entries);
131
+ git_config_list_free(backend->config_list);
139
132
  git_mutex_free(&backend->values_mutex);
140
133
  git__free(backend);
141
134
  }
@@ -143,7 +136,7 @@ static void config_snapshot_free(git_config_backend *_backend)
143
136
  static int config_snapshot_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
144
137
  {
145
138
  config_snapshot_backend *b = GIT_CONTAINER_OF(cfg, config_snapshot_backend, parent);
146
- git_config_entries *entries = NULL;
139
+ git_config_list *config_list = NULL;
147
140
  git_config_iterator *it = NULL;
148
141
  git_config_entry *entry;
149
142
  int error;
@@ -152,12 +145,12 @@ static int config_snapshot_open(git_config_backend *cfg, git_config_level_t leve
152
145
  GIT_UNUSED(level);
153
146
  GIT_UNUSED(repo);
154
147
 
155
- if ((error = git_config_entries_new(&entries)) < 0 ||
148
+ if ((error = git_config_list_new(&config_list)) < 0 ||
156
149
  (error = b->source->iterator(&it, b->source)) < 0)
157
150
  goto out;
158
151
 
159
152
  while ((error = git_config_next(&entry, it)) == 0)
160
- if ((error = git_config_entries_dup_entry(entries, entry)) < 0)
153
+ if ((error = git_config_list_dup_entry(config_list, entry)) < 0)
161
154
  goto out;
162
155
 
163
156
  if (error < 0) {
@@ -166,12 +159,12 @@ static int config_snapshot_open(git_config_backend *cfg, git_config_level_t leve
166
159
  error = 0;
167
160
  }
168
161
 
169
- b->entries = entries;
162
+ b->config_list = config_list;
170
163
 
171
164
  out:
172
165
  git_config_iterator_free(it);
173
166
  if (error)
174
- git_config_entries_free(entries);
167
+ git_config_list_free(config_list);
175
168
  return error;
176
169
  }
177
170
 
@@ -14,7 +14,6 @@
14
14
  #include "buf.h"
15
15
  #include "commit.h"
16
16
  #include "commit_list.h"
17
- #include "oidmap.h"
18
17
  #include "refs.h"
19
18
  #include "repository.h"
20
19
  #include "revwalk.h"
@@ -22,6 +21,7 @@
22
21
  #include "tag.h"
23
22
  #include "vector.h"
24
23
  #include "wildmatch.h"
24
+ #include "hashmap_oid.h"
25
25
 
26
26
  /* Ported from https://github.com/git/git/blob/89dde7882f71f846ccd0359756d27bebc31108de/builtin/describe.c */
27
27
 
@@ -32,20 +32,22 @@ struct commit_name {
32
32
  git_oid sha1;
33
33
  char *path;
34
34
 
35
- /* Khash workaround. They original key has to still be reachable */
35
+ /* The original key for the hashmap */
36
36
  git_oid peeled;
37
37
  };
38
38
 
39
- static void *oidmap_value_bykey(git_oidmap *map, const git_oid *key)
40
- {
41
- return git_oidmap_get(map, key);
42
- }
39
+ GIT_HASHMAP_OID_SETUP(git_describe_oidmap, struct commit_name *);
43
40
 
44
41
  static struct commit_name *find_commit_name(
45
- git_oidmap *names,
42
+ git_describe_oidmap *names,
46
43
  const git_oid *peeled)
47
44
  {
48
- return (struct commit_name *)(oidmap_value_bykey(names, peeled));
45
+ struct commit_name *result;
46
+
47
+ if (git_describe_oidmap_get(&result, names, peeled) == 0)
48
+ return result;
49
+
50
+ return NULL;
49
51
  }
50
52
 
51
53
  static int replace_name(
@@ -92,7 +94,7 @@ static int replace_name(
92
94
 
93
95
  static int add_to_known_names(
94
96
  git_repository *repo,
95
- git_oidmap *names,
97
+ git_describe_oidmap *names,
96
98
  const char *path,
97
99
  const git_oid *peeled,
98
100
  unsigned int prio,
@@ -121,7 +123,7 @@ static int add_to_known_names(
121
123
  e->path = git__strdup(path);
122
124
  git_oid_cpy(&e->peeled, peeled);
123
125
 
124
- if (!found && git_oidmap_set(names, &e->peeled, e) < 0)
126
+ if (!found && git_describe_oidmap_put(names, &e->peeled, e) < 0)
125
127
  return -1;
126
128
  }
127
129
  else
@@ -174,7 +176,7 @@ struct get_name_data
174
176
  {
175
177
  git_describe_options *opts;
176
178
  git_repository *repo;
177
- git_oidmap *names;
179
+ git_describe_oidmap names;
178
180
  git_describe_result *result;
179
181
  };
180
182
 
@@ -240,7 +242,7 @@ static int get_name(const char *refname, void *payload)
240
242
  else
241
243
  prio = 0;
242
244
 
243
- add_to_known_names(data->repo, data->names,
245
+ add_to_known_names(data->repo, &data->names,
244
246
  all ? refname + strlen(GIT_REFS_DIR) : refname + strlen(GIT_REFS_TAGS_DIR),
245
247
  &peeled, prio, &sha1);
246
248
  return 0;
@@ -451,7 +453,7 @@ static int describe(
451
453
 
452
454
  git_oid_cpy(&data->result->commit_id, git_commit_id(commit));
453
455
 
454
- n = find_commit_name(data->names, git_commit_id(commit));
456
+ n = find_commit_name(&data->names, git_commit_id(commit));
455
457
  if (n && (tags || all || n->prio == 2)) {
456
458
  /*
457
459
  * Exact match to an existing ref.
@@ -492,7 +494,7 @@ static int describe(
492
494
  git_commit_list_node *c = (git_commit_list_node *)git_pqueue_pop(&list);
493
495
  seen_commits++;
494
496
 
495
- n = find_commit_name(data->names, &c->oid);
497
+ n = find_commit_name(&data->names, &c->oid);
496
498
 
497
499
  if (n) {
498
500
  if (!tags && !all && n->prio < 2) {
@@ -627,7 +629,7 @@ cleanup:
627
629
  git__free(match);
628
630
  }
629
631
  }
630
- git_vector_free(&all_matches);
632
+ git_vector_dispose(&all_matches);
631
633
  git_pqueue_free(&list);
632
634
  git_revwalk_free(walk);
633
635
  return error;
@@ -653,11 +655,12 @@ int git_describe_commit(
653
655
  git_object *committish,
654
656
  git_describe_options *opts)
655
657
  {
656
- struct get_name_data data;
658
+ struct get_name_data data = {0};
657
659
  struct commit_name *name;
658
660
  git_commit *commit;
659
- int error = -1;
660
661
  git_describe_options normalized;
662
+ git_hashmap_iter_t iter = GIT_HASHMAP_INIT;
663
+ int error = -1;
661
664
 
662
665
  GIT_ASSERT_ARG(result);
663
666
  GIT_ASSERT_ARG(committish);
@@ -677,9 +680,6 @@ int git_describe_commit(
677
680
  "git_describe_options");
678
681
  data.opts = &normalized;
679
682
 
680
- if ((error = git_oidmap_new(&data.names)) < 0)
681
- return error;
682
-
683
683
  /** TODO: contains to be implemented */
684
684
 
685
685
  if ((error = git_object_peel((git_object **)(&commit), committish, GIT_OBJECT_COMMIT)) < 0)
@@ -690,7 +690,7 @@ int git_describe_commit(
690
690
  get_name, &data)) < 0)
691
691
  goto cleanup;
692
692
 
693
- if (git_oidmap_size(data.names) == 0 && !normalized.show_commit_oid_as_fallback) {
693
+ if (git_describe_oidmap_size(&data.names) == 0 && !normalized.show_commit_oid_as_fallback) {
694
694
  git_error_set(GIT_ERROR_DESCRIBE, "cannot describe - "
695
695
  "no reference found, cannot describe anything.");
696
696
  error = -1;
@@ -703,13 +703,13 @@ int git_describe_commit(
703
703
  cleanup:
704
704
  git_commit_free(commit);
705
705
 
706
- git_oidmap_foreach_value(data.names, name, {
706
+ while (git_describe_oidmap_iterate(&iter, NULL, &name, &data.names) == 0) {
707
707
  git_tag_free(name->tag);
708
708
  git__free(name->path);
709
709
  git__free(name);
710
- });
710
+ }
711
711
 
712
- git_oidmap_free(data.names);
712
+ git_describe_oidmap_dispose(&data.names);
713
713
 
714
714
  if (error < 0)
715
715
  git_describe_result_free(data.result);
@@ -16,7 +16,7 @@
16
16
  #include "diff_generate.h"
17
17
 
18
18
  #include "git2/version.h"
19
- #include "git2/email.h"
19
+ #include "git2/sys/email.h"
20
20
 
21
21
  struct patch_id_args {
22
22
  git_diff *diff;
@@ -11,11 +11,11 @@
11
11
 
12
12
  #include "common.h"
13
13
  #include "diff.h"
14
- #include "strmap.h"
15
14
  #include "map.h"
16
15
  #include "config.h"
17
16
  #include "regexp.h"
18
17
  #include "repository.h"
18
+ #include "userdiff.h"
19
19
 
20
20
  typedef enum {
21
21
  DIFF_DRIVER_AUTO = 0,
@@ -43,10 +43,10 @@ struct git_diff_driver {
43
43
  char name[GIT_FLEX_ARRAY];
44
44
  };
45
45
 
46
- #include "userdiff.h"
46
+ GIT_HASHMAP_STR_SETUP(git_diff_driver_map, git_diff_driver *);
47
47
 
48
48
  struct git_diff_driver_registry {
49
- git_strmap *drivers;
49
+ git_diff_driver_map map;
50
50
  };
51
51
 
52
52
  #define FORCE_DIFFABLE (GIT_DIFF_FORCE_TEXT | GIT_DIFF_FORCE_BINARY)
@@ -57,28 +57,21 @@ static git_diff_driver diff_driver_text = { DIFF_DRIVER_TEXT, GIT_DIFF_FORCE
57
57
 
58
58
  git_diff_driver_registry *git_diff_driver_registry_new(void)
59
59
  {
60
- git_diff_driver_registry *reg =
61
- git__calloc(1, sizeof(git_diff_driver_registry));
62
- if (!reg)
63
- return NULL;
64
-
65
- if (git_strmap_new(&reg->drivers) < 0) {
66
- git_diff_driver_registry_free(reg);
67
- return NULL;
68
- }
69
-
70
- return reg;
60
+ return git__calloc(1, sizeof(git_diff_driver_registry));
71
61
  }
72
62
 
73
63
  void git_diff_driver_registry_free(git_diff_driver_registry *reg)
74
64
  {
75
65
  git_diff_driver *drv;
66
+ git_hashmap_iter_t iter = 0;
76
67
 
77
68
  if (!reg)
78
69
  return;
79
70
 
80
- git_strmap_foreach_value(reg->drivers, drv, git_diff_driver_free(drv));
81
- git_strmap_free(reg->drivers);
71
+ while (git_diff_driver_map_iterate(&iter, NULL, &drv, &reg->map) == 0)
72
+ git_diff_driver_free(drv);
73
+
74
+ git_diff_driver_map_dispose(&reg->map);
82
75
  git__free(reg);
83
76
  }
84
77
 
@@ -215,7 +208,7 @@ static int git_diff_driver_builtin(
215
208
  (error = git_regexp_compile(&drv->word_pattern, ddef->words, ddef->flags)) < 0)
216
209
  goto done;
217
210
 
218
- if ((error = git_strmap_set(reg->drivers, drv->name, drv)) < 0)
211
+ if ((error = git_diff_driver_map_put(&reg->map, drv->name, drv)) < 0)
219
212
  goto done;
220
213
 
221
214
  done:
@@ -242,7 +235,7 @@ static int git_diff_driver_load(
242
235
  if ((reg = git_repository_driver_registry(repo)) == NULL)
243
236
  return -1;
244
237
 
245
- if ((drv = git_strmap_get(reg->drivers, driver_name)) != NULL) {
238
+ if (git_diff_driver_map_get(&drv, &reg->map, driver_name) == 0) {
246
239
  *out = drv;
247
240
  return 0;
248
241
  }
@@ -331,7 +324,7 @@ static int git_diff_driver_load(
331
324
  goto done;
332
325
 
333
326
  /* store driver in registry */
334
- if ((error = git_strmap_set(reg->drivers, drv->name, drv)) < 0)
327
+ if ((error = git_diff_driver_map_put(&reg->map, drv->name, drv)) < 0)
335
328
  goto done;
336
329
 
337
330
  *out = drv;
@@ -11,14 +11,14 @@
11
11
 
12
12
  #include "attr_file.h"
13
13
  #include "str.h"
14
+ #include "hashmap.h"
14
15
 
16
+ typedef struct git_diff_driver git_diff_driver;
15
17
  typedef struct git_diff_driver_registry git_diff_driver_registry;
16
18
 
17
19
  git_diff_driver_registry *git_diff_driver_registry_new(void);
18
20
  void git_diff_driver_registry_free(git_diff_driver_registry *);
19
21
 
20
- typedef struct git_diff_driver git_diff_driver;
21
-
22
22
  int git_diff_driver_lookup(git_diff_driver **, git_repository *,
23
23
  git_attr_session *attrsession, const char *);
24
24
  void git_diff_driver_free(git_diff_driver *);
@@ -429,7 +429,7 @@ static void diff_generated_free(git_diff *d)
429
429
  git_diff_generated *diff = (git_diff_generated *)d;
430
430
 
431
431
  git_attr_session__free(&diff->base.attrsession);
432
- git_vector_free_deep(&diff->base.deltas);
432
+ git_vector_dispose_deep(&diff->base.deltas);
433
433
 
434
434
  git_pathspec__vfree(&diff->pathspec);
435
435
  git_pool_clear(&diff->base.pool);
@@ -729,7 +729,7 @@ typedef struct {
729
729
  git_iterator *new_iter;
730
730
  const git_index_entry *oitem;
731
731
  const git_index_entry *nitem;
732
- git_strmap *submodule_cache;
732
+ git_submodule_cache *submodule_cache;
733
733
  bool submodule_cache_initialized;
734
734
  } diff_in_progress;
735
735
 
@@ -745,7 +745,7 @@ static int maybe_modified_submodule(
745
745
  git_submodule *sub;
746
746
  unsigned int sm_status = 0;
747
747
  git_submodule_ignore_t ign = diff->base.opts.ignore_submodules;
748
- git_strmap *submodule_cache = NULL;
748
+ git_submodule_cache *submodule_cache = NULL;
749
749
 
750
750
  *status = GIT_DELTA_UNMODIFIED;
751
751
 
@@ -20,9 +20,9 @@ static void diff_parsed_free(git_diff *d)
20
20
  git_vector_foreach(&diff->patches, i, patch)
21
21
  git_patch_free(patch);
22
22
 
23
- git_vector_free(&diff->patches);
23
+ git_vector_dispose(&diff->patches);
24
24
 
25
- git_vector_free(&diff->base.deltas);
25
+ git_vector_dispose(&diff->base.deltas);
26
26
  git_pool_clear(&diff->base.pool);
27
27
 
28
28
  git__memzero(diff, sizeof(*diff));
@@ -15,6 +15,7 @@
15
15
  #include "zstream.h"
16
16
  #include "blob.h"
17
17
  #include "delta.h"
18
+ #include "repository.h"
18
19
  #include "git2/sys/diff.h"
19
20
 
20
21
  typedef struct {
@@ -29,6 +30,7 @@ typedef struct {
29
30
  const char *new_prefix;
30
31
  uint32_t flags;
31
32
  int id_strlen;
33
+ unsigned int sent_file_header;
32
34
  git_oid_t oid_type;
33
35
 
34
36
  int (*strcomp)(const char *, const char *);
@@ -52,14 +54,10 @@ static int diff_print_info_init__common(
52
54
  if (!pi->id_strlen) {
53
55
  if (!repo)
54
56
  pi->id_strlen = GIT_ABBREV_DEFAULT;
55
- else if (git_repository__configmap_lookup(&pi->id_strlen, repo, GIT_CONFIGMAP_ABBREV) < 0)
57
+ else if (git_repository__abbrev_length(&pi->id_strlen, repo) < 0)
56
58
  return -1;
57
59
  }
58
60
 
59
- if (pi->id_strlen > 0 &&
60
- (size_t)pi->id_strlen > git_oid_hexsize(pi->oid_type))
61
- pi->id_strlen = (int)git_oid_hexsize(pi->oid_type);
62
-
63
61
  memset(&pi->line, 0, sizeof(pi->line));
64
62
  pi->line.old_lineno = -1;
65
63
  pi->line.new_lineno = -1;
@@ -579,6 +577,30 @@ static int diff_print_patch_file_binary(
579
577
  return error;
580
578
  }
581
579
 
580
+ GIT_INLINE(int) should_force_header(const git_diff_delta *delta)
581
+ {
582
+ if (delta->old_file.mode != delta->new_file.mode)
583
+ return 1;
584
+
585
+ if (delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED)
586
+ return 1;
587
+
588
+ return 0;
589
+ }
590
+
591
+ GIT_INLINE(int) flush_file_header(const git_diff_delta *delta, diff_print_info *pi)
592
+ {
593
+ if (pi->sent_file_header)
594
+ return 0;
595
+
596
+ pi->line.origin = GIT_DIFF_LINE_FILE_HDR;
597
+ pi->line.content = git_str_cstr(pi->buf);
598
+ pi->line.content_len = git_str_len(pi->buf);
599
+ pi->sent_file_header = 1;
600
+
601
+ return pi->print_cb(delta, NULL, &pi->line, pi->payload);
602
+ }
603
+
582
604
  static int diff_print_patch_file(
583
605
  const git_diff_delta *delta, float progress, void *data)
584
606
  {
@@ -609,15 +631,22 @@ static int diff_print_patch_file(
609
631
  (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0))
610
632
  return 0;
611
633
 
634
+ pi->sent_file_header = 0;
635
+
612
636
  if ((error = git_diff_delta__format_file_header(pi->buf, delta, oldpfx, newpfx,
613
637
  id_strlen, print_index)) < 0)
614
638
  return error;
615
639
 
616
- pi->line.origin = GIT_DIFF_LINE_FILE_HDR;
617
- pi->line.content = git_str_cstr(pi->buf);
618
- pi->line.content_len = git_str_len(pi->buf);
640
+ /*
641
+ * pi->buf now contains the file header data. Go ahead and send it
642
+ * if there's useful data in there, like similarity. Otherwise, we
643
+ * should queue it to send when we see the first hunk. This prevents
644
+ * us from sending a header when all hunks were ignored.
645
+ */
646
+ if (should_force_header(delta) && (error = flush_file_header(delta, pi)) < 0)
647
+ return error;
619
648
 
620
- return pi->print_cb(delta, NULL, &pi->line, pi->payload);
649
+ return 0;
621
650
  }
622
651
 
623
652
  static int diff_print_patch_binary(
@@ -632,6 +661,16 @@ static int diff_print_patch_binary(
632
661
  pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
633
662
  int error;
634
663
 
664
+ if ((error = flush_file_header(delta, pi)) < 0)
665
+ return error;
666
+
667
+ /*
668
+ * If the caller only wants the header, we just needed to make sure to
669
+ * call flush_file_header
670
+ */
671
+ if (pi->format == GIT_DIFF_FORMAT_PATCH_HEADER)
672
+ return 0;
673
+
635
674
  git_str_clear(pi->buf);
636
675
 
637
676
  if ((error = diff_print_patch_file_binary(
@@ -651,10 +690,21 @@ static int diff_print_patch_hunk(
651
690
  void *data)
652
691
  {
653
692
  diff_print_info *pi = data;
693
+ int error;
654
694
 
655
695
  if (S_ISDIR(d->new_file.mode))
656
696
  return 0;
657
697
 
698
+ if ((error = flush_file_header(d, pi)) < 0)
699
+ return error;
700
+
701
+ /*
702
+ * If the caller only wants the header, we just needed to make sure to
703
+ * call flush_file_header
704
+ */
705
+ if (pi->format == GIT_DIFF_FORMAT_PATCH_HEADER)
706
+ return 0;
707
+
658
708
  pi->line.origin = GIT_DIFF_LINE_HUNK_HDR;
659
709
  pi->line.content = h->header;
660
710
  pi->line.content_len = h->header_len;
@@ -669,10 +719,14 @@ static int diff_print_patch_line(
669
719
  void *data)
670
720
  {
671
721
  diff_print_info *pi = data;
722
+ int error;
672
723
 
673
724
  if (S_ISDIR(delta->new_file.mode))
674
725
  return 0;
675
726
 
727
+ if ((error = flush_file_header(delta, pi)) < 0)
728
+ return error;
729
+
676
730
  return pi->print_cb(delta, hunk, line, pi->payload);
677
731
  }
678
732
 
@@ -705,6 +759,8 @@ int git_diff_print(
705
759
  break;
706
760
  case GIT_DIFF_FORMAT_PATCH_HEADER:
707
761
  print_file = diff_print_patch_file;
762
+ print_binary = diff_print_patch_binary;
763
+ print_hunk = diff_print_patch_hunk;
708
764
  break;
709
765
  case GIT_DIFF_FORMAT_RAW:
710
766
  print_file = diff_print_one_raw;
@@ -190,7 +190,7 @@ int git_diff__merge(
190
190
  git_pool_strdup_safe(&onto->pool, onto->opts.new_prefix);
191
191
  }
192
192
 
193
- git_vector_free_deep(&onto_new);
193
+ git_vector_dispose_deep(&onto_new);
194
194
  git_pool_clear(&onto_pool);
195
195
 
196
196
  return error;
@@ -424,13 +424,13 @@ static int apply_splits_and_deletes(
424
424
 
425
425
  /* swap new delta list into place */
426
426
  git_vector_swap(&diff->deltas, &onto);
427
- git_vector_free(&onto);
427
+ git_vector_dispose(&onto);
428
428
  git_vector_sort(&diff->deltas);
429
429
 
430
430
  return 0;
431
431
 
432
432
  on_error:
433
- git_vector_free_deep(&onto);
433
+ git_vector_dispose_deep(&onto);
434
434
 
435
435
  return -1;
436
436
  }
@@ -653,6 +653,23 @@ static int calc_self_similarity(
653
653
  return 0;
654
654
  }
655
655
 
656
+ static void handle_non_blob(
657
+ git_diff *diff,
658
+ const git_diff_find_options *opts,
659
+ size_t delta_idx)
660
+ {
661
+ git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx);
662
+
663
+ /* skip things that are blobs */
664
+ if (GIT_MODE_ISBLOB(delta->old_file.mode))
665
+ return;
666
+
667
+ /* honor "remove unmodified" flag for non-blobs (eg submodules) */
668
+ if (delta->status == GIT_DELTA_UNMODIFIED &&
669
+ FLAG_SET(opts, GIT_DIFF_FIND_REMOVE_UNMODIFIED))
670
+ delta->flags |= GIT_DIFF_FLAG__TO_DELETE;
671
+ }
672
+
656
673
  static bool is_rename_target(
657
674
  git_diff *diff,
658
675
  const git_diff_find_options *opts,
@@ -810,7 +827,8 @@ int git_diff_find_similar(
810
827
  git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT;
811
828
  size_t num_deltas, num_srcs = 0, num_tgts = 0;
812
829
  size_t tried_srcs = 0, tried_tgts = 0;
813
- size_t num_rewrites = 0, num_updates = 0, num_bumped = 0;
830
+ size_t num_rewrites = 0, num_updates = 0, num_bumped = 0,
831
+ num_to_delete = 0;
814
832
  size_t sigcache_size;
815
833
  void **sigcache = NULL; /* cache of similarity metric file signatures */
816
834
  diff_find_match *tgt2src = NULL;
@@ -844,6 +862,8 @@ int git_diff_find_similar(
844
862
  * mark them for splitting if break-rewrites is enabled
845
863
  */
846
864
  git_vector_foreach(&diff->deltas, t, tgt) {
865
+ handle_non_blob(diff, &opts, t);
866
+
847
867
  if (is_rename_source(diff, &opts, t, sigcache))
848
868
  ++num_srcs;
849
869
 
@@ -852,11 +872,14 @@ int git_diff_find_similar(
852
872
 
853
873
  if ((tgt->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0)
854
874
  num_rewrites++;
875
+
876
+ if ((tgt->flags & GIT_DIFF_FLAG__TO_DELETE) != 0)
877
+ num_to_delete++;
855
878
  }
856
879
 
857
- /* if there are no candidate srcs or tgts, we're done */
880
+ /* If there are no candidate srcs or tgts, no need to find matches */
858
881
  if (!num_srcs || !num_tgts)
859
- goto cleanup;
882
+ goto split_and_delete;
860
883
 
861
884
  src2tgt = git__calloc(num_deltas, sizeof(diff_find_match));
862
885
  GIT_ERROR_CHECK_ALLOC(src2tgt);
@@ -1093,15 +1116,20 @@ find_best_matches:
1093
1116
  }
1094
1117
  }
1095
1118
 
1119
+ split_and_delete:
1096
1120
  /*
1097
1121
  * Actually split and delete entries as needed
1098
1122
  */
1099
1123
 
1100
- if (num_rewrites > 0 || num_updates > 0)
1124
+ if (num_rewrites > 0 || num_updates > 0 || num_to_delete > 0) {
1125
+ size_t apply_len = diff->deltas.length -
1126
+ num_rewrites - num_to_delete;
1127
+
1101
1128
  error = apply_splits_and_deletes(
1102
- diff, diff->deltas.length - num_rewrites,
1129
+ diff, apply_len,
1103
1130
  FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) &&
1104
1131
  !FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY));
1132
+ }
1105
1133
 
1106
1134
  cleanup:
1107
1135
  git__free(tgt2src);