rugged 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (338) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +3 -3
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_commit.c +1 -1
  6. data/ext/rugged/rugged_config.c +1 -1
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +32 -2
  9. data/ext/rugged/rugged_repo.c +13 -3
  10. data/lib/rugged/commit.rb +17 -4
  11. data/lib/rugged/repository.rb +7 -8
  12. data/lib/rugged/submodule_collection.rb +4 -4
  13. data/lib/rugged/version.rb +1 -1
  14. data/vendor/libgit2/CMakeLists.txt +41 -74
  15. data/vendor/libgit2/COPYING +109 -1
  16. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  20. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  21. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  23. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  24. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  25. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  26. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  27. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  30. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  31. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  32. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  33. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  34. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
  35. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
  36. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  37. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  38. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
  39. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
  40. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  41. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  42. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  43. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  44. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  45. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  46. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  47. data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
  48. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  49. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  50. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  51. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  52. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  53. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  54. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  55. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  56. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  57. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  58. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  59. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  60. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  61. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  62. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  63. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  64. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  65. data/vendor/libgit2/include/git2/apply.h +2 -0
  66. data/vendor/libgit2/include/git2/attr.h +89 -0
  67. data/vendor/libgit2/include/git2/blame.h +95 -42
  68. data/vendor/libgit2/include/git2/blob.h +31 -3
  69. data/vendor/libgit2/include/git2/branch.h +25 -0
  70. data/vendor/libgit2/include/git2/cert.h +42 -5
  71. data/vendor/libgit2/include/git2/checkout.h +28 -12
  72. data/vendor/libgit2/include/git2/commit.h +35 -19
  73. data/vendor/libgit2/include/git2/common.h +33 -6
  74. data/vendor/libgit2/include/git2/config.h +1 -1
  75. data/vendor/libgit2/include/git2/deprecated.h +248 -8
  76. data/vendor/libgit2/include/git2/diff.h +35 -20
  77. data/vendor/libgit2/include/git2/errors.h +8 -7
  78. data/vendor/libgit2/include/git2/filter.h +57 -17
  79. data/vendor/libgit2/include/git2/graph.h +20 -2
  80. data/vendor/libgit2/include/git2/index.h +4 -5
  81. data/vendor/libgit2/include/git2/indexer.h +2 -1
  82. data/vendor/libgit2/include/git2/odb.h +44 -20
  83. data/vendor/libgit2/include/git2/pack.h +1 -1
  84. data/vendor/libgit2/include/git2/patch.h +8 -0
  85. data/vendor/libgit2/include/git2/rebase.h +25 -1
  86. data/vendor/libgit2/include/git2/refs.h +9 -5
  87. data/vendor/libgit2/include/git2/remote.h +59 -6
  88. data/vendor/libgit2/include/git2/repository.h +95 -52
  89. data/vendor/libgit2/include/git2/revparse.h +5 -5
  90. data/vendor/libgit2/include/git2/status.h +115 -59
  91. data/vendor/libgit2/include/git2/strarray.h +6 -10
  92. data/vendor/libgit2/include/git2/submodule.h +9 -0
  93. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  94. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  95. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  96. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  97. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  98. data/vendor/libgit2/include/git2/tag.h +12 -0
  99. data/vendor/libgit2/include/git2/transport.h +1 -1
  100. data/vendor/libgit2/include/git2/tree.h +2 -14
  101. data/vendor/libgit2/include/git2/types.h +9 -0
  102. data/vendor/libgit2/include/git2/version.h +3 -3
  103. data/vendor/libgit2/include/git2/worktree.h +1 -0
  104. data/vendor/libgit2/src/CMakeLists.txt +77 -44
  105. data/vendor/libgit2/src/alloc.c +21 -8
  106. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  107. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  108. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  109. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  110. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  111. data/vendor/libgit2/src/annotated_commit.c +21 -9
  112. data/vendor/libgit2/src/apply.c +21 -8
  113. data/vendor/libgit2/src/array.h +11 -11
  114. data/vendor/libgit2/src/assert_safe.h +58 -0
  115. data/vendor/libgit2/src/attr.c +181 -74
  116. data/vendor/libgit2/src/attr_file.c +92 -42
  117. data/vendor/libgit2/src/attr_file.h +32 -11
  118. data/vendor/libgit2/src/attrcache.c +44 -40
  119. data/vendor/libgit2/src/attrcache.h +4 -5
  120. data/vendor/libgit2/src/blame.c +28 -15
  121. data/vendor/libgit2/src/blame_git.c +6 -3
  122. data/vendor/libgit2/src/blob.c +46 -24
  123. data/vendor/libgit2/src/branch.c +87 -37
  124. data/vendor/libgit2/src/buffer.c +339 -27
  125. data/vendor/libgit2/src/buffer.h +153 -2
  126. data/vendor/libgit2/src/cache.c +3 -24
  127. data/vendor/libgit2/src/cache.h +7 -7
  128. data/vendor/libgit2/src/cc-compat.h +10 -2
  129. data/vendor/libgit2/src/checkout.c +97 -98
  130. data/vendor/libgit2/src/cherrypick.c +8 -2
  131. data/vendor/libgit2/src/clone.c +104 -29
  132. data/vendor/libgit2/src/commit.c +41 -28
  133. data/vendor/libgit2/src/commit_graph.c +1209 -0
  134. data/vendor/libgit2/src/commit_graph.h +162 -0
  135. data/vendor/libgit2/src/commit_list.c +46 -0
  136. data/vendor/libgit2/src/commit_list.h +2 -0
  137. data/vendor/libgit2/src/common.h +26 -2
  138. data/vendor/libgit2/src/config.c +40 -22
  139. data/vendor/libgit2/src/config_cache.c +9 -4
  140. data/vendor/libgit2/src/config_entries.c +35 -27
  141. data/vendor/libgit2/src/config_file.c +25 -8
  142. data/vendor/libgit2/src/config_parse.c +5 -7
  143. data/vendor/libgit2/src/config_snapshot.c +2 -1
  144. data/vendor/libgit2/src/crlf.c +16 -6
  145. data/vendor/libgit2/src/date.c +4 -3
  146. data/vendor/libgit2/src/delta.c +1 -1
  147. data/vendor/libgit2/src/describe.c +11 -4
  148. data/vendor/libgit2/src/diff.c +23 -19
  149. data/vendor/libgit2/src/diff_driver.c +21 -17
  150. data/vendor/libgit2/src/diff_file.c +5 -7
  151. data/vendor/libgit2/src/diff_generate.c +56 -28
  152. data/vendor/libgit2/src/diff_parse.c +2 -3
  153. data/vendor/libgit2/src/diff_print.c +81 -65
  154. data/vendor/libgit2/src/diff_stats.c +19 -16
  155. data/vendor/libgit2/src/diff_tform.c +13 -13
  156. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  157. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  158. data/vendor/libgit2/src/errors.c +26 -19
  159. data/vendor/libgit2/src/features.h.in +5 -1
  160. data/vendor/libgit2/src/fetch.c +7 -2
  161. data/vendor/libgit2/src/fetchhead.c +8 -4
  162. data/vendor/libgit2/src/filebuf.c +9 -7
  163. data/vendor/libgit2/src/filter.c +209 -113
  164. data/vendor/libgit2/src/filter.h +24 -5
  165. data/vendor/libgit2/src/futils.c +8 -8
  166. data/vendor/libgit2/src/futils.h +4 -4
  167. data/vendor/libgit2/src/graph.c +64 -9
  168. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  169. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  170. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  171. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  172. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  173. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  174. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  175. data/vendor/libgit2/src/hash.c +16 -13
  176. data/vendor/libgit2/src/hash.h +1 -1
  177. data/vendor/libgit2/src/hashsig.c +23 -10
  178. data/vendor/libgit2/src/ident.c +13 -3
  179. data/vendor/libgit2/src/idxmap.c +0 -22
  180. data/vendor/libgit2/src/ignore.c +35 -19
  181. data/vendor/libgit2/src/index.c +126 -84
  182. data/vendor/libgit2/src/index.h +1 -1
  183. data/vendor/libgit2/src/indexer.c +60 -36
  184. data/vendor/libgit2/src/integer.h +79 -2
  185. data/vendor/libgit2/src/iterator.c +40 -28
  186. data/vendor/libgit2/src/iterator.h +1 -1
  187. data/vendor/libgit2/src/khash.h +2 -11
  188. data/vendor/libgit2/src/{settings.c → libgit2.c} +125 -49
  189. data/vendor/libgit2/src/libgit2.h +15 -0
  190. data/vendor/libgit2/src/mailmap.c +23 -10
  191. data/vendor/libgit2/src/map.h +3 -3
  192. data/vendor/libgit2/src/merge.c +108 -46
  193. data/vendor/libgit2/src/merge.h +2 -1
  194. data/vendor/libgit2/src/merge_driver.c +19 -13
  195. data/vendor/libgit2/src/merge_file.c +15 -9
  196. data/vendor/libgit2/src/message.c +3 -1
  197. data/vendor/libgit2/src/midx.c +879 -0
  198. data/vendor/libgit2/src/midx.h +110 -0
  199. data/vendor/libgit2/src/mwindow.c +214 -95
  200. data/vendor/libgit2/src/mwindow.h +3 -3
  201. data/vendor/libgit2/src/net.c +133 -4
  202. data/vendor/libgit2/src/net.h +16 -2
  203. data/vendor/libgit2/src/netops.c +6 -4
  204. data/vendor/libgit2/src/netops.h +2 -2
  205. data/vendor/libgit2/src/notes.c +10 -10
  206. data/vendor/libgit2/src/object.c +24 -15
  207. data/vendor/libgit2/src/odb.c +298 -57
  208. data/vendor/libgit2/src/odb.h +16 -2
  209. data/vendor/libgit2/src/odb_loose.c +31 -21
  210. data/vendor/libgit2/src/odb_mempack.c +3 -1
  211. data/vendor/libgit2/src/odb_pack.c +391 -114
  212. data/vendor/libgit2/src/oid.c +7 -4
  213. data/vendor/libgit2/src/pack-objects.c +83 -69
  214. data/vendor/libgit2/src/pack.c +383 -150
  215. data/vendor/libgit2/src/pack.h +44 -9
  216. data/vendor/libgit2/src/patch.c +14 -7
  217. data/vendor/libgit2/src/patch_generate.c +3 -5
  218. data/vendor/libgit2/src/patch_parse.c +6 -3
  219. data/vendor/libgit2/src/path.c +102 -57
  220. data/vendor/libgit2/src/path.h +79 -6
  221. data/vendor/libgit2/src/pathspec.c +12 -11
  222. data/vendor/libgit2/src/pool.c +34 -22
  223. data/vendor/libgit2/src/pool.h +9 -1
  224. data/vendor/libgit2/src/posix.c +43 -12
  225. data/vendor/libgit2/src/posix.h +9 -0
  226. data/vendor/libgit2/src/proxy.c +2 -0
  227. data/vendor/libgit2/src/push.c +2 -0
  228. data/vendor/libgit2/src/reader.c +10 -6
  229. data/vendor/libgit2/src/rebase.c +95 -49
  230. data/vendor/libgit2/src/refdb.c +165 -13
  231. data/vendor/libgit2/src/refdb.h +69 -0
  232. data/vendor/libgit2/src/refdb_fs.c +144 -152
  233. data/vendor/libgit2/src/reflog.c +21 -20
  234. data/vendor/libgit2/src/refs.c +151 -231
  235. data/vendor/libgit2/src/refs.h +2 -20
  236. data/vendor/libgit2/src/refspec.c +80 -44
  237. data/vendor/libgit2/src/regexp.c +2 -2
  238. data/vendor/libgit2/src/remote.c +312 -121
  239. data/vendor/libgit2/src/remote.h +2 -1
  240. data/vendor/libgit2/src/repository.c +351 -189
  241. data/vendor/libgit2/src/repository.h +23 -29
  242. data/vendor/libgit2/src/reset.c +7 -6
  243. data/vendor/libgit2/src/revert.c +8 -2
  244. data/vendor/libgit2/src/revparse.c +19 -13
  245. data/vendor/libgit2/src/revwalk.c +35 -20
  246. data/vendor/libgit2/src/runtime.c +162 -0
  247. data/vendor/libgit2/src/runtime.h +62 -0
  248. data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
  249. data/vendor/libgit2/src/signature.c +6 -5
  250. data/vendor/libgit2/src/sortedcache.c +2 -3
  251. data/vendor/libgit2/src/sortedcache.h +10 -8
  252. data/vendor/libgit2/src/stash.c +7 -3
  253. data/vendor/libgit2/src/status.c +9 -4
  254. data/vendor/libgit2/src/strarray.c +64 -0
  255. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  256. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  257. data/vendor/libgit2/src/streams/openssl.c +113 -207
  258. data/vendor/libgit2/src/streams/openssl.h +9 -1
  259. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  260. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  261. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  262. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  263. data/vendor/libgit2/src/streams/registry.c +10 -9
  264. data/vendor/libgit2/src/streams/socket.c +6 -2
  265. data/vendor/libgit2/src/streams/stransport.c +6 -3
  266. data/vendor/libgit2/src/streams/tls.c +5 -3
  267. data/vendor/libgit2/src/submodule.c +134 -66
  268. data/vendor/libgit2/src/submodule.h +9 -9
  269. data/vendor/libgit2/src/sysdir.c +8 -26
  270. data/vendor/libgit2/src/sysdir.h +0 -11
  271. data/vendor/libgit2/src/tag.c +49 -11
  272. data/vendor/libgit2/src/thread.c +140 -0
  273. data/vendor/libgit2/src/thread.h +479 -0
  274. data/vendor/libgit2/src/threadstate.c +83 -0
  275. data/vendor/libgit2/src/threadstate.h +24 -0
  276. data/vendor/libgit2/src/trace.c +2 -2
  277. data/vendor/libgit2/src/trace.h +17 -13
  278. data/vendor/libgit2/src/transaction.c +21 -9
  279. data/vendor/libgit2/src/transport.c +3 -3
  280. data/vendor/libgit2/src/transports/auth.c +1 -1
  281. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  282. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  283. data/vendor/libgit2/src/transports/credential.c +17 -7
  284. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  285. data/vendor/libgit2/src/transports/git.c +1 -3
  286. data/vendor/libgit2/src/transports/http.c +19 -17
  287. data/vendor/libgit2/src/transports/http.h +1 -0
  288. data/vendor/libgit2/src/transports/httpclient.c +84 -42
  289. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  290. data/vendor/libgit2/src/transports/local.c +5 -5
  291. data/vendor/libgit2/src/transports/smart.c +14 -9
  292. data/vendor/libgit2/src/transports/smart.h +1 -1
  293. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  294. data/vendor/libgit2/src/transports/ssh.c +51 -17
  295. data/vendor/libgit2/src/transports/winhttp.c +156 -88
  296. data/vendor/libgit2/src/tree.c +100 -77
  297. data/vendor/libgit2/src/tree.h +1 -0
  298. data/vendor/libgit2/src/tsort.c +0 -2
  299. data/vendor/libgit2/src/unix/map.c +3 -1
  300. data/vendor/libgit2/src/unix/posix.h +16 -1
  301. data/vendor/libgit2/src/unix/pthread.h +2 -1
  302. data/vendor/libgit2/src/utf8.c +150 -0
  303. data/vendor/libgit2/src/utf8.h +52 -0
  304. data/vendor/libgit2/src/util.c +74 -183
  305. data/vendor/libgit2/src/util.h +33 -39
  306. data/vendor/libgit2/src/vector.c +23 -19
  307. data/vendor/libgit2/src/vector.h +4 -2
  308. data/vendor/libgit2/src/win32/findfile.c +4 -2
  309. data/vendor/libgit2/src/win32/git2.rc +18 -3
  310. data/vendor/libgit2/src/win32/map.c +1 -1
  311. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  312. data/vendor/libgit2/src/win32/path_w32.c +23 -25
  313. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  314. data/vendor/libgit2/src/win32/posix_w32.c +77 -1
  315. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  316. data/vendor/libgit2/src/win32/reparse.h +4 -4
  317. data/vendor/libgit2/src/win32/thread.c +24 -15
  318. data/vendor/libgit2/src/win32/thread.h +1 -1
  319. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  320. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  321. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  322. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  323. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  324. data/vendor/libgit2/src/worktree.c +37 -15
  325. data/vendor/libgit2/src/zstream.c +1 -1
  326. metadata +56 -38
  327. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  328. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  329. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  330. data/vendor/libgit2/src/buf_text.c +0 -316
  331. data/vendor/libgit2/src/buf_text.h +0 -122
  332. data/vendor/libgit2/src/global.c +0 -361
  333. data/vendor/libgit2/src/global.h +0 -41
  334. data/vendor/libgit2/src/thread-utils.c +0 -58
  335. data/vendor/libgit2/src/thread-utils.h +0 -246
  336. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  337. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  338. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -17,12 +17,34 @@
17
17
  * } git_buf;
18
18
  */
19
19
 
20
+ typedef enum {
21
+ GIT_BUF_BOM_NONE = 0,
22
+ GIT_BUF_BOM_UTF8 = 1,
23
+ GIT_BUF_BOM_UTF16_LE = 2,
24
+ GIT_BUF_BOM_UTF16_BE = 3,
25
+ GIT_BUF_BOM_UTF32_LE = 4,
26
+ GIT_BUF_BOM_UTF32_BE = 5
27
+ } git_buf_bom_t;
28
+
29
+ typedef struct {
30
+ git_buf_bom_t bom; /* BOM found at head of text */
31
+ unsigned int nul, cr, lf, crlf; /* NUL, CR, LF and CRLF counts */
32
+ unsigned int printable, nonprintable; /* These are just approximations! */
33
+ } git_buf_text_stats;
34
+
20
35
  extern char git_buf__initbuf[];
21
36
  extern char git_buf__oom[];
22
37
 
23
38
  /* Use to initialize buffer structure when git_buf is on stack */
24
39
  #define GIT_BUF_INIT { git_buf__initbuf, 0, 0 }
25
40
 
41
+ /**
42
+ * Static initializer for git_buf from static buffer
43
+ */
44
+ #ifdef GIT_DEPRECATE_HARD
45
+ # define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) }
46
+ #endif
47
+
26
48
  GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf)
27
49
  {
28
50
  return (buf->ptr != NULL && buf->asize > 0);
@@ -36,6 +58,33 @@ GIT_INLINE(bool) git_buf_is_allocated(const git_buf *buf)
36
58
  */
37
59
  extern int git_buf_init(git_buf *buf, size_t initial_size);
38
60
 
61
+ #ifdef GIT_DEPRECATE_HARD
62
+
63
+ /**
64
+ * Resize the buffer allocation to make more space.
65
+ *
66
+ * This will attempt to grow the buffer to accommodate the target size.
67
+ *
68
+ * If the buffer refers to memory that was not allocated by libgit2 (i.e.
69
+ * the `asize` field is zero), then `ptr` will be replaced with a newly
70
+ * allocated block of data. Be careful so that memory allocated by the
71
+ * caller is not lost. As a special variant, if you pass `target_size` as
72
+ * 0 and the memory is not allocated by libgit2, this will allocate a new
73
+ * buffer of size `size` and copy the external data into it.
74
+ *
75
+ * Currently, this will never shrink a buffer, only expand it.
76
+ *
77
+ * If the allocation fails, this will return an error and the buffer will be
78
+ * marked as invalid for future operations, invaliding the contents.
79
+ *
80
+ * @param buffer The buffer to be resized; may or may not be allocated yet
81
+ * @param target_size The desired available size
82
+ * @return 0 on success, -1 on allocation failure
83
+ */
84
+ int git_buf_grow(git_buf *buffer, size_t target_size);
85
+
86
+ #endif
87
+
39
88
  /**
40
89
  * Resize the buffer allocation to make more space.
41
90
  *
@@ -69,7 +118,7 @@ extern int git_buf_try_grow(
69
118
  * git_buf__initbuf. If a buffer with a non-NULL ptr is passed in, this method
70
119
  * assures that the buffer is '\0'-terminated.
71
120
  */
72
- extern void git_buf_sanitize(git_buf *buf);
121
+ extern int git_buf_sanitize(git_buf *buf);
73
122
 
74
123
  extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b);
75
124
  extern char *git_buf_detach(git_buf *buf);
@@ -105,6 +154,11 @@ GIT_INLINE(bool) git_buf_oom(const git_buf *buf)
105
154
  * return code of these functions and call them in a series then just call
106
155
  * git_buf_oom at the end.
107
156
  */
157
+
158
+ #ifdef GIT_DEPRECATE_HARD
159
+ int git_buf_set(git_buf *buffer, const void *data, size_t datalen);
160
+ #endif
161
+
108
162
  int git_buf_sets(git_buf *buf, const char *string);
109
163
  int git_buf_putc(git_buf *buf, char c);
110
164
  int git_buf_putcn(git_buf *buf, char c, size_t len);
@@ -145,7 +199,7 @@ GIT_INLINE(size_t) git_buf_len(const git_buf *buf)
145
199
  return buf->size;
146
200
  }
147
201
 
148
- void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf);
202
+ int git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf);
149
203
 
150
204
  #define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1)
151
205
 
@@ -219,4 +273,101 @@ int git_buf_splice(
219
273
  const char *data,
220
274
  size_t nb_to_insert);
221
275
 
276
+ /**
277
+ * Append string to buffer, prefixing each character from `esc_chars` with
278
+ * `esc_with` string.
279
+ *
280
+ * @param buf Buffer to append data to
281
+ * @param string String to escape and append
282
+ * @param esc_chars Characters to be escaped
283
+ * @param esc_with String to insert in from of each found character
284
+ * @return 0 on success, <0 on failure (probably allocation problem)
285
+ */
286
+ extern int git_buf_puts_escaped(
287
+ git_buf *buf,
288
+ const char *string,
289
+ const char *esc_chars,
290
+ const char *esc_with);
291
+
292
+ /**
293
+ * Append string escaping characters that are regex special
294
+ */
295
+ GIT_INLINE(int) git_buf_puts_escape_regex(git_buf *buf, const char *string)
296
+ {
297
+ return git_buf_puts_escaped(buf, string, "^.[]$()|*+?{}\\", "\\");
298
+ }
299
+
300
+ /**
301
+ * Unescape all characters in a buffer in place
302
+ *
303
+ * I.e. remove backslashes
304
+ */
305
+ extern void git_buf_unescape(git_buf *buf);
306
+
307
+ /**
308
+ * Replace all \r\n with \n.
309
+ *
310
+ * @return 0 on success, -1 on memory error
311
+ */
312
+ extern int git_buf_crlf_to_lf(git_buf *tgt, const git_buf *src);
313
+
314
+ /**
315
+ * Replace all \n with \r\n. Does not modify existing \r\n.
316
+ *
317
+ * @return 0 on success, -1 on memory error
318
+ */
319
+ extern int git_buf_lf_to_crlf(git_buf *tgt, const git_buf *src);
320
+
321
+ /**
322
+ * Fill buffer with the common prefix of a array of strings
323
+ *
324
+ * Buffer will be set to empty if there is no common prefix
325
+ */
326
+ extern int git_buf_common_prefix(git_buf *buf, const git_strarray *strs);
327
+
328
+ /**
329
+ * Check if a buffer begins with a UTF BOM
330
+ *
331
+ * @param bom Set to the type of BOM detected or GIT_BOM_NONE
332
+ * @param buf Buffer in which to check the first bytes for a BOM
333
+ * @return Number of bytes of BOM data (or 0 if no BOM found)
334
+ */
335
+ extern int git_buf_detect_bom(git_buf_bom_t *bom, const git_buf *buf);
336
+
337
+ /**
338
+ * Gather stats for a piece of text
339
+ *
340
+ * Fill the `stats` structure with counts of unreadable characters, carriage
341
+ * returns, etc, so it can be used in heuristics. This automatically skips
342
+ * a trailing EOF (\032 character). Also it will look for a BOM at the
343
+ * start of the text and can be told to skip that as well.
344
+ *
345
+ * @param stats Structure to be filled in
346
+ * @param buf Text to process
347
+ * @param skip_bom Exclude leading BOM from stats if true
348
+ * @return Does the buffer heuristically look like binary data
349
+ */
350
+ extern bool git_buf_gather_text_stats(
351
+ git_buf_text_stats *stats, const git_buf *buf, bool skip_bom);
352
+
353
+ #ifdef GIT_DEPRECATE_HARD
354
+
355
+ /**
356
+ * Check quickly if buffer looks like it contains binary data
357
+ *
358
+ * @param buf Buffer to check
359
+ * @return 1 if buffer looks like non-text data
360
+ */
361
+ int git_buf_is_binary(const git_buf *buf);
362
+
363
+ /**
364
+ * Check quickly if buffer contains a NUL byte
365
+ *
366
+ * @param buf Buffer to check
367
+ * @return 1 if buffer contains a NUL byte
368
+ */
369
+ int git_buf_contains_nul(const git_buf *buf);
370
+
371
+ #endif
372
+
222
373
  #endif
@@ -9,7 +9,7 @@
9
9
 
10
10
  #include "repository.h"
11
11
  #include "commit.h"
12
- #include "thread-utils.h"
12
+ #include "thread.h"
13
13
  #include "util.h"
14
14
  #include "odb.h"
15
15
  #include "object.h"
@@ -41,27 +41,6 @@ int git_cache_set_max_object_size(git_object_t type, size_t size)
41
41
  return 0;
42
42
  }
43
43
 
44
- void git_cache_dump_stats(git_cache *cache)
45
- {
46
- git_cached_obj *object;
47
-
48
- if (git_cache_size(cache) == 0)
49
- return;
50
-
51
- printf("Cache %p: %"PRIuZ" items cached, %"PRIdZ" bytes\n",
52
- cache, git_cache_size(cache), cache->used_memory);
53
-
54
- git_oidmap_foreach_value(cache->map, object, {
55
- char oid_str[9];
56
- printf(" %s%c %s (%"PRIuZ")\n",
57
- git_object_type2string(object->type),
58
- object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ',
59
- git_oid_tostr(oid_str, sizeof(oid_str), &object->oid),
60
- object->size
61
- );
62
- });
63
- }
64
-
65
44
  int git_cache_init(git_cache *cache)
66
45
  {
67
46
  memset(cache, 0, sizeof(*cache));
@@ -189,7 +168,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
189
168
  return entry;
190
169
 
191
170
  /* soften the load on the cache */
192
- if (git_cache__current_storage.val > git_cache__max_storage)
171
+ if (git_atomic_ssize_get(&git_cache__current_storage) > git_cache__max_storage)
193
172
  cache_evict_entries(cache);
194
173
 
195
174
  /* not found */
@@ -256,7 +235,7 @@ void git_cached_obj_decref(void *_obj)
256
235
  {
257
236
  git_cached_obj *obj = _obj;
258
237
 
259
- if (git_atomic_dec(&obj->refcount) == 0) {
238
+ if (git_atomic32_dec(&obj->refcount) == 0) {
260
239
  switch (obj->flags) {
261
240
  case GIT_CACHE_STORE_RAW:
262
241
  git_odb_object__free(_obj);
@@ -13,7 +13,7 @@
13
13
  #include "git2/oid.h"
14
14
  #include "git2/odb.h"
15
15
 
16
- #include "thread-utils.h"
16
+ #include "thread.h"
17
17
  #include "oidmap.h"
18
18
 
19
19
  enum {
@@ -23,11 +23,11 @@ enum {
23
23
  };
24
24
 
25
25
  typedef struct {
26
- git_oid oid;
27
- int16_t type; /* git_object_t value */
28
- uint16_t flags; /* GIT_CACHE_STORE value */
29
- size_t size;
30
- git_atomic refcount;
26
+ git_oid oid;
27
+ int16_t type; /* git_object_t value */
28
+ uint16_t flags; /* GIT_CACHE_STORE value */
29
+ size_t size;
30
+ git_atomic32 refcount;
31
31
  } git_cached_obj;
32
32
 
33
33
  typedef struct {
@@ -61,7 +61,7 @@ GIT_INLINE(size_t) git_cache_size(git_cache *cache)
61
61
  GIT_INLINE(void) git_cached_obj_incref(void *_obj)
62
62
  {
63
63
  git_cached_obj *obj = _obj;
64
- git_atomic_inc(&obj->refcount);
64
+ git_atomic32_inc(&obj->refcount);
65
65
  }
66
66
 
67
67
  void git_cached_obj_decref(void *_obj);
@@ -43,9 +43,17 @@
43
43
  # define GIT_ALIGN(x,size) x
44
44
  #endif
45
45
 
46
- #define GIT_UNUSED(x) ((void)(x))
46
+ #if defined(__GNUC__)
47
+ # define GIT_UNUSED(x) \
48
+ do { \
49
+ typeof(x) _unused __attribute__((unused)); \
50
+ _unused = (x); \
51
+ } while (0)
52
+ #else
53
+ # define GIT_UNUSED(x) ((void)(x))
54
+ #endif
47
55
 
48
- /* Define the printf format specifer to use for size_t output */
56
+ /* Define the printf format specifier to use for size_t output */
49
57
  #if defined(_MSC_VER) || defined(__MINGW32__)
50
58
 
51
59
  /* Visual Studio 2012 and prior lack PRId64 entirely */
@@ -26,7 +26,6 @@
26
26
  #include "diff.h"
27
27
  #include "diff_generate.h"
28
28
  #include "pathspec.h"
29
- #include "buf_text.h"
30
29
  #include "diff_xdiff.h"
31
30
  #include "path.h"
32
31
  #include "attr.h"
@@ -44,7 +43,6 @@ enum {
44
43
  CHECKOUT_ACTION__REMOVE_CONFLICT = 16,
45
44
  CHECKOUT_ACTION__UPDATE_CONFLICT = 32,
46
45
  CHECKOUT_ACTION__MAX = 32,
47
- CHECKOUT_ACTION__DEFER_REMOVE = 64,
48
46
  CHECKOUT_ACTION__REMOVE_AND_UPDATE =
49
47
  (CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE),
50
48
  };
@@ -196,7 +194,7 @@ static bool checkout_is_workdir_modified(
196
194
  }
197
195
 
198
196
  if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 ||
199
- GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
197
+ GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status))
200
198
  rval = true;
201
199
  else if ((sm_oid = git_submodule_wd_id(sm)) == NULL)
202
200
  rval = false;
@@ -217,9 +215,10 @@ static bool checkout_is_workdir_modified(
217
215
  ie = git_index_get_bypath(data->index, wditem->path, 0);
218
216
 
219
217
  if (ie != NULL &&
220
- git_index_time_eq(&wditem->mtime, &ie->mtime) &&
221
- wditem->file_size == ie->file_size &&
222
- !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) {
218
+ !git_index_entry_newer_than_index(ie, data->index) &&
219
+ git_index_time_eq(&wditem->mtime, &ie->mtime) &&
220
+ wditem->file_size == ie->file_size &&
221
+ !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) {
223
222
 
224
223
  /* The workdir is modified iff the index entry is modified */
225
224
  return !is_workdir_base_or_new(&ie->id, baseitem, newitem) ||
@@ -273,9 +272,8 @@ static int checkout_action_common(
273
272
 
274
273
  /* if the file is on disk and doesn't match our mode, force update */
275
274
  if (wd &&
276
- GIT_PERMS_IS_EXEC(wd->mode) !=
277
- GIT_PERMS_IS_EXEC(delta->new_file.mode))
278
- *action |= CHECKOUT_ACTION__REMOVE;
275
+ GIT_PERMS_IS_EXEC(wd->mode) != GIT_PERMS_IS_EXEC(delta->new_file.mode))
276
+ *action |= CHECKOUT_ACTION__REMOVE;
279
277
 
280
278
  notify = GIT_CHECKOUT_NOTIFY_UPDATED;
281
279
  }
@@ -330,6 +328,9 @@ static int checkout_target_fullpath(
330
328
  if (path && git_buf_puts(&data->target_path, path) < 0)
331
329
  return -1;
332
330
 
331
+ if (git_path_validate_workdir_buf(data->repo, &data->target_path) < 0)
332
+ return -1;
333
+
333
334
  *out = &data->target_path;
334
335
 
335
336
  return 0;
@@ -371,8 +372,13 @@ static int checkout_action_wd_only(
371
372
  if (!git_pathspec__match(
372
373
  pathspec, wd->path,
373
374
  (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0,
374
- git_iterator_ignore_case(workdir), NULL, NULL))
375
- return git_iterator_advance(wditem, workdir);
375
+ git_iterator_ignore_case(workdir), NULL, NULL)) {
376
+
377
+ if (wd->mode == GIT_FILEMODE_TREE)
378
+ return git_iterator_advance_into(wditem, workdir);
379
+ else
380
+ return git_iterator_advance(wditem, workdir);
381
+ }
376
382
 
377
383
  /* check if item is tracked in the index but not in the checkout diff */
378
384
  if (data->index != NULL) {
@@ -794,13 +800,13 @@ static int checkout_conflictdata_cmp(const void *a, const void *b)
794
800
  int diff;
795
801
 
796
802
  if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 &&
797
- (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
803
+ (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0)
798
804
  diff = checkout_idxentry_cmp(ca->theirs, cb->theirs);
799
805
 
800
806
  return diff;
801
807
  }
802
808
 
803
- int checkout_conflictdata_empty(
809
+ static int checkout_conflictdata_empty(
804
810
  const git_vector *conflicts, size_t idx, void *payload)
805
811
  {
806
812
  checkout_conflictdata *conflict;
@@ -1173,7 +1179,7 @@ static int checkout_conflicts_mark_directoryfile(
1173
1179
  /* Find d/f conflicts */
1174
1180
  git_vector_foreach(&data->update_conflicts, i, conflict) {
1175
1181
  if ((conflict->ours && conflict->theirs) ||
1176
- (!conflict->ours && !conflict->theirs))
1182
+ (!conflict->ours && !conflict->theirs))
1177
1183
  continue;
1178
1184
 
1179
1185
  path = conflict->ours ?
@@ -1222,8 +1228,8 @@ static int checkout_get_update_conflicts(
1222
1228
  return 0;
1223
1229
 
1224
1230
  if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 ||
1225
- (error = checkout_conflicts_coalesce_renames(data)) < 0 ||
1226
- (error = checkout_conflicts_mark_directoryfile(data)) < 0)
1231
+ (error = checkout_conflicts_coalesce_renames(data)) < 0 ||
1232
+ (error = checkout_conflicts_mark_directoryfile(data)) < 0)
1227
1233
  goto done;
1228
1234
 
1229
1235
  done:
@@ -1239,7 +1245,7 @@ static int checkout_conflict_append_remove(
1239
1245
  checkout_data *data = payload;
1240
1246
  const char *name;
1241
1247
 
1242
- assert(ancestor || ours || theirs);
1248
+ GIT_ASSERT_ARG(ancestor || ours || theirs);
1243
1249
 
1244
1250
  if (ancestor)
1245
1251
  name = git__strdup(ancestor->path);
@@ -1274,14 +1280,14 @@ static int checkout_verify_paths(
1274
1280
  unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;
1275
1281
 
1276
1282
  if (action & CHECKOUT_ACTION__REMOVE) {
1277
- if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
1283
+ if (!git_path_validate(repo, delta->old_file.path, delta->old_file.mode, flags)) {
1278
1284
  git_error_set(GIT_ERROR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
1279
1285
  return -1;
1280
1286
  }
1281
1287
  }
1282
1288
 
1283
1289
  if (action & ~CHECKOUT_ACTION__REMOVE) {
1284
- if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
1290
+ if (!git_path_validate(repo, delta->new_file.path, delta->new_file.mode, flags)) {
1285
1291
  git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
1286
1292
  return -1;
1287
1293
  }
@@ -1304,14 +1310,15 @@ static int checkout_get_actions(
1304
1310
  size_t i, *counts = NULL;
1305
1311
  uint32_t *actions = NULL;
1306
1312
 
1307
- git_pool_init(&pathpool, 1);
1313
+ if (git_pool_init(&pathpool, 1) < 0)
1314
+ return -1;
1308
1315
 
1309
1316
  if (data->opts.paths.count > 0 &&
1310
- git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
1317
+ git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0)
1311
1318
  return -1;
1312
1319
 
1313
1320
  if ((error = git_iterator_current(&wditem, workdir)) < 0 &&
1314
- error != GIT_ITEROVER)
1321
+ error != GIT_ITEROVER)
1315
1322
  goto fail;
1316
1323
 
1317
1324
  deltas = &data->diff->deltas;
@@ -1350,8 +1357,7 @@ static int checkout_get_actions(
1350
1357
  counts[CHECKOUT_ACTION__REMOVE] += data->removes.length;
1351
1358
 
1352
1359
  if (counts[CHECKOUT_ACTION__CONFLICT] > 0 &&
1353
- (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0)
1354
- {
1360
+ (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) {
1355
1361
  git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout",
1356
1362
  counts[CHECKOUT_ACTION__CONFLICT],
1357
1363
  counts[CHECKOUT_ACTION__CONFLICT] == 1 ?
@@ -1362,7 +1368,7 @@ static int checkout_get_actions(
1362
1368
 
1363
1369
 
1364
1370
  if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 ||
1365
- (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
1371
+ (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0)
1366
1372
  goto fail;
1367
1373
 
1368
1374
  counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts);
@@ -1483,7 +1489,9 @@ static int checkout_stream_write(
1483
1489
  static int checkout_stream_close(git_writestream *s)
1484
1490
  {
1485
1491
  struct checkout_stream *stream = (struct checkout_stream *)s;
1486
- assert(stream && stream->open);
1492
+
1493
+ GIT_ASSERT_ARG(stream);
1494
+ GIT_ASSERT_ARG(stream->open);
1487
1495
 
1488
1496
  stream->open = 0;
1489
1497
  return p_close(stream->fd);
@@ -1505,7 +1513,7 @@ static int blob_content_to_file(
1505
1513
  int flags = data->opts.file_open_flags;
1506
1514
  mode_t file_mode = data->opts.file_mode ?
1507
1515
  data->opts.file_mode : entry_filemode;
1508
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
1516
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
1509
1517
  struct checkout_stream writer;
1510
1518
  mode_t mode;
1511
1519
  git_filter_list *fl = NULL;
@@ -1528,13 +1536,13 @@ static int blob_content_to_file(
1528
1536
  return fd;
1529
1537
  }
1530
1538
 
1531
- filter_opts.attr_session = &data->attr_session;
1532
- filter_opts.temp_buf = &data->tmp;
1539
+ filter_session.attr_session = &data->attr_session;
1540
+ filter_session.temp_buf = &data->tmp;
1533
1541
 
1534
1542
  if (!data->opts.disable_filters &&
1535
- (error = git_filter_list__load_ext(
1543
+ (error = git_filter_list__load(
1536
1544
  &fl, data->repo, blob, hint_path,
1537
- GIT_FILTER_TO_WORKTREE, &filter_opts))) {
1545
+ GIT_FILTER_TO_WORKTREE, &filter_session))) {
1538
1546
  p_close(fd);
1539
1547
  return error;
1540
1548
  }
@@ -1550,7 +1558,7 @@ static int blob_content_to_file(
1550
1558
 
1551
1559
  error = git_filter_list_stream_blob(fl, blob, &writer.base);
1552
1560
 
1553
- assert(writer.open == 0);
1561
+ GIT_ASSERT(writer.open == 0);
1554
1562
 
1555
1563
  git_filter_list_free(fl);
1556
1564
 
@@ -1853,26 +1861,6 @@ static int checkout_remove_the_old(
1853
1861
  return 0;
1854
1862
  }
1855
1863
 
1856
- static int checkout_deferred_remove(git_repository *repo, const char *path)
1857
- {
1858
- #if 0
1859
- int error = git_futils_rmdir_r(
1860
- path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS);
1861
-
1862
- if (error == GIT_ENOTFOUND) {
1863
- error = 0;
1864
- git_error_clear();
1865
- }
1866
-
1867
- return error;
1868
- #else
1869
- GIT_UNUSED(repo);
1870
- GIT_UNUSED(path);
1871
- assert(false);
1872
- return 0;
1873
- #endif
1874
- }
1875
-
1876
1864
  static int checkout_create_the_new(
1877
1865
  unsigned int *actions,
1878
1866
  checkout_data *data)
@@ -1882,15 +1870,6 @@ static int checkout_create_the_new(
1882
1870
  size_t i;
1883
1871
 
1884
1872
  git_vector_foreach(&data->diff->deltas, i, delta) {
1885
- if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1886
- /* this had a blocker directory that should only be removed iff
1887
- * all of the contents of the directory were safely removed
1888
- */
1889
- if ((error = checkout_deferred_remove(
1890
- data->repo, delta->old_file.path)) < 0)
1891
- return error;
1892
- }
1893
-
1894
1873
  if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) {
1895
1874
  if ((error = checkout_blob(data, &delta->new_file)) < 0)
1896
1875
  return error;
@@ -1915,20 +1894,10 @@ static int checkout_create_submodules(
1915
1894
  unsigned int *actions,
1916
1895
  checkout_data *data)
1917
1896
  {
1918
- int error = 0;
1919
1897
  git_diff_delta *delta;
1920
1898
  size_t i;
1921
1899
 
1922
1900
  git_vector_foreach(&data->diff->deltas, i, delta) {
1923
- if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) {
1924
- /* this has a blocker directory that should only be removed iff
1925
- * all of the contents of the directory were safely removed
1926
- */
1927
- if ((error = checkout_deferred_remove(
1928
- data->repo, delta->old_file.path)) < 0)
1929
- return error;
1930
- }
1931
-
1932
1901
  if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) {
1933
1902
  int error = checkout_submodule(data, &delta->new_file);
1934
1903
  if (error < 0)
@@ -2011,7 +1980,7 @@ static int checkout_write_entry(
2011
1980
  struct stat st;
2012
1981
  int error;
2013
1982
 
2014
- assert (side == conflict->ours || side == conflict->theirs);
1983
+ GIT_ASSERT(side == conflict->ours || side == conflict->theirs);
2015
1984
 
2016
1985
  if (checkout_target_fullpath(&fullpath, data, side->path) < 0)
2017
1986
  return -1;
@@ -2065,7 +2034,8 @@ static int checkout_merge_path(
2065
2034
  const char *our_label_raw, *their_label_raw, *suffix;
2066
2035
  int error = 0;
2067
2036
 
2068
- if ((error = git_buf_joinpath(out, git_repository_workdir(data->repo), result->path)) < 0)
2037
+ if ((error = git_buf_joinpath(out, data->opts.target_directory, result->path)) < 0 ||
2038
+ (error = git_path_validate_workdir_buf(data->repo, out)) < 0)
2069
2039
  return error;
2070
2040
 
2071
2041
  /* Most conflicts simply use the filename in the index */
@@ -2094,7 +2064,7 @@ static int checkout_write_merge(
2094
2064
  git_merge_file_result result = {0};
2095
2065
  git_filebuf output = GIT_FILEBUF_INIT;
2096
2066
  git_filter_list *fl = NULL;
2097
- git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT;
2067
+ git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
2098
2068
  int error = 0;
2099
2069
 
2100
2070
  if (data->opts.checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3)
@@ -2144,13 +2114,13 @@ static int checkout_write_merge(
2144
2114
  in_data.ptr = (char *)result.ptr;
2145
2115
  in_data.size = result.len;
2146
2116
 
2147
- filter_opts.attr_session = &data->attr_session;
2148
- filter_opts.temp_buf = &data->tmp;
2117
+ filter_session.attr_session = &data->attr_session;
2118
+ filter_session.temp_buf = &data->tmp;
2149
2119
 
2150
- if ((error = git_filter_list__load_ext(
2120
+ if ((error = git_filter_list__load(
2151
2121
  &fl, data->repo, NULL, git_buf_cstr(&path_workdir),
2152
- GIT_FILTER_TO_WORKTREE, &filter_opts)) < 0 ||
2153
- (error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0)
2122
+ GIT_FILTER_TO_WORKTREE, &filter_session)) < 0 ||
2123
+ (error = git_filter_list__convert_buf(&out_data, fl, &in_data)) < 0)
2154
2124
  goto done;
2155
2125
  } else {
2156
2126
  out_data.ptr = (char *)result.ptr;
@@ -2364,6 +2334,22 @@ static void checkout_data_clear(checkout_data *data)
2364
2334
  git_attr_session__free(&data->attr_session);
2365
2335
  }
2366
2336
 
2337
+ static int validate_target_directory(checkout_data *data)
2338
+ {
2339
+ int error;
2340
+
2341
+ if ((error = git_path_validate_workdir(data->repo, data->opts.target_directory)) < 0)
2342
+ return error;
2343
+
2344
+ if (git_path_isdir(data->opts.target_directory))
2345
+ return 0;
2346
+
2347
+ error = checkout_mkdir(data, data->opts.target_directory, NULL,
2348
+ GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR);
2349
+
2350
+ return error;
2351
+ }
2352
+
2367
2353
  static int checkout_data_init(
2368
2354
  checkout_data *data,
2369
2355
  git_iterator *target,
@@ -2396,10 +2382,7 @@ static int checkout_data_init(
2396
2382
 
2397
2383
  if (!data->opts.target_directory)
2398
2384
  data->opts.target_directory = git_repository_workdir(repo);
2399
- else if (!git_path_isdir(data->opts.target_directory) &&
2400
- (error = checkout_mkdir(data,
2401
- data->opts.target_directory, NULL,
2402
- GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0)
2385
+ else if ((error = validate_target_directory(data)) < 0)
2403
2386
  goto cleanup;
2404
2387
 
2405
2388
  if ((error = git_repository_index(&data->index, data->repo)) < 0)
@@ -2520,9 +2503,8 @@ static int checkout_data_init(
2520
2503
  git_config_entry_free(conflict_style);
2521
2504
  }
2522
2505
 
2523
- git_pool_init(&data->pool, 1);
2524
-
2525
- if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2506
+ if ((error = git_pool_init(&data->pool, 1)) < 0 ||
2507
+ (error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 ||
2526
2508
  (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
2527
2509
  (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
2528
2510
  (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 ||
@@ -2544,6 +2526,17 @@ cleanup:
2544
2526
  #define CHECKOUT_INDEX_DONT_WRITE_MASK \
2545
2527
  (GIT_CHECKOUT_DONT_UPDATE_INDEX | GIT_CHECKOUT_DONT_WRITE_INDEX)
2546
2528
 
2529
+ GIT_INLINE(void) setup_pathspecs(
2530
+ git_iterator_options *iter_opts,
2531
+ const git_checkout_options *checkout_opts)
2532
+ {
2533
+ if (checkout_opts &&
2534
+ (checkout_opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2535
+ iter_opts->pathlist.count = checkout_opts->paths.count;
2536
+ iter_opts->pathlist.strings = checkout_opts->paths.strings;
2537
+ }
2538
+ }
2539
+
2547
2540
  int git_checkout_iterator(
2548
2541
  git_iterator *target,
2549
2542
  git_index *index,
@@ -2586,6 +2579,8 @@ int git_checkout_iterator(
2586
2579
  workdir_opts.start = data.pfx;
2587
2580
  workdir_opts.end = data.pfx;
2588
2581
 
2582
+ setup_pathspecs(&workdir_opts, opts);
2583
+
2589
2584
  if ((error = git_iterator_reset_range(target, data.pfx, data.pfx)) < 0 ||
2590
2585
  (error = git_iterator_for_workdir_ext(
2591
2586
  &workdir, data.repo, data.opts.target_directory, index, NULL,
@@ -2596,10 +2591,8 @@ int git_checkout_iterator(
2596
2591
  GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
2597
2592
  baseline_opts.start = data.pfx;
2598
2593
  baseline_opts.end = data.pfx;
2599
- if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2600
- baseline_opts.pathlist.count = opts->paths.count;
2601
- baseline_opts.pathlist.strings = opts->paths.strings;
2602
- }
2594
+
2595
+ setup_pathspecs(&baseline_opts, opts);
2603
2596
 
2604
2597
  if (data.opts.baseline_index) {
2605
2598
  if ((error = git_iterator_for_index(
@@ -2613,7 +2606,7 @@ int git_checkout_iterator(
2613
2606
  }
2614
2607
 
2615
2608
  /* Should not have case insensitivity mismatch */
2616
- assert(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
2609
+ GIT_ASSERT(git_iterator_ignore_case(workdir) == git_iterator_ignore_case(baseline));
2617
2610
 
2618
2611
  /* Generate baseline-to-target diff which will include an entry for
2619
2612
  * every possible update that might need to be made.
@@ -2629,6 +2622,9 @@ int git_checkout_iterator(
2629
2622
  if ((error = checkout_get_actions(&actions, &counts, &data, workdir)) != 0)
2630
2623
  goto cleanup;
2631
2624
 
2625
+ if (data.strategy & GIT_CHECKOUT_DRY_RUN)
2626
+ goto cleanup;
2627
+
2632
2628
  data.total_steps = counts[CHECKOUT_ACTION__REMOVE] +
2633
2629
  counts[CHECKOUT_ACTION__REMOVE_CONFLICT] +
2634
2630
  counts[CHECKOUT_ACTION__UPDATE_BLOB] +
@@ -2664,7 +2660,7 @@ int git_checkout_iterator(
2664
2660
  (error = checkout_extensions_update_index(&data)) < 0)
2665
2661
  goto cleanup;
2666
2662
 
2667
- assert(data.completed_steps == data.total_steps);
2663
+ GIT_ASSERT(data.completed_steps == data.total_steps);
2668
2664
 
2669
2665
  if (data.opts.perfdata_cb)
2670
2666
  data.opts.perfdata_cb(&data.perfdata, data.opts.perfdata_payload);
@@ -2689,6 +2685,7 @@ int git_checkout_index(
2689
2685
  git_index *index,
2690
2686
  const git_checkout_options *opts)
2691
2687
  {
2688
+ git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
2692
2689
  int error, owned = 0;
2693
2690
  git_iterator *index_i;
2694
2691
 
@@ -2716,7 +2713,9 @@ int git_checkout_index(
2716
2713
  return error;
2717
2714
  GIT_REFCOUNT_INC(index);
2718
2715
 
2719
- if (!(error = git_iterator_for_index(&index_i, repo, index, NULL)))
2716
+ setup_pathspecs(&iter_opts, opts);
2717
+
2718
+ if (!(error = git_iterator_for_index(&index_i, repo, index, &iter_opts)))
2720
2719
  error = git_checkout_iterator(index_i, index, opts);
2721
2720
 
2722
2721
  if (owned)
@@ -2773,10 +2772,7 @@ int git_checkout_tree(
2773
2772
  if ((error = git_repository_index(&index, repo)) < 0)
2774
2773
  return error;
2775
2774
 
2776
- if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2777
- iter_opts.pathlist.count = opts->paths.count;
2778
- iter_opts.pathlist.strings = opts->paths.strings;
2779
- }
2775
+ setup_pathspecs(&iter_opts, opts);
2780
2776
 
2781
2777
  if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts)))
2782
2778
  error = git_checkout_iterator(tree_i, index, opts);
@@ -2792,7 +2788,8 @@ int git_checkout_head(
2792
2788
  git_repository *repo,
2793
2789
  const git_checkout_options *opts)
2794
2790
  {
2795
- assert(repo);
2791
+ GIT_ASSERT_ARG(repo);
2792
+
2796
2793
  return git_checkout_tree(repo, NULL, opts);
2797
2794
  }
2798
2795
 
@@ -2803,7 +2800,9 @@ int git_checkout_options_init(git_checkout_options *opts, unsigned int version)
2803
2800
  return 0;
2804
2801
  }
2805
2802
 
2803
+ #ifndef GIT_DEPRECATE_HARD
2806
2804
  int git_checkout_init_options(git_checkout_options *opts, unsigned int version)
2807
2805
  {
2808
2806
  return git_checkout_options_init(opts, version);
2809
2807
  }
2808
+ #endif