rugged 1.1.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (407) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/extconf.rb +2 -2
  5. data/ext/rugged/rugged.c +7 -4
  6. data/ext/rugged/rugged_config.c +7 -2
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +17 -0
  9. data/ext/rugged/rugged_repo.c +3 -3
  10. data/lib/rugged/repository.rb +2 -2
  11. data/lib/rugged/version.rb +1 -1
  12. data/vendor/libgit2/CMakeLists.txt +103 -271
  13. data/vendor/libgit2/COPYING +149 -24
  14. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  15. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  16. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  17. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  19. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  20. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  21. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  22. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  23. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  24. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  25. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  26. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  27. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  30. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  31. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  32. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  33. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  34. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  35. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
  36. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
  37. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  38. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  39. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  40. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  41. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  42. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
  43. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  44. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  45. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  46. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  47. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  48. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  49. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  50. data/vendor/libgit2/deps/ntlmclient/ntlm.c +154 -122
  51. data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
  52. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
  53. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  54. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  55. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  56. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  57. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  58. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  59. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  60. data/vendor/libgit2/include/git2/apply.h +16 -2
  61. data/vendor/libgit2/include/git2/attr.h +106 -2
  62. data/vendor/libgit2/include/git2/blame.h +97 -43
  63. data/vendor/libgit2/include/git2/blob.h +33 -2
  64. data/vendor/libgit2/include/git2/branch.h +27 -0
  65. data/vendor/libgit2/include/git2/buffer.h +18 -78
  66. data/vendor/libgit2/include/git2/cert.h +43 -6
  67. data/vendor/libgit2/include/git2/checkout.h +32 -13
  68. data/vendor/libgit2/include/git2/clone.h +4 -4
  69. data/vendor/libgit2/include/git2/commit.h +37 -19
  70. data/vendor/libgit2/include/git2/common.h +46 -5
  71. data/vendor/libgit2/include/git2/config.h +19 -3
  72. data/vendor/libgit2/include/git2/credential.h +2 -1
  73. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  74. data/vendor/libgit2/include/git2/deprecated.h +326 -6
  75. data/vendor/libgit2/include/git2/describe.h +7 -2
  76. data/vendor/libgit2/include/git2/diff.h +50 -121
  77. data/vendor/libgit2/include/git2/email.h +127 -0
  78. data/vendor/libgit2/include/git2/errors.h +7 -6
  79. data/vendor/libgit2/include/git2/filter.h +69 -18
  80. data/vendor/libgit2/include/git2/graph.h +21 -2
  81. data/vendor/libgit2/include/git2/ignore.h +1 -1
  82. data/vendor/libgit2/include/git2/index.h +13 -7
  83. data/vendor/libgit2/include/git2/indexer.h +19 -0
  84. data/vendor/libgit2/include/git2/merge.h +23 -3
  85. data/vendor/libgit2/include/git2/message.h +2 -0
  86. data/vendor/libgit2/include/git2/notes.h +2 -2
  87. data/vendor/libgit2/include/git2/object.h +23 -0
  88. data/vendor/libgit2/include/git2/odb.h +65 -6
  89. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  90. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  91. data/vendor/libgit2/include/git2/pack.h +24 -8
  92. data/vendor/libgit2/include/git2/patch.h +16 -0
  93. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  94. data/vendor/libgit2/include/git2/proxy.h +1 -1
  95. data/vendor/libgit2/include/git2/rebase.h +34 -2
  96. data/vendor/libgit2/include/git2/refdb.h +3 -0
  97. data/vendor/libgit2/include/git2/reflog.h +1 -1
  98. data/vendor/libgit2/include/git2/refs.h +8 -4
  99. data/vendor/libgit2/include/git2/remote.h +246 -46
  100. data/vendor/libgit2/include/git2/repository.h +25 -18
  101. data/vendor/libgit2/include/git2/reset.h +2 -2
  102. data/vendor/libgit2/include/git2/revparse.h +5 -5
  103. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  104. data/vendor/libgit2/include/git2/signature.h +1 -1
  105. data/vendor/libgit2/include/git2/stash.h +4 -4
  106. data/vendor/libgit2/include/git2/status.h +124 -62
  107. data/vendor/libgit2/include/git2/stdint.h +3 -3
  108. data/vendor/libgit2/include/git2/submodule.h +16 -2
  109. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  110. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  111. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  112. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  113. data/vendor/libgit2/include/git2/sys/odb_backend.h +9 -5
  114. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  115. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  116. data/vendor/libgit2/include/git2/sys/transport.h +26 -34
  117. data/vendor/libgit2/include/git2/tag.h +13 -0
  118. data/vendor/libgit2/include/git2/tree.h +4 -17
  119. data/vendor/libgit2/include/git2/types.h +16 -7
  120. data/vendor/libgit2/include/git2/version.h +4 -4
  121. data/vendor/libgit2/include/git2/worktree.h +13 -2
  122. data/vendor/libgit2/include/git2.h +1 -0
  123. data/vendor/libgit2/src/CMakeLists.txt +192 -290
  124. data/vendor/libgit2/src/alloc.c +21 -8
  125. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  126. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  127. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  128. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  129. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  130. data/vendor/libgit2/src/annotated_commit.c +21 -9
  131. data/vendor/libgit2/src/annotated_commit.h +1 -1
  132. data/vendor/libgit2/src/apply.c +34 -25
  133. data/vendor/libgit2/src/apply.h +2 -2
  134. data/vendor/libgit2/src/array.h +11 -11
  135. data/vendor/libgit2/src/attr.c +204 -82
  136. data/vendor/libgit2/src/attr_file.c +105 -52
  137. data/vendor/libgit2/src/attr_file.h +36 -15
  138. data/vendor/libgit2/src/attrcache.c +55 -45
  139. data/vendor/libgit2/src/attrcache.h +4 -5
  140. data/vendor/libgit2/src/blame.c +15 -9
  141. data/vendor/libgit2/src/blame_git.c +2 -2
  142. data/vendor/libgit2/src/blob.c +76 -52
  143. data/vendor/libgit2/src/blob.h +1 -1
  144. data/vendor/libgit2/src/branch.c +203 -110
  145. data/vendor/libgit2/src/branch.h +15 -3
  146. data/vendor/libgit2/src/buf.c +126 -0
  147. data/vendor/libgit2/src/buf.h +50 -0
  148. data/vendor/libgit2/src/cache.c +2 -2
  149. data/vendor/libgit2/src/cache.h +7 -7
  150. data/vendor/libgit2/src/cc-compat.h +11 -9
  151. data/vendor/libgit2/src/checkout.c +118 -91
  152. data/vendor/libgit2/src/cherrypick.c +16 -12
  153. data/vendor/libgit2/src/clone.c +97 -103
  154. data/vendor/libgit2/src/commit.c +167 -84
  155. data/vendor/libgit2/src/commit.h +24 -1
  156. data/vendor/libgit2/src/commit_graph.c +1224 -0
  157. data/vendor/libgit2/src/commit_graph.h +169 -0
  158. data/vendor/libgit2/src/commit_list.c +48 -3
  159. data/vendor/libgit2/src/commit_list.h +2 -0
  160. data/vendor/libgit2/src/common.h +35 -5
  161. data/vendor/libgit2/src/config.c +119 -64
  162. data/vendor/libgit2/src/config.h +15 -2
  163. data/vendor/libgit2/src/config_cache.c +5 -3
  164. data/vendor/libgit2/src/config_file.c +120 -100
  165. data/vendor/libgit2/src/config_mem.c +9 -9
  166. data/vendor/libgit2/src/config_parse.c +29 -27
  167. data/vendor/libgit2/src/crlf.c +36 -23
  168. data/vendor/libgit2/src/date.c +13 -19
  169. data/vendor/libgit2/src/date.h +33 -0
  170. data/vendor/libgit2/src/delta.c +1 -1
  171. data/vendor/libgit2/src/describe.c +32 -21
  172. data/vendor/libgit2/src/diff.c +71 -183
  173. data/vendor/libgit2/src/diff.h +2 -4
  174. data/vendor/libgit2/src/diff_driver.c +53 -51
  175. data/vendor/libgit2/src/diff_driver.h +3 -3
  176. data/vendor/libgit2/src/diff_file.c +31 -26
  177. data/vendor/libgit2/src/diff_generate.c +76 -23
  178. data/vendor/libgit2/src/diff_generate.h +5 -3
  179. data/vendor/libgit2/src/diff_print.c +120 -95
  180. data/vendor/libgit2/src/diff_stats.c +47 -34
  181. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  182. data/vendor/libgit2/src/diff_tform.c +18 -16
  183. data/vendor/libgit2/src/diff_xdiff.c +7 -10
  184. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  185. data/vendor/libgit2/src/email.c +315 -0
  186. data/vendor/libgit2/src/email.h +25 -0
  187. data/vendor/libgit2/src/errors.c +37 -32
  188. data/vendor/libgit2/src/features.h.in +11 -2
  189. data/vendor/libgit2/src/fetch.c +77 -26
  190. data/vendor/libgit2/src/fetch.h +1 -1
  191. data/vendor/libgit2/src/fetchhead.c +27 -23
  192. data/vendor/libgit2/src/filebuf.c +36 -34
  193. data/vendor/libgit2/src/filebuf.h +1 -1
  194. data/vendor/libgit2/src/filter.c +278 -132
  195. data/vendor/libgit2/src/filter.h +46 -6
  196. data/vendor/libgit2/src/fs_path.c +2071 -0
  197. data/vendor/libgit2/src/fs_path.h +772 -0
  198. data/vendor/libgit2/src/futils.c +96 -90
  199. data/vendor/libgit2/src/futils.h +27 -15
  200. data/vendor/libgit2/src/graph.c +64 -9
  201. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
  202. data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
  203. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  204. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  205. data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
  206. data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
  207. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
  208. data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
  209. data/vendor/libgit2/src/hash/sha1.h +3 -1
  210. data/vendor/libgit2/src/hash.c +71 -36
  211. data/vendor/libgit2/src/hash.h +13 -13
  212. data/vendor/libgit2/src/hashsig.c +23 -10
  213. data/vendor/libgit2/src/ident.c +30 -20
  214. data/vendor/libgit2/src/ignore.c +63 -46
  215. data/vendor/libgit2/src/ignore.h +2 -2
  216. data/vendor/libgit2/src/index.c +184 -149
  217. data/vendor/libgit2/src/index.h +7 -4
  218. data/vendor/libgit2/src/indexer.c +143 -89
  219. data/vendor/libgit2/src/integer.h +64 -2
  220. data/vendor/libgit2/src/iterator.c +93 -73
  221. data/vendor/libgit2/src/iterator.h +6 -6
  222. data/vendor/libgit2/src/khash.h +3 -12
  223. data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
  224. data/vendor/libgit2/src/libgit2.h +15 -0
  225. data/vendor/libgit2/src/mailmap.c +60 -45
  226. data/vendor/libgit2/src/map.h +3 -3
  227. data/vendor/libgit2/src/merge.c +104 -61
  228. data/vendor/libgit2/src/merge.h +3 -15
  229. data/vendor/libgit2/src/merge_driver.c +21 -15
  230. data/vendor/libgit2/src/merge_file.c +24 -6
  231. data/vendor/libgit2/src/message.c +21 -8
  232. data/vendor/libgit2/src/midx.c +501 -18
  233. data/vendor/libgit2/src/midx.h +29 -2
  234. data/vendor/libgit2/src/mwindow.c +103 -59
  235. data/vendor/libgit2/src/mwindow.h +3 -3
  236. data/vendor/libgit2/src/net.c +405 -71
  237. data/vendor/libgit2/src/net.h +26 -5
  238. data/vendor/libgit2/src/netops.c +7 -5
  239. data/vendor/libgit2/src/netops.h +3 -3
  240. data/vendor/libgit2/src/notes.c +40 -49
  241. data/vendor/libgit2/src/object.c +68 -20
  242. data/vendor/libgit2/src/object.h +1 -1
  243. data/vendor/libgit2/src/odb.c +320 -80
  244. data/vendor/libgit2/src/odb.h +17 -3
  245. data/vendor/libgit2/src/odb_loose.c +96 -86
  246. data/vendor/libgit2/src/odb_mempack.c +19 -6
  247. data/vendor/libgit2/src/odb_pack.c +402 -125
  248. data/vendor/libgit2/src/oid.c +16 -8
  249. data/vendor/libgit2/src/oid.h +15 -0
  250. data/vendor/libgit2/src/oidarray.c +10 -1
  251. data/vendor/libgit2/src/pack-objects.c +90 -69
  252. data/vendor/libgit2/src/pack-objects.h +11 -6
  253. data/vendor/libgit2/src/pack.c +337 -127
  254. data/vendor/libgit2/src/pack.h +25 -7
  255. data/vendor/libgit2/src/patch.c +17 -10
  256. data/vendor/libgit2/src/patch.h +1 -0
  257. data/vendor/libgit2/src/patch_generate.c +29 -13
  258. data/vendor/libgit2/src/patch_generate.h +5 -5
  259. data/vendor/libgit2/src/patch_parse.c +26 -25
  260. data/vendor/libgit2/src/path.c +86 -1768
  261. data/vendor/libgit2/src/path.h +39 -635
  262. data/vendor/libgit2/src/pathspec.c +12 -12
  263. data/vendor/libgit2/src/pathspec.h +2 -2
  264. data/vendor/libgit2/src/pool.c +13 -7
  265. data/vendor/libgit2/src/posix.c +14 -6
  266. data/vendor/libgit2/src/posix.h +1 -0
  267. data/vendor/libgit2/src/pqueue.h +1 -1
  268. data/vendor/libgit2/src/proxy.c +4 -1
  269. data/vendor/libgit2/src/proxy.h +1 -1
  270. data/vendor/libgit2/src/push.c +30 -35
  271. data/vendor/libgit2/src/push.h +4 -16
  272. data/vendor/libgit2/src/rand.c +226 -0
  273. data/vendor/libgit2/src/rand.h +37 -0
  274. data/vendor/libgit2/src/reader.c +18 -14
  275. data/vendor/libgit2/src/reader.h +2 -2
  276. data/vendor/libgit2/src/rebase.c +177 -132
  277. data/vendor/libgit2/src/refdb.c +30 -13
  278. data/vendor/libgit2/src/refdb_fs.c +548 -222
  279. data/vendor/libgit2/src/reflog.c +19 -14
  280. data/vendor/libgit2/src/refs.c +107 -72
  281. data/vendor/libgit2/src/refs.h +2 -2
  282. data/vendor/libgit2/src/refspec.c +53 -38
  283. data/vendor/libgit2/src/refspec.h +5 -2
  284. data/vendor/libgit2/src/regexp.c +1 -1
  285. data/vendor/libgit2/src/remote.c +960 -486
  286. data/vendor/libgit2/src/remote.h +16 -10
  287. data/vendor/libgit2/src/repository.c +702 -422
  288. data/vendor/libgit2/src/repository.h +26 -8
  289. data/vendor/libgit2/src/reset.c +16 -12
  290. data/vendor/libgit2/src/revert.c +16 -12
  291. data/vendor/libgit2/src/revparse.c +66 -48
  292. data/vendor/libgit2/src/revwalk.c +39 -22
  293. data/vendor/libgit2/src/runtime.c +162 -0
  294. data/vendor/libgit2/src/runtime.h +62 -0
  295. data/vendor/libgit2/src/settings.h +11 -0
  296. data/vendor/libgit2/src/signature.c +18 -11
  297. data/vendor/libgit2/src/signature.h +1 -1
  298. data/vendor/libgit2/src/sortedcache.c +1 -1
  299. data/vendor/libgit2/src/sortedcache.h +10 -8
  300. data/vendor/libgit2/src/stash.c +39 -38
  301. data/vendor/libgit2/src/status.c +11 -5
  302. data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
  303. data/vendor/libgit2/src/str.h +357 -0
  304. data/vendor/libgit2/src/strarray.c +2 -1
  305. data/vendor/libgit2/src/streams/mbedtls.c +22 -23
  306. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  307. data/vendor/libgit2/src/streams/openssl.c +101 -201
  308. data/vendor/libgit2/src/streams/openssl.h +9 -1
  309. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  310. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  311. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  312. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  313. data/vendor/libgit2/src/streams/registry.c +5 -6
  314. data/vendor/libgit2/src/streams/socket.c +6 -2
  315. data/vendor/libgit2/src/streams/stransport.c +6 -3
  316. data/vendor/libgit2/src/streams/tls.c +5 -3
  317. data/vendor/libgit2/src/submodule.c +290 -212
  318. data/vendor/libgit2/src/submodule.h +10 -10
  319. data/vendor/libgit2/src/sysdir.c +70 -56
  320. data/vendor/libgit2/src/sysdir.h +15 -10
  321. data/vendor/libgit2/src/tag.c +72 -34
  322. data/vendor/libgit2/src/thread.c +140 -0
  323. data/vendor/libgit2/src/thread.h +479 -0
  324. data/vendor/libgit2/src/threadstate.c +84 -0
  325. data/vendor/libgit2/src/threadstate.h +24 -0
  326. data/vendor/libgit2/src/trace.c +3 -16
  327. data/vendor/libgit2/src/trace.h +17 -30
  328. data/vendor/libgit2/src/trailer.c +2 -2
  329. data/vendor/libgit2/src/transaction.c +20 -9
  330. data/vendor/libgit2/src/transport.c +13 -13
  331. data/vendor/libgit2/src/transports/auth.c +8 -10
  332. data/vendor/libgit2/src/transports/auth.h +2 -3
  333. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
  334. data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
  335. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  336. data/vendor/libgit2/src/transports/credential.c +15 -7
  337. data/vendor/libgit2/src/transports/git.c +10 -14
  338. data/vendor/libgit2/src/transports/http.c +56 -34
  339. data/vendor/libgit2/src/transports/http.h +3 -3
  340. data/vendor/libgit2/src/transports/httpclient.c +106 -79
  341. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  342. data/vendor/libgit2/src/transports/local.c +127 -119
  343. data/vendor/libgit2/src/transports/smart.c +61 -144
  344. data/vendor/libgit2/src/transports/smart.h +26 -32
  345. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  346. data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
  347. data/vendor/libgit2/src/transports/ssh.c +100 -131
  348. data/vendor/libgit2/src/transports/winhttp.c +86 -82
  349. data/vendor/libgit2/src/tree-cache.c +5 -5
  350. data/vendor/libgit2/src/tree-cache.h +2 -2
  351. data/vendor/libgit2/src/tree.c +150 -116
  352. data/vendor/libgit2/src/tree.h +1 -0
  353. data/vendor/libgit2/src/tsort.c +0 -2
  354. data/vendor/libgit2/src/unix/map.c +3 -3
  355. data/vendor/libgit2/src/unix/posix.h +1 -4
  356. data/vendor/libgit2/src/unix/pthread.h +2 -1
  357. data/vendor/libgit2/src/unix/realpath.c +0 -2
  358. data/vendor/libgit2/src/utf8.c +150 -0
  359. data/vendor/libgit2/src/utf8.h +52 -0
  360. data/vendor/libgit2/src/util.c +68 -144
  361. data/vendor/libgit2/src/util.h +36 -68
  362. data/vendor/libgit2/src/vector.c +23 -19
  363. data/vendor/libgit2/src/vector.h +5 -3
  364. data/vendor/libgit2/src/win32/findfile.c +172 -114
  365. data/vendor/libgit2/src/win32/findfile.h +7 -4
  366. data/vendor/libgit2/src/win32/map.c +1 -1
  367. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  368. data/vendor/libgit2/src/win32/path_w32.c +162 -33
  369. data/vendor/libgit2/src/win32/path_w32.h +2 -1
  370. data/vendor/libgit2/src/win32/posix.h +6 -7
  371. data/vendor/libgit2/src/win32/posix_w32.c +26 -33
  372. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  373. data/vendor/libgit2/src/win32/reparse.h +4 -4
  374. data/vendor/libgit2/src/win32/thread.c +24 -15
  375. data/vendor/libgit2/src/win32/thread.h +1 -1
  376. data/vendor/libgit2/src/win32/w32_buffer.c +5 -6
  377. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  378. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  379. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  380. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  381. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  382. data/vendor/libgit2/src/worktree.c +138 -105
  383. data/vendor/libgit2/src/worktree.h +1 -1
  384. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  385. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  386. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  387. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  388. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  389. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  390. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  391. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  392. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  393. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  394. data/vendor/libgit2/src/zstream.c +6 -6
  395. data/vendor/libgit2/src/zstream.h +4 -4
  396. metadata +60 -24
  397. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  398. data/vendor/libgit2/src/buf_text.c +0 -316
  399. data/vendor/libgit2/src/buf_text.h +0 -122
  400. data/vendor/libgit2/src/buffer.h +0 -222
  401. data/vendor/libgit2/src/global.c +0 -363
  402. data/vendor/libgit2/src/global.h +0 -41
  403. data/vendor/libgit2/src/thread-utils.c +0 -58
  404. data/vendor/libgit2/src/thread-utils.h +0 -369
  405. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  406. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  407. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -7,53 +7,56 @@
7
7
 
8
8
  #include "worktree.h"
9
9
 
10
+ #include "buf.h"
11
+ #include "repository.h"
12
+ #include "path.h"
13
+
10
14
  #include "git2/branch.h"
11
15
  #include "git2/commit.h"
12
16
  #include "git2/worktree.h"
13
17
 
14
- #include "repository.h"
15
-
16
18
  static bool is_worktree_dir(const char *dir)
17
19
  {
18
- git_buf buf = GIT_BUF_INIT;
20
+ git_str buf = GIT_STR_INIT;
19
21
  int error;
20
22
 
21
- if (git_buf_sets(&buf, dir) < 0)
23
+ if (git_str_sets(&buf, dir) < 0)
22
24
  return -1;
23
25
 
24
- error = git_path_contains_file(&buf, "commondir")
25
- && git_path_contains_file(&buf, "gitdir")
26
- && git_path_contains_file(&buf, "HEAD");
26
+ error = git_fs_path_contains_file(&buf, "commondir")
27
+ && git_fs_path_contains_file(&buf, "gitdir")
28
+ && git_fs_path_contains_file(&buf, "HEAD");
27
29
 
28
- git_buf_dispose(&buf);
30
+ git_str_dispose(&buf);
29
31
  return error;
30
32
  }
31
33
 
32
34
  int git_worktree_list(git_strarray *wts, git_repository *repo)
33
35
  {
34
36
  git_vector worktrees = GIT_VECTOR_INIT;
35
- git_buf path = GIT_BUF_INIT;
37
+ git_str path = GIT_STR_INIT;
36
38
  char *worktree;
37
39
  size_t i, len;
38
40
  int error;
39
41
 
40
- assert(wts && repo);
42
+ GIT_ASSERT_ARG(wts);
43
+ GIT_ASSERT_ARG(repo);
41
44
 
42
45
  wts->count = 0;
43
46
  wts->strings = NULL;
44
47
 
45
- if ((error = git_buf_printf(&path, "%s/worktrees/", repo->commondir)) < 0)
48
+ if ((error = git_str_joinpath(&path, repo->commondir, "worktrees/")) < 0)
46
49
  goto exit;
47
- if (!git_path_exists(path.ptr) || git_path_is_empty_dir(path.ptr))
50
+ if (!git_fs_path_exists(path.ptr) || git_fs_path_is_empty_dir(path.ptr))
48
51
  goto exit;
49
- if ((error = git_path_dirload(&worktrees, path.ptr, path.size, 0x0)) < 0)
52
+ if ((error = git_fs_path_dirload(&worktrees, path.ptr, path.size, 0x0)) < 0)
50
53
  goto exit;
51
54
 
52
55
  len = path.size;
53
56
 
54
57
  git_vector_foreach(&worktrees, i, worktree) {
55
- git_buf_truncate(&path, len);
56
- git_buf_puts(&path, worktree);
58
+ git_str_truncate(&path, len);
59
+ git_str_puts(&path, worktree);
57
60
 
58
61
  if (!is_worktree_dir(path.ptr)) {
59
62
  git_vector_remove(&worktrees, i);
@@ -64,65 +67,68 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
64
67
  wts->strings = (char **)git_vector_detach(&wts->count, NULL, &worktrees);
65
68
 
66
69
  exit:
67
- git_buf_dispose(&path);
70
+ git_str_dispose(&path);
68
71
 
69
72
  return error;
70
73
  }
71
74
 
72
75
  char *git_worktree__read_link(const char *base, const char *file)
73
76
  {
74
- git_buf path = GIT_BUF_INIT, buf = GIT_BUF_INIT;
77
+ git_str path = GIT_STR_INIT, buf = GIT_STR_INIT;
75
78
 
76
- assert(base && file);
79
+ GIT_ASSERT_ARG_WITH_RETVAL(base, NULL);
80
+ GIT_ASSERT_ARG_WITH_RETVAL(file, NULL);
77
81
 
78
- if (git_buf_joinpath(&path, base, file) < 0)
82
+ if (git_str_joinpath(&path, base, file) < 0)
79
83
  goto err;
80
84
  if (git_futils_readbuffer(&buf, path.ptr) < 0)
81
85
  goto err;
82
- git_buf_dispose(&path);
86
+ git_str_dispose(&path);
83
87
 
84
- git_buf_rtrim(&buf);
88
+ git_str_rtrim(&buf);
85
89
 
86
- if (!git_path_is_relative(buf.ptr))
87
- return git_buf_detach(&buf);
90
+ if (!git_fs_path_is_relative(buf.ptr))
91
+ return git_str_detach(&buf);
88
92
 
89
- if (git_buf_sets(&path, base) < 0)
93
+ if (git_str_sets(&path, base) < 0)
90
94
  goto err;
91
- if (git_path_apply_relative(&path, buf.ptr) < 0)
95
+ if (git_fs_path_apply_relative(&path, buf.ptr) < 0)
92
96
  goto err;
93
- git_buf_dispose(&buf);
97
+ git_str_dispose(&buf);
94
98
 
95
- return git_buf_detach(&path);
99
+ return git_str_detach(&path);
96
100
 
97
101
  err:
98
- git_buf_dispose(&buf);
99
- git_buf_dispose(&path);
102
+ git_str_dispose(&buf);
103
+ git_str_dispose(&path);
100
104
 
101
105
  return NULL;
102
106
  }
103
107
 
104
- static int write_wtfile(const char *base, const char *file, const git_buf *buf)
108
+ static int write_wtfile(const char *base, const char *file, const git_str *buf)
105
109
  {
106
- git_buf path = GIT_BUF_INIT;
110
+ git_str path = GIT_STR_INIT;
107
111
  int err;
108
112
 
109
- assert(base && file && buf);
113
+ GIT_ASSERT_ARG(base);
114
+ GIT_ASSERT_ARG(file);
115
+ GIT_ASSERT_ARG(buf);
110
116
 
111
- if ((err = git_buf_joinpath(&path, base, file)) < 0)
117
+ if ((err = git_str_joinpath(&path, base, file)) < 0)
112
118
  goto out;
113
119
 
114
120
  if ((err = git_futils_writebuffer(buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
115
121
  goto out;
116
122
 
117
123
  out:
118
- git_buf_dispose(&path);
124
+ git_str_dispose(&path);
119
125
 
120
126
  return err;
121
127
  }
122
128
 
123
129
  static int open_worktree_dir(git_worktree **out, const char *parent, const char *dir, const char *name)
124
130
  {
125
- git_buf gitdir = GIT_BUF_INIT;
131
+ git_str gitdir = GIT_STR_INIT;
126
132
  git_worktree *wt = NULL;
127
133
  int error = 0;
128
134
 
@@ -131,6 +137,9 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
131
137
  goto out;
132
138
  }
133
139
 
140
+ if ((error = git_path_validate_length(NULL, dir)) < 0)
141
+ goto out;
142
+
134
143
  if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
135
144
  error = -1;
136
145
  goto out;
@@ -140,14 +149,14 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
140
149
  (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL ||
141
150
  (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL ||
142
151
  (parent && (wt->parent_path = git__strdup(parent)) == NULL) ||
143
- (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
152
+ (wt->worktree_path = git_fs_path_dirname(wt->gitlink_path)) == NULL) {
144
153
  error = -1;
145
154
  goto out;
146
155
  }
147
156
 
148
- if ((error = git_path_prettify_dir(&gitdir, dir, NULL)) < 0)
157
+ if ((error = git_fs_path_prettify_dir(&gitdir, dir, NULL)) < 0)
149
158
  goto out;
150
- wt->gitdir_path = git_buf_detach(&gitdir);
159
+ wt->gitdir_path = git_str_detach(&gitdir);
151
160
 
152
161
  if ((error = git_worktree_is_locked(NULL, wt)) < 0)
153
162
  goto out;
@@ -159,29 +168,30 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
159
168
  out:
160
169
  if (error)
161
170
  git_worktree_free(wt);
162
- git_buf_dispose(&gitdir);
171
+ git_str_dispose(&gitdir);
163
172
 
164
173
  return error;
165
174
  }
166
175
 
167
176
  int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *name)
168
177
  {
169
- git_buf path = GIT_BUF_INIT;
178
+ git_str path = GIT_STR_INIT;
170
179
  git_worktree *wt = NULL;
171
180
  int error;
172
181
 
173
- assert(repo && name);
182
+ GIT_ASSERT_ARG(repo);
183
+ GIT_ASSERT_ARG(name);
174
184
 
175
185
  *out = NULL;
176
186
 
177
- if ((error = git_buf_printf(&path, "%s/worktrees/%s", repo->commondir, name)) < 0)
187
+ if ((error = git_str_join3(&path, '/', repo->commondir, "worktrees", name)) < 0)
178
188
  goto out;
179
189
 
180
190
  if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0)
181
191
  goto out;
182
192
 
183
193
  out:
184
- git_buf_dispose(&path);
194
+ git_str_dispose(&path);
185
195
 
186
196
  if (error)
187
197
  git_worktree_free(wt);
@@ -191,7 +201,7 @@ out:
191
201
 
192
202
  int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
193
203
  {
194
- git_buf parent = GIT_BUF_INIT;
204
+ git_str parent = GIT_STR_INIT;
195
205
  const char *gitdir, *commondir;
196
206
  char *name = NULL;
197
207
  int error = 0;
@@ -205,18 +215,18 @@ int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
205
215
  gitdir = git_repository_path(repo);
206
216
  commondir = git_repository_commondir(repo);
207
217
 
208
- if ((error = git_path_prettify_dir(&parent, "..", commondir)) < 0)
218
+ if ((error = git_fs_path_prettify_dir(&parent, "..", commondir)) < 0)
209
219
  goto out;
210
220
 
211
221
  /* The name is defined by the last component in '.git/worktree/%s' */
212
- name = git_path_basename(gitdir);
222
+ name = git_fs_path_basename(gitdir);
213
223
 
214
224
  if ((error = open_worktree_dir(out, parent.ptr, gitdir, name)) < 0)
215
225
  goto out;
216
226
 
217
227
  out:
218
228
  git__free(name);
219
- git_buf_dispose(&parent);
229
+ git_str_dispose(&parent);
220
230
 
221
231
  return error;
222
232
  }
@@ -237,7 +247,7 @@ void git_worktree_free(git_worktree *wt)
237
247
 
238
248
  int git_worktree_validate(const git_worktree *wt)
239
249
  {
240
- assert(wt);
250
+ GIT_ASSERT_ARG(wt);
241
251
 
242
252
  if (!is_worktree_dir(wt->gitdir_path)) {
243
253
  git_error_set(GIT_ERROR_WORKTREE,
@@ -246,27 +256,27 @@ int git_worktree_validate(const git_worktree *wt)
246
256
  return GIT_ERROR;
247
257
  }
248
258
 
249
- if (wt->parent_path && !git_path_exists(wt->parent_path)) {
259
+ if (wt->parent_path && !git_fs_path_exists(wt->parent_path)) {
250
260
  git_error_set(GIT_ERROR_WORKTREE,
251
261
  "worktree parent directory ('%s') does not exist ",
252
262
  wt->parent_path);
253
263
  return GIT_ERROR;
254
264
  }
255
265
 
256
- if (!git_path_exists(wt->commondir_path)) {
266
+ if (!git_fs_path_exists(wt->commondir_path)) {
257
267
  git_error_set(GIT_ERROR_WORKTREE,
258
268
  "worktree common directory ('%s') does not exist ",
259
269
  wt->commondir_path);
260
270
  return GIT_ERROR;
261
271
  }
262
-
263
- if (!git_path_exists(wt->worktree_path)) {
272
+
273
+ if (!git_fs_path_exists(wt->worktree_path)) {
264
274
  git_error_set(GIT_ERROR_WORKTREE,
265
275
  "worktree directory '%s' does not exist",
266
276
  wt->worktree_path);
267
277
  return GIT_ERROR;
268
278
  }
269
-
279
+
270
280
  return 0;
271
281
  }
272
282
 
@@ -290,23 +300,28 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
290
300
  const char *name, const char *worktree,
291
301
  const git_worktree_add_options *opts)
292
302
  {
293
- git_buf gitdir = GIT_BUF_INIT, wddir = GIT_BUF_INIT, buf = GIT_BUF_INIT;
303
+ git_str gitdir = GIT_STR_INIT, wddir = GIT_STR_INIT, buf = GIT_STR_INIT;
294
304
  git_reference *ref = NULL, *head = NULL;
295
305
  git_commit *commit = NULL;
296
306
  git_repository *wt = NULL;
297
- git_checkout_options coopts = GIT_CHECKOUT_OPTIONS_INIT;
307
+ git_checkout_options coopts;
298
308
  git_worktree_add_options wtopts = GIT_WORKTREE_ADD_OPTIONS_INIT;
299
309
  int err;
300
310
 
301
311
  GIT_ERROR_CHECK_VERSION(
302
312
  opts, GIT_WORKTREE_ADD_OPTIONS_VERSION, "git_worktree_add_options");
303
313
 
314
+ GIT_ASSERT_ARG(out);
315
+ GIT_ASSERT_ARG(repo);
316
+ GIT_ASSERT_ARG(name);
317
+ GIT_ASSERT_ARG(worktree);
318
+
319
+ *out = NULL;
320
+
304
321
  if (opts)
305
322
  memcpy(&wtopts, opts, sizeof(wtopts));
306
323
 
307
- assert(out && repo && name && worktree);
308
-
309
- *out = NULL;
324
+ memcpy(&coopts, &wtopts.checkout_options, sizeof(coopts));
310
325
 
311
326
  if (wtopts.ref) {
312
327
  if (!git_reference_is_branch(wtopts.ref)) {
@@ -323,28 +338,28 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
323
338
  }
324
339
 
325
340
  /* Create gitdir directory ".git/worktrees/<name>" */
326
- if ((err = git_buf_joinpath(&gitdir, repo->commondir, "worktrees")) < 0)
341
+ if ((err = git_str_joinpath(&gitdir, repo->commondir, "worktrees")) < 0)
327
342
  goto out;
328
- if (!git_path_exists(gitdir.ptr))
343
+ if (!git_fs_path_exists(gitdir.ptr))
329
344
  if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
330
345
  goto out;
331
- if ((err = git_buf_joinpath(&gitdir, gitdir.ptr, name)) < 0)
346
+ if ((err = git_str_joinpath(&gitdir, gitdir.ptr, name)) < 0)
332
347
  goto out;
333
348
  if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
334
349
  goto out;
335
- if ((err = git_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0)
350
+ if ((err = git_fs_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0)
336
351
  goto out;
337
352
 
338
353
  /* Create worktree work dir */
339
354
  if ((err = git_futils_mkdir(worktree, 0755, GIT_MKDIR_EXCL)) < 0)
340
355
  goto out;
341
- if ((err = git_path_prettify_dir(&wddir, worktree, NULL)) < 0)
356
+ if ((err = git_fs_path_prettify_dir(&wddir, worktree, NULL)) < 0)
342
357
  goto out;
343
358
 
344
359
  if (wtopts.lock) {
345
360
  int fd;
346
361
 
347
- if ((err = git_buf_joinpath(&buf, gitdir.ptr, "locked")) < 0)
362
+ if ((err = git_str_joinpath(&buf, gitdir.ptr, "locked")) < 0)
348
363
  goto out;
349
364
 
350
365
  if ((fd = p_creat(buf.ptr, 0644)) < 0) {
@@ -353,22 +368,22 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
353
368
  }
354
369
 
355
370
  p_close(fd);
356
- git_buf_clear(&buf);
371
+ git_str_clear(&buf);
357
372
  }
358
373
 
359
374
  /* Create worktree .git file */
360
- if ((err = git_buf_printf(&buf, "gitdir: %s\n", gitdir.ptr)) < 0)
375
+ if ((err = git_str_printf(&buf, "gitdir: %s\n", gitdir.ptr)) < 0)
361
376
  goto out;
362
377
  if ((err = write_wtfile(wddir.ptr, ".git", &buf)) < 0)
363
378
  goto out;
364
379
 
365
380
  /* Create gitdir files */
366
- if ((err = git_path_prettify_dir(&buf, repo->commondir, NULL) < 0)
367
- || (err = git_buf_putc(&buf, '\n')) < 0
381
+ if ((err = git_fs_path_prettify_dir(&buf, repo->commondir, NULL) < 0)
382
+ || (err = git_str_putc(&buf, '\n')) < 0
368
383
  || (err = write_wtfile(gitdir.ptr, "commondir", &buf)) < 0)
369
384
  goto out;
370
- if ((err = git_buf_joinpath(&buf, wddir.ptr, ".git")) < 0
371
- || (err = git_buf_putc(&buf, '\n')) < 0
385
+ if ((err = git_str_joinpath(&buf, wddir.ptr, ".git")) < 0
386
+ || (err = git_str_putc(&buf, '\n')) < 0
372
387
  || (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0)
373
388
  goto out;
374
389
 
@@ -392,7 +407,6 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
392
407
  goto out;
393
408
 
394
409
  /* Checkout worktree's HEAD */
395
- coopts.checkout_strategy = GIT_CHECKOUT_FORCE;
396
410
  if ((err = git_checkout_head(wt, &coopts)) < 0)
397
411
  goto out;
398
412
 
@@ -401,9 +415,9 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
401
415
  goto out;
402
416
 
403
417
  out:
404
- git_buf_dispose(&gitdir);
405
- git_buf_dispose(&wddir);
406
- git_buf_dispose(&buf);
418
+ git_str_dispose(&gitdir);
419
+ git_str_dispose(&wddir);
420
+ git_str_dispose(&buf);
407
421
  git_reference_free(ref);
408
422
  git_reference_free(head);
409
423
  git_commit_free(commit);
@@ -414,10 +428,10 @@ out:
414
428
 
415
429
  int git_worktree_lock(git_worktree *wt, const char *reason)
416
430
  {
417
- git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
431
+ git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
418
432
  int error;
419
433
 
420
- assert(wt);
434
+ GIT_ASSERT_ARG(wt);
421
435
 
422
436
  if ((error = git_worktree_is_locked(NULL, wt)) < 0)
423
437
  goto out;
@@ -426,11 +440,11 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
426
440
  goto out;
427
441
  }
428
442
 
429
- if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
443
+ if ((error = git_str_joinpath(&path, wt->gitdir_path, "locked")) < 0)
430
444
  goto out;
431
445
 
432
446
  if (reason)
433
- git_buf_attach_notowned(&buf, reason, strlen(reason));
447
+ git_str_attach_notowned(&buf, reason, strlen(reason));
434
448
 
435
449
  if ((error = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
436
450
  goto out;
@@ -438,71 +452,90 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
438
452
  wt->locked = 1;
439
453
 
440
454
  out:
441
- git_buf_dispose(&path);
455
+ git_str_dispose(&path);
442
456
 
443
457
  return error;
444
458
  }
445
459
 
446
460
  int git_worktree_unlock(git_worktree *wt)
447
461
  {
448
- git_buf path = GIT_BUF_INIT;
462
+ git_str path = GIT_STR_INIT;
449
463
  int error;
450
464
 
451
- assert(wt);
465
+ GIT_ASSERT_ARG(wt);
452
466
 
453
467
  if ((error = git_worktree_is_locked(NULL, wt)) < 0)
454
468
  return error;
455
469
  if (!error)
456
470
  return 1;
457
471
 
458
- if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0)
472
+ if (git_str_joinpath(&path, wt->gitdir_path, "locked") < 0)
459
473
  return -1;
460
474
 
461
475
  if (p_unlink(path.ptr) != 0) {
462
- git_buf_dispose(&path);
476
+ git_str_dispose(&path);
463
477
  return -1;
464
478
  }
465
479
 
466
480
  wt->locked = 0;
467
481
 
468
- git_buf_dispose(&path);
482
+ git_str_dispose(&path);
469
483
 
470
484
  return 0;
471
485
  }
472
486
 
473
- int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
487
+ static int git_worktree__is_locked(git_str *reason, const git_worktree *wt)
474
488
  {
475
- git_buf path = GIT_BUF_INIT;
489
+ git_str path = GIT_STR_INIT;
476
490
  int error, locked;
477
491
 
478
- assert(wt);
492
+ GIT_ASSERT_ARG(wt);
479
493
 
480
494
  if (reason)
481
- git_buf_clear(reason);
495
+ git_str_clear(reason);
482
496
 
483
- if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
497
+ if ((error = git_str_joinpath(&path, wt->gitdir_path, "locked")) < 0)
484
498
  goto out;
485
- locked = git_path_exists(path.ptr);
499
+ locked = git_fs_path_exists(path.ptr);
486
500
  if (locked && reason &&
487
501
  (error = git_futils_readbuffer(reason, path.ptr)) < 0)
488
502
  goto out;
489
503
 
490
504
  error = locked;
491
505
  out:
492
- git_buf_dispose(&path);
506
+ git_str_dispose(&path);
507
+
508
+ return error;
509
+ }
510
+
511
+ int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
512
+ {
513
+ git_str str = GIT_STR_INIT;
514
+ int error = 0;
515
+
516
+ if (reason && (error = git_buf_tostr(&str, reason)) < 0)
517
+ return error;
518
+
519
+ error = git_worktree__is_locked(reason ? &str : NULL, wt);
520
+
521
+ if (error >= 0 && reason) {
522
+ if (git_buf_fromstr(reason, &str) < 0)
523
+ error = -1;
524
+ }
493
525
 
526
+ git_str_dispose(&str);
494
527
  return error;
495
528
  }
496
529
 
497
530
  const char *git_worktree_name(const git_worktree *wt)
498
531
  {
499
- assert(wt);
532
+ GIT_ASSERT_ARG_WITH_RETVAL(wt, NULL);
500
533
  return wt->name;
501
534
  }
502
535
 
503
536
  const char *git_worktree_path(const git_worktree *wt)
504
537
  {
505
- assert(wt);
538
+ GIT_ASSERT_ARG_WITH_RETVAL(wt, NULL);
506
539
  return wt->worktree_path;
507
540
  }
508
541
 
@@ -536,17 +569,17 @@ int git_worktree_is_prunable(git_worktree *wt,
536
569
  memcpy(&popts, opts, sizeof(popts));
537
570
 
538
571
  if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) {
539
- git_buf reason = GIT_BUF_INIT;
572
+ git_str reason = GIT_STR_INIT;
540
573
  int error;
541
574
 
542
- if ((error = git_worktree_is_locked(&reason, wt)) < 0)
575
+ if ((error = git_worktree__is_locked(&reason, wt)) < 0)
543
576
  return error;
544
577
 
545
578
  if (error) {
546
579
  if (!reason.size)
547
- git_buf_attach_notowned(&reason, "no reason given", 15);
580
+ git_str_attach_notowned(&reason, "no reason given", 15);
548
581
  git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
549
- git_buf_dispose(&reason);
582
+ git_str_dispose(&reason);
550
583
  return 0;
551
584
  }
552
585
  }
@@ -564,7 +597,7 @@ int git_worktree_prune(git_worktree *wt,
564
597
  git_worktree_prune_options *opts)
565
598
  {
566
599
  git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
567
- git_buf path = GIT_BUF_INIT;
600
+ git_str path = GIT_STR_INIT;
568
601
  char *wtpath;
569
602
  int err;
570
603
 
@@ -581,9 +614,9 @@ int git_worktree_prune(git_worktree *wt,
581
614
  }
582
615
 
583
616
  /* Delete gitdir in parent repository */
584
- if ((err = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name)) < 0)
617
+ if ((err = git_str_join3(&path, '/', wt->commondir_path, "worktrees", wt->name)) < 0)
585
618
  goto out;
586
- if (!git_path_exists(path.ptr))
619
+ if (!git_fs_path_exists(path.ptr))
587
620
  {
588
621
  git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir '%s' does not exist", path.ptr);
589
622
  err = -1;
@@ -595,15 +628,15 @@ int git_worktree_prune(git_worktree *wt,
595
628
  /* Skip deletion of the actual working tree if it does
596
629
  * not exist or deletion was not requested */
597
630
  if ((popts.flags & GIT_WORKTREE_PRUNE_WORKING_TREE) == 0 ||
598
- !git_path_exists(wt->gitlink_path))
631
+ !git_fs_path_exists(wt->gitlink_path))
599
632
  {
600
633
  goto out;
601
634
  }
602
635
 
603
- if ((wtpath = git_path_dirname(wt->gitlink_path)) == NULL)
636
+ if ((wtpath = git_fs_path_dirname(wt->gitlink_path)) == NULL)
604
637
  goto out;
605
- git_buf_attach(&path, wtpath, 0);
606
- if (!git_path_exists(path.ptr))
638
+ git_str_attach(&path, wtpath, 0);
639
+ if (!git_fs_path_exists(path.ptr))
607
640
  {
608
641
  git_error_set(GIT_ERROR_WORKTREE, "working tree '%s' does not exist", path.ptr);
609
642
  err = -1;
@@ -613,7 +646,7 @@ int git_worktree_prune(git_worktree *wt,
613
646
  goto out;
614
647
 
615
648
  out:
616
- git_buf_dispose(&path);
649
+ git_str_dispose(&path);
617
650
 
618
651
  return err;
619
652
  }
@@ -31,7 +31,7 @@ struct git_worktree {
31
31
  /* Path to the parent's working directory */
32
32
  char *parent_path;
33
33
 
34
- int locked:1;
34
+ unsigned int locked:1;
35
35
  };
36
36
 
37
37
  char *git_worktree__read_link(const char *base, const char *file);
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+
8
+ /*
9
+ * This file provides the necessary indirection between xdiff and
10
+ * libgit2. libgit2-specific functionality should live here, so
11
+ * that git and libgit2 can share a common xdiff implementation.
12
+ */
13
+
14
+ #ifndef INCLUDE_git_xdiff_h__
15
+ #define INCLUDE_git_xdiff_h__
16
+
17
+ #include "regexp.h"
18
+
19
+ /* Work around C90-conformance issues */
20
+ #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
21
+ # if defined(_MSC_VER)
22
+ # define inline __inline
23
+ # elif defined(__GNUC__)
24
+ # define inline __inline__
25
+ # else
26
+ # define inline
27
+ # endif
28
+ #endif
29
+
30
+ #define xdl_malloc(x) git__malloc(x)
31
+ #define xdl_free(ptr) git__free(ptr)
32
+ #define xdl_realloc(ptr, x) git__realloc(ptr, x)
33
+
34
+ #define XDL_BUG(msg) GIT_ASSERT(msg)
35
+
36
+ #define xdl_regex_t git_regexp
37
+ #define xdl_regmatch_t git_regmatch
38
+
39
+ GIT_INLINE(int) xdl_regexec_buf(
40
+ const xdl_regex_t *preg, const char *buf, size_t size,
41
+ size_t nmatch, xdl_regmatch_t pmatch[], int eflags)
42
+ {
43
+ GIT_UNUSED(preg);
44
+ GIT_UNUSED(buf);
45
+ GIT_UNUSED(size);
46
+ GIT_UNUSED(nmatch);
47
+ GIT_UNUSED(pmatch);
48
+ GIT_UNUSED(eflags);
49
+ GIT_ASSERT("not implemented");
50
+ return -1;
51
+ }
52
+
53
+ #endif