rugged 1.3.2.3 → 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 (329) 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/deps/zlib/adler32.c +0 -7
  44. data/vendor/libgit2/deps/zlib/crc32.c +288 -975
  45. data/vendor/libgit2/deps/zlib/crc32.h +436 -9441
  46. data/vendor/libgit2/deps/zlib/deflate.c +31 -83
  47. data/vendor/libgit2/deps/zlib/deflate.h +15 -12
  48. data/vendor/libgit2/deps/zlib/gzguts.h +2 -3
  49. data/vendor/libgit2/deps/zlib/infback.c +1 -2
  50. data/vendor/libgit2/deps/zlib/inffast.c +14 -14
  51. data/vendor/libgit2/deps/zlib/inflate.c +8 -39
  52. data/vendor/libgit2/deps/zlib/inflate.h +2 -3
  53. data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
  54. data/vendor/libgit2/deps/zlib/trees.c +48 -27
  55. data/vendor/libgit2/deps/zlib/zlib.h +100 -126
  56. data/vendor/libgit2/deps/zlib/zutil.c +2 -2
  57. data/vendor/libgit2/deps/zlib/zutil.h +9 -12
  58. data/vendor/libgit2/include/git2/apply.h +16 -2
  59. data/vendor/libgit2/include/git2/attr.h +11 -2
  60. data/vendor/libgit2/include/git2/blame.h +4 -1
  61. data/vendor/libgit2/include/git2/blob.h +14 -1
  62. data/vendor/libgit2/include/git2/branch.h +2 -0
  63. data/vendor/libgit2/include/git2/buffer.h +18 -78
  64. data/vendor/libgit2/include/git2/cert.h +2 -2
  65. data/vendor/libgit2/include/git2/checkout.h +5 -2
  66. data/vendor/libgit2/include/git2/clone.h +3 -3
  67. data/vendor/libgit2/include/git2/commit.h +2 -0
  68. data/vendor/libgit2/include/git2/common.h +5 -12
  69. data/vendor/libgit2/include/git2/config.h +19 -3
  70. data/vendor/libgit2/include/git2/credential.h +2 -1
  71. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  72. data/vendor/libgit2/include/git2/deprecated.h +1 -1
  73. data/vendor/libgit2/include/git2/describe.h +7 -2
  74. data/vendor/libgit2/include/git2/diff.h +17 -9
  75. data/vendor/libgit2/include/git2/email.h +1 -1
  76. data/vendor/libgit2/include/git2/errors.h +1 -2
  77. data/vendor/libgit2/include/git2/filter.h +7 -2
  78. data/vendor/libgit2/include/git2/graph.h +1 -0
  79. data/vendor/libgit2/include/git2/ignore.h +1 -1
  80. data/vendor/libgit2/include/git2/index.h +11 -5
  81. data/vendor/libgit2/include/git2/indexer.h +19 -0
  82. data/vendor/libgit2/include/git2/merge.h +23 -3
  83. data/vendor/libgit2/include/git2/message.h +2 -0
  84. data/vendor/libgit2/include/git2/object.h +23 -0
  85. data/vendor/libgit2/include/git2/odb.h +37 -7
  86. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  87. data/vendor/libgit2/include/git2/pack.h +24 -8
  88. data/vendor/libgit2/include/git2/patch.h +8 -0
  89. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  90. data/vendor/libgit2/include/git2/proxy.h +1 -1
  91. data/vendor/libgit2/include/git2/rebase.h +9 -1
  92. data/vendor/libgit2/include/git2/refdb.h +3 -0
  93. data/vendor/libgit2/include/git2/reflog.h +1 -1
  94. data/vendor/libgit2/include/git2/refs.h +2 -2
  95. data/vendor/libgit2/include/git2/remote.h +184 -37
  96. data/vendor/libgit2/include/git2/repository.h +14 -9
  97. data/vendor/libgit2/include/git2/reset.h +2 -2
  98. data/vendor/libgit2/include/git2/revparse.h +1 -1
  99. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  100. data/vendor/libgit2/include/git2/signature.h +1 -1
  101. data/vendor/libgit2/include/git2/stash.h +3 -3
  102. data/vendor/libgit2/include/git2/status.h +9 -3
  103. data/vendor/libgit2/include/git2/submodule.h +7 -2
  104. data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
  105. data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
  106. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  107. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  108. data/vendor/libgit2/include/git2/sys/transport.h +25 -34
  109. data/vendor/libgit2/include/git2/tag.h +1 -0
  110. data/vendor/libgit2/include/git2/tree.h +4 -3
  111. data/vendor/libgit2/include/git2/types.h +7 -7
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/include/git2/worktree.h +12 -2
  114. data/vendor/libgit2/src/CMakeLists.txt +189 -315
  115. data/vendor/libgit2/src/annotated_commit.h +1 -1
  116. data/vendor/libgit2/src/apply.c +18 -18
  117. data/vendor/libgit2/src/apply.h +2 -2
  118. data/vendor/libgit2/src/attr.c +18 -18
  119. data/vendor/libgit2/src/attr_file.c +17 -17
  120. data/vendor/libgit2/src/attr_file.h +4 -4
  121. data/vendor/libgit2/src/attrcache.c +17 -12
  122. data/vendor/libgit2/src/blame_git.c +1 -1
  123. data/vendor/libgit2/src/blob.c +33 -26
  124. data/vendor/libgit2/src/blob.h +1 -1
  125. data/vendor/libgit2/src/branch.c +150 -109
  126. data/vendor/libgit2/src/branch.h +15 -3
  127. data/vendor/libgit2/src/buf.c +126 -0
  128. data/vendor/libgit2/src/buf.h +50 -0
  129. data/vendor/libgit2/src/cc-compat.h +1 -1
  130. data/vendor/libgit2/src/checkout.c +74 -68
  131. data/vendor/libgit2/src/cherrypick.c +10 -10
  132. data/vendor/libgit2/src/clone.c +66 -66
  133. data/vendor/libgit2/src/commit.c +128 -58
  134. data/vendor/libgit2/src/commit.h +24 -1
  135. data/vendor/libgit2/src/commit_graph.c +68 -53
  136. data/vendor/libgit2/src/commit_graph.h +10 -3
  137. data/vendor/libgit2/src/commit_list.c +2 -3
  138. data/vendor/libgit2/src/common.h +10 -3
  139. data/vendor/libgit2/src/config.c +99 -77
  140. data/vendor/libgit2/src/config.h +15 -2
  141. data/vendor/libgit2/src/config_file.c +103 -91
  142. data/vendor/libgit2/src/config_mem.c +9 -9
  143. data/vendor/libgit2/src/config_parse.c +27 -23
  144. data/vendor/libgit2/src/crlf.c +24 -21
  145. data/vendor/libgit2/src/date.c +10 -17
  146. data/vendor/libgit2/src/date.h +33 -0
  147. data/vendor/libgit2/src/describe.c +27 -19
  148. data/vendor/libgit2/src/diff.c +25 -8
  149. data/vendor/libgit2/src/diff.h +2 -4
  150. data/vendor/libgit2/src/diff_driver.c +34 -36
  151. data/vendor/libgit2/src/diff_driver.h +3 -3
  152. data/vendor/libgit2/src/diff_file.c +29 -20
  153. data/vendor/libgit2/src/diff_generate.c +30 -6
  154. data/vendor/libgit2/src/diff_generate.h +5 -3
  155. data/vendor/libgit2/src/diff_print.c +102 -95
  156. data/vendor/libgit2/src/diff_stats.c +40 -29
  157. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  158. data/vendor/libgit2/src/diff_tform.c +9 -8
  159. data/vendor/libgit2/src/diff_xdiff.c +3 -8
  160. data/vendor/libgit2/src/email.c +54 -38
  161. data/vendor/libgit2/src/email.h +1 -1
  162. data/vendor/libgit2/src/errors.c +18 -18
  163. data/vendor/libgit2/src/features.h.in +6 -1
  164. data/vendor/libgit2/src/fetch.c +69 -24
  165. data/vendor/libgit2/src/fetch.h +1 -1
  166. data/vendor/libgit2/src/fetchhead.c +19 -19
  167. data/vendor/libgit2/src/filebuf.c +28 -28
  168. data/vendor/libgit2/src/filebuf.h +1 -1
  169. data/vendor/libgit2/src/filter.c +96 -52
  170. data/vendor/libgit2/src/filter.h +26 -5
  171. data/vendor/libgit2/src/fs_path.c +1912 -0
  172. data/vendor/libgit2/src/fs_path.h +752 -0
  173. data/vendor/libgit2/src/futils.c +91 -85
  174. data/vendor/libgit2/src/futils.h +26 -14
  175. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
  176. data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
  177. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  178. data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
  179. data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
  180. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
  181. data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
  182. data/vendor/libgit2/src/hash/sha1.h +3 -1
  183. data/vendor/libgit2/src/hash.c +67 -35
  184. data/vendor/libgit2/src/hash.h +12 -12
  185. data/vendor/libgit2/src/ident.c +18 -18
  186. data/vendor/libgit2/src/ignore.c +35 -34
  187. data/vendor/libgit2/src/ignore.h +2 -2
  188. data/vendor/libgit2/src/index.c +79 -80
  189. data/vendor/libgit2/src/index.h +6 -3
  190. data/vendor/libgit2/src/indexer.c +75 -57
  191. data/vendor/libgit2/src/iterator.c +64 -56
  192. data/vendor/libgit2/src/iterator.h +5 -5
  193. data/vendor/libgit2/src/khash.h +1 -1
  194. data/vendor/libgit2/src/libgit2.c +22 -19
  195. data/vendor/libgit2/src/mailmap.c +38 -36
  196. data/vendor/libgit2/src/merge.c +27 -27
  197. data/vendor/libgit2/src/merge.h +1 -14
  198. data/vendor/libgit2/src/merge_driver.c +2 -2
  199. data/vendor/libgit2/src/merge_file.c +13 -3
  200. data/vendor/libgit2/src/message.c +21 -10
  201. data/vendor/libgit2/src/midx.c +83 -66
  202. data/vendor/libgit2/src/midx.h +3 -3
  203. data/vendor/libgit2/src/mwindow.c +1 -1
  204. data/vendor/libgit2/src/net.c +278 -68
  205. data/vendor/libgit2/src/net.h +10 -3
  206. data/vendor/libgit2/src/netops.c +1 -1
  207. data/vendor/libgit2/src/netops.h +1 -1
  208. data/vendor/libgit2/src/notes.c +20 -29
  209. data/vendor/libgit2/src/object.c +49 -9
  210. data/vendor/libgit2/src/object.h +1 -1
  211. data/vendor/libgit2/src/odb.c +35 -32
  212. data/vendor/libgit2/src/odb.h +1 -1
  213. data/vendor/libgit2/src/odb_loose.c +68 -68
  214. data/vendor/libgit2/src/odb_mempack.c +18 -5
  215. data/vendor/libgit2/src/odb_pack.c +43 -43
  216. data/vendor/libgit2/src/oid.c +11 -4
  217. data/vendor/libgit2/src/oid.h +15 -0
  218. data/vendor/libgit2/src/pack-objects.c +41 -26
  219. data/vendor/libgit2/src/pack-objects.h +11 -6
  220. data/vendor/libgit2/src/pack.c +10 -10
  221. data/vendor/libgit2/src/patch.c +3 -3
  222. data/vendor/libgit2/src/patch.h +1 -0
  223. data/vendor/libgit2/src/patch_generate.c +27 -11
  224. data/vendor/libgit2/src/patch_generate.h +5 -5
  225. data/vendor/libgit2/src/patch_parse.c +24 -24
  226. data/vendor/libgit2/src/path.c +76 -1951
  227. data/vendor/libgit2/src/path.h +34 -741
  228. data/vendor/libgit2/src/pathspec.c +6 -6
  229. data/vendor/libgit2/src/pathspec.h +2 -2
  230. data/vendor/libgit2/src/posix.c +3 -3
  231. data/vendor/libgit2/src/posix.h +1 -0
  232. data/vendor/libgit2/src/pqueue.h +1 -1
  233. data/vendor/libgit2/src/proxy.c +4 -1
  234. data/vendor/libgit2/src/proxy.h +1 -1
  235. data/vendor/libgit2/src/push.c +30 -35
  236. data/vendor/libgit2/src/push.h +4 -16
  237. data/vendor/libgit2/src/rand.c +226 -0
  238. data/vendor/libgit2/src/rand.h +37 -0
  239. data/vendor/libgit2/src/reader.c +8 -8
  240. data/vendor/libgit2/src/reader.h +2 -2
  241. data/vendor/libgit2/src/rebase.c +89 -88
  242. data/vendor/libgit2/src/refdb_fs.c +447 -173
  243. data/vendor/libgit2/src/refs.c +32 -32
  244. data/vendor/libgit2/src/refs.h +2 -2
  245. data/vendor/libgit2/src/refspec.c +32 -37
  246. data/vendor/libgit2/src/refspec.h +5 -2
  247. data/vendor/libgit2/src/regexp.c +1 -1
  248. data/vendor/libgit2/src/remote.c +713 -419
  249. data/vendor/libgit2/src/remote.h +15 -10
  250. data/vendor/libgit2/src/repository.c +350 -467
  251. data/vendor/libgit2/src/repository.h +11 -10
  252. data/vendor/libgit2/src/reset.c +8 -5
  253. data/vendor/libgit2/src/revert.c +10 -10
  254. data/vendor/libgit2/src/revparse.c +48 -35
  255. data/vendor/libgit2/src/revwalk.c +7 -7
  256. data/vendor/libgit2/src/signature.c +12 -6
  257. data/vendor/libgit2/src/signature.h +1 -1
  258. data/vendor/libgit2/src/sortedcache.c +1 -1
  259. data/vendor/libgit2/src/sortedcache.h +1 -1
  260. data/vendor/libgit2/src/stash.c +36 -37
  261. data/vendor/libgit2/src/status.c +4 -1
  262. data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
  263. data/vendor/libgit2/src/str.h +357 -0
  264. data/vendor/libgit2/src/streams/mbedtls.c +8 -6
  265. data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
  266. data/vendor/libgit2/src/submodule.c +171 -159
  267. data/vendor/libgit2/src/submodule.h +1 -1
  268. data/vendor/libgit2/src/sysdir.c +68 -52
  269. data/vendor/libgit2/src/sysdir.h +15 -10
  270. data/vendor/libgit2/src/tag.c +29 -27
  271. data/vendor/libgit2/src/thread.h +3 -3
  272. data/vendor/libgit2/src/threadstate.c +3 -3
  273. data/vendor/libgit2/src/threadstate.h +1 -1
  274. data/vendor/libgit2/src/trace.c +1 -14
  275. data/vendor/libgit2/src/trace.h +5 -22
  276. data/vendor/libgit2/src/trailer.c +1 -1
  277. data/vendor/libgit2/src/transaction.c +1 -1
  278. data/vendor/libgit2/src/transport.c +10 -10
  279. data/vendor/libgit2/src/transports/auth.c +7 -9
  280. data/vendor/libgit2/src/transports/auth.h +2 -3
  281. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
  282. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
  283. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  284. data/vendor/libgit2/src/transports/git.c +9 -11
  285. data/vendor/libgit2/src/transports/http.c +37 -17
  286. data/vendor/libgit2/src/transports/http.h +2 -3
  287. data/vendor/libgit2/src/transports/httpclient.c +65 -65
  288. data/vendor/libgit2/src/transports/local.c +124 -116
  289. data/vendor/libgit2/src/transports/smart.c +51 -139
  290. data/vendor/libgit2/src/transports/smart.h +25 -31
  291. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  292. data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
  293. data/vendor/libgit2/src/transports/ssh.c +47 -112
  294. data/vendor/libgit2/src/transports/winhttp.c +50 -56
  295. data/vendor/libgit2/src/tree-cache.c +5 -5
  296. data/vendor/libgit2/src/tree-cache.h +2 -2
  297. data/vendor/libgit2/src/tree.c +59 -48
  298. data/vendor/libgit2/src/tree.h +1 -1
  299. data/vendor/libgit2/src/unix/map.c +0 -2
  300. data/vendor/libgit2/src/unix/posix.h +1 -4
  301. data/vendor/libgit2/src/unix/realpath.c +0 -2
  302. data/vendor/libgit2/src/util.c +14 -14
  303. data/vendor/libgit2/src/util.h +2 -28
  304. data/vendor/libgit2/src/vector.h +1 -1
  305. data/vendor/libgit2/src/win32/findfile.c +172 -116
  306. data/vendor/libgit2/src/win32/findfile.h +7 -4
  307. data/vendor/libgit2/src/win32/path_w32.c +140 -9
  308. data/vendor/libgit2/src/win32/path_w32.h +2 -0
  309. data/vendor/libgit2/src/win32/posix.h +0 -1
  310. data/vendor/libgit2/src/win32/posix_w32.c +11 -27
  311. data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
  312. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  313. data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
  314. data/vendor/libgit2/src/worktree.c +116 -94
  315. data/vendor/libgit2/src/worktree.h +1 -1
  316. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  317. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  318. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  319. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  320. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  321. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  322. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  323. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  324. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  325. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  326. data/vendor/libgit2/src/zstream.c +5 -5
  327. data/vendor/libgit2/src/zstream.h +4 -4
  328. metadata +25 -10
  329. 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,108 +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)
1119
1159
  {
1120
- git_path_owner_t owner_level =
1121
- GIT_PATH_OWNER_CURRENT_USER |
1122
- GIT_PATH_OWNER_ADMINISTRATOR;
1123
- bool is_safe;
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)
1172
+ {
1124
1173
  int ret;
1125
1174
 
1126
- if ((ret = git_buf_sanitize(path)) < 0 ||
1127
- (ret = git_sysdir_find_programdata_file(path,
1128
- GIT_CONFIG_FILENAME_PROGRAMDATA)) < 0 ||
1129
- (ret = git_path_owner_is(&is_safe, path->ptr, owner_level)) < 0)
1130
- return ret;
1175
+ ret = git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA);
1131
1176
 
1132
- if (!is_safe) {
1133
- git_error_set(GIT_ERROR_CONFIG, "programdata path has invalid ownership");
1134
- return -1;
1135
- }
1177
+ if (ret != GIT_OK)
1178
+ return ret;
1136
1179
 
1137
- return 0;
1180
+ return git_fs_path_validate_system_file_ownership(path->ptr);
1138
1181
  }
1139
1182
 
1140
- int git_config__global_location(git_buf *buf)
1183
+ int git_config__global_location(git_str *buf)
1141
1184
  {
1142
- const git_buf *paths;
1185
+ const git_str *paths;
1143
1186
  const char *sep, *start;
1144
1187
 
1145
1188
  if (git_sysdir_get(&paths, GIT_SYSDIR_GLOBAL) < 0)
1146
1189
  return -1;
1147
1190
 
1148
1191
  /* no paths, so give up */
1149
- if (!paths || !git_buf_len(paths))
1192
+ if (!paths || !git_str_len(paths))
1150
1193
  return -1;
1151
1194
 
1152
1195
  /* find unescaped separator or end of string */
1153
- for (sep = start = git_buf_cstr(paths); *sep; ++sep) {
1196
+ for (sep = start = git_str_cstr(paths); *sep; ++sep) {
1154
1197
  if (*sep == GIT_PATH_LIST_SEPARATOR &&
1155
1198
  (sep <= start || sep[-1] != '\\'))
1156
1199
  break;
1157
1200
  }
1158
1201
 
1159
- if (git_buf_set(buf, start, (size_t)(sep - start)) < 0)
1202
+ if (git_str_set(buf, start, (size_t)(sep - start)) < 0)
1160
1203
  return -1;
1161
1204
 
1162
- return git_buf_joinpath(buf, buf->ptr, GIT_CONFIG_FILENAME_GLOBAL);
1205
+ return git_str_joinpath(buf, buf->ptr, GIT_CONFIG_FILENAME_GLOBAL);
1163
1206
  }
1164
1207
 
1165
1208
  int git_config_open_default(git_config **out)
1166
1209
  {
1167
1210
  int error;
1168
1211
  git_config *cfg = NULL;
1169
- git_buf buf = GIT_BUF_INIT;
1212
+ git_str buf = GIT_STR_INIT;
1170
1213
 
1171
1214
  if ((error = git_config_new(&cfg)) < 0)
1172
1215
  return error;
1173
1216
 
1174
- if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) {
1217
+ if (!git_config__find_global(&buf) ||
1218
+ !git_config__global_location(&buf)) {
1175
1219
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1176
1220
  GIT_CONFIG_LEVEL_GLOBAL, NULL, 0);
1177
1221
  }
1178
1222
 
1179
- if (!error && !git_config_find_xdg(&buf))
1223
+ if (!error && !git_config__find_xdg(&buf))
1180
1224
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1181
1225
  GIT_CONFIG_LEVEL_XDG, NULL, 0);
1182
1226
 
1183
- if (!error && !git_config_find_system(&buf))
1227
+ if (!error && !git_config__find_system(&buf))
1184
1228
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1185
1229
  GIT_CONFIG_LEVEL_SYSTEM, NULL, 0);
1186
1230
 
1187
- if (!error && !git_config_find_programdata(&buf))
1231
+ if (!error && !git_config__find_programdata(&buf))
1188
1232
  error = git_config_add_file_ondisk(cfg, buf.ptr,
1189
1233
  GIT_CONFIG_LEVEL_PROGRAMDATA, NULL, 0);
1190
1234
 
1191
- git_buf_dispose(&buf);
1235
+ git_str_dispose(&buf);
1192
1236
 
1193
1237
  if (error) {
1194
1238
  git_config_free(cfg);
@@ -1382,28 +1426,6 @@ fail_parse:
1382
1426
  return -1;
1383
1427
  }
1384
1428
 
1385
- int git_config_parse_path(git_buf *out, const char *value)
1386
- {
1387
- int error;
1388
-
1389
- GIT_ASSERT_ARG(out);
1390
- GIT_ASSERT_ARG(value);
1391
-
1392
- if ((error = git_buf_sanitize(out)) < 0)
1393
- return error;
1394
-
1395
- if (value[0] == '~') {
1396
- if (value[1] != '\0' && value[1] != '/') {
1397
- git_error_set(GIT_ERROR_CONFIG, "retrieving a homedir by name is not supported");
1398
- return -1;
1399
- }
1400
-
1401
- return git_sysdir_expand_global_file(out, value[1] ? &value[2] : NULL);
1402
- }
1403
-
1404
- return git_buf_sets(out, value);
1405
- }
1406
-
1407
1429
  static int normalize_section(char *start, char *end)
1408
1430
  {
1409
1431
  char *scan;
@@ -1466,7 +1488,7 @@ invalid:
1466
1488
 
1467
1489
  struct rename_data {
1468
1490
  git_config *config;
1469
- git_buf *name;
1491
+ git_str *name;
1470
1492
  size_t old_len;
1471
1493
  };
1472
1494
 
@@ -1476,15 +1498,15 @@ static int rename_config_entries_cb(
1476
1498
  {
1477
1499
  int error = 0;
1478
1500
  struct rename_data *data = (struct rename_data *)payload;
1479
- size_t base_len = git_buf_len(data->name);
1501
+ size_t base_len = git_str_len(data->name);
1480
1502
 
1481
1503
  if (base_len > 0 &&
1482
- !(error = git_buf_puts(data->name, entry->name + data->old_len)))
1504
+ !(error = git_str_puts(data->name, entry->name + data->old_len)))
1483
1505
  {
1484
1506
  error = git_config_set_string(
1485
- data->config, git_buf_cstr(data->name), entry->value);
1507
+ data->config, git_str_cstr(data->name), entry->value);
1486
1508
 
1487
- git_buf_truncate(data->name, base_len);
1509
+ git_str_truncate(data->name, base_len);
1488
1510
  }
1489
1511
 
1490
1512
  if (!error)
@@ -1499,13 +1521,13 @@ int git_config_rename_section(
1499
1521
  const char *new_section_name)
1500
1522
  {
1501
1523
  git_config *config;
1502
- git_buf pattern = GIT_BUF_INIT, replace = GIT_BUF_INIT;
1524
+ git_str pattern = GIT_STR_INIT, replace = GIT_STR_INIT;
1503
1525
  int error = 0;
1504
1526
  struct rename_data data;
1505
1527
 
1506
- git_buf_puts_escape_regex(&pattern, old_section_name);
1528
+ git_str_puts_escape_regex(&pattern, old_section_name);
1507
1529
 
1508
- if ((error = git_buf_puts(&pattern, "\\..+")) < 0)
1530
+ if ((error = git_str_puts(&pattern, "\\..+")) < 0)
1509
1531
  goto cleanup;
1510
1532
 
1511
1533
  if ((error = git_repository_config__weakptr(&config, repo)) < 0)
@@ -1515,7 +1537,7 @@ int git_config_rename_section(
1515
1537
  data.name = &replace;
1516
1538
  data.old_len = strlen(old_section_name) + 1;
1517
1539
 
1518
- if ((error = git_buf_join(&replace, '.', new_section_name, "")) < 0)
1540
+ if ((error = git_str_join(&replace, '.', new_section_name, "")) < 0)
1519
1541
  goto cleanup;
1520
1542
 
1521
1543
  if (new_section_name != NULL &&
@@ -1527,11 +1549,11 @@ int git_config_rename_section(
1527
1549
  }
1528
1550
 
1529
1551
  error = git_config_foreach_match(
1530
- config, git_buf_cstr(&pattern), rename_config_entries_cb, &data);
1552
+ config, git_str_cstr(&pattern), rename_config_entries_cb, &data);
1531
1553
 
1532
1554
  cleanup:
1533
- git_buf_dispose(&pattern);
1534
- git_buf_dispose(&replace);
1555
+ git_str_dispose(&pattern);
1556
+ git_str_dispose(&replace);
1535
1557
 
1536
1558
  return error;
1537
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
  *