rugged 1.3.1 → 1.4.2

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 (314) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +1 -1
  3. data/ext/rugged/rugged_config.c +7 -2
  4. data/ext/rugged/rugged_remote.c +17 -0
  5. data/lib/rugged/version.rb +1 -1
  6. data/vendor/libgit2/CMakeLists.txt +103 -276
  7. data/vendor/libgit2/COPYING +36 -19
  8. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  9. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  10. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  11. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  12. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  13. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  14. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  15. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  16. data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
  17. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  19. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  20. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  21. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  22. data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
  23. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  24. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  25. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  26. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  27. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  28. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  29. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
  30. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -49
  31. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  32. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  33. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  34. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  35. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
  36. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +31 -31
  37. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +1 -1
  38. data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
  39. data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
  40. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
  41. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  42. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  43. data/vendor/libgit2/include/git2/apply.h +16 -2
  44. data/vendor/libgit2/include/git2/attr.h +11 -2
  45. data/vendor/libgit2/include/git2/blame.h +4 -1
  46. data/vendor/libgit2/include/git2/blob.h +14 -1
  47. data/vendor/libgit2/include/git2/branch.h +2 -0
  48. data/vendor/libgit2/include/git2/buffer.h +18 -78
  49. data/vendor/libgit2/include/git2/cert.h +2 -2
  50. data/vendor/libgit2/include/git2/checkout.h +5 -2
  51. data/vendor/libgit2/include/git2/clone.h +3 -3
  52. data/vendor/libgit2/include/git2/commit.h +2 -0
  53. data/vendor/libgit2/include/git2/common.h +4 -1
  54. data/vendor/libgit2/include/git2/config.h +19 -3
  55. data/vendor/libgit2/include/git2/credential.h +2 -1
  56. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  57. data/vendor/libgit2/include/git2/deprecated.h +1 -1
  58. data/vendor/libgit2/include/git2/describe.h +7 -2
  59. data/vendor/libgit2/include/git2/diff.h +17 -9
  60. data/vendor/libgit2/include/git2/email.h +1 -1
  61. data/vendor/libgit2/include/git2/errors.h +1 -1
  62. data/vendor/libgit2/include/git2/filter.h +7 -2
  63. data/vendor/libgit2/include/git2/graph.h +1 -0
  64. data/vendor/libgit2/include/git2/ignore.h +1 -1
  65. data/vendor/libgit2/include/git2/index.h +11 -5
  66. data/vendor/libgit2/include/git2/indexer.h +19 -0
  67. data/vendor/libgit2/include/git2/merge.h +23 -3
  68. data/vendor/libgit2/include/git2/message.h +2 -0
  69. data/vendor/libgit2/include/git2/object.h +23 -0
  70. data/vendor/libgit2/include/git2/odb.h +37 -7
  71. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  72. data/vendor/libgit2/include/git2/pack.h +24 -8
  73. data/vendor/libgit2/include/git2/patch.h +8 -0
  74. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  75. data/vendor/libgit2/include/git2/proxy.h +1 -1
  76. data/vendor/libgit2/include/git2/rebase.h +9 -1
  77. data/vendor/libgit2/include/git2/refdb.h +3 -0
  78. data/vendor/libgit2/include/git2/reflog.h +1 -1
  79. data/vendor/libgit2/include/git2/refs.h +2 -2
  80. data/vendor/libgit2/include/git2/remote.h +184 -37
  81. data/vendor/libgit2/include/git2/repository.h +14 -9
  82. data/vendor/libgit2/include/git2/reset.h +2 -2
  83. data/vendor/libgit2/include/git2/revparse.h +1 -1
  84. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  85. data/vendor/libgit2/include/git2/signature.h +1 -1
  86. data/vendor/libgit2/include/git2/stash.h +3 -3
  87. data/vendor/libgit2/include/git2/status.h +9 -3
  88. data/vendor/libgit2/include/git2/submodule.h +7 -2
  89. data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
  90. data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
  91. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  92. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  93. data/vendor/libgit2/include/git2/sys/transport.h +25 -34
  94. data/vendor/libgit2/include/git2/tag.h +1 -0
  95. data/vendor/libgit2/include/git2/tree.h +4 -3
  96. data/vendor/libgit2/include/git2/types.h +7 -7
  97. data/vendor/libgit2/include/git2/version.h +4 -4
  98. data/vendor/libgit2/include/git2/worktree.h +12 -2
  99. data/vendor/libgit2/src/CMakeLists.txt +189 -315
  100. data/vendor/libgit2/src/annotated_commit.h +1 -1
  101. data/vendor/libgit2/src/apply.c +18 -18
  102. data/vendor/libgit2/src/apply.h +2 -2
  103. data/vendor/libgit2/src/attr.c +18 -18
  104. data/vendor/libgit2/src/attr_file.c +17 -17
  105. data/vendor/libgit2/src/attr_file.h +4 -4
  106. data/vendor/libgit2/src/attrcache.c +17 -12
  107. data/vendor/libgit2/src/blame_git.c +1 -1
  108. data/vendor/libgit2/src/blob.c +33 -26
  109. data/vendor/libgit2/src/blob.h +1 -1
  110. data/vendor/libgit2/src/branch.c +150 -109
  111. data/vendor/libgit2/src/branch.h +15 -3
  112. data/vendor/libgit2/src/buf.c +126 -0
  113. data/vendor/libgit2/src/buf.h +50 -0
  114. data/vendor/libgit2/src/cc-compat.h +1 -1
  115. data/vendor/libgit2/src/checkout.c +74 -68
  116. data/vendor/libgit2/src/cherrypick.c +10 -10
  117. data/vendor/libgit2/src/clone.c +66 -66
  118. data/vendor/libgit2/src/commit.c +128 -58
  119. data/vendor/libgit2/src/commit.h +24 -1
  120. data/vendor/libgit2/src/commit_graph.c +68 -53
  121. data/vendor/libgit2/src/commit_graph.h +10 -3
  122. data/vendor/libgit2/src/commit_list.c +2 -3
  123. data/vendor/libgit2/src/common.h +10 -3
  124. data/vendor/libgit2/src/config.c +97 -68
  125. data/vendor/libgit2/src/config.h +15 -2
  126. data/vendor/libgit2/src/config_file.c +103 -91
  127. data/vendor/libgit2/src/config_mem.c +9 -9
  128. data/vendor/libgit2/src/config_parse.c +27 -23
  129. data/vendor/libgit2/src/crlf.c +24 -21
  130. data/vendor/libgit2/src/date.c +10 -17
  131. data/vendor/libgit2/src/date.h +33 -0
  132. data/vendor/libgit2/src/describe.c +27 -19
  133. data/vendor/libgit2/src/diff.c +25 -8
  134. data/vendor/libgit2/src/diff.h +2 -4
  135. data/vendor/libgit2/src/diff_driver.c +34 -36
  136. data/vendor/libgit2/src/diff_driver.h +3 -3
  137. data/vendor/libgit2/src/diff_file.c +29 -20
  138. data/vendor/libgit2/src/diff_generate.c +30 -6
  139. data/vendor/libgit2/src/diff_generate.h +5 -3
  140. data/vendor/libgit2/src/diff_print.c +102 -95
  141. data/vendor/libgit2/src/diff_stats.c +40 -29
  142. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  143. data/vendor/libgit2/src/diff_tform.c +9 -8
  144. data/vendor/libgit2/src/diff_xdiff.c +3 -8
  145. data/vendor/libgit2/src/email.c +54 -38
  146. data/vendor/libgit2/src/email.h +1 -1
  147. data/vendor/libgit2/src/errors.c +18 -18
  148. data/vendor/libgit2/src/features.h.in +6 -1
  149. data/vendor/libgit2/src/fetch.c +69 -24
  150. data/vendor/libgit2/src/fetch.h +1 -1
  151. data/vendor/libgit2/src/fetchhead.c +19 -19
  152. data/vendor/libgit2/src/filebuf.c +28 -28
  153. data/vendor/libgit2/src/filebuf.h +1 -1
  154. data/vendor/libgit2/src/filter.c +96 -52
  155. data/vendor/libgit2/src/filter.h +26 -5
  156. data/vendor/libgit2/src/fs_path.c +1912 -0
  157. data/vendor/libgit2/src/fs_path.h +752 -0
  158. data/vendor/libgit2/src/futils.c +91 -85
  159. data/vendor/libgit2/src/futils.h +26 -14
  160. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
  161. data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
  162. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  163. data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
  164. data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
  165. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
  166. data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
  167. data/vendor/libgit2/src/hash/sha1.h +3 -1
  168. data/vendor/libgit2/src/hash.c +67 -35
  169. data/vendor/libgit2/src/hash.h +12 -12
  170. data/vendor/libgit2/src/ident.c +18 -18
  171. data/vendor/libgit2/src/ignore.c +35 -34
  172. data/vendor/libgit2/src/ignore.h +2 -2
  173. data/vendor/libgit2/src/index.c +79 -80
  174. data/vendor/libgit2/src/index.h +6 -3
  175. data/vendor/libgit2/src/indexer.c +75 -57
  176. data/vendor/libgit2/src/iterator.c +64 -56
  177. data/vendor/libgit2/src/iterator.h +5 -5
  178. data/vendor/libgit2/src/khash.h +1 -1
  179. data/vendor/libgit2/src/libgit2.c +22 -11
  180. data/vendor/libgit2/src/mailmap.c +38 -36
  181. data/vendor/libgit2/src/merge.c +27 -27
  182. data/vendor/libgit2/src/merge.h +1 -14
  183. data/vendor/libgit2/src/merge_driver.c +2 -2
  184. data/vendor/libgit2/src/merge_file.c +13 -3
  185. data/vendor/libgit2/src/message.c +21 -10
  186. data/vendor/libgit2/src/midx.c +83 -66
  187. data/vendor/libgit2/src/midx.h +3 -3
  188. data/vendor/libgit2/src/mwindow.c +1 -1
  189. data/vendor/libgit2/src/net.c +278 -68
  190. data/vendor/libgit2/src/net.h +10 -3
  191. data/vendor/libgit2/src/netops.c +1 -1
  192. data/vendor/libgit2/src/netops.h +1 -1
  193. data/vendor/libgit2/src/notes.c +20 -29
  194. data/vendor/libgit2/src/object.c +49 -9
  195. data/vendor/libgit2/src/object.h +1 -1
  196. data/vendor/libgit2/src/odb.c +35 -32
  197. data/vendor/libgit2/src/odb.h +1 -1
  198. data/vendor/libgit2/src/odb_loose.c +68 -68
  199. data/vendor/libgit2/src/odb_mempack.c +18 -5
  200. data/vendor/libgit2/src/odb_pack.c +43 -43
  201. data/vendor/libgit2/src/oid.c +11 -4
  202. data/vendor/libgit2/src/oid.h +15 -0
  203. data/vendor/libgit2/src/pack-objects.c +41 -26
  204. data/vendor/libgit2/src/pack-objects.h +11 -6
  205. data/vendor/libgit2/src/pack.c +10 -10
  206. data/vendor/libgit2/src/patch.c +3 -3
  207. data/vendor/libgit2/src/patch.h +1 -0
  208. data/vendor/libgit2/src/patch_generate.c +27 -11
  209. data/vendor/libgit2/src/patch_generate.h +5 -5
  210. data/vendor/libgit2/src/patch_parse.c +24 -24
  211. data/vendor/libgit2/src/path.c +76 -1803
  212. data/vendor/libgit2/src/path.h +34 -703
  213. data/vendor/libgit2/src/pathspec.c +6 -6
  214. data/vendor/libgit2/src/pathspec.h +2 -2
  215. data/vendor/libgit2/src/posix.c +3 -3
  216. data/vendor/libgit2/src/posix.h +1 -0
  217. data/vendor/libgit2/src/pqueue.h +1 -1
  218. data/vendor/libgit2/src/proxy.c +4 -1
  219. data/vendor/libgit2/src/proxy.h +1 -1
  220. data/vendor/libgit2/src/push.c +30 -35
  221. data/vendor/libgit2/src/push.h +4 -16
  222. data/vendor/libgit2/src/rand.c +226 -0
  223. data/vendor/libgit2/src/rand.h +37 -0
  224. data/vendor/libgit2/src/reader.c +8 -8
  225. data/vendor/libgit2/src/reader.h +2 -2
  226. data/vendor/libgit2/src/rebase.c +89 -88
  227. data/vendor/libgit2/src/refdb_fs.c +447 -173
  228. data/vendor/libgit2/src/refs.c +32 -32
  229. data/vendor/libgit2/src/refs.h +2 -2
  230. data/vendor/libgit2/src/refspec.c +32 -37
  231. data/vendor/libgit2/src/refspec.h +5 -2
  232. data/vendor/libgit2/src/regexp.c +1 -1
  233. data/vendor/libgit2/src/remote.c +713 -419
  234. data/vendor/libgit2/src/remote.h +15 -10
  235. data/vendor/libgit2/src/repository.c +338 -323
  236. data/vendor/libgit2/src/repository.h +11 -9
  237. data/vendor/libgit2/src/reset.c +8 -5
  238. data/vendor/libgit2/src/revert.c +10 -10
  239. data/vendor/libgit2/src/revparse.c +48 -35
  240. data/vendor/libgit2/src/revwalk.c +7 -7
  241. data/vendor/libgit2/src/signature.c +12 -6
  242. data/vendor/libgit2/src/signature.h +1 -1
  243. data/vendor/libgit2/src/sortedcache.c +1 -1
  244. data/vendor/libgit2/src/sortedcache.h +1 -1
  245. data/vendor/libgit2/src/stash.c +36 -37
  246. data/vendor/libgit2/src/status.c +4 -1
  247. data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
  248. data/vendor/libgit2/src/str.h +357 -0
  249. data/vendor/libgit2/src/streams/mbedtls.c +8 -6
  250. data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
  251. data/vendor/libgit2/src/submodule.c +171 -159
  252. data/vendor/libgit2/src/submodule.h +1 -1
  253. data/vendor/libgit2/src/sysdir.c +68 -52
  254. data/vendor/libgit2/src/sysdir.h +15 -10
  255. data/vendor/libgit2/src/tag.c +29 -27
  256. data/vendor/libgit2/src/thread.h +3 -3
  257. data/vendor/libgit2/src/threadstate.c +3 -3
  258. data/vendor/libgit2/src/threadstate.h +1 -1
  259. data/vendor/libgit2/src/trace.c +1 -14
  260. data/vendor/libgit2/src/trace.h +5 -22
  261. data/vendor/libgit2/src/trailer.c +1 -1
  262. data/vendor/libgit2/src/transaction.c +1 -1
  263. data/vendor/libgit2/src/transport.c +10 -10
  264. data/vendor/libgit2/src/transports/auth.c +7 -9
  265. data/vendor/libgit2/src/transports/auth.h +2 -3
  266. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
  267. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
  268. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  269. data/vendor/libgit2/src/transports/git.c +9 -11
  270. data/vendor/libgit2/src/transports/http.c +37 -17
  271. data/vendor/libgit2/src/transports/http.h +2 -3
  272. data/vendor/libgit2/src/transports/httpclient.c +65 -65
  273. data/vendor/libgit2/src/transports/local.c +124 -116
  274. data/vendor/libgit2/src/transports/smart.c +51 -139
  275. data/vendor/libgit2/src/transports/smart.h +25 -31
  276. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  277. data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
  278. data/vendor/libgit2/src/transports/ssh.c +47 -112
  279. data/vendor/libgit2/src/transports/winhttp.c +50 -56
  280. data/vendor/libgit2/src/tree-cache.c +5 -5
  281. data/vendor/libgit2/src/tree-cache.h +2 -2
  282. data/vendor/libgit2/src/tree.c +59 -48
  283. data/vendor/libgit2/src/tree.h +1 -1
  284. data/vendor/libgit2/src/unix/map.c +0 -2
  285. data/vendor/libgit2/src/unix/posix.h +1 -4
  286. data/vendor/libgit2/src/unix/realpath.c +0 -2
  287. data/vendor/libgit2/src/util.c +14 -14
  288. data/vendor/libgit2/src/util.h +2 -28
  289. data/vendor/libgit2/src/vector.h +1 -1
  290. data/vendor/libgit2/src/win32/findfile.c +172 -116
  291. data/vendor/libgit2/src/win32/findfile.h +7 -4
  292. data/vendor/libgit2/src/win32/path_w32.c +140 -9
  293. data/vendor/libgit2/src/win32/path_w32.h +2 -0
  294. data/vendor/libgit2/src/win32/posix.h +0 -1
  295. data/vendor/libgit2/src/win32/posix_w32.c +11 -27
  296. data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
  297. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  298. data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
  299. data/vendor/libgit2/src/worktree.c +116 -94
  300. data/vendor/libgit2/src/worktree.h +1 -1
  301. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  302. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  303. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  304. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  305. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  306. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  307. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  308. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  309. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  310. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  311. data/vendor/libgit2/src/zstream.c +5 -5
  312. data/vendor/libgit2/src/zstream.h +4 -4
  313. metadata +25 -10
  314. data/vendor/libgit2/src/buffer.h +0 -374
@@ -10,6 +10,7 @@
10
10
  #include "git2/config.h"
11
11
  #include "git2/sys/config.h"
12
12
 
13
+ #include "buf.h"
13
14
  #include "config_backend.h"
14
15
  #include "regexp.h"
15
16
  #include "sysdir.h"
@@ -848,7 +849,40 @@ static int is_readonly(const git_config *cfg)
848
849
  return 1;
849
850
  }
850
851
 
851
- int git_config_get_path(git_buf *out, const git_config *cfg, const char *name)
852
+ static int git_config__parse_path(git_str *out, const char *value)
853
+ {
854
+ GIT_ASSERT_ARG(out);
855
+ GIT_ASSERT_ARG(value);
856
+
857
+ if (value[0] == '~') {
858
+ if (value[1] != '\0' && value[1] != '/') {
859
+ git_error_set(GIT_ERROR_CONFIG, "retrieving a homedir by name is not supported");
860
+ return -1;
861
+ }
862
+
863
+ return git_sysdir_expand_global_file(out, value[1] ? &value[2] : NULL);
864
+ }
865
+
866
+ return git_str_sets(out, value);
867
+ }
868
+
869
+ int git_config_parse_path(git_buf *out, const char *value)
870
+ {
871
+ GIT_BUF_WRAP_PRIVATE(out, git_config__parse_path, value);
872
+ }
873
+
874
+ int git_config_get_path(
875
+ git_buf *out,
876
+ const git_config *cfg,
877
+ const char *name)
878
+ {
879
+ GIT_BUF_WRAP_PRIVATE(out, git_config__get_path, cfg, name);
880
+ }
881
+
882
+ int git_config__get_path(
883
+ git_str *out,
884
+ const git_config *cfg,
885
+ const char *name)
852
886
  {
853
887
  git_config_entry *entry;
854
888
  int error;
@@ -856,7 +890,7 @@ int git_config_get_path(git_buf *out, const git_config *cfg, const char *name)
856
890
  if ((error = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0)
857
891
  return error;
858
892
 
859
- error = git_config_parse_path(out, entry->value);
893
+ error = git_config__parse_path(out, entry->value);
860
894
  git_config_entry_free(entry);
861
895
 
862
896
  return error;
@@ -883,19 +917,25 @@ int git_config_get_string(
883
917
 
884
918
  int git_config_get_string_buf(
885
919
  git_buf *out, const git_config *cfg, const char *name)
920
+ {
921
+ GIT_BUF_WRAP_PRIVATE(out, git_config__get_string_buf, cfg, name);
922
+ }
923
+
924
+ int git_config__get_string_buf(
925
+ git_str *out, const git_config *cfg, const char *name)
886
926
  {
887
927
  git_config_entry *entry;
888
928
  int ret;
889
929
  const char *str;
890
930
 
891
- if ((ret = git_buf_sanitize(out)) < 0)
892
- return ret;
931
+ GIT_ASSERT_ARG(out);
932
+ GIT_ASSERT_ARG(cfg);
893
933
 
894
934
  ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS);
895
935
  str = !ret ? (entry->value ? entry->value : "") : NULL;
896
936
 
897
937
  if (str)
898
- ret = git_buf_puts(out, str);
938
+ ret = git_str_puts(out, str);
899
939
 
900
940
  git_config_entry_free(entry);
901
941
 
@@ -1087,101 +1127,112 @@ void git_config_iterator_free(git_config_iterator *iter)
1087
1127
 
1088
1128
  int git_config_find_global(git_buf *path)
1089
1129
  {
1090
- int error;
1091
-
1092
- if ((error = git_buf_sanitize(path)) < 0)
1093
- return error;
1130
+ GIT_BUF_WRAP_PRIVATE(path, git_sysdir_find_global_file, GIT_CONFIG_FILENAME_GLOBAL);
1131
+ }
1094
1132
 
1133
+ int git_config__find_global(git_str *path)
1134
+ {
1095
1135
  return git_sysdir_find_global_file(path, GIT_CONFIG_FILENAME_GLOBAL);
1096
1136
  }
1097
1137
 
1098
1138
  int git_config_find_xdg(git_buf *path)
1099
1139
  {
1100
- int error;
1101
-
1102
- if ((error = git_buf_sanitize(path)) < 0)
1103
- return error;
1140
+ GIT_BUF_WRAP_PRIVATE(path, git_sysdir_find_global_file, GIT_CONFIG_FILENAME_XDG);
1141
+ }
1104
1142
 
1143
+ int git_config__find_xdg(git_str *path)
1144
+ {
1105
1145
  return git_sysdir_find_xdg_file(path, GIT_CONFIG_FILENAME_XDG);
1106
1146
  }
1107
1147
 
1108
1148
  int git_config_find_system(git_buf *path)
1109
1149
  {
1110
- int error;
1111
-
1112
- if ((error = git_buf_sanitize(path)) < 0)
1113
- return error;
1150
+ GIT_BUF_WRAP_PRIVATE(path, git_sysdir_find_global_file, GIT_CONFIG_FILENAME_SYSTEM);
1151
+ }
1114
1152
 
1153
+ int git_config__find_system(git_str *path)
1154
+ {
1115
1155
  return git_sysdir_find_system_file(path, GIT_CONFIG_FILENAME_SYSTEM);
1116
1156
  }
1117
1157
 
1118
1158
  int git_config_find_programdata(git_buf *path)
1159
+ {
1160
+ git_str str = GIT_STR_INIT;
1161
+ int error;
1162
+
1163
+ if ((error = git_buf_tostr(&str, path)) == 0 &&
1164
+ (error = git_config__find_programdata(&str)) == 0)
1165
+ error = git_buf_fromstr(path, &str);
1166
+
1167
+ git_str_dispose(&str);
1168
+ return error;
1169
+ }
1170
+
1171
+ int git_config__find_programdata(git_str *path)
1119
1172
  {
1120
1173
  int ret;
1121
1174
 
1122
- if ((ret = git_buf_sanitize(path)) < 0)
1123
- return ret;
1175
+ ret = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA);
1124
1176
 
1125
- ret = git_sysdir_find_programdata_file(path,
1126
- GIT_CONFIG_FILENAME_PROGRAMDATA);
1127
1177
  if (ret != GIT_OK)
1128
1178
  return ret;
1129
1179
 
1130
- return git_path_validate_system_file_ownership(path->ptr);
1180
+ return git_fs_path_validate_system_file_ownership(path->ptr);
1131
1181
  }
1132
1182
 
1133
- int git_config__global_location(git_buf *buf)
1183
+ int git_config__global_location(git_str *buf)
1134
1184
  {
1135
- const git_buf *paths;
1185
+ const git_str *paths;
1136
1186
  const char *sep, *start;
1137
1187
 
1138
1188
  if (git_sysdir_get(&paths, GIT_SYSDIR_GLOBAL) < 0)
1139
1189
  return -1;
1140
1190
 
1141
1191
  /* no paths, so give up */
1142
- if (!paths || !git_buf_len(paths))
1192
+ if (!paths || !git_str_len(paths))
1143
1193
  return -1;
1144
1194
 
1145
1195
  /* find unescaped separator or end of string */
1146
- for (sep = start = git_buf_cstr(paths); *sep; ++sep) {
1196
+ for (sep = start = git_str_cstr(paths); *sep; ++sep) {
1147
1197
  if (*sep == GIT_PATH_LIST_SEPARATOR &&
1148
1198
  (sep <= start || sep[-1] != '\\'))
1149
1199
  break;
1150
1200
  }
1151
1201
 
1152
- if (git_buf_set(buf, start, (size_t)(sep - start)) < 0)
1202
+ if (git_str_set(buf, start, (size_t)(sep - start)) < 0)
1153
1203
  return -1;
1154
1204
 
1155
- return git_buf_joinpath(buf, buf->ptr, GIT_CONFIG_FILENAME_GLOBAL);
1205
+ return git_str_joinpath(buf, buf->ptr, GIT_CONFIG_FILENAME_GLOBAL);
1156
1206
  }
1157
1207
 
1158
1208
  int git_config_open_default(git_config **out)
1159
1209
  {
1160
1210
  int error;
1161
1211
  git_config *cfg = NULL;
1162
- git_buf buf = GIT_BUF_INIT;
1212
+ git_str buf = GIT_STR_INIT;
1163
1213
 
1164
1214
  if ((error = git_config_new(&cfg)) < 0)
1165
1215
  return error;
1166
1216
 
1167
- if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) {
1217
+ if (!git_config__find_global(&buf) ||
1218
+ !git_config__global_location(&buf)) {
1168
1219
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1169
1220
  GIT_CONFIG_LEVEL_GLOBAL, NULL, 0);
1170
1221
  }
1171
1222
 
1172
- if (!error && !git_config_find_xdg(&buf))
1223
+ if (!error && !git_config__find_xdg(&buf))
1173
1224
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1174
1225
  GIT_CONFIG_LEVEL_XDG, NULL, 0);
1175
1226
 
1176
- if (!error && !git_config_find_system(&buf))
1227
+ if (!error && !git_config__find_system(&buf))
1177
1228
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1178
1229
  GIT_CONFIG_LEVEL_SYSTEM, NULL, 0);
1179
1230
 
1180
- if (!error && !git_config_find_programdata(&buf))
1231
+ if (!error && !git_config__find_programdata(&buf))
1181
1232
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1182
1233
  GIT_CONFIG_LEVEL_PROGRAMDATA, NULL, 0);
1183
1234
 
1184
- git_buf_dispose(&buf);
1235
+ git_str_dispose(&buf);
1185
1236
 
1186
1237
  if (error) {
1187
1238
  git_config_free(cfg);
@@ -1375,28 +1426,6 @@ fail_parse:
1375
1426
  return -1;
1376
1427
  }
1377
1428
 
1378
- int git_config_parse_path(git_buf *out, const char *value)
1379
- {
1380
- int error;
1381
-
1382
- GIT_ASSERT_ARG(out);
1383
- GIT_ASSERT_ARG(value);
1384
-
1385
- if ((error = git_buf_sanitize(out)) < 0)
1386
- return error;
1387
-
1388
- if (value[0] == '~') {
1389
- if (value[1] != '\0' && value[1] != '/') {
1390
- git_error_set(GIT_ERROR_CONFIG, "retrieving a homedir by name is not supported");
1391
- return -1;
1392
- }
1393
-
1394
- return git_sysdir_expand_global_file(out, value[1] ? &value[2] : NULL);
1395
- }
1396
-
1397
- return git_buf_sets(out, value);
1398
- }
1399
-
1400
1429
  static int normalize_section(char *start, char *end)
1401
1430
  {
1402
1431
  char *scan;
@@ -1459,7 +1488,7 @@ invalid:
1459
1488
 
1460
1489
  struct rename_data {
1461
1490
  git_config *config;
1462
- git_buf *name;
1491
+ git_str *name;
1463
1492
  size_t old_len;
1464
1493
  };
1465
1494
 
@@ -1469,15 +1498,15 @@ static int rename_config_entries_cb(
1469
1498
  {
1470
1499
  int error = 0;
1471
1500
  struct rename_data *data = (struct rename_data *)payload;
1472
- size_t base_len = git_buf_len(data->name);
1501
+ size_t base_len = git_str_len(data->name);
1473
1502
 
1474
1503
  if (base_len > 0 &&
1475
- !(error = git_buf_puts(data->name, entry->name + data->old_len)))
1504
+ !(error = git_str_puts(data->name, entry->name + data->old_len)))
1476
1505
  {
1477
1506
  error = git_config_set_string(
1478
- data->config, git_buf_cstr(data->name), entry->value);
1507
+ data->config, git_str_cstr(data->name), entry->value);
1479
1508
 
1480
- git_buf_truncate(data->name, base_len);
1509
+ git_str_truncate(data->name, base_len);
1481
1510
  }
1482
1511
 
1483
1512
  if (!error)
@@ -1492,13 +1521,13 @@ int git_config_rename_section(
1492
1521
  const char *new_section_name)
1493
1522
  {
1494
1523
  git_config *config;
1495
- git_buf pattern = GIT_BUF_INIT, replace = GIT_BUF_INIT;
1524
+ git_str pattern = GIT_STR_INIT, replace = GIT_STR_INIT;
1496
1525
  int error = 0;
1497
1526
  struct rename_data data;
1498
1527
 
1499
- git_buf_puts_escape_regex(&pattern, old_section_name);
1528
+ git_str_puts_escape_regex(&pattern, old_section_name);
1500
1529
 
1501
- if ((error = git_buf_puts(&pattern, "\\..+")) < 0)
1530
+ if ((error = git_str_puts(&pattern, "\\..+")) < 0)
1502
1531
  goto cleanup;
1503
1532
 
1504
1533
  if ((error = git_repository_config__weakptr(&config, repo)) < 0)
@@ -1508,7 +1537,7 @@ int git_config_rename_section(
1508
1537
  data.name = &replace;
1509
1538
  data.old_len = strlen(old_section_name) + 1;
1510
1539
 
1511
- if ((error = git_buf_join(&replace, '.', new_section_name, "")) < 0)
1540
+ if ((error = git_str_join(&replace, '.', new_section_name, "")) < 0)
1512
1541
  goto cleanup;
1513
1542
 
1514
1543
  if (new_section_name != NULL &&
@@ -1520,11 +1549,11 @@ int git_config_rename_section(
1520
1549
  }
1521
1550
 
1522
1551
  error = git_config_foreach_match(
1523
- config, git_buf_cstr(&pattern), rename_config_entries_cb, &data);
1552
+ config, git_str_cstr(&pattern), rename_config_entries_cb, &data);
1524
1553
 
1525
1554
  cleanup:
1526
- git_buf_dispose(&pattern);
1527
- git_buf_dispose(&replace);
1555
+ git_str_dispose(&pattern);
1556
+ git_str_dispose(&replace);
1528
1557
 
1529
1558
  return error;
1530
1559
  }
@@ -27,7 +27,12 @@ struct git_config {
27
27
  git_vector backends;
28
28
  };
29
29
 
30
- extern int git_config__global_location(git_buf *buf);
30
+ extern int git_config__global_location(git_str *buf);
31
+
32
+ extern int git_config__find_global(git_str *path);
33
+ extern int git_config__find_xdg(git_str *path);
34
+ extern int git_config__find_system(git_str *path);
35
+ extern int git_config__find_programdata(git_str *path);
31
36
 
32
37
  extern int git_config_rename_section(
33
38
  git_repository *repo,
@@ -51,6 +56,14 @@ extern int git_config__update_entry(
51
56
  bool overwrite_existing,
52
57
  bool only_if_existing);
53
58
 
59
+ int git_config__get_path(
60
+ git_str *out,
61
+ const git_config *cfg,
62
+ const char *name);
63
+
64
+ int git_config__get_string_buf(
65
+ git_str *out, const git_config *cfg, const char *name);
66
+
54
67
  /*
55
68
  * Lookup functions that cannot fail. These functions look up a config
56
69
  * value and return a fallback value if the value is missing or if any
@@ -83,7 +96,7 @@ int git_config_lookup_map_enum(git_configmap_t *type_out,
83
96
  /**
84
97
  * Unlock the backend with the highest priority
85
98
  *
86
- * Unlocking will allow other writers to updat the configuration
99
+ * Unlocking will allow other writers to update the configuration
87
100
  * file. Optionally, any changes performed since the lock will be
88
101
  * applied to the configuration.
89
102
  *