rugged 1.3.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (656) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -2
  3. data/ext/rugged/extconf.rb +6 -3
  4. data/ext/rugged/rugged.c +16 -0
  5. data/ext/rugged/rugged.h +4 -0
  6. data/ext/rugged/rugged_allocator.c +0 -54
  7. data/ext/rugged/rugged_blame.c +2 -0
  8. data/ext/rugged/rugged_blob.c +3 -0
  9. data/ext/rugged/rugged_commit.c +1 -0
  10. data/ext/rugged/rugged_config.c +9 -2
  11. data/ext/rugged/rugged_diff.c +1 -0
  12. data/ext/rugged/rugged_index.c +2 -0
  13. data/ext/rugged/rugged_patch.c +1 -0
  14. data/ext/rugged/rugged_rebase.c +1 -0
  15. data/ext/rugged/rugged_reference.c +1 -0
  16. data/ext/rugged/rugged_remote.c +28 -10
  17. data/ext/rugged/rugged_repo.c +7 -9
  18. data/ext/rugged/rugged_revwalk.c +5 -1
  19. data/ext/rugged/rugged_settings.c +5 -0
  20. data/ext/rugged/rugged_submodule.c +1 -0
  21. data/ext/rugged/rugged_tag.c +1 -0
  22. data/ext/rugged/rugged_tree.c +4 -0
  23. data/lib/rugged/index.rb +1 -1
  24. data/lib/rugged/tree.rb +5 -1
  25. data/lib/rugged/version.rb +1 -1
  26. data/vendor/libgit2/AUTHORS +1 -0
  27. data/vendor/libgit2/CMakeLists.txt +141 -289
  28. data/vendor/libgit2/COPYING +301 -20
  29. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  30. data/vendor/libgit2/cmake/AddClarTest.cmake +7 -0
  31. data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
  32. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  33. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  34. data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
  35. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  36. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  37. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  38. data/vendor/libgit2/cmake/FindHTTP_Parser.cmake +17 -17
  39. data/vendor/libgit2/cmake/FindIntlIconv.cmake +51 -0
  40. data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
  41. data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
  42. data/vendor/libgit2/cmake/FindPCRE.cmake +12 -13
  43. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  44. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  45. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  46. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  47. data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
  48. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  49. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  50. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  51. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  52. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  53. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +34 -0
  54. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +129 -101
  55. data/vendor/libgit2/cmake/SelectHashes.cmake +113 -54
  56. data/vendor/libgit2/cmake/SelectRegex.cmake +56 -0
  57. data/vendor/libgit2/cmake/SelectSSH.cmake +46 -0
  58. data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
  59. data/vendor/libgit2/cmake/SelectZlib.cmake +38 -0
  60. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
  61. data/vendor/libgit2/deps/llhttp/CMakeLists.txt +8 -0
  62. data/vendor/libgit2/deps/llhttp/LICENSE-MIT +22 -0
  63. data/vendor/libgit2/deps/llhttp/api.c +510 -0
  64. data/vendor/libgit2/deps/llhttp/http.c +170 -0
  65. data/vendor/libgit2/deps/llhttp/llhttp.c +10168 -0
  66. data/vendor/libgit2/deps/llhttp/llhttp.h +897 -0
  67. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +33 -31
  68. data/vendor/libgit2/deps/ntlmclient/crypt_builtin_md4.c +311 -0
  69. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +2 -1
  70. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -20
  71. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +7 -5
  72. data/vendor/libgit2/deps/ntlmclient/ntlm.c +25 -25
  73. data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
  74. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
  75. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +5 -4
  76. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +2 -1
  77. data/vendor/libgit2/deps/ntlmclient/utf8.h +1176 -721
  78. data/vendor/libgit2/deps/ntlmclient/util.h +11 -0
  79. data/vendor/libgit2/deps/pcre/CMakeLists.txt +89 -88
  80. data/vendor/libgit2/deps/pcre/LICENCE +5 -5
  81. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  82. data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
  83. data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
  84. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  85. data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
  86. data/vendor/libgit2/deps/xdiff/git-xdiff.h +56 -0
  87. data/vendor/libgit2/{src → deps}/xdiff/xdiff.h +15 -15
  88. data/vendor/libgit2/{src → deps}/xdiff/xdiffi.c +152 -125
  89. data/vendor/libgit2/{src → deps}/xdiff/xdiffi.h +2 -4
  90. data/vendor/libgit2/{src → deps}/xdiff/xemit.c +26 -10
  91. data/vendor/libgit2/{src → deps}/xdiff/xhistogram.c +92 -94
  92. data/vendor/libgit2/{src → deps}/xdiff/xinclude.h +1 -12
  93. data/vendor/libgit2/{src → deps}/xdiff/xmacros.h +18 -1
  94. data/vendor/libgit2/{src → deps}/xdiff/xmerge.c +126 -137
  95. data/vendor/libgit2/{src → deps}/xdiff/xpatience.c +26 -46
  96. data/vendor/libgit2/{src → deps}/xdiff/xprepare.c +24 -46
  97. data/vendor/libgit2/{src → deps}/xdiff/xutils.c +36 -8
  98. data/vendor/libgit2/{src → deps}/xdiff/xutils.h +2 -1
  99. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -1
  100. data/vendor/libgit2/deps/zlib/LICENSE +22 -0
  101. data/vendor/libgit2/deps/zlib/adler32.c +7 -22
  102. data/vendor/libgit2/deps/zlib/crc32.c +931 -317
  103. data/vendor/libgit2/deps/zlib/crc32.h +9441 -436
  104. data/vendor/libgit2/deps/zlib/deflate.c +428 -453
  105. data/vendor/libgit2/deps/zlib/deflate.h +51 -23
  106. data/vendor/libgit2/deps/zlib/gzguts.h +15 -19
  107. data/vendor/libgit2/deps/zlib/infback.c +19 -31
  108. data/vendor/libgit2/deps/zlib/inffast.c +15 -18
  109. data/vendor/libgit2/deps/zlib/inffast.h +1 -1
  110. data/vendor/libgit2/deps/zlib/inflate.c +75 -110
  111. data/vendor/libgit2/deps/zlib/inflate.h +3 -2
  112. data/vendor/libgit2/deps/zlib/inftrees.c +6 -11
  113. data/vendor/libgit2/deps/zlib/inftrees.h +6 -6
  114. data/vendor/libgit2/deps/zlib/trees.c +294 -380
  115. data/vendor/libgit2/deps/zlib/zconf.h +23 -14
  116. data/vendor/libgit2/deps/zlib/zlib.h +310 -284
  117. data/vendor/libgit2/deps/zlib/zutil.c +20 -46
  118. data/vendor/libgit2/deps/zlib/zutil.h +24 -41
  119. data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
  120. data/vendor/libgit2/include/git2/apply.h +43 -8
  121. data/vendor/libgit2/include/git2/attr.h +28 -6
  122. data/vendor/libgit2/include/git2/blame.h +137 -29
  123. data/vendor/libgit2/include/git2/blob.h +85 -29
  124. data/vendor/libgit2/include/git2/branch.h +25 -16
  125. data/vendor/libgit2/include/git2/buffer.h +24 -82
  126. data/vendor/libgit2/include/git2/cert.h +4 -3
  127. data/vendor/libgit2/include/git2/checkout.h +88 -34
  128. data/vendor/libgit2/include/git2/cherrypick.h +10 -3
  129. data/vendor/libgit2/include/git2/clone.h +28 -12
  130. data/vendor/libgit2/include/git2/commit.h +134 -3
  131. data/vendor/libgit2/include/git2/common.h +172 -59
  132. data/vendor/libgit2/include/git2/config.h +118 -32
  133. data/vendor/libgit2/include/git2/credential.h +32 -3
  134. data/vendor/libgit2/include/git2/credential_helpers.h +2 -0
  135. data/vendor/libgit2/include/git2/deprecated.h +141 -3
  136. data/vendor/libgit2/include/git2/describe.h +20 -3
  137. data/vendor/libgit2/include/git2/diff.h +95 -19
  138. data/vendor/libgit2/include/git2/email.h +10 -30
  139. data/vendor/libgit2/include/git2/errors.h +51 -61
  140. data/vendor/libgit2/include/git2/experimental.h +20 -0
  141. data/vendor/libgit2/include/git2/filter.h +21 -9
  142. data/vendor/libgit2/include/git2/global.h +8 -1
  143. data/vendor/libgit2/include/git2/graph.h +4 -2
  144. data/vendor/libgit2/include/git2/ignore.h +11 -1
  145. data/vendor/libgit2/include/git2/index.h +111 -11
  146. data/vendor/libgit2/include/git2/indexer.h +67 -2
  147. data/vendor/libgit2/include/git2/mailmap.h +7 -1
  148. data/vendor/libgit2/include/git2/merge.h +70 -5
  149. data/vendor/libgit2/include/git2/message.h +4 -2
  150. data/vendor/libgit2/include/git2/net.h +3 -1
  151. data/vendor/libgit2/include/git2/notes.h +9 -6
  152. data/vendor/libgit2/include/git2/object.h +57 -7
  153. data/vendor/libgit2/include/git2/odb.h +156 -33
  154. data/vendor/libgit2/include/git2/odb_backend.h +132 -16
  155. data/vendor/libgit2/include/git2/oid.h +116 -17
  156. data/vendor/libgit2/include/git2/oidarray.h +7 -1
  157. data/vendor/libgit2/include/git2/pack.h +37 -9
  158. data/vendor/libgit2/include/git2/patch.h +10 -3
  159. data/vendor/libgit2/include/git2/pathspec.h +10 -1
  160. data/vendor/libgit2/include/git2/proxy.h +11 -1
  161. data/vendor/libgit2/include/git2/rebase.h +18 -7
  162. data/vendor/libgit2/include/git2/refdb.h +5 -2
  163. data/vendor/libgit2/include/git2/reflog.h +4 -3
  164. data/vendor/libgit2/include/git2/refs.h +11 -8
  165. data/vendor/libgit2/include/git2/refspec.h +14 -4
  166. data/vendor/libgit2/include/git2/remote.h +295 -54
  167. data/vendor/libgit2/include/git2/repository.h +95 -25
  168. data/vendor/libgit2/include/git2/reset.h +18 -5
  169. data/vendor/libgit2/include/git2/revert.h +9 -4
  170. data/vendor/libgit2/include/git2/revparse.h +4 -4
  171. data/vendor/libgit2/include/git2/revwalk.h +7 -3
  172. data/vendor/libgit2/include/git2/signature.h +47 -2
  173. data/vendor/libgit2/include/git2/stash.h +78 -10
  174. data/vendor/libgit2/include/git2/status.h +24 -11
  175. data/vendor/libgit2/include/git2/stdint.h +87 -85
  176. data/vendor/libgit2/include/git2/strarray.h +2 -16
  177. data/vendor/libgit2/include/git2/submodule.h +27 -11
  178. data/vendor/libgit2/include/git2/sys/alloc.h +12 -34
  179. data/vendor/libgit2/include/git2/sys/commit.h +77 -3
  180. data/vendor/libgit2/include/git2/sys/commit_graph.h +110 -59
  181. data/vendor/libgit2/include/git2/sys/config.h +80 -4
  182. data/vendor/libgit2/include/git2/sys/credential.h +4 -3
  183. data/vendor/libgit2/include/git2/sys/diff.h +21 -1
  184. data/vendor/libgit2/include/git2/sys/email.h +7 -0
  185. data/vendor/libgit2/include/git2/sys/errors.h +76 -0
  186. data/vendor/libgit2/include/git2/sys/filter.h +66 -3
  187. data/vendor/libgit2/include/git2/sys/hashsig.h +11 -0
  188. data/vendor/libgit2/include/git2/sys/index.h +3 -2
  189. data/vendor/libgit2/include/git2/sys/mempack.h +32 -2
  190. data/vendor/libgit2/include/git2/sys/merge.h +55 -7
  191. data/vendor/libgit2/include/git2/sys/midx.h +47 -4
  192. data/vendor/libgit2/include/git2/sys/odb_backend.h +10 -9
  193. data/vendor/libgit2/include/git2/sys/openssl.h +8 -1
  194. data/vendor/libgit2/include/git2/sys/path.h +12 -1
  195. data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -36
  196. data/vendor/libgit2/include/git2/sys/refs.h +3 -2
  197. data/vendor/libgit2/include/git2/sys/remote.h +53 -0
  198. data/vendor/libgit2/include/git2/sys/repository.h +63 -3
  199. data/vendor/libgit2/include/git2/sys/stream.h +26 -3
  200. data/vendor/libgit2/include/git2/sys/transport.h +87 -41
  201. data/vendor/libgit2/include/git2/tag.h +4 -1
  202. data/vendor/libgit2/include/git2/trace.h +9 -3
  203. data/vendor/libgit2/include/git2/transaction.h +3 -2
  204. data/vendor/libgit2/include/git2/transport.h +11 -3
  205. data/vendor/libgit2/include/git2/tree.h +20 -8
  206. data/vendor/libgit2/include/git2/types.h +26 -10
  207. data/vendor/libgit2/include/git2/version.h +63 -6
  208. data/vendor/libgit2/include/git2/worktree.h +30 -8
  209. data/vendor/libgit2/include/git2.h +1 -0
  210. data/vendor/libgit2/src/CMakeLists.txt +203 -420
  211. data/vendor/libgit2/src/README.md +12 -0
  212. data/vendor/libgit2/src/cli/CMakeLists.txt +56 -0
  213. data/vendor/libgit2/src/cli/README.md +26 -0
  214. data/vendor/libgit2/src/{branch.h → cli/cmd.c} +10 -8
  215. data/vendor/libgit2/src/cli/cmd.h +37 -0
  216. data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
  217. data/vendor/libgit2/src/cli/cmd_cat_file.c +202 -0
  218. data/vendor/libgit2/src/cli/cmd_clone.c +190 -0
  219. data/vendor/libgit2/src/cli/cmd_config.c +241 -0
  220. data/vendor/libgit2/src/cli/cmd_hash_object.c +152 -0
  221. data/vendor/libgit2/src/cli/cmd_help.c +85 -0
  222. data/vendor/libgit2/src/cli/cmd_index_pack.c +114 -0
  223. data/vendor/libgit2/src/cli/cmd_init.c +102 -0
  224. data/vendor/libgit2/src/cli/common.c +168 -0
  225. data/vendor/libgit2/src/cli/common.h +63 -0
  226. data/vendor/libgit2/src/cli/error.h +51 -0
  227. data/vendor/libgit2/src/cli/main.c +134 -0
  228. data/vendor/libgit2/src/cli/opt.c +695 -0
  229. data/vendor/libgit2/src/cli/opt.h +367 -0
  230. data/vendor/libgit2/src/cli/opt_usage.c +263 -0
  231. data/vendor/libgit2/src/cli/opt_usage.h +40 -0
  232. data/vendor/libgit2/src/cli/progress.c +395 -0
  233. data/vendor/libgit2/src/cli/progress.h +129 -0
  234. data/vendor/libgit2/src/cli/sighandler.h +20 -0
  235. data/vendor/libgit2/src/cli/unix/sighandler.c +37 -0
  236. data/vendor/libgit2/src/cli/win32/precompiled.h +3 -0
  237. data/vendor/libgit2/src/cli/win32/sighandler.c +37 -0
  238. data/vendor/libgit2/src/libgit2/CMakeLists.txt +140 -0
  239. data/vendor/libgit2/src/{annotated_commit.c → libgit2/annotated_commit.c} +2 -2
  240. data/vendor/libgit2/src/{annotated_commit.h → libgit2/annotated_commit.h} +2 -2
  241. data/vendor/libgit2/src/{apply.c → libgit2/apply.c} +32 -34
  242. data/vendor/libgit2/src/{apply.h → libgit2/apply.h} +2 -2
  243. data/vendor/libgit2/src/{attr.c → libgit2/attr.c} +48 -31
  244. data/vendor/libgit2/src/{attr_file.c → libgit2/attr_file.c} +25 -20
  245. data/vendor/libgit2/src/{attr_file.h → libgit2/attr_file.h} +6 -4
  246. data/vendor/libgit2/src/{attrcache.c → libgit2/attrcache.c} +87 -46
  247. data/vendor/libgit2/src/{attrcache.h → libgit2/attrcache.h} +5 -9
  248. data/vendor/libgit2/src/{blame.c → libgit2/blame.c} +152 -57
  249. data/vendor/libgit2/src/{blame.h → libgit2/blame.h} +1 -0
  250. data/vendor/libgit2/src/{blame_git.c → libgit2/blame_git.c} +1 -2
  251. data/vendor/libgit2/src/{blob.c → libgit2/blob.c} +38 -29
  252. data/vendor/libgit2/src/{blob.h → libgit2/blob.h} +3 -3
  253. data/vendor/libgit2/src/{branch.c → libgit2/branch.c} +164 -118
  254. data/vendor/libgit2/src/libgit2/branch.h +31 -0
  255. data/vendor/libgit2/src/libgit2/buf.c +126 -0
  256. data/vendor/libgit2/src/libgit2/buf.h +50 -0
  257. data/vendor/libgit2/src/{cache.c → libgit2/cache.c} +22 -17
  258. data/vendor/libgit2/src/{cache.h → libgit2/cache.h} +7 -9
  259. data/vendor/libgit2/src/{checkout.c → libgit2/checkout.c} +107 -91
  260. data/vendor/libgit2/src/{checkout.h → libgit2/checkout.h} +0 -2
  261. data/vendor/libgit2/src/{cherrypick.c → libgit2/cherrypick.c} +14 -15
  262. data/vendor/libgit2/src/{clone.c → libgit2/clone.c} +254 -203
  263. data/vendor/libgit2/src/{clone.h → libgit2/clone.h} +4 -1
  264. data/vendor/libgit2/src/{commit.c → libgit2/commit.c} +296 -77
  265. data/vendor/libgit2/src/libgit2/commit.h +87 -0
  266. data/vendor/libgit2/src/{commit_graph.c → libgit2/commit_graph.c} +246 -135
  267. data/vendor/libgit2/src/{commit_graph.h → libgit2/commit_graph.h} +33 -8
  268. data/vendor/libgit2/src/{commit_list.c → libgit2/commit_list.c} +17 -7
  269. data/vendor/libgit2/src/{commit_list.h → libgit2/commit_list.h} +1 -0
  270. data/vendor/libgit2/src/libgit2/common.h +55 -0
  271. data/vendor/libgit2/src/{config.c → libgit2/config.c} +490 -360
  272. data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
  273. data/vendor/libgit2/src/{config.h → libgit2/config.h} +24 -6
  274. data/vendor/libgit2/src/{config_backend.h → libgit2/config_backend.h} +8 -10
  275. data/vendor/libgit2/src/{config_cache.c → libgit2/config_cache.c} +4 -5
  276. data/vendor/libgit2/src/{config_file.c → libgit2/config_file.c} +212 -183
  277. data/vendor/libgit2/src/libgit2/config_list.c +285 -0
  278. data/vendor/libgit2/src/libgit2/config_list.h +32 -0
  279. data/vendor/libgit2/src/libgit2/config_mem.c +374 -0
  280. data/vendor/libgit2/src/{config_parse.c → libgit2/config_parse.c} +37 -32
  281. data/vendor/libgit2/src/{config_snapshot.c → libgit2/config_snapshot.c} +24 -31
  282. data/vendor/libgit2/src/{crlf.c → libgit2/crlf.c} +24 -21
  283. data/vendor/libgit2/src/{describe.c → libgit2/describe.c} +62 -51
  284. data/vendor/libgit2/src/{diff.c → libgit2/diff.c} +44 -14
  285. data/vendor/libgit2/src/{diff.h → libgit2/diff.h} +8 -10
  286. data/vendor/libgit2/src/{diff_driver.c → libgit2/diff_driver.c} +46 -55
  287. data/vendor/libgit2/src/{diff_driver.h → libgit2/diff_driver.h} +5 -5
  288. data/vendor/libgit2/src/{diff_file.c → libgit2/diff_file.c} +45 -27
  289. data/vendor/libgit2/src/{diff_generate.c → libgit2/diff_generate.c} +70 -20
  290. data/vendor/libgit2/src/{diff_generate.h → libgit2/diff_generate.h} +5 -3
  291. data/vendor/libgit2/src/{diff_parse.c → libgit2/diff_parse.c} +22 -6
  292. data/vendor/libgit2/src/{diff_print.c → libgit2/diff_print.c} +192 -105
  293. data/vendor/libgit2/src/{diff_stats.c → libgit2/diff_stats.c} +40 -29
  294. data/vendor/libgit2/src/libgit2/diff_stats.h +18 -0
  295. data/vendor/libgit2/src/{diff_tform.c → libgit2/diff_tform.c} +49 -16
  296. data/vendor/libgit2/src/{diff_xdiff.c → libgit2/diff_xdiff.c} +4 -8
  297. data/vendor/libgit2/src/{diff_xdiff.h → libgit2/diff_xdiff.h} +1 -1
  298. data/vendor/libgit2/src/{email.c → libgit2/email.c} +58 -40
  299. data/vendor/libgit2/src/{email.h → libgit2/email.h} +1 -1
  300. data/vendor/libgit2/src/{transports/ssh.h → libgit2/experimental.h.in} +3 -4
  301. data/vendor/libgit2/src/{fetch.c → libgit2/fetch.c} +105 -30
  302. data/vendor/libgit2/src/{fetch.h → libgit2/fetch.h} +1 -3
  303. data/vendor/libgit2/src/{fetchhead.c → libgit2/fetchhead.c} +30 -28
  304. data/vendor/libgit2/src/{filter.c → libgit2/filter.c} +132 -58
  305. data/vendor/libgit2/src/{filter.h → libgit2/filter.h} +26 -5
  306. data/vendor/libgit2/src/{win32 → libgit2}/git2.rc +3 -3
  307. data/vendor/libgit2/src/libgit2/grafts.c +270 -0
  308. data/vendor/libgit2/src/libgit2/grafts.h +35 -0
  309. data/vendor/libgit2/src/{graph.c → libgit2/graph.c} +1 -1
  310. data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
  311. data/vendor/libgit2/src/{ident.c → libgit2/ident.c} +20 -20
  312. data/vendor/libgit2/src/{ignore.c → libgit2/ignore.c} +44 -39
  313. data/vendor/libgit2/src/{ignore.h → libgit2/ignore.h} +2 -2
  314. data/vendor/libgit2/src/{index.c → libgit2/index.c} +460 -276
  315. data/vendor/libgit2/src/{index.h → libgit2/index.h} +21 -5
  316. data/vendor/libgit2/src/libgit2/index_map.c +95 -0
  317. data/vendor/libgit2/src/libgit2/index_map.h +28 -0
  318. data/vendor/libgit2/src/{indexer.c → libgit2/indexer.c} +208 -124
  319. data/vendor/libgit2/src/{iterator.c → libgit2/iterator.c} +102 -71
  320. data/vendor/libgit2/src/{iterator.h → libgit2/iterator.h} +8 -5
  321. data/vendor/libgit2/src/libgit2/libgit2.c +268 -0
  322. data/vendor/libgit2/src/{mailmap.c → libgit2/mailmap.c} +39 -37
  323. data/vendor/libgit2/src/{merge.c → libgit2/merge.c} +83 -73
  324. data/vendor/libgit2/src/{merge.h → libgit2/merge.h} +1 -14
  325. data/vendor/libgit2/src/{merge_driver.c → libgit2/merge_driver.c} +4 -4
  326. data/vendor/libgit2/src/{merge_file.c → libgit2/merge_file.c} +13 -5
  327. data/vendor/libgit2/src/{message.c → libgit2/message.c} +21 -10
  328. data/vendor/libgit2/src/{midx.c → libgit2/midx.c} +174 -112
  329. data/vendor/libgit2/src/{midx.h → libgit2/midx.h} +17 -6
  330. data/vendor/libgit2/src/{mwindow.c → libgit2/mwindow.c} +53 -57
  331. data/vendor/libgit2/src/{mwindow.h → libgit2/mwindow.h} +9 -2
  332. data/vendor/libgit2/src/{notes.c → libgit2/notes.c} +29 -37
  333. data/vendor/libgit2/src/{object.c → libgit2/object.c} +166 -35
  334. data/vendor/libgit2/src/{object.h → libgit2/object.h} +17 -2
  335. data/vendor/libgit2/src/{odb.c → libgit2/odb.c} +261 -88
  336. data/vendor/libgit2/src/{odb.h → libgit2/odb.h} +44 -5
  337. data/vendor/libgit2/src/{odb_loose.c → libgit2/odb_loose.c} +192 -134
  338. data/vendor/libgit2/src/{odb_mempack.c → libgit2/odb_mempack.c} +67 -22
  339. data/vendor/libgit2/src/{odb_pack.c → libgit2/odb_pack.c} +162 -89
  340. data/vendor/libgit2/src/{oid.c → libgit2/oid.c} +171 -92
  341. data/vendor/libgit2/src/libgit2/oid.h +284 -0
  342. data/vendor/libgit2/src/libgit2/oidarray.c +89 -0
  343. data/vendor/libgit2/src/{oidarray.h → libgit2/oidarray.h} +5 -1
  344. data/vendor/libgit2/src/{pack-objects.c → libgit2/pack-objects.c} +126 -66
  345. data/vendor/libgit2/src/{pack-objects.h → libgit2/pack-objects.h} +28 -12
  346. data/vendor/libgit2/src/{pack.c → libgit2/pack.c} +146 -111
  347. data/vendor/libgit2/src/{pack.h → libgit2/pack.h} +45 -25
  348. data/vendor/libgit2/src/{parse.c → libgit2/parse.c} +8 -4
  349. data/vendor/libgit2/src/{parse.h → libgit2/parse.h} +1 -1
  350. data/vendor/libgit2/src/{patch.c → libgit2/patch.c} +3 -3
  351. data/vendor/libgit2/src/{patch.h → libgit2/patch.h} +8 -1
  352. data/vendor/libgit2/src/{patch_generate.c → libgit2/patch_generate.c} +51 -16
  353. data/vendor/libgit2/src/{patch_generate.h → libgit2/patch_generate.h} +5 -5
  354. data/vendor/libgit2/src/{patch_parse.c → libgit2/patch_parse.c} +42 -34
  355. data/vendor/libgit2/src/libgit2/path.c +375 -0
  356. data/vendor/libgit2/src/libgit2/path.h +68 -0
  357. data/vendor/libgit2/src/{pathspec.c → libgit2/pathspec.c} +7 -7
  358. data/vendor/libgit2/src/{pathspec.h → libgit2/pathspec.h} +2 -2
  359. data/vendor/libgit2/src/{proxy.c → libgit2/proxy.c} +4 -1
  360. data/vendor/libgit2/src/{proxy.h → libgit2/proxy.h} +1 -1
  361. data/vendor/libgit2/src/{push.c → libgit2/push.c} +116 -60
  362. data/vendor/libgit2/src/{push.h → libgit2/push.h} +5 -16
  363. data/vendor/libgit2/src/{reader.c → libgit2/reader.c} +9 -9
  364. data/vendor/libgit2/src/{reader.h → libgit2/reader.h} +2 -2
  365. data/vendor/libgit2/src/{rebase.c → libgit2/rebase.c} +147 -147
  366. data/vendor/libgit2/src/{refdb_fs.c → libgit2/refdb_fs.c} +639 -254
  367. data/vendor/libgit2/src/{reflog.c → libgit2/reflog.c} +8 -7
  368. data/vendor/libgit2/src/{reflog.h → libgit2/reflog.h} +3 -2
  369. data/vendor/libgit2/src/{refs.c → libgit2/refs.c} +67 -39
  370. data/vendor/libgit2/src/{refs.h → libgit2/refs.h} +8 -3
  371. data/vendor/libgit2/src/{refspec.c → libgit2/refspec.c} +60 -38
  372. data/vendor/libgit2/src/{refspec.h → libgit2/refspec.h} +13 -2
  373. data/vendor/libgit2/src/{remote.c → libgit2/remote.c} +821 -454
  374. data/vendor/libgit2/src/libgit2/remote.h +101 -0
  375. data/vendor/libgit2/src/{repository.c → libgit2/repository.c} +1377 -594
  376. data/vendor/libgit2/src/{repository.h → libgit2/repository.h} +43 -12
  377. data/vendor/libgit2/src/{reset.c → libgit2/reset.c} +8 -5
  378. data/vendor/libgit2/src/{revert.c → libgit2/revert.c} +18 -22
  379. data/vendor/libgit2/src/{revparse.c → libgit2/revparse.c} +76 -44
  380. data/vendor/libgit2/src/{revwalk.c → libgit2/revwalk.c} +48 -19
  381. data/vendor/libgit2/src/{revwalk.h → libgit2/revwalk.h} +3 -3
  382. data/vendor/libgit2/src/{libgit2.c → libgit2/settings.c} +162 -95
  383. data/vendor/libgit2/src/{settings.h → libgit2/settings.h} +6 -2
  384. data/vendor/libgit2/src/{signature.c → libgit2/signature.c} +144 -21
  385. data/vendor/libgit2/src/{signature.h → libgit2/signature.h} +1 -2
  386. data/vendor/libgit2/src/{stash.c → libgit2/stash.c} +243 -68
  387. data/vendor/libgit2/src/{status.c → libgit2/status.c} +5 -2
  388. data/vendor/libgit2/src/{strarray.c → libgit2/strarray.c} +1 -0
  389. data/vendor/libgit2/src/libgit2/strarray.h +25 -0
  390. data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.c +62 -67
  391. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.c +41 -24
  392. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.h +2 -0
  393. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.c +11 -3
  394. data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.h +6 -3
  395. data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
  396. data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
  397. data/vendor/libgit2/src/libgit2/streams/socket.c +428 -0
  398. data/vendor/libgit2/src/{streams → libgit2/streams}/socket.h +3 -1
  399. data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.c +79 -19
  400. data/vendor/libgit2/src/{streams → libgit2/streams}/tls.c +5 -0
  401. data/vendor/libgit2/src/{submodule.c → libgit2/submodule.c} +279 -220
  402. data/vendor/libgit2/src/{submodule.h → libgit2/submodule.h} +10 -11
  403. data/vendor/libgit2/src/libgit2/sysdir.c +650 -0
  404. data/vendor/libgit2/src/{sysdir.h → libgit2/sysdir.h} +55 -18
  405. data/vendor/libgit2/src/{tag.c → libgit2/tag.c} +74 -43
  406. data/vendor/libgit2/src/{tag.h → libgit2/tag.h} +2 -2
  407. data/vendor/libgit2/src/{trace.c → libgit2/trace.c} +1 -14
  408. data/vendor/libgit2/src/{trace.h → libgit2/trace.h} +5 -22
  409. data/vendor/libgit2/src/{trailer.c → libgit2/trailer.c} +7 -7
  410. data/vendor/libgit2/src/{transaction.c → libgit2/transaction.c} +27 -21
  411. data/vendor/libgit2/src/{transaction.h → libgit2/transaction.h} +4 -1
  412. data/vendor/libgit2/src/{transport.c → libgit2/transport.c} +14 -11
  413. data/vendor/libgit2/src/{transports → libgit2/transports}/auth.c +7 -9
  414. data/vendor/libgit2/src/{transports → libgit2/transports}/auth.h +3 -5
  415. data/vendor/libgit2/src/{transports/auth_negotiate.c → libgit2/transports/auth_gssapi.c} +44 -45
  416. data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.h +1 -1
  417. data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.h +1 -2
  418. data/vendor/libgit2/src/{transports/auth_ntlm.c → libgit2/transports/auth_ntlmclient.c} +22 -22
  419. data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
  420. data/vendor/libgit2/src/{transports → libgit2/transports}/credential.c +1 -1
  421. data/vendor/libgit2/src/{transports → libgit2/transports}/git.c +16 -19
  422. data/vendor/libgit2/src/{transports → libgit2/transports}/http.c +49 -24
  423. data/vendor/libgit2/src/{transports → libgit2/transports}/http.h +0 -11
  424. data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.c +188 -134
  425. data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.h +10 -0
  426. data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
  427. data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
  428. data/vendor/libgit2/src/{transports → libgit2/transports}/local.c +159 -127
  429. data/vendor/libgit2/src/{transports → libgit2/transports}/smart.c +142 -165
  430. data/vendor/libgit2/src/{transports → libgit2/transports}/smart.h +56 -36
  431. data/vendor/libgit2/src/{transports → libgit2/transports}/smart_pkt.c +307 -74
  432. data/vendor/libgit2/src/{transports → libgit2/transports}/smart_protocol.c +297 -97
  433. data/vendor/libgit2/src/libgit2/transports/ssh.c +85 -0
  434. data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +347 -0
  435. data/vendor/libgit2/src/libgit2/transports/ssh_exec.h +26 -0
  436. data/vendor/libgit2/src/{transports/ssh.c → libgit2/transports/ssh_libssh2.c} +414 -268
  437. data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
  438. data/vendor/libgit2/src/{transports → libgit2/transports}/winhttp.c +101 -75
  439. data/vendor/libgit2/src/{tree-cache.c → libgit2/tree-cache.c} +30 -20
  440. data/vendor/libgit2/src/{tree-cache.h → libgit2/tree-cache.h} +7 -5
  441. data/vendor/libgit2/src/{tree.c → libgit2/tree.c} +128 -110
  442. data/vendor/libgit2/src/{tree.h → libgit2/tree.h} +7 -6
  443. data/vendor/libgit2/src/{worktree.c → libgit2/worktree.c} +160 -121
  444. data/vendor/libgit2/src/{worktree.h → libgit2/worktree.h} +1 -1
  445. data/vendor/libgit2/src/util/CMakeLists.txt +77 -0
  446. data/vendor/libgit2/src/{alloc.c → util/alloc.c} +69 -7
  447. data/vendor/libgit2/src/util/alloc.h +65 -0
  448. data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
  449. data/vendor/libgit2/src/util/allocators/debugalloc.h +17 -0
  450. data/vendor/libgit2/src/util/allocators/failalloc.c +32 -0
  451. data/vendor/libgit2/src/util/allocators/failalloc.h +17 -0
  452. data/vendor/libgit2/src/util/allocators/stdalloc.c +37 -0
  453. data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.h +1 -1
  454. data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +50 -0
  455. data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.h +1 -1
  456. data/vendor/libgit2/src/{array.h → util/array.h} +25 -19
  457. data/vendor/libgit2/src/{assert_safe.h → util/assert_safe.h} +16 -0
  458. data/vendor/libgit2/src/{cc-compat.h → util/cc-compat.h} +5 -1
  459. data/vendor/libgit2/src/util/ctype_compat.h +70 -0
  460. data/vendor/libgit2/src/{date.c → util/date.c} +35 -33
  461. data/vendor/libgit2/src/util/date.h +45 -0
  462. data/vendor/libgit2/src/util/errors.c +401 -0
  463. data/vendor/libgit2/src/{errors.h → util/errors.h} +22 -19
  464. data/vendor/libgit2/src/{filebuf.c → util/filebuf.c} +35 -30
  465. data/vendor/libgit2/src/{filebuf.h → util/filebuf.h} +21 -8
  466. data/vendor/libgit2/src/{path.c → util/fs_path.c} +591 -615
  467. data/vendor/libgit2/src/{path.h → util/fs_path.h} +257 -181
  468. data/vendor/libgit2/src/{futils.c → util/futils.c} +144 -95
  469. data/vendor/libgit2/src/{futils.h → util/futils.h} +40 -18
  470. data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +33 -2
  471. data/vendor/libgit2/src/{common.h → util/git2_util.h} +26 -59
  472. data/vendor/libgit2/src/util/hash/builtin.c +53 -0
  473. data/vendor/libgit2/src/{hash/sha1/openssl.h → util/hash/builtin.h} +6 -6
  474. data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.c +3 -3
  475. data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.h +3 -3
  476. data/vendor/libgit2/src/util/hash/common_crypto.c +112 -0
  477. data/vendor/libgit2/src/{hash/sha1 → util/hash}/common_crypto.h +11 -3
  478. data/vendor/libgit2/src/util/hash/mbedtls.c +92 -0
  479. data/vendor/libgit2/src/{hash/sha1 → util/hash}/mbedtls.h +14 -4
  480. data/vendor/libgit2/src/util/hash/openssl.c +347 -0
  481. data/vendor/libgit2/src/util/hash/openssl.h +61 -0
  482. data/vendor/libgit2/src/util/hash/rfc6234/sha.h +243 -0
  483. data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +601 -0
  484. data/vendor/libgit2/src/util/hash/sha.h +73 -0
  485. data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.c +1 -1
  486. data/vendor/libgit2/src/util/hash/win32.c +549 -0
  487. data/vendor/libgit2/src/util/hash/win32.h +60 -0
  488. data/vendor/libgit2/src/util/hash.c +158 -0
  489. data/vendor/libgit2/src/util/hash.h +61 -0
  490. data/vendor/libgit2/src/util/hashmap.h +424 -0
  491. data/vendor/libgit2/src/util/hashmap_str.h +43 -0
  492. data/vendor/libgit2/src/{integer.h → util/integer.h} +3 -1
  493. data/vendor/libgit2/src/{map.h → util/map.h} +1 -1
  494. data/vendor/libgit2/src/util/net.c +1160 -0
  495. data/vendor/libgit2/src/{net.h → util/net.h} +45 -4
  496. data/vendor/libgit2/src/{pool.c → util/pool.c} +1 -1
  497. data/vendor/libgit2/src/{pool.h → util/pool.h} +6 -1
  498. data/vendor/libgit2/src/{posix.c → util/posix.c} +57 -3
  499. data/vendor/libgit2/src/{posix.h → util/posix.h} +26 -1
  500. data/vendor/libgit2/src/{pqueue.h → util/pqueue.h} +3 -3
  501. data/vendor/libgit2/src/util/process.h +222 -0
  502. data/vendor/libgit2/src/util/rand.c +230 -0
  503. data/vendor/libgit2/src/util/rand.h +37 -0
  504. data/vendor/libgit2/src/{regexp.c → util/regexp.c} +5 -5
  505. data/vendor/libgit2/src/{regexp.h → util/regexp.h} +1 -1
  506. data/vendor/libgit2/src/{runtime.c → util/runtime.c} +1 -1
  507. data/vendor/libgit2/src/{runtime.h → util/runtime.h} +1 -1
  508. data/vendor/libgit2/src/{sortedcache.c → util/sortedcache.c} +15 -14
  509. data/vendor/libgit2/src/{sortedcache.h → util/sortedcache.h} +5 -5
  510. data/vendor/libgit2/src/util/staticstr.h +66 -0
  511. data/vendor/libgit2/src/{buffer.c → util/str.c} +159 -153
  512. data/vendor/libgit2/src/util/str.h +357 -0
  513. data/vendor/libgit2/src/util/strlist.c +108 -0
  514. data/vendor/libgit2/src/util/strlist.h +36 -0
  515. data/vendor/libgit2/src/{thread.c → util/thread.c} +1 -1
  516. data/vendor/libgit2/src/{thread.h → util/thread.h} +23 -22
  517. data/vendor/libgit2/src/{tsort.c → util/tsort.c} +1 -1
  518. data/vendor/libgit2/src/{unix → util/unix}/map.c +1 -3
  519. data/vendor/libgit2/src/{unix → util/unix}/posix.h +1 -6
  520. data/vendor/libgit2/src/util/unix/process.c +629 -0
  521. data/vendor/libgit2/src/{unix → util/unix}/realpath.c +24 -8
  522. data/vendor/libgit2/src/{utf8.c → util/utf8.c} +1 -1
  523. data/vendor/libgit2/src/{utf8.h → util/utf8.h} +1 -1
  524. data/vendor/libgit2/src/{util.c → util/util.c} +24 -19
  525. data/vendor/libgit2/src/{util.h → util/util.h} +30 -81
  526. data/vendor/libgit2/src/{varint.h → util/varint.h} +1 -1
  527. data/vendor/libgit2/src/{vector.c → util/vector.c} +3 -3
  528. data/vendor/libgit2/src/{vector.h → util/vector.h} +4 -4
  529. data/vendor/libgit2/src/{wildmatch.h → util/wildmatch.h} +1 -1
  530. data/vendor/libgit2/src/{win32 → util/win32}/dir.h +1 -1
  531. data/vendor/libgit2/src/{win32 → util/win32}/error.c +1 -1
  532. data/vendor/libgit2/src/{win32 → util/win32}/error.h +1 -1
  533. data/vendor/libgit2/src/{win32 → util/win32}/map.c +1 -1
  534. data/vendor/libgit2/src/{win32 → util/win32}/path_w32.c +148 -17
  535. data/vendor/libgit2/src/{win32 → util/win32}/path_w32.h +3 -1
  536. data/vendor/libgit2/src/{win32 → util/win32}/posix.h +1 -2
  537. data/vendor/libgit2/src/{win32 → util/win32}/posix_w32.c +42 -35
  538. data/vendor/libgit2/src/util/win32/precompiled.c +1 -0
  539. data/vendor/libgit2/src/{win32 → util/win32}/precompiled.h +1 -1
  540. data/vendor/libgit2/src/util/win32/process.c +506 -0
  541. data/vendor/libgit2/src/{win32 → util/win32}/thread.h +1 -1
  542. data/vendor/libgit2/src/util/win32/utf-conv.c +144 -0
  543. data/vendor/libgit2/src/util/win32/utf-conv.h +127 -0
  544. data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.c +2 -3
  545. data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.h +3 -4
  546. data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.c +1 -1
  547. data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.h +1 -1
  548. data/vendor/libgit2/src/{win32 → util/win32}/w32_util.c +1 -1
  549. data/vendor/libgit2/src/{win32 → util/win32}/w32_util.h +1 -1
  550. data/vendor/libgit2/src/{zstream.c → util/zstream.c} +5 -5
  551. data/vendor/libgit2/src/{zstream.h → util/zstream.h} +5 -5
  552. metadata +431 -362
  553. data/vendor/libgit2/cmake/FindIconv.cmake +0 -45
  554. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -6
  555. data/vendor/libgit2/deps/http-parser/COPYING +0 -23
  556. data/vendor/libgit2/deps/http-parser/http_parser.c +0 -2182
  557. data/vendor/libgit2/deps/http-parser/http_parser.h +0 -305
  558. data/vendor/libgit2/deps/zlib/COPYING +0 -27
  559. data/vendor/libgit2/include/git2/sys/reflog.h +0 -21
  560. data/vendor/libgit2/src/alloc.h +0 -40
  561. data/vendor/libgit2/src/allocators/failalloc.c +0 -92
  562. data/vendor/libgit2/src/allocators/failalloc.h +0 -23
  563. data/vendor/libgit2/src/allocators/stdalloc.c +0 -150
  564. data/vendor/libgit2/src/allocators/win32_leakcheck.c +0 -118
  565. data/vendor/libgit2/src/buffer.h +0 -374
  566. data/vendor/libgit2/src/commit.h +0 -46
  567. data/vendor/libgit2/src/config_entries.c +0 -237
  568. data/vendor/libgit2/src/config_entries.h +0 -24
  569. data/vendor/libgit2/src/config_mem.c +0 -220
  570. data/vendor/libgit2/src/errors.c +0 -238
  571. data/vendor/libgit2/src/hash/sha1/common_crypto.c +0 -57
  572. data/vendor/libgit2/src/hash/sha1/generic.c +0 -300
  573. data/vendor/libgit2/src/hash/sha1/generic.h +0 -19
  574. data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
  575. data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
  576. data/vendor/libgit2/src/hash/sha1/win32.c +0 -333
  577. data/vendor/libgit2/src/hash/sha1/win32.h +0 -128
  578. data/vendor/libgit2/src/hash/sha1.h +0 -38
  579. data/vendor/libgit2/src/hash.c +0 -110
  580. data/vendor/libgit2/src/hash.h +0 -46
  581. data/vendor/libgit2/src/idxmap.c +0 -157
  582. data/vendor/libgit2/src/idxmap.h +0 -177
  583. data/vendor/libgit2/src/khash.h +0 -615
  584. data/vendor/libgit2/src/libgit2.h +0 -15
  585. data/vendor/libgit2/src/message.h +0 -17
  586. data/vendor/libgit2/src/net.c +0 -540
  587. data/vendor/libgit2/src/netops.c +0 -125
  588. data/vendor/libgit2/src/netops.h +0 -68
  589. data/vendor/libgit2/src/offmap.c +0 -101
  590. data/vendor/libgit2/src/offmap.h +0 -133
  591. data/vendor/libgit2/src/oid.h +0 -51
  592. data/vendor/libgit2/src/oidarray.c +0 -43
  593. data/vendor/libgit2/src/oidmap.c +0 -107
  594. data/vendor/libgit2/src/oidmap.h +0 -128
  595. data/vendor/libgit2/src/remote.h +0 -55
  596. data/vendor/libgit2/src/streams/socket.c +0 -239
  597. data/vendor/libgit2/src/strmap.c +0 -100
  598. data/vendor/libgit2/src/strmap.h +0 -131
  599. data/vendor/libgit2/src/sysdir.c +0 -347
  600. data/vendor/libgit2/src/threadstate.c +0 -84
  601. data/vendor/libgit2/src/threadstate.h +0 -24
  602. data/vendor/libgit2/src/win32/findfile.c +0 -230
  603. data/vendor/libgit2/src/win32/findfile.h +0 -19
  604. data/vendor/libgit2/src/win32/utf-conv.c +0 -146
  605. data/vendor/libgit2/src/win32/utf-conv.h +0 -60
  606. /data/vendor/libgit2/{src → deps}/xdiff/xemit.h +0 -0
  607. /data/vendor/libgit2/{src → deps}/xdiff/xprepare.h +0 -0
  608. /data/vendor/libgit2/{src → deps}/xdiff/xtypes.h +0 -0
  609. /data/vendor/libgit2/src/{win32 → cli/win32}/precompiled.c +0 -0
  610. /data/vendor/libgit2/src/{attr.h → libgit2/attr.h} +0 -0
  611. /data/vendor/libgit2/src/{blame_git.h → libgit2/blame_git.h} +0 -0
  612. /data/vendor/libgit2/src/{config_parse.h → libgit2/config_parse.h} +0 -0
  613. /data/vendor/libgit2/src/{delta.c → libgit2/delta.c} +0 -0
  614. /data/vendor/libgit2/src/{delta.h → libgit2/delta.h} +0 -0
  615. /data/vendor/libgit2/src/{diff_file.h → libgit2/diff_file.h} +0 -0
  616. /data/vendor/libgit2/src/{diff_parse.h → libgit2/diff_parse.h} +0 -0
  617. /data/vendor/libgit2/src/{diff_tform.h → libgit2/diff_tform.h} +0 -0
  618. /data/vendor/libgit2/src/{fetchhead.h → libgit2/fetchhead.h} +0 -0
  619. /data/vendor/libgit2/src/{hashsig.c → libgit2/hashsig.c} +0 -0
  620. /data/vendor/libgit2/src/{indexer.h → libgit2/indexer.h} +0 -0
  621. /data/vendor/libgit2/src/{mailmap.h → libgit2/mailmap.h} +0 -0
  622. /data/vendor/libgit2/src/{merge_driver.h → libgit2/merge_driver.h} +0 -0
  623. /data/vendor/libgit2/src/{notes.h → libgit2/notes.h} +0 -0
  624. /data/vendor/libgit2/src/{object_api.c → libgit2/object_api.c} +0 -0
  625. /data/vendor/libgit2/src/{patch_parse.h → libgit2/patch_parse.h} +0 -0
  626. /data/vendor/libgit2/src/{refdb.c → libgit2/refdb.c} +0 -0
  627. /data/vendor/libgit2/src/{refdb.h → libgit2/refdb.h} +0 -0
  628. /data/vendor/libgit2/src/{repo_template.h → libgit2/repo_template.h} +0 -0
  629. /data/vendor/libgit2/src/{status.h → libgit2/status.h} +0 -0
  630. /data/vendor/libgit2/src/{stream.h → libgit2/stream.h} +0 -0
  631. /data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.h +0 -0
  632. /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.c +0 -0
  633. /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.h +0 -0
  634. /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.c +0 -0
  635. /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.h +0 -0
  636. /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.h +0 -0
  637. /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.h +0 -0
  638. /data/vendor/libgit2/src/{transports → libgit2/transports}/credential_helpers.c +0 -0
  639. /data/vendor/libgit2/src/{userdiff.h → libgit2/userdiff.h} +0 -0
  640. /data/vendor/libgit2/src/{bitvec.h → util/bitvec.h} +0 -0
  641. /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.h +0 -0
  642. /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.c +0 -0
  643. /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.h +0 -0
  644. /data/vendor/libgit2/src/{pqueue.c → util/pqueue.c} +0 -0
  645. /data/vendor/libgit2/src/{strnlen.h → util/strnlen.h} +0 -0
  646. /data/vendor/libgit2/src/{unix → util/unix}/pthread.h +0 -0
  647. /data/vendor/libgit2/src/{varint.c → util/varint.c} +0 -0
  648. /data/vendor/libgit2/src/{wildmatch.c → util/wildmatch.c} +0 -0
  649. /data/vendor/libgit2/src/{win32 → util/win32}/dir.c +0 -0
  650. /data/vendor/libgit2/src/{win32 → util/win32}/mingw-compat.h +0 -0
  651. /data/vendor/libgit2/src/{win32 → util/win32}/msvc-compat.h +0 -0
  652. /data/vendor/libgit2/src/{win32 → util/win32}/reparse.h +0 -0
  653. /data/vendor/libgit2/src/{win32 → util/win32}/thread.c +0 -0
  654. /data/vendor/libgit2/src/{win32 → util/win32}/version.h +0 -0
  655. /data/vendor/libgit2/src/{win32 → util/win32}/w32_common.h +0 -0
  656. /data/vendor/libgit2/src/{win32 → util/win32}/win32-compat.h +0 -0
@@ -5,10 +5,11 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
- #include "path.h"
8
+ #include "fs_path.h"
9
9
 
10
+ #include "git2_util.h"
11
+ #include "futils.h"
10
12
  #include "posix.h"
11
- #include "repository.h"
12
13
  #ifdef GIT_WIN32
13
14
  #include "win32/posix.h"
14
15
  #include "win32/w32_buffer.h"
@@ -21,6 +22,13 @@
21
22
  #include <stdio.h>
22
23
  #include <ctype.h>
23
24
 
25
+ #define ensure_error_set(code) do { \
26
+ const git_error *e = git_error_last(); \
27
+ if (!e || !e->message) \
28
+ git_error_set(e ? e->klass : GIT_ERROR_CALLBACK, \
29
+ "filesystem callback returned %d", code); \
30
+ } while(0)
31
+
24
32
  static int dos_drive_prefix_length(const char *path)
25
33
  {
26
34
  int i;
@@ -93,7 +101,7 @@ static bool looks_like_network_computer_name(const char *path, int pos)
93
101
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94
102
  * SUCH DAMAGE.
95
103
  */
96
- int git_path_basename_r(git_buf *buffer, const char *path)
104
+ int git_fs_path_basename_r(git_str *buffer, const char *path)
97
105
  {
98
106
  const char *endp, *startp;
99
107
  int len, result;
@@ -101,7 +109,7 @@ int git_path_basename_r(git_buf *buffer, const char *path)
101
109
  /* Empty or NULL string gets treated as "." */
102
110
  if (path == NULL || *path == '\0') {
103
111
  startp = ".";
104
- len = 1;
112
+ len = 1;
105
113
  goto Exit;
106
114
  }
107
115
 
@@ -113,7 +121,7 @@ int git_path_basename_r(git_buf *buffer, const char *path)
113
121
  /* All slashes becomes "/" */
114
122
  if (endp == path && *endp == '/') {
115
123
  startp = "/";
116
- len = 1;
124
+ len = 1;
117
125
  goto Exit;
118
126
  }
119
127
 
@@ -128,7 +136,7 @@ int git_path_basename_r(git_buf *buffer, const char *path)
128
136
  Exit:
129
137
  result = len;
130
138
 
131
- if (buffer != NULL && git_buf_set(buffer, startp, len) < 0)
139
+ if (buffer != NULL && git_str_set(buffer, startp, len) < 0)
132
140
  return -1;
133
141
 
134
142
  return result;
@@ -136,7 +144,7 @@ Exit:
136
144
 
137
145
  /*
138
146
  * Determine if the path is a Windows prefix and, if so, returns
139
- * its actual lentgh. If it is not a prefix, returns -1.
147
+ * its actual length. If it is not a prefix, returns -1.
140
148
  */
141
149
  static int win32_prefix_length(const char *path, int len)
142
150
  {
@@ -166,7 +174,7 @@ static int win32_prefix_length(const char *path, int len)
166
174
  * Based on the Android implementation, BSD licensed.
167
175
  * Check http://android.git.kernel.org/
168
176
  */
169
- int git_path_dirname_r(git_buf *buffer, const char *path)
177
+ int git_fs_path_dirname_r(git_str *buffer, const char *path)
170
178
  {
171
179
  const char *endp;
172
180
  int is_prefix = 0, len;
@@ -185,8 +193,7 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
185
193
 
186
194
  if (endp - path + 1 > INT_MAX) {
187
195
  git_error_set(GIT_ERROR_INVALID, "path too long");
188
- len = -1;
189
- goto Exit;
196
+ return -1;
190
197
  }
191
198
 
192
199
  if ((len = win32_prefix_length(path, (int)(endp - path + 1))) > 0) {
@@ -211,8 +218,7 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
211
218
 
212
219
  if (endp - path + 1 > INT_MAX) {
213
220
  git_error_set(GIT_ERROR_INVALID, "path too long");
214
- len = -1;
215
- goto Exit;
221
+ return -1;
216
222
  }
217
223
 
218
224
  if ((len = win32_prefix_length(path, (int)(endp - path + 1))) > 0) {
@@ -225,9 +231,9 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
225
231
 
226
232
  Exit:
227
233
  if (buffer) {
228
- if (git_buf_set(buffer, path, len) < 0)
234
+ if (git_str_set(buffer, path, len) < 0)
229
235
  return -1;
230
- if (is_prefix && git_buf_putc(buffer, '/') < 0)
236
+ if (is_prefix && git_str_putc(buffer, '/') < 0)
231
237
  return -1;
232
238
  }
233
239
 
@@ -235,38 +241,38 @@ Exit:
235
241
  }
236
242
 
237
243
 
238
- char *git_path_dirname(const char *path)
244
+ char *git_fs_path_dirname(const char *path)
239
245
  {
240
- git_buf buf = GIT_BUF_INIT;
246
+ git_str buf = GIT_STR_INIT;
241
247
  char *dirname;
242
248
 
243
- git_path_dirname_r(&buf, path);
244
- dirname = git_buf_detach(&buf);
245
- git_buf_dispose(&buf); /* avoid memleak if error occurs */
249
+ git_fs_path_dirname_r(&buf, path);
250
+ dirname = git_str_detach(&buf);
251
+ git_str_dispose(&buf); /* avoid memleak if error occurs */
246
252
 
247
253
  return dirname;
248
254
  }
249
255
 
250
- char *git_path_basename(const char *path)
256
+ char *git_fs_path_basename(const char *path)
251
257
  {
252
- git_buf buf = GIT_BUF_INIT;
258
+ git_str buf = GIT_STR_INIT;
253
259
  char *basename;
254
260
 
255
- git_path_basename_r(&buf, path);
256
- basename = git_buf_detach(&buf);
257
- git_buf_dispose(&buf); /* avoid memleak if error occurs */
261
+ git_fs_path_basename_r(&buf, path);
262
+ basename = git_str_detach(&buf);
263
+ git_str_dispose(&buf); /* avoid memleak if error occurs */
258
264
 
259
265
  return basename;
260
266
  }
261
267
 
262
- size_t git_path_basename_offset(git_buf *buffer)
268
+ size_t git_fs_path_basename_offset(git_str *buffer)
263
269
  {
264
270
  ssize_t slash;
265
271
 
266
272
  if (!buffer || buffer->size <= 0)
267
273
  return 0;
268
274
 
269
- slash = git_buf_rfind_next(buffer, '/');
275
+ slash = git_str_rfind_next(buffer, '/');
270
276
 
271
277
  if (slash >= 0 && buffer->ptr[slash] == '/')
272
278
  return (size_t)(slash + 1);
@@ -274,7 +280,7 @@ size_t git_path_basename_offset(git_buf *buffer)
274
280
  return 0;
275
281
  }
276
282
 
277
- int git_path_root(const char *path)
283
+ int git_fs_path_root(const char *path)
278
284
  {
279
285
  int offset = 0, prefix_len;
280
286
 
@@ -304,9 +310,9 @@ int git_path_root(const char *path)
304
310
  return -1; /* Not a real error - signals that path is not rooted */
305
311
  }
306
312
 
307
- static void path_trim_slashes(git_buf *path)
313
+ static void path_trim_slashes(git_str *path)
308
314
  {
309
- int ceiling = git_path_root(path->ptr) + 1;
315
+ int ceiling = git_fs_path_root(path->ptr) + 1;
310
316
 
311
317
  if (ceiling < 0)
312
318
  return;
@@ -320,29 +326,29 @@ static void path_trim_slashes(git_buf *path)
320
326
  }
321
327
  }
322
328
 
323
- int git_path_join_unrooted(
324
- git_buf *path_out, const char *path, const char *base, ssize_t *root_at)
329
+ int git_fs_path_join_unrooted(
330
+ git_str *path_out, const char *path, const char *base, ssize_t *root_at)
325
331
  {
326
332
  ssize_t root;
327
333
 
328
334
  GIT_ASSERT_ARG(path_out);
329
335
  GIT_ASSERT_ARG(path);
330
336
 
331
- root = (ssize_t)git_path_root(path);
337
+ root = (ssize_t)git_fs_path_root(path);
332
338
 
333
339
  if (base != NULL && root < 0) {
334
- if (git_buf_joinpath(path_out, base, path) < 0)
340
+ if (git_str_joinpath(path_out, base, path) < 0)
335
341
  return -1;
336
342
 
337
343
  root = (ssize_t)strlen(base);
338
344
  } else {
339
- if (git_buf_sets(path_out, path) < 0)
345
+ if (git_str_sets(path_out, path) < 0)
340
346
  return -1;
341
347
 
342
348
  if (root < 0)
343
349
  root = 0;
344
350
  else if (base)
345
- git_path_equal_or_prefixed(base, path, &root);
351
+ git_fs_path_equal_or_prefixed(base, path, &root);
346
352
  }
347
353
 
348
354
  if (root_at)
@@ -351,7 +357,7 @@ int git_path_join_unrooted(
351
357
  return 0;
352
358
  }
353
359
 
354
- void git_path_squash_slashes(git_buf *path)
360
+ void git_fs_path_squash_slashes(git_str *path)
355
361
  {
356
362
  char *p, *q;
357
363
 
@@ -370,7 +376,7 @@ void git_path_squash_slashes(git_buf *path)
370
376
  *p = '\0';
371
377
  }
372
378
 
373
- int git_path_prettify(git_buf *path_out, const char *path, const char *base)
379
+ int git_fs_path_prettify(git_str *path_out, const char *path, const char *base)
374
380
  {
375
381
  char buf[GIT_PATH_MAX];
376
382
 
@@ -378,8 +384,8 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
378
384
  GIT_ASSERT_ARG(path);
379
385
 
380
386
  /* construct path if needed */
381
- if (base != NULL && git_path_root(path) < 0) {
382
- if (git_buf_joinpath(path_out, base, path) < 0)
387
+ if (base != NULL && git_fs_path_root(path) < 0) {
388
+ if (git_str_joinpath(path_out, base, path) < 0)
383
389
  return -1;
384
390
  path = path_out->ptr;
385
391
  }
@@ -389,31 +395,41 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
389
395
  int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_ENOTFOUND : -1;
390
396
  git_error_set(GIT_ERROR_OS, "failed to resolve path '%s'", path);
391
397
 
392
- git_buf_clear(path_out);
398
+ git_str_clear(path_out);
393
399
 
394
400
  return error;
395
401
  }
396
402
 
397
- return git_buf_sets(path_out, buf);
403
+ return git_str_sets(path_out, buf);
398
404
  }
399
405
 
400
- int git_path_prettify_dir(git_buf *path_out, const char *path, const char *base)
406
+ int git_fs_path_prettify_dir(git_str *path_out, const char *path, const char *base)
401
407
  {
402
- int error = git_path_prettify(path_out, path, base);
403
- return (error < 0) ? error : git_path_to_dir(path_out);
408
+ int error = git_fs_path_prettify(path_out, path, base);
409
+ return (error < 0) ? error : git_fs_path_to_dir(path_out);
404
410
  }
405
411
 
406
- int git_path_to_dir(git_buf *path)
412
+ int git_fs_path_to_dir(git_str *path)
407
413
  {
408
414
  if (path->asize > 0 &&
409
- git_buf_len(path) > 0 &&
410
- path->ptr[git_buf_len(path) - 1] != '/')
411
- git_buf_putc(path, '/');
415
+ git_str_len(path) > 0 &&
416
+ path->ptr[git_str_len(path) - 1] != '/')
417
+ git_str_putc(path, '/');
418
+
419
+ return git_str_oom(path) ? -1 : 0;
420
+ }
421
+
422
+ size_t git_fs_path_dirlen(const char *path)
423
+ {
424
+ size_t len = strlen(path);
425
+
426
+ while (len > 1 && path[len - 1] == '/')
427
+ len--;
412
428
 
413
- return git_buf_oom(path) ? -1 : 0;
429
+ return len;
414
430
  }
415
431
 
416
- void git_path_string_to_dir(char *path, size_t size)
432
+ void git_fs_path_string_to_dir(char *path, size_t size)
417
433
  {
418
434
  size_t end = strlen(path);
419
435
 
@@ -423,7 +439,7 @@ void git_path_string_to_dir(char *path, size_t size)
423
439
  }
424
440
  }
425
441
 
426
- int git__percent_decode(git_buf *decoded_out, const char *input)
442
+ int git__percent_decode(git_str *decoded_out, const char *input)
427
443
  {
428
444
  int len, hi, lo, i;
429
445
 
@@ -431,7 +447,7 @@ int git__percent_decode(git_buf *decoded_out, const char *input)
431
447
  GIT_ASSERT_ARG(input);
432
448
 
433
449
  len = (int)strlen(input);
434
- git_buf_clear(decoded_out);
450
+ git_str_clear(decoded_out);
435
451
 
436
452
  for(i = 0; i < len; i++)
437
453
  {
@@ -453,7 +469,7 @@ int git__percent_decode(git_buf *decoded_out, const char *input)
453
469
  i += 2;
454
470
 
455
471
  append:
456
- if (git_buf_putc(decoded_out, c) < 0)
472
+ if (git_str_putc(decoded_out, c) < 0)
457
473
  return -1;
458
474
  }
459
475
 
@@ -480,12 +496,12 @@ static int local_file_url_prefixlen(const char *file_url)
480
496
  return len;
481
497
  }
482
498
 
483
- bool git_path_is_local_file_url(const char *file_url)
499
+ bool git_fs_path_is_local_file_url(const char *file_url)
484
500
  {
485
501
  return (local_file_url_prefixlen(file_url) > 0);
486
502
  }
487
503
 
488
- int git_path_fromurl(git_buf *local_path_out, const char *file_url)
504
+ int git_fs_path_fromurl(git_str *local_path_out, const char *file_url)
489
505
  {
490
506
  int offset;
491
507
 
@@ -500,18 +516,18 @@ int git_path_fromurl(git_buf *local_path_out, const char *file_url)
500
516
  offset--; /* A *nix absolute path starts with a forward slash */
501
517
  #endif
502
518
 
503
- git_buf_clear(local_path_out);
519
+ git_str_clear(local_path_out);
504
520
  return git__percent_decode(local_path_out, file_url + offset);
505
521
  }
506
522
 
507
- int git_path_walk_up(
508
- git_buf *path,
523
+ int git_fs_path_walk_up(
524
+ git_str *path,
509
525
  const char *ceiling,
510
526
  int (*cb)(void *data, const char *),
511
527
  void *data)
512
528
  {
513
529
  int error = 0;
514
- git_buf iter;
530
+ git_str iter;
515
531
  ssize_t stop = 0, scan;
516
532
  char oldc = '\0';
517
533
 
@@ -522,20 +538,20 @@ int git_path_walk_up(
522
538
  if (git__prefixcmp(path->ptr, ceiling) == 0)
523
539
  stop = (ssize_t)strlen(ceiling);
524
540
  else
525
- stop = git_buf_len(path);
541
+ stop = git_str_len(path);
526
542
  }
527
- scan = git_buf_len(path);
543
+ scan = git_str_len(path);
528
544
 
529
545
  /* empty path: yield only once */
530
546
  if (!scan) {
531
547
  error = cb(data, "");
532
548
  if (error)
533
- git_error_set_after_callback(error);
549
+ ensure_error_set(error);
534
550
  return error;
535
551
  }
536
552
 
537
553
  iter.ptr = path->ptr;
538
- iter.size = git_buf_len(path);
554
+ iter.size = git_str_len(path);
539
555
  iter.asize = path->asize;
540
556
 
541
557
  while (scan >= stop) {
@@ -543,11 +559,11 @@ int git_path_walk_up(
543
559
  iter.ptr[scan] = oldc;
544
560
 
545
561
  if (error) {
546
- git_error_set_after_callback(error);
562
+ ensure_error_set(error);
547
563
  break;
548
564
  }
549
565
 
550
- scan = git_buf_rfind_next(&iter, '/');
566
+ scan = git_str_rfind_next(&iter, '/');
551
567
  if (scan >= 0) {
552
568
  scan++;
553
569
  oldc = iter.ptr[scan];
@@ -563,19 +579,19 @@ int git_path_walk_up(
563
579
  if (!error && stop == 0 && iter.ptr[0] != '/') {
564
580
  error = cb(data, "");
565
581
  if (error)
566
- git_error_set_after_callback(error);
582
+ ensure_error_set(error);
567
583
  }
568
584
 
569
585
  return error;
570
586
  }
571
587
 
572
- bool git_path_exists(const char *path)
588
+ bool git_fs_path_exists(const char *path)
573
589
  {
574
590
  GIT_ASSERT_ARG_WITH_RETVAL(path, false);
575
591
  return p_access(path, F_OK) == 0;
576
592
  }
577
593
 
578
- bool git_path_isdir(const char *path)
594
+ bool git_fs_path_isdir(const char *path)
579
595
  {
580
596
  struct stat st;
581
597
  if (p_stat(path, &st) < 0)
@@ -584,7 +600,7 @@ bool git_path_isdir(const char *path)
584
600
  return S_ISDIR(st.st_mode) != 0;
585
601
  }
586
602
 
587
- bool git_path_isfile(const char *path)
603
+ bool git_fs_path_isfile(const char *path)
588
604
  {
589
605
  struct stat st;
590
606
 
@@ -595,7 +611,7 @@ bool git_path_isfile(const char *path)
595
611
  return S_ISREG(st.st_mode) != 0;
596
612
  }
597
613
 
598
- bool git_path_islink(const char *path)
614
+ bool git_fs_path_islink(const char *path)
599
615
  {
600
616
  struct stat st;
601
617
 
@@ -608,7 +624,7 @@ bool git_path_islink(const char *path)
608
624
 
609
625
  #ifdef GIT_WIN32
610
626
 
611
- bool git_path_is_empty_dir(const char *path)
627
+ bool git_fs_path_is_empty_dir(const char *path)
612
628
  {
613
629
  git_win32_path filter_w;
614
630
  bool empty = false;
@@ -627,7 +643,7 @@ bool git_path_is_empty_dir(const char *path)
627
643
  * (a mount point).
628
644
  */
629
645
  if (hFind == INVALID_HANDLE_VALUE)
630
- return git_path_isdir(path);
646
+ return git_fs_path_isdir(path);
631
647
 
632
648
  /* If the find handle was created successfully, then it's a directory */
633
649
  empty = true;
@@ -637,7 +653,7 @@ bool git_path_is_empty_dir(const char *path)
637
653
  * empty. In the special case of drive roots (i.e. C:\) where . and
638
654
  * .. do not occur, we can still consider the path to be an empty
639
655
  * directory if there's nothing there. */
640
- if (!git_path_is_dot_or_dotdotW(findData.cFileName)) {
656
+ if (!git_fs_path_is_dot_or_dotdotW(findData.cFileName)) {
641
657
  empty = false;
642
658
  break;
643
659
  }
@@ -651,33 +667,33 @@ bool git_path_is_empty_dir(const char *path)
651
667
 
652
668
  #else
653
669
 
654
- static int path_found_entry(void *payload, git_buf *path)
670
+ static int path_found_entry(void *payload, git_str *path)
655
671
  {
656
672
  GIT_UNUSED(payload);
657
- return !git_path_is_dot_or_dotdot(path->ptr);
673
+ return !git_fs_path_is_dot_or_dotdot(path->ptr);
658
674
  }
659
675
 
660
- bool git_path_is_empty_dir(const char *path)
676
+ bool git_fs_path_is_empty_dir(const char *path)
661
677
  {
662
678
  int error;
663
- git_buf dir = GIT_BUF_INIT;
679
+ git_str dir = GIT_STR_INIT;
664
680
 
665
- if (!git_path_isdir(path))
681
+ if (!git_fs_path_isdir(path))
666
682
  return false;
667
683
 
668
- if ((error = git_buf_sets(&dir, path)) != 0)
684
+ if ((error = git_str_sets(&dir, path)) != 0)
669
685
  git_error_clear();
670
686
  else
671
- error = git_path_direach(&dir, 0, path_found_entry, NULL);
687
+ error = git_fs_path_direach(&dir, 0, path_found_entry, NULL);
672
688
 
673
- git_buf_dispose(&dir);
689
+ git_str_dispose(&dir);
674
690
 
675
691
  return !error;
676
692
  }
677
693
 
678
694
  #endif
679
695
 
680
- int git_path_set_error(int errno_value, const char *path, const char *action)
696
+ int git_fs_path_set_error(int errno_value, const char *path, const char *action)
681
697
  {
682
698
  switch (errno_value) {
683
699
  case ENOENT:
@@ -704,87 +720,87 @@ int git_path_set_error(int errno_value, const char *path, const char *action)
704
720
  }
705
721
  }
706
722
 
707
- int git_path_lstat(const char *path, struct stat *st)
723
+ int git_fs_path_lstat(const char *path, struct stat *st)
708
724
  {
709
725
  if (p_lstat(path, st) == 0)
710
726
  return 0;
711
727
 
712
- return git_path_set_error(errno, path, "stat");
728
+ return git_fs_path_set_error(errno, path, "stat");
713
729
  }
714
730
 
715
731
  static bool _check_dir_contents(
716
- git_buf *dir,
732
+ git_str *dir,
717
733
  const char *sub,
718
734
  bool (*predicate)(const char *))
719
735
  {
720
736
  bool result;
721
- size_t dir_size = git_buf_len(dir);
737
+ size_t dir_size = git_str_len(dir);
722
738
  size_t sub_size = strlen(sub);
723
739
  size_t alloc_size;
724
740
 
725
741
  /* leave base valid even if we could not make space for subdir */
726
742
  if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, dir_size, sub_size) ||
727
743
  GIT_ADD_SIZET_OVERFLOW(&alloc_size, alloc_size, 2) ||
728
- git_buf_try_grow(dir, alloc_size, false) < 0)
744
+ git_str_try_grow(dir, alloc_size, false) < 0)
729
745
  return false;
730
746
 
731
747
  /* save excursion */
732
- if (git_buf_joinpath(dir, dir->ptr, sub) < 0)
748
+ if (git_str_joinpath(dir, dir->ptr, sub) < 0)
733
749
  return false;
734
750
 
735
751
  result = predicate(dir->ptr);
736
752
 
737
753
  /* restore path */
738
- git_buf_truncate(dir, dir_size);
754
+ git_str_truncate(dir, dir_size);
739
755
  return result;
740
756
  }
741
757
 
742
- bool git_path_contains(git_buf *dir, const char *item)
758
+ bool git_fs_path_contains(git_str *dir, const char *item)
743
759
  {
744
- return _check_dir_contents(dir, item, &git_path_exists);
760
+ return _check_dir_contents(dir, item, &git_fs_path_exists);
745
761
  }
746
762
 
747
- bool git_path_contains_dir(git_buf *base, const char *subdir)
763
+ bool git_fs_path_contains_dir(git_str *base, const char *subdir)
748
764
  {
749
- return _check_dir_contents(base, subdir, &git_path_isdir);
765
+ return _check_dir_contents(base, subdir, &git_fs_path_isdir);
750
766
  }
751
767
 
752
- bool git_path_contains_file(git_buf *base, const char *file)
768
+ bool git_fs_path_contains_file(git_str *base, const char *file)
753
769
  {
754
- return _check_dir_contents(base, file, &git_path_isfile);
770
+ return _check_dir_contents(base, file, &git_fs_path_isfile);
755
771
  }
756
772
 
757
- int git_path_find_dir(git_buf *dir)
773
+ int git_fs_path_find_dir(git_str *dir)
758
774
  {
759
775
  int error = 0;
760
776
  char buf[GIT_PATH_MAX];
761
777
 
762
778
  if (p_realpath(dir->ptr, buf) != NULL)
763
- error = git_buf_sets(dir, buf);
779
+ error = git_str_sets(dir, buf);
764
780
 
765
781
  /* call dirname if this is not a directory */
766
- if (!error) /* && git_path_isdir(dir->ptr) == false) */
767
- error = (git_path_dirname_r(dir, dir->ptr) < 0) ? -1 : 0;
782
+ if (!error) /* && git_fs_path_isdir(dir->ptr) == false) */
783
+ error = (git_fs_path_dirname_r(dir, dir->ptr) < 0) ? -1 : 0;
768
784
 
769
785
  if (!error)
770
- error = git_path_to_dir(dir);
786
+ error = git_fs_path_to_dir(dir);
771
787
 
772
788
  return error;
773
789
  }
774
790
 
775
- int git_path_resolve_relative(git_buf *path, size_t ceiling)
791
+ int git_fs_path_resolve_relative(git_str *path, size_t ceiling)
776
792
  {
777
793
  char *base, *to, *from, *next;
778
794
  size_t len;
779
795
 
780
- GIT_ERROR_CHECK_ALLOC_BUF(path);
796
+ GIT_ERROR_CHECK_ALLOC_STR(path);
781
797
 
782
798
  if (ceiling > path->size)
783
799
  ceiling = path->size;
784
800
 
785
801
  /* recognize drive prefixes, etc. that should not be backed over */
786
802
  if (ceiling == 0)
787
- ceiling = git_path_root(path->ptr) + 1;
803
+ ceiling = git_fs_path_root(path->ptr) + 1;
788
804
 
789
805
  /* recognize URL prefixes that should not be backed over */
790
806
  if (ceiling == 0) {
@@ -851,13 +867,13 @@ int git_path_resolve_relative(git_buf *path, size_t ceiling)
851
867
  return 0;
852
868
  }
853
869
 
854
- int git_path_apply_relative(git_buf *target, const char *relpath)
870
+ int git_fs_path_apply_relative(git_str *target, const char *relpath)
855
871
  {
856
- return git_buf_joinpath(target, git_buf_cstr(target), relpath) ||
857
- git_path_resolve_relative(target, 0);
872
+ return git_str_joinpath(target, git_str_cstr(target), relpath) ||
873
+ git_fs_path_resolve_relative(target, 0);
858
874
  }
859
875
 
860
- int git_path_cmp(
876
+ int git_fs_path_cmp(
861
877
  const char *name1, size_t len1, int isdir1,
862
878
  const char *name2, size_t len2, int isdir2,
863
879
  int (*compare)(const char *, const char *, size_t))
@@ -882,7 +898,7 @@ int git_path_cmp(
882
898
  return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
883
899
  }
884
900
 
885
- size_t git_path_common_dirlen(const char *one, const char *two)
901
+ size_t git_fs_path_common_dirlen(const char *one, const char *two)
886
902
  {
887
903
  const char *p, *q, *dirsep = NULL;
888
904
 
@@ -896,7 +912,7 @@ size_t git_path_common_dirlen(const char *one, const char *two)
896
912
  return dirsep ? (dirsep - one) + 1 : 0;
897
913
  }
898
914
 
899
- int git_path_make_relative(git_buf *path, const char *parent)
915
+ int git_fs_path_make_relative(git_str *path, const char *parent)
900
916
  {
901
917
  const char *p, *q, *p_dirsep, *q_dirsep;
902
918
  size_t plen = path->size, newlen, alloclen, depth = 1, i, offset;
@@ -923,7 +939,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
923
939
  else if (!*p && *q == '/')
924
940
  q++;
925
941
  else if (!*p && !*q)
926
- return git_buf_clear(path), 0;
942
+ return git_str_clear(path), 0;
927
943
  else {
928
944
  p = p_dirsep + 1;
929
945
  q = q_dirsep + 1;
@@ -932,7 +948,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
932
948
  plen -= (p - path->ptr);
933
949
 
934
950
  if (!*q)
935
- return git_buf_set(path, p, plen);
951
+ return git_str_set(path, p, plen);
936
952
 
937
953
  for (; (q = strchr(q, '/')) && *(q + 1); q++)
938
954
  depth++;
@@ -944,7 +960,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
944
960
 
945
961
  /* save the offset as we might realllocate the pointer */
946
962
  offset = p - path->ptr;
947
- if (git_buf_try_grow(path, alloclen, 1) < 0)
963
+ if (git_str_try_grow(path, alloclen, 1) < 0)
948
964
  return -1;
949
965
  p = path->ptr + offset;
950
966
 
@@ -957,7 +973,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
957
973
  return 0;
958
974
  }
959
975
 
960
- bool git_path_has_non_ascii(const char *path, size_t pathlen)
976
+ bool git_fs_path_has_non_ascii(const char *path, size_t pathlen)
961
977
  {
962
978
  const uint8_t *scan = (const uint8_t *)path, *end;
963
979
 
@@ -970,37 +986,37 @@ bool git_path_has_non_ascii(const char *path, size_t pathlen)
970
986
 
971
987
  #ifdef GIT_USE_ICONV
972
988
 
973
- int git_path_iconv_init_precompose(git_path_iconv_t *ic)
989
+ int git_fs_path_iconv_init_precompose(git_fs_path_iconv_t *ic)
974
990
  {
975
- git_buf_init(&ic->buf, 0);
991
+ git_str_init(&ic->buf, 0);
976
992
  ic->map = iconv_open(GIT_PATH_REPO_ENCODING, GIT_PATH_NATIVE_ENCODING);
977
993
  return 0;
978
994
  }
979
995
 
980
- void git_path_iconv_clear(git_path_iconv_t *ic)
996
+ void git_fs_path_iconv_clear(git_fs_path_iconv_t *ic)
981
997
  {
982
998
  if (ic) {
983
999
  if (ic->map != (iconv_t)-1)
984
1000
  iconv_close(ic->map);
985
- git_buf_dispose(&ic->buf);
1001
+ git_str_dispose(&ic->buf);
986
1002
  }
987
1003
  }
988
1004
 
989
- int git_path_iconv(git_path_iconv_t *ic, const char **in, size_t *inlen)
1005
+ int git_fs_path_iconv(git_fs_path_iconv_t *ic, const char **in, size_t *inlen)
990
1006
  {
991
1007
  char *nfd = (char*)*in, *nfc;
992
1008
  size_t nfdlen = *inlen, nfclen, wantlen = nfdlen, alloclen, rv;
993
1009
  int retry = 1;
994
1010
 
995
1011
  if (!ic || ic->map == (iconv_t)-1 ||
996
- !git_path_has_non_ascii(*in, *inlen))
1012
+ !git_fs_path_has_non_ascii(*in, *inlen))
997
1013
  return 0;
998
1014
 
999
- git_buf_clear(&ic->buf);
1015
+ git_str_clear(&ic->buf);
1000
1016
 
1001
1017
  while (1) {
1002
1018
  GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, wantlen, 1);
1003
- if (git_buf_grow(&ic->buf, alloclen) < 0)
1019
+ if (git_str_grow(&ic->buf, alloclen) < 0)
1004
1020
  return -1;
1005
1021
 
1006
1022
  nfc = ic->buf.ptr + ic->buf.size;
@@ -1040,8 +1056,8 @@ fail:
1040
1056
  return -1;
1041
1057
  }
1042
1058
 
1043
- static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D.XXXXXX";
1044
- static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX";
1059
+ static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
1060
+ static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
1045
1061
 
1046
1062
  /* Check if the platform is decomposing unicode data for us. We will
1047
1063
  * emulate core Git and prefer to use precomposed unicode data internally
@@ -1052,47 +1068,50 @@ static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX";
1052
1068
  * return decomposed unicode from readdir() even when the actual
1053
1069
  * filesystem is storing precomposed unicode.
1054
1070
  */
1055
- bool git_path_does_fs_decompose_unicode(const char *root)
1071
+ bool git_fs_path_does_decompose_unicode(const char *root)
1056
1072
  {
1057
- git_buf path = GIT_BUF_INIT;
1073
+ git_str nfc_path = GIT_STR_INIT;
1074
+ git_str nfd_path = GIT_STR_INIT;
1058
1075
  int fd;
1059
1076
  bool found_decomposed = false;
1060
- char tmp[6];
1077
+ size_t orig_len;
1078
+ const char *trailer;
1061
1079
 
1062
1080
  /* Create a file using a precomposed path and then try to find it
1063
1081
  * using the decomposed name. If the lookup fails, then we will mark
1064
1082
  * that we should precompose unicode for this repository.
1065
1083
  */
1066
- if (git_buf_joinpath(&path, root, nfc_file) < 0 ||
1067
- (fd = p_mkstemp(path.ptr)) < 0)
1084
+ if (git_str_joinpath(&nfc_path, root, nfc_file) < 0)
1085
+ goto done;
1086
+
1087
+ /* record original path length before trailer */
1088
+ orig_len = nfc_path.size;
1089
+
1090
+ if ((fd = git_futils_mktmp(&nfc_path, nfc_path.ptr, 0666)) < 0)
1068
1091
  goto done;
1069
1092
  p_close(fd);
1070
1093
 
1071
- /* record trailing digits generated by mkstemp */
1072
- memcpy(tmp, path.ptr + path.size - sizeof(tmp), sizeof(tmp));
1094
+ trailer = nfc_path.ptr + orig_len;
1073
1095
 
1074
1096
  /* try to look up as NFD path */
1075
- if (git_buf_joinpath(&path, root, nfd_file) < 0)
1097
+ if (git_str_joinpath(&nfd_path, root, nfd_file) < 0 ||
1098
+ git_str_puts(&nfd_path, trailer) < 0)
1076
1099
  goto done;
1077
- memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp));
1078
1100
 
1079
- found_decomposed = git_path_exists(path.ptr);
1101
+ found_decomposed = git_fs_path_exists(nfd_path.ptr);
1080
1102
 
1081
1103
  /* remove temporary file (using original precomposed path) */
1082
- if (git_buf_joinpath(&path, root, nfc_file) < 0)
1083
- goto done;
1084
- memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp));
1085
-
1086
- (void)p_unlink(path.ptr);
1104
+ (void)p_unlink(nfc_path.ptr);
1087
1105
 
1088
1106
  done:
1089
- git_buf_dispose(&path);
1107
+ git_str_dispose(&nfc_path);
1108
+ git_str_dispose(&nfd_path);
1090
1109
  return found_decomposed;
1091
1110
  }
1092
1111
 
1093
1112
  #else
1094
1113
 
1095
- bool git_path_does_fs_decompose_unicode(const char *root)
1114
+ bool git_fs_path_does_decompose_unicode(const char *root)
1096
1115
  {
1097
1116
  GIT_UNUSED(root);
1098
1117
  return false;
@@ -1106,10 +1125,10 @@ typedef char path_dirent_data[sizeof(struct dirent) + FILENAME_MAX + 1];
1106
1125
  typedef struct dirent path_dirent_data;
1107
1126
  #endif
1108
1127
 
1109
- int git_path_direach(
1110
- git_buf *path,
1128
+ int git_fs_path_direach(
1129
+ git_str *path,
1111
1130
  uint32_t flags,
1112
- int (*fn)(void *, git_buf *),
1131
+ int (*fn)(void *, git_str *),
1113
1132
  void *arg)
1114
1133
  {
1115
1134
  int error = 0;
@@ -1118,15 +1137,15 @@ int git_path_direach(
1118
1137
  struct dirent *de;
1119
1138
 
1120
1139
  #ifdef GIT_USE_ICONV
1121
- git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
1140
+ git_fs_path_iconv_t ic = GIT_PATH_ICONV_INIT;
1122
1141
  #endif
1123
1142
 
1124
1143
  GIT_UNUSED(flags);
1125
1144
 
1126
- if (git_path_to_dir(path) < 0)
1145
+ if (git_fs_path_to_dir(path) < 0)
1127
1146
  return -1;
1128
1147
 
1129
- wd_len = git_buf_len(path);
1148
+ wd_len = git_str_len(path);
1130
1149
 
1131
1150
  if ((dir = opendir(path->ptr)) == NULL) {
1132
1151
  git_error_set(GIT_ERROR_OS, "failed to open directory '%s'", path->ptr);
@@ -1137,34 +1156,34 @@ int git_path_direach(
1137
1156
  }
1138
1157
 
1139
1158
  #ifdef GIT_USE_ICONV
1140
- if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
1141
- (void)git_path_iconv_init_precompose(&ic);
1159
+ if ((flags & GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
1160
+ (void)git_fs_path_iconv_init_precompose(&ic);
1142
1161
  #endif
1143
1162
 
1144
1163
  while ((de = readdir(dir)) != NULL) {
1145
1164
  const char *de_path = de->d_name;
1146
1165
  size_t de_len = strlen(de_path);
1147
1166
 
1148
- if (git_path_is_dot_or_dotdot(de_path))
1167
+ if (git_fs_path_is_dot_or_dotdot(de_path))
1149
1168
  continue;
1150
1169
 
1151
1170
  #ifdef GIT_USE_ICONV
1152
- if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0)
1171
+ if ((error = git_fs_path_iconv(&ic, &de_path, &de_len)) < 0)
1153
1172
  break;
1154
1173
  #endif
1155
1174
 
1156
- if ((error = git_buf_put(path, de_path, de_len)) < 0)
1175
+ if ((error = git_str_put(path, de_path, de_len)) < 0)
1157
1176
  break;
1158
1177
 
1159
1178
  git_error_clear();
1160
1179
  error = fn(arg, path);
1161
1180
 
1162
- git_buf_truncate(path, wd_len); /* restore path */
1181
+ git_str_truncate(path, wd_len); /* restore path */
1163
1182
 
1164
1183
  /* Only set our own error if the callback did not set one already */
1165
1184
  if (error != 0) {
1166
1185
  if (!git_error_last())
1167
- git_error_set_after_callback(error);
1186
+ ensure_error_set(error);
1168
1187
 
1169
1188
  break;
1170
1189
  }
@@ -1173,7 +1192,7 @@ int git_path_direach(
1173
1192
  closedir(dir);
1174
1193
 
1175
1194
  #ifdef GIT_USE_ICONV
1176
- git_path_iconv_clear(&ic);
1195
+ git_fs_path_iconv_clear(&ic);
1177
1196
  #endif
1178
1197
 
1179
1198
  return error;
@@ -1188,8 +1207,8 @@ int git_path_direach(
1188
1207
  # define FIND_FIRST_EX_LARGE_FETCH 2
1189
1208
  #endif
1190
1209
 
1191
- int git_path_diriter_init(
1192
- git_path_diriter *diriter,
1210
+ int git_fs_path_diriter_init(
1211
+ git_fs_path_diriter *diriter,
1193
1212
  const char *path,
1194
1213
  unsigned int flags)
1195
1214
  {
@@ -1202,10 +1221,10 @@ int git_path_diriter_init(
1202
1221
  GIT_ASSERT_ARG(diriter);
1203
1222
  GIT_ASSERT_ARG(path);
1204
1223
 
1205
- memset(diriter, 0, sizeof(git_path_diriter));
1224
+ memset(diriter, 0, sizeof(git_fs_path_diriter));
1206
1225
  diriter->handle = INVALID_HANDLE_VALUE;
1207
1226
 
1208
- if (git_buf_puts(&diriter->path_utf8, path) < 0)
1227
+ if (git_str_puts(&diriter->path_utf8, path) < 0)
1209
1228
  return -1;
1210
1229
 
1211
1230
  path_trim_slashes(&diriter->path_utf8);
@@ -1239,7 +1258,7 @@ int git_path_diriter_init(
1239
1258
  return 0;
1240
1259
  }
1241
1260
 
1242
- static int diriter_update_paths(git_path_diriter *diriter)
1261
+ static int diriter_update_paths(git_fs_path_diriter *diriter)
1243
1262
  {
1244
1263
  size_t filename_len, path_len;
1245
1264
 
@@ -1261,23 +1280,23 @@ static int diriter_update_paths(git_path_diriter *diriter)
1261
1280
  diriter->current.cFileName, filename_len * sizeof(wchar_t));
1262
1281
  diriter->path[path_len-1] = L'\0';
1263
1282
 
1264
- git_buf_truncate(&diriter->path_utf8, diriter->parent_utf8_len);
1283
+ git_str_truncate(&diriter->path_utf8, diriter->parent_utf8_len);
1265
1284
 
1266
1285
  if (diriter->parent_utf8_len > 0 &&
1267
1286
  diriter->path_utf8.ptr[diriter->parent_utf8_len-1] != '/')
1268
- git_buf_putc(&diriter->path_utf8, '/');
1287
+ git_str_putc(&diriter->path_utf8, '/');
1269
1288
 
1270
- git_buf_put_w(&diriter->path_utf8, diriter->current.cFileName, filename_len);
1289
+ git_str_put_w(&diriter->path_utf8, diriter->current.cFileName, filename_len);
1271
1290
 
1272
- if (git_buf_oom(&diriter->path_utf8))
1291
+ if (git_str_oom(&diriter->path_utf8))
1273
1292
  return -1;
1274
1293
 
1275
1294
  return 0;
1276
1295
  }
1277
1296
 
1278
- int git_path_diriter_next(git_path_diriter *diriter)
1297
+ int git_fs_path_diriter_next(git_fs_path_diriter *diriter)
1279
1298
  {
1280
- bool skip_dot = !(diriter->flags & GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
1299
+ bool skip_dot = !(diriter->flags & GIT_FS_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
1281
1300
 
1282
1301
  do {
1283
1302
  /* Our first time through, we already have the data from
@@ -1287,7 +1306,7 @@ int git_path_diriter_next(git_path_diriter *diriter)
1287
1306
  diriter->needs_next = 1;
1288
1307
  else if (!FindNextFileW(diriter->handle, &diriter->current))
1289
1308
  return GIT_ITEROVER;
1290
- } while (skip_dot && git_path_is_dot_or_dotdotW(diriter->current.cFileName));
1309
+ } while (skip_dot && git_fs_path_is_dot_or_dotdotW(diriter->current.cFileName));
1291
1310
 
1292
1311
  if (diriter_update_paths(diriter) < 0)
1293
1312
  return -1;
@@ -1295,10 +1314,10 @@ int git_path_diriter_next(git_path_diriter *diriter)
1295
1314
  return 0;
1296
1315
  }
1297
1316
 
1298
- int git_path_diriter_filename(
1317
+ int git_fs_path_diriter_filename(
1299
1318
  const char **out,
1300
1319
  size_t *out_len,
1301
- git_path_diriter *diriter)
1320
+ git_fs_path_diriter *diriter)
1302
1321
  {
1303
1322
  GIT_ASSERT_ARG(out);
1304
1323
  GIT_ASSERT_ARG(out_len);
@@ -1310,10 +1329,10 @@ int git_path_diriter_filename(
1310
1329
  return 0;
1311
1330
  }
1312
1331
 
1313
- int git_path_diriter_fullpath(
1332
+ int git_fs_path_diriter_fullpath(
1314
1333
  const char **out,
1315
1334
  size_t *out_len,
1316
- git_path_diriter *diriter)
1335
+ git_fs_path_diriter *diriter)
1317
1336
  {
1318
1337
  GIT_ASSERT_ARG(out);
1319
1338
  GIT_ASSERT_ARG(out_len);
@@ -1324,7 +1343,7 @@ int git_path_diriter_fullpath(
1324
1343
  return 0;
1325
1344
  }
1326
1345
 
1327
- int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter)
1346
+ int git_fs_path_diriter_stat(struct stat *out, git_fs_path_diriter *diriter)
1328
1347
  {
1329
1348
  GIT_ASSERT_ARG(out);
1330
1349
  GIT_ASSERT_ARG(diriter);
@@ -1334,12 +1353,12 @@ int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter)
1334
1353
  diriter->path);
1335
1354
  }
1336
1355
 
1337
- void git_path_diriter_free(git_path_diriter *diriter)
1356
+ void git_fs_path_diriter_free(git_fs_path_diriter *diriter)
1338
1357
  {
1339
1358
  if (diriter == NULL)
1340
1359
  return;
1341
1360
 
1342
- git_buf_dispose(&diriter->path_utf8);
1361
+ git_str_dispose(&diriter->path_utf8);
1343
1362
 
1344
1363
  if (diriter->handle != INVALID_HANDLE_VALUE) {
1345
1364
  FindClose(diriter->handle);
@@ -1349,17 +1368,17 @@ void git_path_diriter_free(git_path_diriter *diriter)
1349
1368
 
1350
1369
  #else
1351
1370
 
1352
- int git_path_diriter_init(
1353
- git_path_diriter *diriter,
1371
+ int git_fs_path_diriter_init(
1372
+ git_fs_path_diriter *diriter,
1354
1373
  const char *path,
1355
1374
  unsigned int flags)
1356
1375
  {
1357
1376
  GIT_ASSERT_ARG(diriter);
1358
1377
  GIT_ASSERT_ARG(path);
1359
1378
 
1360
- memset(diriter, 0, sizeof(git_path_diriter));
1379
+ memset(diriter, 0, sizeof(git_fs_path_diriter));
1361
1380
 
1362
- if (git_buf_puts(&diriter->path, path) < 0)
1381
+ if (git_str_puts(&diriter->path, path) < 0)
1363
1382
  return -1;
1364
1383
 
1365
1384
  path_trim_slashes(&diriter->path);
@@ -1370,15 +1389,15 @@ int git_path_diriter_init(
1370
1389
  }
1371
1390
 
1372
1391
  if ((diriter->dir = opendir(diriter->path.ptr)) == NULL) {
1373
- git_buf_dispose(&diriter->path);
1392
+ git_str_dispose(&diriter->path);
1374
1393
 
1375
1394
  git_error_set(GIT_ERROR_OS, "failed to open directory '%s'", path);
1376
1395
  return -1;
1377
1396
  }
1378
1397
 
1379
1398
  #ifdef GIT_USE_ICONV
1380
- if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
1381
- (void)git_path_iconv_init_precompose(&diriter->ic);
1399
+ if ((flags & GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
1400
+ (void)git_fs_path_iconv_init_precompose(&diriter->ic);
1382
1401
  #endif
1383
1402
 
1384
1403
  diriter->parent_len = diriter->path.size;
@@ -1387,12 +1406,12 @@ int git_path_diriter_init(
1387
1406
  return 0;
1388
1407
  }
1389
1408
 
1390
- int git_path_diriter_next(git_path_diriter *diriter)
1409
+ int git_fs_path_diriter_next(git_fs_path_diriter *diriter)
1391
1410
  {
1392
1411
  struct dirent *de;
1393
1412
  const char *filename;
1394
1413
  size_t filename_len;
1395
- bool skip_dot = !(diriter->flags & GIT_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
1414
+ bool skip_dot = !(diriter->flags & GIT_FS_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
1396
1415
  int error = 0;
1397
1416
 
1398
1417
  GIT_ASSERT_ARG(diriter);
@@ -1408,35 +1427,35 @@ int git_path_diriter_next(git_path_diriter *diriter)
1408
1427
  "could not read directory '%s'", diriter->path.ptr);
1409
1428
  return -1;
1410
1429
  }
1411
- } while (skip_dot && git_path_is_dot_or_dotdot(de->d_name));
1430
+ } while (skip_dot && git_fs_path_is_dot_or_dotdot(de->d_name));
1412
1431
 
1413
1432
  filename = de->d_name;
1414
1433
  filename_len = strlen(filename);
1415
1434
 
1416
1435
  #ifdef GIT_USE_ICONV
1417
- if ((diriter->flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0 &&
1418
- (error = git_path_iconv(&diriter->ic, &filename, &filename_len)) < 0)
1436
+ if ((diriter->flags & GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE) != 0 &&
1437
+ (error = git_fs_path_iconv(&diriter->ic, &filename, &filename_len)) < 0)
1419
1438
  return error;
1420
1439
  #endif
1421
1440
 
1422
- git_buf_truncate(&diriter->path, diriter->parent_len);
1441
+ git_str_truncate(&diriter->path, diriter->parent_len);
1423
1442
 
1424
1443
  if (diriter->parent_len > 0 &&
1425
1444
  diriter->path.ptr[diriter->parent_len-1] != '/')
1426
- git_buf_putc(&diriter->path, '/');
1445
+ git_str_putc(&diriter->path, '/');
1427
1446
 
1428
- git_buf_put(&diriter->path, filename, filename_len);
1447
+ git_str_put(&diriter->path, filename, filename_len);
1429
1448
 
1430
- if (git_buf_oom(&diriter->path))
1449
+ if (git_str_oom(&diriter->path))
1431
1450
  return -1;
1432
1451
 
1433
1452
  return error;
1434
1453
  }
1435
1454
 
1436
- int git_path_diriter_filename(
1455
+ int git_fs_path_diriter_filename(
1437
1456
  const char **out,
1438
1457
  size_t *out_len,
1439
- git_path_diriter *diriter)
1458
+ git_fs_path_diriter *diriter)
1440
1459
  {
1441
1460
  GIT_ASSERT_ARG(out);
1442
1461
  GIT_ASSERT_ARG(out_len);
@@ -1448,10 +1467,10 @@ int git_path_diriter_filename(
1448
1467
  return 0;
1449
1468
  }
1450
1469
 
1451
- int git_path_diriter_fullpath(
1470
+ int git_fs_path_diriter_fullpath(
1452
1471
  const char **out,
1453
1472
  size_t *out_len,
1454
- git_path_diriter *diriter)
1473
+ git_fs_path_diriter *diriter)
1455
1474
  {
1456
1475
  GIT_ASSERT_ARG(out);
1457
1476
  GIT_ASSERT_ARG(out_len);
@@ -1462,15 +1481,15 @@ int git_path_diriter_fullpath(
1462
1481
  return 0;
1463
1482
  }
1464
1483
 
1465
- int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter)
1484
+ int git_fs_path_diriter_stat(struct stat *out, git_fs_path_diriter *diriter)
1466
1485
  {
1467
1486
  GIT_ASSERT_ARG(out);
1468
1487
  GIT_ASSERT_ARG(diriter);
1469
1488
 
1470
- return git_path_lstat(diriter->path.ptr, out);
1489
+ return git_fs_path_lstat(diriter->path.ptr, out);
1471
1490
  }
1472
1491
 
1473
- void git_path_diriter_free(git_path_diriter *diriter)
1492
+ void git_fs_path_diriter_free(git_fs_path_diriter *diriter)
1474
1493
  {
1475
1494
  if (diriter == NULL)
1476
1495
  return;
@@ -1481,21 +1500,21 @@ void git_path_diriter_free(git_path_diriter *diriter)
1481
1500
  }
1482
1501
 
1483
1502
  #ifdef GIT_USE_ICONV
1484
- git_path_iconv_clear(&diriter->ic);
1503
+ git_fs_path_iconv_clear(&diriter->ic);
1485
1504
  #endif
1486
1505
 
1487
- git_buf_dispose(&diriter->path);
1506
+ git_str_dispose(&diriter->path);
1488
1507
  }
1489
1508
 
1490
1509
  #endif
1491
1510
 
1492
- int git_path_dirload(
1511
+ int git_fs_path_dirload(
1493
1512
  git_vector *contents,
1494
1513
  const char *path,
1495
1514
  size_t prefix_len,
1496
1515
  uint32_t flags)
1497
1516
  {
1498
- git_path_diriter iter = GIT_PATH_DIRITER_INIT;
1517
+ git_fs_path_diriter iter = GIT_FS_PATH_DIRITER_INIT;
1499
1518
  const char *name;
1500
1519
  size_t name_len;
1501
1520
  char *dup;
@@ -1504,11 +1523,11 @@ int git_path_dirload(
1504
1523
  GIT_ASSERT_ARG(contents);
1505
1524
  GIT_ASSERT_ARG(path);
1506
1525
 
1507
- if ((error = git_path_diriter_init(&iter, path, flags)) < 0)
1526
+ if ((error = git_fs_path_diriter_init(&iter, path, flags)) < 0)
1508
1527
  return error;
1509
1528
 
1510
- while ((error = git_path_diriter_next(&iter)) == 0) {
1511
- if ((error = git_path_diriter_fullpath(&name, &name_len, &iter)) < 0)
1529
+ while ((error = git_fs_path_diriter_next(&iter)) == 0) {
1530
+ if ((error = git_fs_path_diriter_fullpath(&name, &name_len, &iter)) < 0)
1512
1531
  break;
1513
1532
 
1514
1533
  GIT_ASSERT(name_len > prefix_len);
@@ -1523,22 +1542,22 @@ int git_path_dirload(
1523
1542
  if (error == GIT_ITEROVER)
1524
1543
  error = 0;
1525
1544
 
1526
- git_path_diriter_free(&iter);
1545
+ git_fs_path_diriter_free(&iter);
1527
1546
  return error;
1528
1547
  }
1529
1548
 
1530
- int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path)
1549
+ int git_fs_path_from_url_or_path(git_str *local_path_out, const char *url_or_path)
1531
1550
  {
1532
- if (git_path_is_local_file_url(url_or_path))
1533
- return git_path_fromurl(local_path_out, url_or_path);
1551
+ if (git_fs_path_is_local_file_url(url_or_path))
1552
+ return git_fs_path_fromurl(local_path_out, url_or_path);
1534
1553
  else
1535
- return git_buf_sets(local_path_out, url_or_path);
1554
+ return git_str_sets(local_path_out, url_or_path);
1536
1555
  }
1537
1556
 
1538
1557
  /* Reject paths like AUX or COM1, or those versions that end in a dot or
1539
1558
  * colon. ("AUX." or "AUX:")
1540
1559
  */
1541
- GIT_INLINE(bool) verify_dospath(
1560
+ GIT_INLINE(bool) validate_dospath(
1542
1561
  const char *component,
1543
1562
  size_t len,
1544
1563
  const char dospath[3],
@@ -1557,180 +1576,15 @@ GIT_INLINE(bool) verify_dospath(
1557
1576
  component[last] != ':');
1558
1577
  }
1559
1578
 
1560
- static int32_t next_hfs_char(const char **in, size_t *len)
1561
- {
1562
- while (*len) {
1563
- uint32_t codepoint;
1564
- int cp_len = git_utf8_iterate(&codepoint, *in, *len);
1565
- if (cp_len < 0)
1566
- return -1;
1567
-
1568
- (*in) += cp_len;
1569
- (*len) -= cp_len;
1570
-
1571
- /* these code points are ignored completely */
1572
- switch (codepoint) {
1573
- case 0x200c: /* ZERO WIDTH NON-JOINER */
1574
- case 0x200d: /* ZERO WIDTH JOINER */
1575
- case 0x200e: /* LEFT-TO-RIGHT MARK */
1576
- case 0x200f: /* RIGHT-TO-LEFT MARK */
1577
- case 0x202a: /* LEFT-TO-RIGHT EMBEDDING */
1578
- case 0x202b: /* RIGHT-TO-LEFT EMBEDDING */
1579
- case 0x202c: /* POP DIRECTIONAL FORMATTING */
1580
- case 0x202d: /* LEFT-TO-RIGHT OVERRIDE */
1581
- case 0x202e: /* RIGHT-TO-LEFT OVERRIDE */
1582
- case 0x206a: /* INHIBIT SYMMETRIC SWAPPING */
1583
- case 0x206b: /* ACTIVATE SYMMETRIC SWAPPING */
1584
- case 0x206c: /* INHIBIT ARABIC FORM SHAPING */
1585
- case 0x206d: /* ACTIVATE ARABIC FORM SHAPING */
1586
- case 0x206e: /* NATIONAL DIGIT SHAPES */
1587
- case 0x206f: /* NOMINAL DIGIT SHAPES */
1588
- case 0xfeff: /* ZERO WIDTH NO-BREAK SPACE */
1589
- continue;
1590
- }
1591
-
1592
- /* fold into lowercase -- this will only fold characters in
1593
- * the ASCII range, which is perfectly fine, because the
1594
- * git folder name can only be composed of ascii characters
1595
- */
1596
- return git__tolower((int)codepoint);
1597
- }
1598
- return 0; /* NULL byte -- end of string */
1599
- }
1600
-
1601
- static bool verify_dotgit_hfs_generic(const char *path, size_t len, const char *needle, size_t needle_len)
1602
- {
1603
- size_t i;
1604
- char c;
1605
-
1606
- if (next_hfs_char(&path, &len) != '.')
1607
- return true;
1608
-
1609
- for (i = 0; i < needle_len; i++) {
1610
- c = next_hfs_char(&path, &len);
1611
- if (c != needle[i])
1612
- return true;
1613
- }
1614
-
1615
- if (next_hfs_char(&path, &len) != '\0')
1616
- return true;
1617
-
1618
- return false;
1619
- }
1620
-
1621
- static bool verify_dotgit_hfs(const char *path, size_t len)
1622
- {
1623
- return verify_dotgit_hfs_generic(path, len, "git", CONST_STRLEN("git"));
1624
- }
1625
-
1626
- GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size_t len)
1627
- {
1628
- git_buf *reserved = git_repository__reserved_names_win32;
1629
- size_t reserved_len = git_repository__reserved_names_win32_len;
1630
- size_t start = 0, i;
1631
-
1632
- if (repo)
1633
- git_repository__reserved_names(&reserved, &reserved_len, repo, true);
1634
-
1635
- for (i = 0; i < reserved_len; i++) {
1636
- git_buf *r = &reserved[i];
1637
-
1638
- if (len >= r->size &&
1639
- strncasecmp(path, r->ptr, r->size) == 0) {
1640
- start = r->size;
1641
- break;
1642
- }
1643
- }
1644
-
1645
- if (!start)
1646
- return true;
1647
-
1648
- /*
1649
- * Reject paths that start with Windows-style directory separators
1650
- * (".git\") or NTFS alternate streams (".git:") and could be used
1651
- * to write to the ".git" directory on Windows platforms.
1652
- */
1653
- if (path[start] == '\\' || path[start] == ':')
1654
- return false;
1655
-
1656
- /* Reject paths like '.git ' or '.git.' */
1657
- for (i = start; i < len; i++) {
1658
- if (path[i] != ' ' && path[i] != '.')
1659
- return true;
1660
- }
1661
-
1662
- return false;
1663
- }
1664
-
1665
- /*
1666
- * Windows paths that end with spaces and/or dots are elided to the
1667
- * path without them for backward compatibility. That is to say
1668
- * that opening file "foo ", "foo." or even "foo . . ." will all
1669
- * map to a filename of "foo". This function identifies spaces and
1670
- * dots at the end of a filename, whether the proper end of the
1671
- * filename (end of string) or a colon (which would indicate a
1672
- * Windows alternate data stream.)
1673
- */
1674
- GIT_INLINE(bool) ntfs_end_of_filename(const char *path)
1675
- {
1676
- const char *c = path;
1677
-
1678
- for (;; c++) {
1679
- if (*c == '\0' || *c == ':')
1680
- return true;
1681
- if (*c != ' ' && *c != '.')
1682
- return false;
1683
- }
1684
-
1685
- return true;
1686
- }
1687
-
1688
- GIT_INLINE(bool) verify_dotgit_ntfs_generic(const char *name, size_t len, const char *dotgit_name, size_t dotgit_len, const char *shortname_pfix)
1689
- {
1690
- int i, saw_tilde;
1691
-
1692
- if (name[0] == '.' && len >= dotgit_len &&
1693
- !strncasecmp(name + 1, dotgit_name, dotgit_len)) {
1694
- return !ntfs_end_of_filename(name + dotgit_len + 1);
1695
- }
1696
-
1697
- /* Detect the basic NTFS shortname with the first six chars */
1698
- if (!strncasecmp(name, dotgit_name, 6) && name[6] == '~' &&
1699
- name[7] >= '1' && name[7] <= '4')
1700
- return !ntfs_end_of_filename(name + 8);
1701
-
1702
- /* Catch fallback names */
1703
- for (i = 0, saw_tilde = 0; i < 8; i++) {
1704
- if (name[i] == '\0') {
1705
- return true;
1706
- } else if (saw_tilde) {
1707
- if (name[i] < '0' || name[i] > '9')
1708
- return true;
1709
- } else if (name[i] == '~') {
1710
- if (name[i+1] < '1' || name[i+1] > '9')
1711
- return true;
1712
- saw_tilde = 1;
1713
- } else if (i >= 6) {
1714
- return true;
1715
- } else if ((unsigned char)name[i] > 127) {
1716
- return true;
1717
- } else if (git__tolower(name[i]) != shortname_pfix[i]) {
1718
- return true;
1719
- }
1720
- }
1721
-
1722
- return !ntfs_end_of_filename(name + i);
1723
- }
1724
-
1725
- GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags)
1579
+ GIT_INLINE(bool) validate_char(unsigned char c, unsigned int flags)
1726
1580
  {
1727
- if ((flags & GIT_PATH_REJECT_BACKSLASH) && c == '\\')
1581
+ if ((flags & GIT_FS_PATH_REJECT_BACKSLASH) && c == '\\')
1728
1582
  return false;
1729
1583
 
1730
- if ((flags & GIT_PATH_REJECT_SLASH) && c == '/')
1584
+ if ((flags & GIT_FS_PATH_REJECT_SLASH) && c == '/')
1731
1585
  return false;
1732
1586
 
1733
- if (flags & GIT_PATH_REJECT_NT_CHARS) {
1587
+ if (flags & GIT_FS_PATH_REJECT_NT_CHARS) {
1734
1588
  if (c < 32)
1735
1589
  return false;
1736
1590
 
@@ -1749,211 +1603,166 @@ GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags)
1749
1603
  return true;
1750
1604
  }
1751
1605
 
1752
- /*
1753
- * Return the length of the common prefix between str and prefix, comparing them
1754
- * case-insensitively (must be ASCII to match).
1755
- */
1756
- GIT_INLINE(size_t) common_prefix_icase(const char *str, size_t len, const char *prefix)
1757
- {
1758
- size_t count = 0;
1759
-
1760
- while (len >0 && tolower(*str) == tolower(*prefix)) {
1761
- count++;
1762
- str++;
1763
- prefix++;
1764
- len--;
1765
- }
1766
-
1767
- return count;
1768
- }
1769
-
1770
1606
  /*
1771
1607
  * We fundamentally don't like some paths when dealing with user-inputted
1772
- * strings (in checkout or ref names): we don't want dot or dot-dot
1608
+ * strings (to avoid escaping a sandbox): we don't want dot or dot-dot
1773
1609
  * anywhere, we want to avoid writing weird paths on Windows that can't
1774
1610
  * be handled by tools that use the non-\\?\ APIs, we don't want slashes
1775
1611
  * or double slashes at the end of paths that can make them ambiguous.
1776
1612
  *
1777
1613
  * For checkout, we don't want to recurse into ".git" either.
1778
1614
  */
1779
- static bool verify_component(
1780
- git_repository *repo,
1615
+ static bool validate_component(
1781
1616
  const char *component,
1782
1617
  size_t len,
1783
- uint16_t mode,
1784
1618
  unsigned int flags)
1785
1619
  {
1786
1620
  if (len == 0)
1787
- return false;
1621
+ return !(flags & GIT_FS_PATH_REJECT_EMPTY_COMPONENT);
1788
1622
 
1789
- if ((flags & GIT_PATH_REJECT_TRAVERSAL) &&
1790
- len == 1 && component[0] == '.')
1623
+ if ((flags & GIT_FS_PATH_REJECT_TRAVERSAL) &&
1624
+ len == 1 && component[0] == '.')
1791
1625
  return false;
1792
1626
 
1793
- if ((flags & GIT_PATH_REJECT_TRAVERSAL) &&
1794
- len == 2 && component[0] == '.' && component[1] == '.')
1627
+ if ((flags & GIT_FS_PATH_REJECT_TRAVERSAL) &&
1628
+ len == 2 && component[0] == '.' && component[1] == '.')
1795
1629
  return false;
1796
1630
 
1797
- if ((flags & GIT_PATH_REJECT_TRAILING_DOT) && component[len-1] == '.')
1631
+ if ((flags & GIT_FS_PATH_REJECT_TRAILING_DOT) &&
1632
+ component[len - 1] == '.')
1798
1633
  return false;
1799
1634
 
1800
- if ((flags & GIT_PATH_REJECT_TRAILING_SPACE) && component[len-1] == ' ')
1635
+ if ((flags & GIT_FS_PATH_REJECT_TRAILING_SPACE) &&
1636
+ component[len - 1] == ' ')
1801
1637
  return false;
1802
1638
 
1803
- if ((flags & GIT_PATH_REJECT_TRAILING_COLON) && component[len-1] == ':')
1639
+ if ((flags & GIT_FS_PATH_REJECT_TRAILING_COLON) &&
1640
+ component[len - 1] == ':')
1804
1641
  return false;
1805
1642
 
1806
- if (flags & GIT_PATH_REJECT_DOS_PATHS) {
1807
- if (!verify_dospath(component, len, "CON", false) ||
1808
- !verify_dospath(component, len, "PRN", false) ||
1809
- !verify_dospath(component, len, "AUX", false) ||
1810
- !verify_dospath(component, len, "NUL", false) ||
1811
- !verify_dospath(component, len, "COM", true) ||
1812
- !verify_dospath(component, len, "LPT", true))
1643
+ if (flags & GIT_FS_PATH_REJECT_DOS_PATHS) {
1644
+ if (!validate_dospath(component, len, "CON", false) ||
1645
+ !validate_dospath(component, len, "PRN", false) ||
1646
+ !validate_dospath(component, len, "AUX", false) ||
1647
+ !validate_dospath(component, len, "NUL", false) ||
1648
+ !validate_dospath(component, len, "COM", true) ||
1649
+ !validate_dospath(component, len, "LPT", true))
1813
1650
  return false;
1814
1651
  }
1815
1652
 
1816
- if (flags & GIT_PATH_REJECT_DOT_GIT_HFS) {
1817
- if (!verify_dotgit_hfs(component, len))
1818
- return false;
1819
- if (S_ISLNK(mode) && git_path_is_gitfile(component, len, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_HFS))
1820
- return false;
1821
- }
1822
-
1823
- if (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) {
1824
- if (!verify_dotgit_ntfs(repo, component, len))
1825
- return false;
1826
- if (S_ISLNK(mode) && git_path_is_gitfile(component, len, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_NTFS))
1827
- return false;
1828
- }
1829
-
1830
- /* don't bother rerunning the `.git` test if we ran the HFS or NTFS
1831
- * specific tests, they would have already rejected `.git`.
1832
- */
1833
- if ((flags & GIT_PATH_REJECT_DOT_GIT_HFS) == 0 &&
1834
- (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) == 0 &&
1835
- (flags & GIT_PATH_REJECT_DOT_GIT_LITERAL)) {
1836
- if (len >= 4 &&
1837
- component[0] == '.' &&
1838
- (component[1] == 'g' || component[1] == 'G') &&
1839
- (component[2] == 'i' || component[2] == 'I') &&
1840
- (component[3] == 't' || component[3] == 'T')) {
1841
- if (len == 4)
1842
- return false;
1843
-
1844
- if (S_ISLNK(mode) && common_prefix_icase(component, len, ".gitmodules") == len)
1845
- return false;
1846
- }
1847
- }
1848
-
1849
1653
  return true;
1850
1654
  }
1851
1655
 
1852
- GIT_INLINE(unsigned int) dotgit_flags(
1853
- git_repository *repo,
1854
- unsigned int flags)
1656
+ #ifdef GIT_WIN32
1657
+ GIT_INLINE(bool) validate_length(
1658
+ const char *path,
1659
+ size_t len,
1660
+ size_t utf8_char_len)
1855
1661
  {
1856
- int protectHFS = 0, protectNTFS = 1;
1857
- int error = 0;
1858
-
1859
- flags |= GIT_PATH_REJECT_DOT_GIT_LITERAL;
1662
+ GIT_UNUSED(path);
1663
+ GIT_UNUSED(len);
1860
1664
 
1861
- #ifdef __APPLE__
1862
- protectHFS = 1;
1665
+ return (utf8_char_len <= MAX_PATH);
1666
+ }
1863
1667
  #endif
1864
1668
 
1865
- if (repo && !protectHFS)
1866
- error = git_repository__configmap_lookup(&protectHFS, repo, GIT_CONFIGMAP_PROTECTHFS);
1867
- if (!error && protectHFS)
1868
- flags |= GIT_PATH_REJECT_DOT_GIT_HFS;
1669
+ bool git_fs_path_str_is_valid_ext(
1670
+ const git_str *path,
1671
+ unsigned int flags,
1672
+ bool (*validate_char_cb)(char ch, void *payload),
1673
+ bool (*validate_component_cb)(const char *component, size_t len, void *payload),
1674
+ bool (*validate_length_cb)(const char *path, size_t len, size_t utf8_char_len),
1675
+ void *payload)
1676
+ {
1677
+ const char *start, *c;
1678
+ size_t len = 0;
1869
1679
 
1870
- if (repo)
1871
- error = git_repository__configmap_lookup(&protectNTFS, repo, GIT_CONFIGMAP_PROTECTNTFS);
1872
- if (!error && protectNTFS)
1873
- flags |= GIT_PATH_REJECT_DOT_GIT_NTFS;
1680
+ if (!flags)
1681
+ return true;
1874
1682
 
1875
- return flags;
1876
- }
1683
+ for (start = c = path->ptr; *c && len < path->size; c++, len++) {
1684
+ if (!validate_char(*c, flags))
1685
+ return false;
1877
1686
 
1878
- bool git_path_validate(
1879
- git_repository *repo,
1880
- const char *path,
1881
- uint16_t mode,
1882
- unsigned int flags)
1883
- {
1884
- const char *start, *c;
1687
+ if (validate_char_cb && !validate_char_cb(*c, payload))
1688
+ return false;
1885
1689
 
1886
- /* Upgrade the ".git" checks based on platform */
1887
- if ((flags & GIT_PATH_REJECT_DOT_GIT))
1888
- flags = dotgit_flags(repo, flags);
1690
+ if (*c != '/')
1691
+ continue;
1889
1692
 
1890
- for (start = c = path; *c; c++) {
1891
- if (!verify_char(*c, flags))
1693
+ if (!validate_component(start, (c - start), flags))
1892
1694
  return false;
1893
1695
 
1894
- if (*c == '/') {
1895
- if (!verify_component(repo, start, (c - start), mode, flags))
1896
- return false;
1696
+ if (validate_component_cb &&
1697
+ !validate_component_cb(start, (c - start), payload))
1698
+ return false;
1897
1699
 
1898
- start = c+1;
1899
- }
1700
+ start = c + 1;
1900
1701
  }
1901
1702
 
1902
- return verify_component(repo, start, (c - start), mode, flags);
1903
- }
1703
+ /*
1704
+ * We want to support paths specified as either `const char *`
1705
+ * or `git_str *`; we pass size as `SIZE_MAX` when we use a
1706
+ * `const char *` to avoid a `strlen`. Ensure that we didn't
1707
+ * have a NUL in the buffer if there was a non-SIZE_MAX length.
1708
+ */
1709
+ if (path->size != SIZE_MAX && len != path->size)
1710
+ return false;
1904
1711
 
1905
- #ifdef GIT_WIN32
1906
- GIT_INLINE(bool) should_validate_longpaths(git_repository *repo)
1907
- {
1908
- int longpaths = 0;
1712
+ if (!validate_component(start, (c - start), flags))
1713
+ return false;
1909
1714
 
1910
- if (repo &&
1911
- git_repository__configmap_lookup(&longpaths, repo, GIT_CONFIGMAP_LONGPATHS) < 0)
1912
- longpaths = 0;
1715
+ if (validate_component_cb &&
1716
+ !validate_component_cb(start, (c - start), payload))
1717
+ return false;
1913
1718
 
1914
- return (longpaths == 0);
1915
- }
1719
+ #ifdef GIT_WIN32
1720
+ if ((flags & GIT_FS_PATH_REJECT_LONG_PATHS) != 0) {
1721
+ size_t utf8_len = git_utf8_char_length(path->ptr, len);
1916
1722
 
1917
- #else
1723
+ if (!validate_length(path->ptr, len, utf8_len))
1724
+ return false;
1918
1725
 
1919
- GIT_INLINE(bool) should_validate_longpaths(git_repository *repo)
1920
- {
1921
- GIT_UNUSED(repo);
1726
+ if (validate_length_cb &&
1727
+ !validate_length_cb(path->ptr, len, utf8_len))
1728
+ return false;
1729
+ }
1730
+ #else
1731
+ GIT_UNUSED(validate_length_cb);
1732
+ #endif
1922
1733
 
1923
- return false;
1734
+ return true;
1924
1735
  }
1925
- #endif
1926
1736
 
1927
- int git_path_validate_workdir(git_repository *repo, const char *path)
1737
+ int git_fs_path_validate_str_length_with_suffix(
1738
+ git_str *path,
1739
+ size_t suffix_len)
1928
1740
  {
1929
- if (should_validate_longpaths(repo))
1930
- return git_path_validate_filesystem(path, strlen(path));
1741
+ #ifdef GIT_WIN32
1742
+ size_t utf8_len = git_utf8_char_length(path->ptr, path->size);
1743
+ size_t total_len;
1931
1744
 
1932
- return 0;
1933
- }
1745
+ if (GIT_ADD_SIZET_OVERFLOW(&total_len, utf8_len, suffix_len) ||
1746
+ total_len > MAX_PATH) {
1934
1747
 
1935
- int git_path_validate_workdir_with_len(
1936
- git_repository *repo,
1937
- const char *path,
1938
- size_t path_len)
1939
- {
1940
- if (should_validate_longpaths(repo))
1941
- return git_path_validate_filesystem(path, path_len);
1748
+ git_error_set(GIT_ERROR_FILESYSTEM, "path too long: '%.*s'",
1749
+ (int)path->size, path->ptr);
1750
+ return -1;
1751
+ }
1752
+ #else
1753
+ GIT_UNUSED(path);
1754
+ GIT_UNUSED(suffix_len);
1755
+ #endif
1942
1756
 
1943
1757
  return 0;
1944
1758
  }
1945
1759
 
1946
- int git_path_validate_workdir_buf(git_repository *repo, git_buf *path)
1947
- {
1948
- return git_path_validate_workdir_with_len(repo, path->ptr, path->size);
1949
- }
1950
-
1951
- int git_path_normalize_slashes(git_buf *out, const char *path)
1760
+ int git_fs_path_normalize_slashes(git_str *out, const char *path)
1952
1761
  {
1953
1762
  int error;
1954
1763
  char *p;
1955
1764
 
1956
- if ((error = git_buf_puts(out, path)) < 0)
1765
+ if ((error = git_str_puts(out, path)) < 0)
1957
1766
  return error;
1958
1767
 
1959
1768
  for (p = out->ptr; *p; p++) {
@@ -1964,47 +1773,9 @@ int git_path_normalize_slashes(git_buf *out, const char *path)
1964
1773
  return 0;
1965
1774
  }
1966
1775
 
1967
- static const struct {
1968
- const char *file;
1969
- const char *hash;
1970
- size_t filelen;
1971
- } gitfiles[] = {
1972
- { "gitignore", "gi250a", CONST_STRLEN("gitignore") },
1973
- { "gitmodules", "gi7eba", CONST_STRLEN("gitmodules") },
1974
- { "gitattributes", "gi7d29", CONST_STRLEN("gitattributes") }
1975
- };
1976
-
1977
- extern int git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfile gitfile, git_path_fs fs)
1978
- {
1979
- const char *file, *hash;
1980
- size_t filelen;
1981
-
1982
- if (!(gitfile >= GIT_PATH_GITFILE_GITIGNORE && gitfile < ARRAY_SIZE(gitfiles))) {
1983
- git_error_set(GIT_ERROR_OS, "invalid gitfile for path validation");
1984
- return -1;
1985
- }
1986
-
1987
- file = gitfiles[gitfile].file;
1988
- filelen = gitfiles[gitfile].filelen;
1989
- hash = gitfiles[gitfile].hash;
1990
-
1991
- switch (fs) {
1992
- case GIT_PATH_FS_GENERIC:
1993
- return !verify_dotgit_ntfs_generic(path, pathlen, file, filelen, hash) ||
1994
- !verify_dotgit_hfs_generic(path, pathlen, file, filelen);
1995
- case GIT_PATH_FS_NTFS:
1996
- return !verify_dotgit_ntfs_generic(path, pathlen, file, filelen, hash);
1997
- case GIT_PATH_FS_HFS:
1998
- return !verify_dotgit_hfs_generic(path, pathlen, file, filelen);
1999
- default:
2000
- git_error_set(GIT_ERROR_OS, "invalid filesystem for path validation");
2001
- return -1;
2002
- }
2003
- }
2004
-
2005
- bool git_path_supports_symlinks(const char *dir)
1776
+ bool git_fs_path_supports_symlinks(const char *dir)
2006
1777
  {
2007
- git_buf path = GIT_BUF_INIT;
1778
+ git_str path = GIT_STR_INIT;
2008
1779
  bool supported = false;
2009
1780
  struct stat st;
2010
1781
  int fd;
@@ -2020,82 +1791,287 @@ bool git_path_supports_symlinks(const char *dir)
2020
1791
  done:
2021
1792
  if (path.size)
2022
1793
  (void)p_unlink(path.ptr);
2023
- git_buf_dispose(&path);
1794
+ git_str_dispose(&path);
2024
1795
  return supported;
2025
1796
  }
2026
1797
 
2027
- int git_path_validate_system_file_ownership(const char *path)
1798
+ static git_fs_path_owner_t mock_owner = GIT_FS_PATH_OWNER_NONE;
1799
+
1800
+ void git_fs_path__set_owner(git_fs_path_owner_t owner)
1801
+ {
1802
+ mock_owner = owner;
1803
+ }
1804
+
1805
+ #ifdef GIT_WIN32
1806
+ static PSID *sid_dup(PSID sid)
1807
+ {
1808
+ DWORD len;
1809
+ PSID dup;
1810
+
1811
+ len = GetLengthSid(sid);
1812
+
1813
+ if ((dup = git__malloc(len)) == NULL)
1814
+ return NULL;
1815
+
1816
+ if (!CopySid(len, dup, sid)) {
1817
+ git_error_set(GIT_ERROR_OS, "could not duplicate sid");
1818
+ git__free(dup);
1819
+ return NULL;
1820
+ }
1821
+
1822
+ return dup;
1823
+ }
1824
+
1825
+ static int current_user_sid(PSID *out)
2028
1826
  {
2029
- #ifndef GIT_WIN32
2030
- GIT_UNUSED(path);
2031
- return GIT_OK;
2032
- #else
2033
- git_win32_path buf;
2034
- PSID owner_sid;
2035
- PSECURITY_DESCRIPTOR descriptor = NULL;
2036
- HANDLE token;
2037
1827
  TOKEN_USER *info = NULL;
2038
- DWORD err, len;
2039
- int ret;
1828
+ HANDLE token = NULL;
1829
+ DWORD len = 0;
1830
+ int error = -1;
2040
1831
 
2041
- if (git_win32_path_from_utf8(buf, path) < 0)
2042
- return -1;
1832
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
1833
+ git_error_set(GIT_ERROR_OS, "could not lookup process information");
1834
+ goto done;
1835
+ }
2043
1836
 
2044
- err = GetNamedSecurityInfoW(buf, SE_FILE_OBJECT,
2045
- OWNER_SECURITY_INFORMATION |
2046
- DACL_SECURITY_INFORMATION,
2047
- &owner_sid, NULL, NULL, NULL, &descriptor);
1837
+ if (GetTokenInformation(token, TokenUser, NULL, 0, &len) ||
1838
+ GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
1839
+ git_error_set(GIT_ERROR_OS, "could not lookup token metadata");
1840
+ goto done;
1841
+ }
1842
+
1843
+ info = git__malloc(len);
1844
+ GIT_ERROR_CHECK_ALLOC(info);
2048
1845
 
2049
- if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) {
2050
- ret = GIT_ENOTFOUND;
2051
- goto cleanup;
1846
+ if (!GetTokenInformation(token, TokenUser, info, len, &len)) {
1847
+ git_error_set(GIT_ERROR_OS, "could not lookup current user");
1848
+ goto done;
2052
1849
  }
2053
1850
 
2054
- if (err != ERROR_SUCCESS) {
1851
+ if ((*out = sid_dup(info->User.Sid)))
1852
+ error = 0;
1853
+
1854
+ done:
1855
+ if (token)
1856
+ CloseHandle(token);
1857
+
1858
+ git__free(info);
1859
+ return error;
1860
+ }
1861
+
1862
+ static int file_owner_sid(PSID *out, const char *path)
1863
+ {
1864
+ git_win32_path path_w32;
1865
+ PSECURITY_DESCRIPTOR descriptor = NULL;
1866
+ PSID owner_sid;
1867
+ DWORD ret;
1868
+ int error = GIT_EINVALID;
1869
+
1870
+ if (git_win32_path_from_utf8(path_w32, path) < 0)
1871
+ return -1;
1872
+
1873
+ ret = GetNamedSecurityInfoW(path_w32, SE_FILE_OBJECT,
1874
+ OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
1875
+ &owner_sid, NULL, NULL, NULL, &descriptor);
1876
+
1877
+ if (ret == ERROR_FILE_NOT_FOUND || ret == ERROR_PATH_NOT_FOUND)
1878
+ error = GIT_ENOTFOUND;
1879
+ else if (ret != ERROR_SUCCESS)
2055
1880
  git_error_set(GIT_ERROR_OS, "failed to get security information");
2056
- ret = GIT_ERROR;
2057
- goto cleanup;
1881
+ else if (!IsValidSid(owner_sid))
1882
+ git_error_set(GIT_ERROR_OS, "file owner is not valid");
1883
+ else if ((*out = sid_dup(owner_sid)))
1884
+ error = 0;
1885
+
1886
+ if (descriptor)
1887
+ LocalFree(descriptor);
1888
+
1889
+ return error;
1890
+ }
1891
+
1892
+ int git_fs_path_owner_is(
1893
+ bool *out,
1894
+ const char *path,
1895
+ git_fs_path_owner_t owner_type)
1896
+ {
1897
+ PSID owner_sid = NULL, user_sid = NULL;
1898
+ BOOL is_admin, admin_owned;
1899
+ int error;
1900
+
1901
+ if (mock_owner) {
1902
+ *out = ((mock_owner & owner_type) != 0);
1903
+ return 0;
2058
1904
  }
2059
1905
 
2060
- if (!IsValidSid(owner_sid)) {
2061
- git_error_set(GIT_ERROR_INVALID, "programdata configuration file owner is unknown");
2062
- ret = GIT_ERROR;
2063
- goto cleanup;
1906
+ if ((error = file_owner_sid(&owner_sid, path)) < 0)
1907
+ goto done;
1908
+
1909
+ if ((owner_type & GIT_FS_PATH_OWNER_CURRENT_USER) != 0) {
1910
+ if ((error = current_user_sid(&user_sid)) < 0)
1911
+ goto done;
1912
+
1913
+ if (EqualSid(owner_sid, user_sid)) {
1914
+ *out = true;
1915
+ goto done;
1916
+ }
2064
1917
  }
2065
1918
 
2066
- if (IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) ||
2067
- IsWellKnownSid(owner_sid, WinLocalSystemSid)) {
2068
- ret = GIT_OK;
2069
- goto cleanup;
1919
+ admin_owned =
1920
+ IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) ||
1921
+ IsWellKnownSid(owner_sid, WinLocalSystemSid);
1922
+
1923
+ if (admin_owned &&
1924
+ (owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR) != 0) {
1925
+ *out = true;
1926
+ goto done;
2070
1927
  }
2071
1928
 
2072
- /* Obtain current user's SID */
2073
- if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) &&
2074
- !GetTokenInformation(token, TokenUser, NULL, 0, &len)) {
2075
- info = git__malloc(len);
2076
- GIT_ERROR_CHECK_ALLOC(info);
2077
- if (!GetTokenInformation(token, TokenUser, info, len, &len)) {
2078
- git__free(info);
2079
- info = NULL;
2080
- }
1929
+ if (admin_owned &&
1930
+ (owner_type & GIT_FS_PATH_USER_IS_ADMINISTRATOR) != 0 &&
1931
+ CheckTokenMembership(NULL, owner_sid, &is_admin) &&
1932
+ is_admin) {
1933
+ *out = true;
1934
+ goto done;
2081
1935
  }
2082
1936
 
2083
- /*
2084
- * If the file is owned by the same account that is running the current
2085
- * process, it's okay to read from that file.
2086
- */
2087
- if (info && EqualSid(owner_sid, info->User.Sid))
2088
- ret = GIT_OK;
2089
- else {
2090
- git_error_set(GIT_ERROR_INVALID, "programdata configuration file owner is not valid");
2091
- ret = GIT_ERROR;
1937
+ *out = false;
1938
+
1939
+ done:
1940
+ git__free(owner_sid);
1941
+ git__free(user_sid);
1942
+ return error;
1943
+ }
1944
+
1945
+ #else
1946
+
1947
+ static int sudo_uid_lookup(uid_t *out)
1948
+ {
1949
+ git_str uid_str = GIT_STR_INIT;
1950
+ int64_t uid;
1951
+ int error = -1;
1952
+
1953
+ if (git__getenv(&uid_str, "SUDO_UID") == 0 &&
1954
+ git__strntol64(&uid, uid_str.ptr, uid_str.size, NULL, 10) == 0 &&
1955
+ uid == (int64_t)((uid_t)uid)) {
1956
+ *out = (uid_t)uid;
1957
+ error = 0;
2092
1958
  }
2093
- git__free(info);
2094
1959
 
2095
- cleanup:
2096
- if (descriptor)
2097
- LocalFree(descriptor);
1960
+ git_str_dispose(&uid_str);
1961
+ return error;
1962
+ }
1963
+
1964
+ int git_fs_path_owner_is(
1965
+ bool *out,
1966
+ const char *path,
1967
+ git_fs_path_owner_t owner_type)
1968
+ {
1969
+ struct stat st;
1970
+ uid_t euid, sudo_uid;
1971
+
1972
+ if (mock_owner) {
1973
+ *out = ((mock_owner & owner_type) != 0);
1974
+ return 0;
1975
+ }
1976
+
1977
+ euid = geteuid();
1978
+
1979
+ if (p_lstat(path, &st) != 0) {
1980
+ if (errno == ENOENT)
1981
+ return GIT_ENOTFOUND;
1982
+
1983
+ git_error_set(GIT_ERROR_OS, "could not stat '%s'", path);
1984
+ return -1;
1985
+ }
1986
+
1987
+ if ((owner_type & GIT_FS_PATH_OWNER_CURRENT_USER) != 0 &&
1988
+ st.st_uid == euid) {
1989
+ *out = true;
1990
+ return 0;
1991
+ }
1992
+
1993
+ if ((owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR) != 0 &&
1994
+ st.st_uid == 0) {
1995
+ *out = true;
1996
+ return 0;
1997
+ }
1998
+
1999
+ if ((owner_type & GIT_FS_PATH_OWNER_RUNNING_SUDO) != 0 &&
2000
+ euid == 0 &&
2001
+ sudo_uid_lookup(&sudo_uid) == 0 &&
2002
+ st.st_uid == sudo_uid) {
2003
+ *out = true;
2004
+ return 0;
2005
+ }
2006
+
2007
+ *out = false;
2008
+ return 0;
2009
+ }
2010
+
2011
+ #endif
2012
+
2013
+ int git_fs_path_owner_is_current_user(bool *out, const char *path)
2014
+ {
2015
+ return git_fs_path_owner_is(out, path, GIT_FS_PATH_OWNER_CURRENT_USER);
2016
+ }
2017
+
2018
+ int git_fs_path_owner_is_system(bool *out, const char *path)
2019
+ {
2020
+ return git_fs_path_owner_is(out, path, GIT_FS_PATH_OWNER_ADMINISTRATOR);
2021
+ }
2022
+
2023
+ int git_fs_path_find_executable(git_str *fullpath, const char *executable)
2024
+ {
2025
+ #ifdef GIT_WIN32
2026
+ git_win32_path fullpath_w, executable_w;
2027
+ int error;
2028
+
2029
+ if (git_utf8_to_16(executable_w, GIT_WIN_PATH_MAX, executable) < 0)
2030
+ return -1;
2031
+
2032
+ error = git_win32_path_find_executable(fullpath_w, executable_w);
2033
+
2034
+ if (error == 0)
2035
+ error = git_str_put_w(fullpath, fullpath_w, wcslen(fullpath_w));
2036
+
2037
+ return error;
2038
+ #else
2039
+ git_str path = GIT_STR_INIT;
2040
+ const char *current_dir, *term;
2041
+ bool found = false;
2042
+
2043
+ if (git__getenv(&path, "PATH") < 0)
2044
+ return -1;
2045
+
2046
+ current_dir = path.ptr;
2047
+
2048
+ while (*current_dir) {
2049
+ if (! (term = strchr(current_dir, GIT_PATH_LIST_SEPARATOR)))
2050
+ term = strchr(current_dir, '\0');
2051
+
2052
+ git_str_clear(fullpath);
2053
+ if (git_str_put(fullpath, current_dir, (term - current_dir)) < 0 ||
2054
+ git_str_putc(fullpath, '/') < 0 ||
2055
+ git_str_puts(fullpath, executable) < 0)
2056
+ return -1;
2057
+
2058
+ if (git_fs_path_isfile(fullpath->ptr)) {
2059
+ found = true;
2060
+ break;
2061
+ }
2062
+
2063
+ current_dir = term;
2064
+
2065
+ while (*current_dir == GIT_PATH_LIST_SEPARATOR)
2066
+ current_dir++;
2067
+ }
2068
+
2069
+ git_str_dispose(&path);
2070
+
2071
+ if (found)
2072
+ return 0;
2098
2073
 
2099
- return ret;
2074
+ git_str_clear(fullpath);
2075
+ return GIT_ENOTFOUND;
2100
2076
  #endif
2101
2077
  }