rugged 0.28.4 → 0.28.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +0 -1
  4. data/vendor/libgit2/CMakeLists.txt +16 -36
  5. data/vendor/libgit2/COPYING +0 -28
  6. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +1 -5
  7. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  8. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  9. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  10. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +0 -6
  11. data/vendor/libgit2/deps/http-parser/http_parser.c +6 -11
  12. data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
  13. data/vendor/libgit2/deps/regex/COPYING +502 -0
  14. data/vendor/libgit2/deps/regex/config.h +7 -0
  15. data/vendor/libgit2/deps/regex/regcomp.c +3857 -0
  16. data/vendor/libgit2/deps/regex/regex.c +92 -0
  17. data/vendor/libgit2/deps/regex/regex.h +582 -0
  18. data/vendor/libgit2/deps/regex/regex_internal.c +1744 -0
  19. data/vendor/libgit2/deps/regex/regex_internal.h +819 -0
  20. data/vendor/libgit2/deps/regex/regexec.c +4369 -0
  21. data/vendor/libgit2/deps/zlib/adler32.c +7 -0
  22. data/vendor/libgit2/deps/zlib/crc32.c +7 -0
  23. data/vendor/libgit2/include/git2.h +0 -2
  24. data/vendor/libgit2/include/git2/apply.h +2 -22
  25. data/vendor/libgit2/include/git2/attr.h +12 -19
  26. data/vendor/libgit2/include/git2/blame.h +2 -2
  27. data/vendor/libgit2/include/git2/blob.h +12 -44
  28. data/vendor/libgit2/include/git2/buffer.h +14 -20
  29. data/vendor/libgit2/include/git2/checkout.h +14 -46
  30. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  31. data/vendor/libgit2/include/git2/clone.h +2 -2
  32. data/vendor/libgit2/include/git2/commit.h +1 -23
  33. data/vendor/libgit2/include/git2/common.h +5 -7
  34. data/vendor/libgit2/include/git2/config.h +12 -12
  35. data/vendor/libgit2/include/git2/deprecated.h +3 -243
  36. data/vendor/libgit2/include/git2/describe.h +4 -4
  37. data/vendor/libgit2/include/git2/diff.h +14 -16
  38. data/vendor/libgit2/include/git2/filter.h +0 -8
  39. data/vendor/libgit2/include/git2/index.h +1 -2
  40. data/vendor/libgit2/include/git2/indexer.h +4 -48
  41. data/vendor/libgit2/include/git2/inttypes.h +309 -0
  42. data/vendor/libgit2/include/git2/merge.h +10 -6
  43. data/vendor/libgit2/include/git2/net.h +5 -0
  44. data/vendor/libgit2/include/git2/object.h +14 -2
  45. data/vendor/libgit2/include/git2/odb.h +2 -3
  46. data/vendor/libgit2/include/git2/odb_backend.h +4 -5
  47. data/vendor/libgit2/include/git2/oid.h +1 -1
  48. data/vendor/libgit2/include/git2/pack.h +1 -12
  49. data/vendor/libgit2/include/git2/proxy.h +3 -5
  50. data/vendor/libgit2/include/git2/rebase.h +2 -46
  51. data/vendor/libgit2/include/git2/refs.h +0 -19
  52. data/vendor/libgit2/include/git2/remote.h +12 -35
  53. data/vendor/libgit2/include/git2/repository.h +2 -24
  54. data/vendor/libgit2/include/git2/revert.h +1 -1
  55. data/vendor/libgit2/include/git2/stash.h +3 -3
  56. data/vendor/libgit2/include/git2/status.h +16 -25
  57. data/vendor/libgit2/include/git2/submodule.h +3 -20
  58. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  59. data/vendor/libgit2/include/git2/sys/odb_backend.h +4 -48
  60. data/vendor/libgit2/include/git2/sys/refdb_backend.h +21 -57
  61. data/vendor/libgit2/include/git2/sys/repository.h +1 -5
  62. data/vendor/libgit2/include/git2/sys/time.h +31 -0
  63. data/vendor/libgit2/include/git2/sys/transport.h +2 -2
  64. data/vendor/libgit2/include/git2/tag.h +2 -11
  65. data/vendor/libgit2/include/git2/trace.h +2 -2
  66. data/vendor/libgit2/include/git2/transport.h +340 -11
  67. data/vendor/libgit2/include/git2/tree.h +1 -1
  68. data/vendor/libgit2/include/git2/types.h +89 -4
  69. data/vendor/libgit2/include/git2/version.h +2 -2
  70. data/vendor/libgit2/include/git2/worktree.h +5 -5
  71. data/vendor/libgit2/libgit2.pc.in +13 -0
  72. data/vendor/libgit2/src/CMakeLists.txt +222 -88
  73. data/vendor/libgit2/src/alloc.c +14 -2
  74. data/vendor/libgit2/src/apply.c +30 -60
  75. data/vendor/libgit2/src/attr.c +64 -70
  76. data/vendor/libgit2/src/attr_file.c +96 -189
  77. data/vendor/libgit2/src/attr_file.h +9 -9
  78. data/vendor/libgit2/src/attrcache.c +46 -44
  79. data/vendor/libgit2/src/attrcache.h +1 -2
  80. data/vendor/libgit2/src/blame.c +5 -17
  81. data/vendor/libgit2/src/blame.h +1 -1
  82. data/vendor/libgit2/src/blame_git.c +7 -21
  83. data/vendor/libgit2/src/blob.c +17 -81
  84. data/vendor/libgit2/src/blob.h +2 -2
  85. data/vendor/libgit2/src/branch.c +5 -29
  86. data/vendor/libgit2/src/buffer.c +7 -14
  87. data/vendor/libgit2/src/cache.c +33 -26
  88. data/vendor/libgit2/src/cache.h +1 -1
  89. data/vendor/libgit2/src/cc-compat.h +0 -5
  90. data/vendor/libgit2/src/checkout.c +16 -26
  91. data/vendor/libgit2/src/cherrypick.c +3 -9
  92. data/vendor/libgit2/src/clone.c +7 -29
  93. data/vendor/libgit2/src/clone.h +0 -4
  94. data/vendor/libgit2/src/commit.c +21 -69
  95. data/vendor/libgit2/src/commit.h +0 -6
  96. data/vendor/libgit2/src/commit_list.c +76 -28
  97. data/vendor/libgit2/src/commit_list.h +2 -2
  98. data/vendor/libgit2/src/common.h +75 -3
  99. data/vendor/libgit2/src/config.c +40 -31
  100. data/vendor/libgit2/src/config.h +6 -7
  101. data/vendor/libgit2/src/config_backend.h +0 -12
  102. data/vendor/libgit2/src/config_cache.c +39 -39
  103. data/vendor/libgit2/src/config_entries.c +99 -69
  104. data/vendor/libgit2/src/config_entries.h +0 -1
  105. data/vendor/libgit2/src/config_file.c +380 -337
  106. data/vendor/libgit2/src/config_mem.c +16 -12
  107. data/vendor/libgit2/src/config_parse.c +29 -49
  108. data/vendor/libgit2/src/config_parse.h +12 -13
  109. data/vendor/libgit2/src/crlf.c +14 -14
  110. data/vendor/libgit2/src/describe.c +20 -21
  111. data/vendor/libgit2/src/diff.c +58 -43
  112. data/vendor/libgit2/src/diff.h +1 -2
  113. data/vendor/libgit2/src/diff_driver.c +38 -37
  114. data/vendor/libgit2/src/diff_file.c +7 -9
  115. data/vendor/libgit2/src/diff_file.h +1 -1
  116. data/vendor/libgit2/src/diff_generate.c +85 -135
  117. data/vendor/libgit2/src/diff_generate.h +2 -2
  118. data/vendor/libgit2/src/diff_parse.c +1 -1
  119. data/vendor/libgit2/src/diff_print.c +13 -25
  120. data/vendor/libgit2/src/diff_stats.c +1 -1
  121. data/vendor/libgit2/src/diff_tform.c +4 -4
  122. data/vendor/libgit2/src/errors.c +22 -12
  123. data/vendor/libgit2/src/features.h.in +2 -9
  124. data/vendor/libgit2/src/fetch.c +2 -7
  125. data/vendor/libgit2/src/fetchhead.c +1 -1
  126. data/vendor/libgit2/src/filebuf.c +10 -6
  127. data/vendor/libgit2/src/filebuf.h +2 -2
  128. data/vendor/libgit2/src/{futils.c → fileops.c} +17 -21
  129. data/vendor/libgit2/src/{futils.h → fileops.h} +5 -5
  130. data/vendor/libgit2/src/filter.c +8 -16
  131. data/vendor/libgit2/src/fnmatch.c +248 -0
  132. data/vendor/libgit2/src/fnmatch.h +48 -0
  133. data/vendor/libgit2/src/global.c +40 -12
  134. data/vendor/libgit2/src/global.h +2 -0
  135. data/vendor/libgit2/src/hash.c +0 -61
  136. data/vendor/libgit2/src/hash.h +21 -19
  137. data/vendor/libgit2/src/hash/{sha1/collisiondetect.c → hash_collisiondetect.h} +17 -14
  138. data/vendor/libgit2/src/hash/{sha1/common_crypto.c → hash_common_crypto.h} +19 -15
  139. data/vendor/libgit2/src/hash/{sha1/generic.c → hash_generic.c} +10 -22
  140. data/vendor/libgit2/src/hash/{sha1/generic.h → hash_generic.h} +14 -4
  141. data/vendor/libgit2/src/hash/{sha1/mbedtls.c → hash_mbedtls.c} +7 -15
  142. data/vendor/libgit2/src/hash/{sha1/mbedtls.h → hash_mbedtls.h} +11 -6
  143. data/vendor/libgit2/src/hash/{sha1/openssl.c → hash_openssl.h} +18 -14
  144. data/vendor/libgit2/src/hash/{sha1/win32.c → hash_win32.c} +24 -34
  145. data/vendor/libgit2/src/hash/{sha1/win32.h → hash_win32.h} +19 -6
  146. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.c +3 -14
  147. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.h +0 -0
  148. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.c +0 -0
  149. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.h +0 -0
  150. data/vendor/libgit2/src/hashsig.c +1 -1
  151. data/vendor/libgit2/src/idxmap.c +65 -91
  152. data/vendor/libgit2/src/idxmap.h +15 -151
  153. data/vendor/libgit2/src/ignore.c +38 -32
  154. data/vendor/libgit2/src/index.c +43 -66
  155. data/vendor/libgit2/src/index.h +1 -1
  156. data/vendor/libgit2/src/indexer.c +70 -69
  157. data/vendor/libgit2/src/integer.h +4 -39
  158. data/vendor/libgit2/src/iterator.c +22 -27
  159. data/vendor/libgit2/src/map.h +1 -1
  160. data/vendor/libgit2/src/merge.c +44 -58
  161. data/vendor/libgit2/src/merge_driver.c +4 -4
  162. data/vendor/libgit2/src/merge_file.c +1 -1
  163. data/vendor/libgit2/src/mwindow.c +23 -18
  164. data/vendor/libgit2/src/mwindow.h +4 -4
  165. data/vendor/libgit2/src/netops.c +165 -55
  166. data/vendor/libgit2/src/netops.h +25 -3
  167. data/vendor/libgit2/src/notes.c +2 -2
  168. data/vendor/libgit2/src/object.c +2 -2
  169. data/vendor/libgit2/src/object.h +0 -2
  170. data/vendor/libgit2/src/odb.c +23 -41
  171. data/vendor/libgit2/src/odb.h +2 -3
  172. data/vendor/libgit2/src/odb_loose.c +10 -17
  173. data/vendor/libgit2/src/odb_mempack.c +23 -10
  174. data/vendor/libgit2/src/odb_pack.c +4 -4
  175. data/vendor/libgit2/src/offmap.c +55 -43
  176. data/vendor/libgit2/src/offmap.h +24 -102
  177. data/vendor/libgit2/src/oid.c +1 -6
  178. data/vendor/libgit2/src/oidmap.c +57 -39
  179. data/vendor/libgit2/src/oidmap.h +19 -99
  180. data/vendor/libgit2/src/pack-objects.c +32 -25
  181. data/vendor/libgit2/src/pack-objects.h +1 -1
  182. data/vendor/libgit2/src/pack.c +47 -45
  183. data/vendor/libgit2/src/pack.h +14 -12
  184. data/vendor/libgit2/src/parse.c +0 -10
  185. data/vendor/libgit2/src/parse.h +3 -3
  186. data/vendor/libgit2/src/patch.c +1 -1
  187. data/vendor/libgit2/src/patch_generate.c +2 -2
  188. data/vendor/libgit2/src/patch_parse.c +31 -124
  189. data/vendor/libgit2/src/path.c +6 -43
  190. data/vendor/libgit2/src/path.h +0 -2
  191. data/vendor/libgit2/src/pathspec.c +13 -13
  192. data/vendor/libgit2/src/pool.c +22 -26
  193. data/vendor/libgit2/src/pool.h +7 -7
  194. data/vendor/libgit2/src/posix.c +7 -7
  195. data/vendor/libgit2/src/posix.h +1 -12
  196. data/vendor/libgit2/src/proxy.c +2 -7
  197. data/vendor/libgit2/src/push.c +5 -10
  198. data/vendor/libgit2/src/reader.c +2 -2
  199. data/vendor/libgit2/src/rebase.c +7 -66
  200. data/vendor/libgit2/src/refdb.c +0 -12
  201. data/vendor/libgit2/src/refdb_fs.c +165 -214
  202. data/vendor/libgit2/src/reflog.c +13 -11
  203. data/vendor/libgit2/src/refs.c +18 -24
  204. data/vendor/libgit2/src/refspec.c +16 -9
  205. data/vendor/libgit2/src/remote.c +52 -50
  206. data/vendor/libgit2/src/remote.h +2 -2
  207. data/vendor/libgit2/src/repository.c +100 -115
  208. data/vendor/libgit2/src/repository.h +40 -49
  209. data/vendor/libgit2/src/revert.c +3 -8
  210. data/vendor/libgit2/src/revparse.c +19 -18
  211. data/vendor/libgit2/src/revwalk.c +30 -63
  212. data/vendor/libgit2/src/revwalk.h +0 -20
  213. data/vendor/libgit2/src/settings.c +0 -5
  214. data/vendor/libgit2/src/sortedcache.c +26 -12
  215. data/vendor/libgit2/src/sortedcache.h +1 -1
  216. data/vendor/libgit2/src/stash.c +65 -45
  217. data/vendor/libgit2/src/status.c +9 -15
  218. data/vendor/libgit2/src/{allocators/stdalloc.c → stdalloc.c} +4 -3
  219. data/vendor/libgit2/src/{allocators/stdalloc.h → stdalloc.h} +4 -4
  220. data/vendor/libgit2/src/streams/openssl.c +0 -20
  221. data/vendor/libgit2/src/streams/socket.c +2 -2
  222. data/vendor/libgit2/src/strmap.c +84 -37
  223. data/vendor/libgit2/src/strmap.h +33 -105
  224. data/vendor/libgit2/src/submodule.c +70 -102
  225. data/vendor/libgit2/src/submodule.h +1 -1
  226. data/vendor/libgit2/src/sysdir.c +1 -11
  227. data/vendor/libgit2/src/tag.c +2 -10
  228. data/vendor/libgit2/src/trace.c +1 -1
  229. data/vendor/libgit2/src/trace.h +2 -2
  230. data/vendor/libgit2/src/trailer.c +32 -46
  231. data/vendor/libgit2/src/transaction.c +9 -10
  232. data/vendor/libgit2/src/transports/auth.c +9 -10
  233. data/vendor/libgit2/src/transports/auth.h +4 -11
  234. data/vendor/libgit2/src/transports/auth_negotiate.c +9 -23
  235. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  236. data/vendor/libgit2/src/transports/cred.c +6 -6
  237. data/vendor/libgit2/src/{allocators/win32_crtdbg.h → transports/cred.h} +4 -5
  238. data/vendor/libgit2/src/transports/git.c +16 -11
  239. data/vendor/libgit2/src/transports/http.c +276 -419
  240. data/vendor/libgit2/src/transports/http.h +1 -1
  241. data/vendor/libgit2/src/transports/local.c +9 -9
  242. data/vendor/libgit2/src/transports/smart.c +17 -17
  243. data/vendor/libgit2/src/transports/smart.h +2 -2
  244. data/vendor/libgit2/src/transports/smart_protocol.c +60 -36
  245. data/vendor/libgit2/src/transports/ssh.c +36 -46
  246. data/vendor/libgit2/src/transports/winhttp.c +207 -231
  247. data/vendor/libgit2/src/tree-cache.c +7 -14
  248. data/vendor/libgit2/src/tree.c +24 -10
  249. data/vendor/libgit2/src/unix/map.c +1 -1
  250. data/vendor/libgit2/src/unix/posix.h +11 -1
  251. data/vendor/libgit2/src/userdiff.h +1 -3
  252. data/vendor/libgit2/src/util.c +53 -51
  253. data/vendor/libgit2/src/util.h +21 -16
  254. data/vendor/libgit2/src/win32/map.c +5 -3
  255. data/vendor/libgit2/src/win32/path_w32.c +2 -12
  256. data/vendor/libgit2/src/win32/path_w32.h +29 -0
  257. data/vendor/libgit2/src/win32/posix.h +4 -1
  258. data/vendor/libgit2/src/win32/posix_w32.c +5 -40
  259. data/vendor/libgit2/src/win32/precompiled.h +2 -0
  260. data/vendor/libgit2/src/win32/thread.c +10 -5
  261. data/vendor/libgit2/src/win32/w32_buffer.c +3 -7
  262. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +93 -0
  263. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +2 -0
  264. data/vendor/libgit2/src/win32/w32_stack.c +9 -4
  265. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  266. data/vendor/libgit2/src/win32/w32_util.c +0 -31
  267. data/vendor/libgit2/src/win32/w32_util.h +32 -6
  268. data/vendor/libgit2/src/worktree.c +22 -36
  269. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  270. data/vendor/libgit2/src/xdiff/xmerge.c +0 -12
  271. data/vendor/libgit2/src/xdiff/xpatience.c +0 -3
  272. metadata +34 -98
  273. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +0 -28
  274. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +0 -38
  275. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +0 -37
  276. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +0 -110
  277. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +0 -53
  278. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +0 -124
  279. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +0 -66
  280. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +0 -21
  281. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -33
  282. data/vendor/libgit2/deps/ntlmclient/crypt.h +0 -64
  283. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +0 -120
  284. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +0 -18
  285. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -145
  286. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +0 -18
  287. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +0 -130
  288. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +0 -21
  289. data/vendor/libgit2/deps/ntlmclient/ntlm.c +0 -1420
  290. data/vendor/libgit2/deps/ntlmclient/ntlm.h +0 -174
  291. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +0 -320
  292. data/vendor/libgit2/deps/ntlmclient/unicode.h +0 -36
  293. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +0 -445
  294. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +0 -201
  295. data/vendor/libgit2/deps/ntlmclient/utf8.h +0 -1257
  296. data/vendor/libgit2/deps/ntlmclient/util.c +0 -21
  297. data/vendor/libgit2/deps/ntlmclient/util.h +0 -14
  298. data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
  299. data/vendor/libgit2/deps/pcre/COPYING +0 -5
  300. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
  301. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
  302. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
  303. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
  304. data/vendor/libgit2/deps/pcre/config.h.in +0 -57
  305. data/vendor/libgit2/deps/pcre/pcre.h +0 -641
  306. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
  307. data/vendor/libgit2/deps/pcre/pcre_chartables.c +0 -198
  308. data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9800
  309. data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
  310. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +0 -3676
  311. data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
  312. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
  313. data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
  314. data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
  315. data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
  316. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
  317. data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
  318. data/vendor/libgit2/deps/pcre/pcre_newline.c +0 -210
  319. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +0 -94
  320. data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
  321. data/vendor/libgit2/deps/pcre/pcre_refcount.c +0 -92
  322. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
  323. data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
  324. data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
  325. data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
  326. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
  327. data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
  328. data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
  329. data/vendor/libgit2/deps/pcre/pcreposix.c +0 -421
  330. data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
  331. data/vendor/libgit2/deps/pcre/ucp.h +0 -224
  332. data/vendor/libgit2/include/git2/cert.h +0 -135
  333. data/vendor/libgit2/include/git2/cred.h +0 -308
  334. data/vendor/libgit2/include/git2/sys/cred.h +0 -90
  335. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  336. data/vendor/libgit2/src/config_snapshot.c +0 -206
  337. data/vendor/libgit2/src/errors.h +0 -81
  338. data/vendor/libgit2/src/hash/sha1.h +0 -38
  339. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +0 -19
  340. data/vendor/libgit2/src/hash/sha1/common_crypto.h +0 -19
  341. data/vendor/libgit2/src/hash/sha1/openssl.h +0 -19
  342. data/vendor/libgit2/src/net.c +0 -184
  343. data/vendor/libgit2/src/net.h +0 -36
  344. data/vendor/libgit2/src/regexp.c +0 -221
  345. data/vendor/libgit2/src/regexp.h +0 -97
  346. data/vendor/libgit2/src/transports/auth_ntlm.c +0 -223
  347. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -35
  348. data/vendor/libgit2/src/wildmatch.c +0 -320
  349. data/vendor/libgit2/src/wildmatch.h +0 -23
  350. data/vendor/libgit2/src/win32/w32_common.h +0 -39
@@ -14,7 +14,6 @@ typedef struct git_config_entries git_config_entries;
14
14
 
15
15
  int git_config_entries_new(git_config_entries **out);
16
16
  int git_config_entries_dup(git_config_entries **out, git_config_entries *entries);
17
- int git_config_entries_dup_entry(git_config_entries *entries, const git_config_entry *entry);
18
17
  void git_config_entries_incref(git_config_entries *entries);
19
18
  void git_config_entries_free(git_config_entries *entries);
20
19
  /* Add or append the new config option */
@@ -7,35 +7,36 @@
7
7
 
8
8
  #include "config.h"
9
9
 
10
+ #include "filebuf.h"
11
+ #include "sysdir.h"
12
+ #include "buffer.h"
13
+ #include "buf_text.h"
10
14
  #include "git2/config.h"
11
15
  #include "git2/sys/config.h"
12
-
16
+ #include "git2/types.h"
17
+ #include "strmap.h"
13
18
  #include "array.h"
14
- #include "buffer.h"
15
- #include "config_backend.h"
16
- #include "config_entries.h"
17
19
  #include "config_parse.h"
18
- #include "filebuf.h"
19
- #include "regexp.h"
20
- #include "sysdir.h"
21
- #include "wildmatch.h"
20
+ #include "config_entries.h"
21
+
22
+ #include <ctype.h>
23
+ #include <sys/types.h>
24
+ #include <regex.h>
22
25
 
23
26
  /* Max depth for [include] directives */
24
27
  #define MAX_INCLUDE_DEPTH 10
25
28
 
26
- typedef struct config_file {
27
- git_futils_filestamp stamp;
28
- git_oid checksum;
29
- char *path;
30
- git_array_t(struct config_file) includes;
31
- } config_file;
32
-
33
29
  typedef struct {
34
30
  git_config_backend parent;
31
+ /* mutex to coordinate accessing the values */
35
32
  git_mutex values_mutex;
36
33
  git_config_entries *entries;
37
34
  const git_repository *repo;
38
35
  git_config_level_t level;
36
+ } diskfile_header;
37
+
38
+ typedef struct {
39
+ diskfile_header header;
39
40
 
40
41
  git_array_t(git_config_parser) readers;
41
42
 
@@ -43,47 +44,60 @@ typedef struct {
43
44
  git_filebuf locked_buf;
44
45
  git_buf locked_content;
45
46
 
46
- config_file file;
47
- } config_file_backend;
47
+ struct config_file file;
48
+ } diskfile_backend;
49
+
50
+ typedef struct {
51
+ diskfile_header header;
52
+
53
+ diskfile_backend *snapshot_from;
54
+ } diskfile_readonly_backend;
48
55
 
49
56
  typedef struct {
50
57
  const git_repository *repo;
51
- config_file *file;
58
+ const char *file_path;
52
59
  git_config_entries *entries;
53
60
  git_config_level_t level;
54
61
  unsigned int depth;
55
- } config_file_parse_data;
62
+ } diskfile_parse_state;
56
63
 
57
- static int config_file_read(git_config_entries *entries, const git_repository *repo, config_file *file, git_config_level_t level, int depth);
58
- static int config_file_read_buffer(git_config_entries *entries, const git_repository *repo, config_file *file, git_config_level_t level, int depth, const char *buf, size_t buflen);
59
- static int config_file_write(config_file_backend *cfg, const char *orig_key, const char *key, const git_regexp *preg, const char *value);
64
+ static int config_read(git_config_entries *entries, const git_repository *repo, git_config_file *file, git_config_level_t level, int depth);
65
+ static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const regex_t *preg, const char *value);
60
66
  static char *escape_value(const char *ptr);
61
67
 
68
+ static int config_snapshot(git_config_backend **out, git_config_backend *in);
69
+
70
+ static int config_error_readonly(void)
71
+ {
72
+ git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
73
+ return -1;
74
+ }
75
+
62
76
  /**
63
77
  * Take the current values map from the backend and increase its
64
78
  * refcount. This is its own function to make sure we use the mutex to
65
79
  * avoid the map pointer from changing under us.
66
80
  */
67
- static int config_file_entries_take(git_config_entries **out, config_file_backend *b)
81
+ static git_config_entries *diskfile_entries_take(diskfile_header *h)
68
82
  {
69
- int error;
83
+ git_config_entries *entries;
70
84
 
71
- if ((error = git_mutex_lock(&b->values_mutex)) < 0) {
72
- git_error_set(GIT_ERROR_OS, "failed to lock config backend");
73
- return error;
85
+ if (git_mutex_lock(&h->values_mutex) < 0) {
86
+ git_error_set(GIT_ERROR_OS, "failed to lock config backend");
87
+ return NULL;
74
88
  }
75
89
 
76
- git_config_entries_incref(b->entries);
77
- *out = b->entries;
90
+ entries = h->entries;
91
+ git_config_entries_incref(entries);
78
92
 
79
- git_mutex_unlock(&b->values_mutex);
93
+ git_mutex_unlock(&h->values_mutex);
80
94
 
81
- return 0;
95
+ return entries;
82
96
  }
83
97
 
84
- static void config_file_clear(config_file *file)
98
+ static void config_file_clear(struct config_file *file)
85
99
  {
86
- config_file *include;
100
+ struct config_file *include;
87
101
  uint32_t i;
88
102
 
89
103
  if (file == NULL)
@@ -97,31 +111,31 @@ static void config_file_clear(config_file *file)
97
111
  git__free(file->path);
98
112
  }
99
113
 
100
- static int config_file_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
114
+ static int config_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
101
115
  {
102
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
103
116
  int res;
117
+ diskfile_backend *b = (diskfile_backend *)cfg;
104
118
 
105
- b->level = level;
106
- b->repo = repo;
119
+ b->header.level = level;
120
+ b->header.repo = repo;
107
121
 
108
- if ((res = git_config_entries_new(&b->entries)) < 0)
122
+ if ((res = git_config_entries_new(&b->header.entries)) < 0)
109
123
  return res;
110
124
 
111
125
  if (!git_path_exists(b->file.path))
112
126
  return 0;
113
127
 
114
- if (res < 0 || (res = config_file_read(b->entries, repo, &b->file, level, 0)) < 0) {
115
- git_config_entries_free(b->entries);
116
- b->entries = NULL;
128
+ if (res < 0 || (res = config_read(b->header.entries, repo, &b->file, level, 0)) < 0) {
129
+ git_config_entries_free(b->header.entries);
130
+ b->header.entries = NULL;
117
131
  }
118
132
 
119
133
  return res;
120
134
  }
121
135
 
122
- static int config_file_is_modified(int *modified, config_file *file)
136
+ static int config_is_modified(int *modified, struct config_file *file)
123
137
  {
124
- config_file *include;
138
+ git_config_file *include;
125
139
  git_buf buf = GIT_BUF_INIT;
126
140
  git_oid hash;
127
141
  uint32_t i;
@@ -129,9 +143,6 @@ static int config_file_is_modified(int *modified, config_file *file)
129
143
 
130
144
  *modified = 0;
131
145
 
132
- if (!git_futils_filestamp_check(&file->stamp, file->path))
133
- goto check_includes;
134
-
135
146
  if ((error = git_futils_readbuffer(&buf, file->path)) < 0)
136
147
  goto out;
137
148
 
@@ -143,9 +154,8 @@ static int config_file_is_modified(int *modified, config_file *file)
143
154
  goto out;
144
155
  }
145
156
 
146
- check_includes:
147
157
  git_array_foreach(file->includes, i, include) {
148
- if ((error = config_file_is_modified(modified, include)) < 0 || *modified)
158
+ if ((error = config_is_modified(modified, include)) < 0 || *modified)
149
159
  goto out;
150
160
  }
151
161
 
@@ -155,125 +165,89 @@ out:
155
165
  return error;
156
166
  }
157
167
 
158
- static int config_file_set_entries(git_config_backend *cfg, git_config_entries *entries)
168
+ static int config_refresh(git_config_backend *cfg)
159
169
  {
160
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
161
- git_config_entries *old = NULL;
162
- config_file *include;
163
- int error;
170
+ diskfile_backend *b = (diskfile_backend *)cfg;
171
+ git_config_entries *entries = NULL, *tmp;
172
+ git_config_file *include;
173
+ int error, modified;
164
174
  uint32_t i;
165
175
 
166
- if (b->parent.readonly) {
167
- git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
168
- return -1;
169
- }
170
-
171
- git_array_foreach(b->file.includes, i, include)
172
- config_file_clear(include);
173
- git_array_clear(b->file.includes);
176
+ if (b->header.parent.readonly)
177
+ return config_error_readonly();
174
178
 
175
- if ((error = git_mutex_lock(&b->values_mutex)) < 0) {
176
- git_error_set(GIT_ERROR_OS, "failed to lock config backend");
179
+ error = config_is_modified(&modified, &b->file);
180
+ if (error < 0 && error != GIT_ENOTFOUND)
177
181
  goto out;
178
- }
179
-
180
- old = b->entries;
181
- b->entries = entries;
182
-
183
- git_mutex_unlock(&b->values_mutex);
184
182
 
185
- out:
186
- git_config_entries_free(old);
187
- return error;
188
- }
189
-
190
- static int config_file_refresh_from_buffer(git_config_backend *cfg, const char *buf, size_t buflen)
191
- {
192
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
193
- git_config_entries *entries = NULL;
194
- int error;
183
+ if (!modified)
184
+ return 0;
195
185
 
196
- if ((error = git_config_entries_new(&entries)) < 0 ||
197
- (error = config_file_read_buffer(entries, b->repo, &b->file,
198
- b->level, 0, buf, buflen)) < 0 ||
199
- (error = config_file_set_entries(cfg, entries)) < 0)
186
+ if ((error = git_config_entries_new(&entries)) < 0)
200
187
  goto out;
201
188
 
202
- entries = NULL;
203
- out:
204
- git_config_entries_free(entries);
205
- return error;
206
- }
207
-
208
- static int config_file_refresh(git_config_backend *cfg)
209
- {
210
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
211
- git_config_entries *entries = NULL;
212
- int error, modified;
189
+ /* Reparse the current configuration */
190
+ git_array_foreach(b->file.includes, i, include) {
191
+ config_file_clear(include);
192
+ }
193
+ git_array_clear(b->file.includes);
213
194
 
214
- if (cfg->readonly)
215
- return 0;
195
+ if ((error = config_read(entries, b->header.repo, &b->file, b->header.level, 0)) < 0)
196
+ goto out;
216
197
 
217
- if ((error = config_file_is_modified(&modified, &b->file)) < 0 && error != GIT_ENOTFOUND)
198
+ if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) {
199
+ git_error_set(GIT_ERROR_OS, "failed to lock config backend");
218
200
  goto out;
201
+ }
219
202
 
220
- if (!modified)
221
- return 0;
203
+ tmp = b->header.entries;
204
+ b->header.entries = entries;
205
+ entries = tmp;
222
206
 
223
- if ((error = git_config_entries_new(&entries)) < 0 ||
224
- (error = config_file_read(entries, b->repo, &b->file, b->level, 0)) < 0 ||
225
- (error = config_file_set_entries(cfg, entries)) < 0)
226
- goto out;
207
+ git_mutex_unlock(&b->header.values_mutex);
227
208
 
228
- entries = NULL;
229
209
  out:
230
210
  git_config_entries_free(entries);
231
211
 
232
212
  return (error == GIT_ENOTFOUND) ? 0 : error;
233
213
  }
234
214
 
235
- static void config_file_free(git_config_backend *_backend)
215
+ static void backend_free(git_config_backend *_backend)
236
216
  {
237
- config_file_backend *backend = GIT_CONTAINER_OF(_backend, config_file_backend, parent);
217
+ diskfile_backend *backend = (diskfile_backend *)_backend;
238
218
 
239
219
  if (backend == NULL)
240
220
  return;
241
221
 
242
222
  config_file_clear(&backend->file);
243
- git_config_entries_free(backend->entries);
244
- git_mutex_free(&backend->values_mutex);
223
+ git_config_entries_free(backend->header.entries);
224
+ git_mutex_free(&backend->header.values_mutex);
245
225
  git__free(backend);
246
226
  }
247
227
 
248
- static int config_file_iterator(
228
+ static int config_iterator_new(
249
229
  git_config_iterator **iter,
250
- struct git_config_backend *backend)
230
+ struct git_config_backend* backend)
251
231
  {
252
- config_file_backend *b = GIT_CONTAINER_OF(backend, config_file_backend, parent);
253
- git_config_entries *dupped = NULL, *entries = NULL;
232
+ diskfile_header *bh = (diskfile_header *) backend;
233
+ git_config_entries *entries;
254
234
  int error;
255
235
 
256
- if ((error = config_file_refresh(backend)) < 0 ||
257
- (error = config_file_entries_take(&entries, b)) < 0 ||
258
- (error = git_config_entries_dup(&dupped, entries)) < 0 ||
259
- (error = git_config_entries_iterator_new(iter, dupped)) < 0)
236
+ if ((error = git_config_entries_dup(&entries, bh->entries)) < 0)
237
+ return error;
238
+
239
+ if ((error = git_config_entries_iterator_new(iter, entries)) < 0)
260
240
  goto out;
261
241
 
262
242
  out:
263
243
  /* Let iterator delete duplicated entries when it's done */
264
244
  git_config_entries_free(entries);
265
- git_config_entries_free(dupped);
266
245
  return error;
267
246
  }
268
247
 
269
- static int config_file_snapshot(git_config_backend **out, git_config_backend *backend)
248
+ static int config_set(git_config_backend *cfg, const char *name, const char *value)
270
249
  {
271
- return git_config_backend_snapshot(out, backend);
272
- }
273
-
274
- static int config_file_set(git_config_backend *cfg, const char *name, const char *value)
275
- {
276
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
250
+ diskfile_backend *b = (diskfile_backend *)cfg;
277
251
  git_config_entries *entries;
278
252
  git_config_entry *existing;
279
253
  char *key, *esc_value = NULL;
@@ -282,8 +256,8 @@ static int config_file_set(git_config_backend *cfg, const char *name, const char
282
256
  if ((error = git_config__normalize_name(name, &key)) < 0)
283
257
  return error;
284
258
 
285
- if ((error = config_file_entries_take(&entries, b)) < 0)
286
- return error;
259
+ if ((entries = diskfile_entries_take(&b->header)) == NULL)
260
+ return -1;
287
261
 
288
262
  /* Check whether we'd be modifying an included or multivar key */
289
263
  if ((error = git_config_entries_get_unique(&existing, entries, key)) < 0) {
@@ -303,9 +277,11 @@ static int config_file_set(git_config_backend *cfg, const char *name, const char
303
277
  GIT_ERROR_CHECK_ALLOC(esc_value);
304
278
  }
305
279
 
306
- if ((error = config_file_write(b, name, key, NULL, esc_value)) < 0)
280
+ if ((error = config_write(b, name, key, NULL, esc_value)) < 0)
307
281
  goto out;
308
282
 
283
+ error = config_refresh(cfg);
284
+
309
285
  out:
310
286
  git_config_entries_free(entries);
311
287
  git__free(esc_value);
@@ -314,7 +290,7 @@ out:
314
290
  }
315
291
 
316
292
  /* release the map containing the entry as an equivalent to freeing it */
317
- static void config_file_entry_free(git_config_entry *entry)
293
+ static void free_diskfile_entry(git_config_entry *entry)
318
294
  {
319
295
  git_config_entries *entries = (git_config_entries *) entry->payload;
320
296
  git_config_entries_free(entries);
@@ -323,61 +299,67 @@ static void config_file_entry_free(git_config_entry *entry)
323
299
  /*
324
300
  * Internal function that actually gets the value in string form
325
301
  */
326
- static int config_file_get(git_config_backend *cfg, const char *key, git_config_entry **out)
302
+ static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out)
327
303
  {
328
- config_file_backend *h = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
304
+ diskfile_header *h = (diskfile_header *)cfg;
329
305
  git_config_entries *entries = NULL;
330
306
  git_config_entry *entry;
331
307
  int error = 0;
332
308
 
333
- if (!h->parent.readonly && ((error = config_file_refresh(cfg)) < 0))
309
+ if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0))
334
310
  return error;
335
311
 
336
- if ((error = config_file_entries_take(&entries, h)) < 0)
337
- return error;
312
+ if ((entries = diskfile_entries_take(h)) == NULL)
313
+ return -1;
338
314
 
339
315
  if ((error = (git_config_entries_get(&entry, entries, key))) < 0) {
340
316
  git_config_entries_free(entries);
341
317
  return error;
342
318
  }
343
319
 
344
- entry->free = config_file_entry_free;
320
+ entry->free = free_diskfile_entry;
345
321
  entry->payload = entries;
346
322
  *out = entry;
347
323
 
348
324
  return 0;
349
325
  }
350
326
 
351
- static int config_file_set_multivar(
327
+ static int config_set_multivar(
352
328
  git_config_backend *cfg, const char *name, const char *regexp, const char *value)
353
329
  {
354
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
355
- git_regexp preg;
356
- int result;
330
+ diskfile_backend *b = (diskfile_backend *)cfg;
357
331
  char *key;
332
+ regex_t preg;
333
+ int result;
358
334
 
359
335
  assert(regexp);
360
336
 
361
337
  if ((result = git_config__normalize_name(name, &key)) < 0)
362
338
  return result;
363
339
 
364
- if ((result = git_regexp_compile(&preg, regexp, 0)) < 0)
340
+ result = p_regcomp(&preg, regexp, REG_EXTENDED);
341
+ if (result != 0) {
342
+ git_error_set_regex(&preg, result);
343
+ result = -1;
365
344
  goto out;
345
+ }
366
346
 
367
- /* If we do have it, set call config_file_write() and reload */
368
- if ((result = config_file_write(b, name, key, &preg, value)) < 0)
347
+ /* If we do have it, set call config_write() and reload */
348
+ if ((result = config_write(b, name, key, &preg, value)) < 0)
369
349
  goto out;
370
350
 
351
+ result = config_refresh(cfg);
352
+
371
353
  out:
372
354
  git__free(key);
373
- git_regexp_dispose(&preg);
355
+ regfree(&preg);
374
356
 
375
357
  return result;
376
358
  }
377
359
 
378
- static int config_file_delete(git_config_backend *cfg, const char *name)
360
+ static int config_delete(git_config_backend *cfg, const char *name)
379
361
  {
380
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
362
+ diskfile_backend *b = (diskfile_backend *)cfg;
381
363
  git_config_entries *entries = NULL;
382
364
  git_config_entry *entry;
383
365
  char *key = NULL;
@@ -386,7 +368,7 @@ static int config_file_delete(git_config_backend *cfg, const char *name)
386
368
  if ((error = git_config__normalize_name(name, &key)) < 0)
387
369
  goto out;
388
370
 
389
- if ((error = config_file_entries_take(&entries, b)) < 0)
371
+ if ((entries = diskfile_entries_take(&b->header)) == NULL)
390
372
  goto out;
391
373
 
392
374
  /* Check whether we'd be modifying an included or multivar key */
@@ -396,7 +378,10 @@ static int config_file_delete(git_config_backend *cfg, const char *name)
396
378
  goto out;
397
379
  }
398
380
 
399
- if ((error = config_file_write(b, name, entry->name, NULL, NULL)) < 0)
381
+ if ((error = config_write(b, name, entry->name, NULL, NULL)) < 0)
382
+ goto out;
383
+
384
+ if ((error = config_refresh(cfg)) < 0)
400
385
  goto out;
401
386
 
402
387
  out:
@@ -405,20 +390,22 @@ out:
405
390
  return error;
406
391
  }
407
392
 
408
- static int config_file_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
393
+ static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
409
394
  {
410
- config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
395
+ diskfile_backend *b = (diskfile_backend *)cfg;
411
396
  git_config_entries *entries = NULL;
412
397
  git_config_entry *entry = NULL;
413
- git_regexp preg = GIT_REGEX_INIT;
398
+ regex_t preg = { 0 };
414
399
  char *key = NULL;
415
400
  int result;
416
401
 
417
402
  if ((result = git_config__normalize_name(name, &key)) < 0)
418
403
  goto out;
419
404
 
420
- if ((result = config_file_entries_take(&entries, b)) < 0)
405
+ if ((entries = diskfile_entries_take(&b->header)) == NULL) {
406
+ result = -1;
421
407
  goto out;
408
+ }
422
409
 
423
410
  if ((result = git_config_entries_get(&entry, entries, key)) < 0) {
424
411
  if (result == GIT_ENOTFOUND)
@@ -426,22 +413,28 @@ static int config_file_delete_multivar(git_config_backend *cfg, const char *name
426
413
  goto out;
427
414
  }
428
415
 
429
- if ((result = git_regexp_compile(&preg, regexp, 0)) < 0)
416
+ if ((result = p_regcomp(&preg, regexp, REG_EXTENDED)) != 0) {
417
+ git_error_set_regex(&preg, result);
418
+ result = -1;
419
+ goto out;
420
+ }
421
+
422
+ if ((result = config_write(b, name, key, &preg, NULL)) < 0)
430
423
  goto out;
431
424
 
432
- if ((result = config_file_write(b, name, key, &preg, NULL)) < 0)
425
+ if ((result = config_refresh(cfg)) < 0)
433
426
  goto out;
434
427
 
435
428
  out:
436
429
  git_config_entries_free(entries);
437
430
  git__free(key);
438
- git_regexp_dispose(&preg);
431
+ regfree(&preg);
439
432
  return result;
440
433
  }
441
434
 
442
- static int config_file_lock(git_config_backend *_cfg)
435
+ static int config_lock(git_config_backend *_cfg)
443
436
  {
444
- config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
437
+ diskfile_backend *cfg = (diskfile_backend *) _cfg;
445
438
  int error;
446
439
 
447
440
  if ((error = git_filebuf_open(&cfg->locked_buf, cfg->file.path, 0, GIT_CONFIG_FILE_MODE)) < 0)
@@ -458,9 +451,9 @@ static int config_file_lock(git_config_backend *_cfg)
458
451
 
459
452
  }
460
453
 
461
- static int config_file_unlock(git_config_backend *_cfg, int success)
454
+ static int config_unlock(git_config_backend *_cfg, int success)
462
455
  {
463
- config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
456
+ diskfile_backend *cfg = (diskfile_backend *) _cfg;
464
457
  int error = 0;
465
458
 
466
459
  if (success) {
@@ -477,29 +470,145 @@ static int config_file_unlock(git_config_backend *_cfg, int success)
477
470
 
478
471
  int git_config_backend_from_file(git_config_backend **out, const char *path)
479
472
  {
480
- config_file_backend *backend;
473
+ diskfile_backend *backend;
481
474
 
482
- backend = git__calloc(1, sizeof(config_file_backend));
475
+ backend = git__calloc(1, sizeof(diskfile_backend));
483
476
  GIT_ERROR_CHECK_ALLOC(backend);
484
477
 
485
- backend->parent.version = GIT_CONFIG_BACKEND_VERSION;
486
- git_mutex_init(&backend->values_mutex);
478
+ backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
479
+ git_mutex_init(&backend->header.values_mutex);
487
480
 
488
481
  backend->file.path = git__strdup(path);
489
482
  GIT_ERROR_CHECK_ALLOC(backend->file.path);
490
483
  git_array_init(backend->file.includes);
491
484
 
492
- backend->parent.open = config_file_open;
493
- backend->parent.get = config_file_get;
494
- backend->parent.set = config_file_set;
495
- backend->parent.set_multivar = config_file_set_multivar;
496
- backend->parent.del = config_file_delete;
497
- backend->parent.del_multivar = config_file_delete_multivar;
498
- backend->parent.iterator = config_file_iterator;
499
- backend->parent.snapshot = config_file_snapshot;
500
- backend->parent.lock = config_file_lock;
501
- backend->parent.unlock = config_file_unlock;
502
- backend->parent.free = config_file_free;
485
+ backend->header.parent.open = config_open;
486
+ backend->header.parent.get = config_get;
487
+ backend->header.parent.set = config_set;
488
+ backend->header.parent.set_multivar = config_set_multivar;
489
+ backend->header.parent.del = config_delete;
490
+ backend->header.parent.del_multivar = config_delete_multivar;
491
+ backend->header.parent.iterator = config_iterator_new;
492
+ backend->header.parent.snapshot = config_snapshot;
493
+ backend->header.parent.lock = config_lock;
494
+ backend->header.parent.unlock = config_unlock;
495
+ backend->header.parent.free = backend_free;
496
+
497
+ *out = (git_config_backend *)backend;
498
+
499
+ return 0;
500
+ }
501
+
502
+ static int config_set_readonly(git_config_backend *cfg, const char *name, const char *value)
503
+ {
504
+ GIT_UNUSED(cfg);
505
+ GIT_UNUSED(name);
506
+ GIT_UNUSED(value);
507
+
508
+ return config_error_readonly();
509
+ }
510
+
511
+ static int config_set_multivar_readonly(
512
+ git_config_backend *cfg, const char *name, const char *regexp, const char *value)
513
+ {
514
+ GIT_UNUSED(cfg);
515
+ GIT_UNUSED(name);
516
+ GIT_UNUSED(regexp);
517
+ GIT_UNUSED(value);
518
+
519
+ return config_error_readonly();
520
+ }
521
+
522
+ static int config_delete_multivar_readonly(git_config_backend *cfg, const char *name, const char *regexp)
523
+ {
524
+ GIT_UNUSED(cfg);
525
+ GIT_UNUSED(name);
526
+ GIT_UNUSED(regexp);
527
+
528
+ return config_error_readonly();
529
+ }
530
+
531
+ static int config_delete_readonly(git_config_backend *cfg, const char *name)
532
+ {
533
+ GIT_UNUSED(cfg);
534
+ GIT_UNUSED(name);
535
+
536
+ return config_error_readonly();
537
+ }
538
+
539
+ static int config_lock_readonly(git_config_backend *_cfg)
540
+ {
541
+ GIT_UNUSED(_cfg);
542
+
543
+ return config_error_readonly();
544
+ }
545
+
546
+ static int config_unlock_readonly(git_config_backend *_cfg, int success)
547
+ {
548
+ GIT_UNUSED(_cfg);
549
+ GIT_UNUSED(success);
550
+
551
+ return config_error_readonly();
552
+ }
553
+
554
+ static void backend_readonly_free(git_config_backend *_backend)
555
+ {
556
+ diskfile_backend *backend = (diskfile_backend *)_backend;
557
+
558
+ if (backend == NULL)
559
+ return;
560
+
561
+ git_config_entries_free(backend->header.entries);
562
+ git_mutex_free(&backend->header.values_mutex);
563
+ git__free(backend);
564
+ }
565
+
566
+ static int config_readonly_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
567
+ {
568
+ diskfile_readonly_backend *b = (diskfile_readonly_backend *) cfg;
569
+ diskfile_backend *src = b->snapshot_from;
570
+ diskfile_header *src_header = &src->header;
571
+ git_config_entries *entries;
572
+ int error;
573
+
574
+ if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0)
575
+ return error;
576
+
577
+ /* We're just copying data, don't care about the level or repo*/
578
+ GIT_UNUSED(level);
579
+ GIT_UNUSED(repo);
580
+
581
+ if ((entries = diskfile_entries_take(src_header)) == NULL)
582
+ return -1;
583
+ b->header.entries = entries;
584
+
585
+ return 0;
586
+ }
587
+
588
+ static int config_snapshot(git_config_backend **out, git_config_backend *in)
589
+ {
590
+ diskfile_readonly_backend *backend;
591
+
592
+ backend = git__calloc(1, sizeof(diskfile_readonly_backend));
593
+ GIT_ERROR_CHECK_ALLOC(backend);
594
+
595
+ backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
596
+ git_mutex_init(&backend->header.values_mutex);
597
+
598
+ backend->snapshot_from = (diskfile_backend *) in;
599
+
600
+ backend->header.parent.readonly = 1;
601
+ backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
602
+ backend->header.parent.open = config_readonly_open;
603
+ backend->header.parent.get = config_get;
604
+ backend->header.parent.set = config_set_readonly;
605
+ backend->header.parent.set_multivar = config_set_multivar_readonly;
606
+ backend->header.parent.del = config_delete_readonly;
607
+ backend->header.parent.del_multivar = config_delete_multivar_readonly;
608
+ backend->header.parent.iterator = config_iterator_new;
609
+ backend->header.parent.lock = config_lock_readonly;
610
+ backend->header.parent.unlock = config_unlock_readonly;
611
+ backend->header.parent.free = backend_readonly_free;
503
612
 
504
613
  *out = (git_config_backend *)backend;
505
614
 
@@ -547,9 +656,10 @@ static char *escape_value(const char *ptr)
547
656
  return git_buf_detach(&buf);
548
657
  }
549
658
 
550
- static int parse_include(config_file_parse_data *parse_data, const char *file)
659
+ static int parse_include(git_config_parser *reader,
660
+ diskfile_parse_state *parse_data, const char *file)
551
661
  {
552
- config_file *include;
662
+ struct config_file *include;
553
663
  git_buf path = GIT_BUF_INIT;
554
664
  char *dir;
555
665
  int result;
@@ -557,7 +667,7 @@ static int parse_include(config_file_parse_data *parse_data, const char *file)
557
667
  if (!file)
558
668
  return 0;
559
669
 
560
- if ((result = git_path_dirname_r(&path, parse_data->file->path)) < 0)
670
+ if ((result = git_path_dirname_r(&path, reader->file->path)) < 0)
561
671
  return result;
562
672
 
563
673
  dir = git_buf_detach(&path);
@@ -567,14 +677,14 @@ static int parse_include(config_file_parse_data *parse_data, const char *file)
567
677
  if (result < 0)
568
678
  return result;
569
679
 
570
- include = git_array_alloc(parse_data->file->includes);
680
+ include = git_array_alloc(reader->file->includes);
571
681
  GIT_ERROR_CHECK_ALLOC(include);
572
682
  memset(include, 0, sizeof(*include));
573
683
  git_array_init(include->includes);
574
684
  include->path = git_buf_detach(&path);
575
685
 
576
- result = config_file_read(parse_data->entries, parse_data->repo, include,
577
- parse_data->level, parse_data->depth+1);
686
+ result = config_read(parse_data->entries, parse_data->repo,
687
+ include, parse_data->level, parse_data->depth+1);
578
688
 
579
689
  if (result == GIT_ENOTFOUND) {
580
690
  git_error_clear();
@@ -588,41 +698,41 @@ static int do_match_gitdir(
588
698
  int *matches,
589
699
  const git_repository *repo,
590
700
  const char *cfg_file,
591
- const char *condition,
701
+ const char *value,
592
702
  bool case_insensitive)
593
703
  {
594
- git_buf pattern = GIT_BUF_INIT, gitdir = GIT_BUF_INIT;
595
- int error;
596
-
597
- if (condition[0] == '.' && git_path_is_dirsep(condition[1])) {
598
- git_path_dirname_r(&pattern, cfg_file);
599
- git_buf_joinpath(&pattern, pattern.ptr, condition + 2);
600
- } else if (condition[0] == '~' && git_path_is_dirsep(condition[1]))
601
- git_sysdir_expand_global_file(&pattern, condition + 1);
602
- else if (!git_path_is_absolute(condition))
603
- git_buf_joinpath(&pattern, "**", condition);
704
+ git_buf path = GIT_BUF_INIT;
705
+ int error, fnmatch_flags;
706
+
707
+ if (value[0] == '.' && git_path_is_dirsep(value[1])) {
708
+ git_path_dirname_r(&path, cfg_file);
709
+ git_buf_joinpath(&path, path.ptr, value + 2);
710
+ } else if (value[0] == '~' && git_path_is_dirsep(value[1]))
711
+ git_sysdir_expand_global_file(&path, value + 1);
712
+ else if (!git_path_is_absolute(value))
713
+ git_buf_joinpath(&path, "**", value);
604
714
  else
605
- git_buf_sets(&pattern, condition);
715
+ git_buf_sets(&path, value);
606
716
 
607
- if (git_path_is_dirsep(condition[strlen(condition) - 1]))
608
- git_buf_puts(&pattern, "**");
609
-
610
- if (git_buf_oom(&pattern)) {
717
+ if (git_buf_oom(&path)) {
611
718
  error = -1;
612
719
  goto out;
613
720
  }
614
721
 
615
- if ((error = git_repository_item_path(&gitdir, repo, GIT_REPOSITORY_ITEM_GITDIR)) < 0)
722
+ if (git_path_is_dirsep(value[strlen(value) - 1]))
723
+ git_buf_puts(&path, "**");
724
+
725
+ fnmatch_flags = FNM_PATHNAME|FNM_LEADING_DIR;
726
+ if (case_insensitive)
727
+ fnmatch_flags |= FNM_IGNORECASE;
728
+
729
+ if ((error = p_fnmatch(path.ptr, git_repository_path(repo), fnmatch_flags)) < 0)
616
730
  goto out;
617
731
 
618
- if (git_path_is_dirsep(gitdir.ptr[gitdir.size - 1]))
619
- git_buf_truncate(&gitdir, gitdir.size - 1);
732
+ *matches = (error == 0);
620
733
 
621
- *matches = wildmatch(pattern.ptr, gitdir.ptr,
622
- WM_PATHNAME | (case_insensitive ? WM_CASEFOLD : 0)) == WM_MATCH;
623
734
  out:
624
- git_buf_dispose(&pattern);
625
- git_buf_dispose(&gitdir);
735
+ git_buf_dispose(&path);
626
736
  return error;
627
737
  }
628
738
 
@@ -644,67 +754,16 @@ static int conditional_match_gitdir_i(
644
754
  return do_match_gitdir(matches, repo, cfg_file, value, true);
645
755
  }
646
756
 
647
- static int conditional_match_onbranch(
648
- int *matches,
649
- const git_repository *repo,
650
- const char *cfg_file,
651
- const char *condition)
652
- {
653
- git_buf reference = GIT_BUF_INIT, buf = GIT_BUF_INIT;
654
- int error;
655
-
656
- GIT_UNUSED(cfg_file);
657
-
658
- /*
659
- * NOTE: you cannot use `git_repository_head` here. Looking up the
660
- * HEAD reference will create the ODB, which causes us to read the
661
- * repo's config for keys like core.precomposeUnicode. As we're
662
- * just parsing the config right now, though, this would result in
663
- * an endless recursion.
664
- */
665
-
666
- if ((error = git_buf_joinpath(&buf, git_repository_path(repo), GIT_HEAD_FILE)) < 0 ||
667
- (error = git_futils_readbuffer(&reference, buf.ptr)) < 0)
668
- goto out;
669
- git_buf_rtrim(&reference);
670
-
671
- if (git__strncmp(reference.ptr, GIT_SYMREF, strlen(GIT_SYMREF)))
672
- goto out;
673
- git_buf_consume(&reference, reference.ptr + strlen(GIT_SYMREF));
674
-
675
- if (git__strncmp(reference.ptr, GIT_REFS_HEADS_DIR, strlen(GIT_REFS_HEADS_DIR)))
676
- goto out;
677
- git_buf_consume(&reference, reference.ptr + strlen(GIT_REFS_HEADS_DIR));
678
-
679
- /*
680
- * If the condition ends with a '/', then we should treat it as if
681
- * it had '**' appended.
682
- */
683
- if ((error = git_buf_sets(&buf, condition)) < 0)
684
- goto out;
685
- if (git_path_is_dirsep(condition[strlen(condition) - 1]) &&
686
- (error = git_buf_puts(&buf, "**")) < 0)
687
- goto out;
688
-
689
- *matches = wildmatch(buf.ptr, reference.ptr, WM_PATHNAME) == WM_MATCH;
690
- out:
691
- git_buf_dispose(&reference);
692
- git_buf_dispose(&buf);
693
-
694
- return error;
695
-
696
- }
697
-
698
757
  static const struct {
699
758
  const char *prefix;
700
759
  int (*matches)(int *matches, const git_repository *repo, const char *cfg, const char *value);
701
760
  } conditions[] = {
702
761
  { "gitdir:", conditional_match_gitdir },
703
- { "gitdir/i:", conditional_match_gitdir_i },
704
- { "onbranch:", conditional_match_onbranch }
762
+ { "gitdir/i:", conditional_match_gitdir_i }
705
763
  };
706
764
 
707
- static int parse_conditional_include(config_file_parse_data *parse_data, const char *section, const char *file)
765
+ static int parse_conditional_include(git_config_parser *reader,
766
+ diskfile_parse_state *parse_data, const char *section, const char *file)
708
767
  {
709
768
  char *condition;
710
769
  size_t i;
@@ -722,12 +781,12 @@ static int parse_conditional_include(config_file_parse_data *parse_data, const c
722
781
 
723
782
  if ((error = conditions[i].matches(&matches,
724
783
  parse_data->repo,
725
- parse_data->file->path,
784
+ parse_data->file_path,
726
785
  condition + strlen(conditions[i].prefix))) < 0)
727
786
  break;
728
787
 
729
788
  if (matches)
730
- error = parse_include(parse_data, file);
789
+ error = parse_include(reader, parse_data, file);
731
790
 
732
791
  break;
733
792
  }
@@ -745,13 +804,12 @@ static int read_on_variable(
745
804
  size_t line_len,
746
805
  void *data)
747
806
  {
748
- config_file_parse_data *parse_data = (config_file_parse_data *)data;
807
+ diskfile_parse_state *parse_data = (diskfile_parse_state *)data;
749
808
  git_buf buf = GIT_BUF_INIT;
750
809
  git_config_entry *entry;
751
810
  const char *c;
752
811
  int result = 0;
753
812
 
754
- GIT_UNUSED(reader);
755
813
  GIT_UNUSED(line);
756
814
  GIT_UNUSED(line_len);
757
815
 
@@ -784,25 +842,25 @@ static int read_on_variable(
784
842
 
785
843
  /* Add or append the new config option */
786
844
  if (!git__strcmp(entry->name, "include.path"))
787
- result = parse_include(parse_data, entry->value);
845
+ result = parse_include(reader, parse_data, entry->value);
788
846
  else if (!git__prefixcmp(entry->name, "includeif.") &&
789
847
  !git__suffixcmp(entry->name, ".path"))
790
- result = parse_conditional_include(parse_data, entry->name, entry->value);
848
+ result = parse_conditional_include(reader, parse_data,
849
+ entry->name, entry->value);
791
850
 
792
851
  return result;
793
852
  }
794
853
 
795
- static int config_file_read_buffer(
854
+ static int config_read(
796
855
  git_config_entries *entries,
797
856
  const git_repository *repo,
798
- config_file *file,
857
+ git_config_file *file,
799
858
  git_config_level_t level,
800
- int depth,
801
- const char *buf,
802
- size_t buflen)
859
+ int depth)
803
860
  {
804
- config_file_parse_data parse_data;
861
+ diskfile_parse_state parse_data;
805
862
  git_config_parser reader;
863
+ git_buf contents = GIT_BUF_INIT;
806
864
  int error;
807
865
 
808
866
  if (depth >= MAX_INCLUDE_DEPTH) {
@@ -810,55 +868,30 @@ static int config_file_read_buffer(
810
868
  return -1;
811
869
  }
812
870
 
871
+ if ((error = git_futils_readbuffer(&contents, file->path)) < 0)
872
+ goto out;
873
+
874
+ git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size);
875
+
876
+ if ((error = git_hash_buf(&file->checksum, contents.ptr, contents.size)) < 0)
877
+ goto out;
878
+
813
879
  /* Initialize the reading position */
814
- reader.path = file->path;
815
- git_parse_ctx_init(&reader.ctx, buf, buflen);
880
+ reader.file = file;
881
+ git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size);
816
882
 
817
883
  /* If the file is empty, there's nothing for us to do */
818
- if (!reader.ctx.content || *reader.ctx.content == '\0') {
819
- error = 0;
884
+ if (!reader.ctx.content || *reader.ctx.content == '\0')
820
885
  goto out;
821
- }
822
886
 
823
887
  parse_data.repo = repo;
824
- parse_data.file = file;
888
+ parse_data.file_path = file->path;
825
889
  parse_data.entries = entries;
826
890
  parse_data.level = level;
827
891
  parse_data.depth = depth;
828
892
 
829
893
  error = git_config_parse(&reader, NULL, read_on_variable, NULL, NULL, &parse_data);
830
894
 
831
- out:
832
- return error;
833
- }
834
-
835
- static int config_file_read(
836
- git_config_entries *entries,
837
- const git_repository *repo,
838
- config_file *file,
839
- git_config_level_t level,
840
- int depth)
841
- {
842
- git_buf contents = GIT_BUF_INIT;
843
- struct stat st;
844
- int error;
845
-
846
- if (p_stat(file->path, &st) < 0) {
847
- error = git_path_set_error(errno, file->path, "stat");
848
- goto out;
849
- }
850
-
851
- if ((error = git_futils_readbuffer(&contents, file->path)) < 0)
852
- goto out;
853
-
854
- git_futils_filestamp_set_from_stat(&file->stamp, &st);
855
- if ((error = git_hash_buf(&file->checksum, contents.ptr, contents.size)) < 0)
856
- goto out;
857
-
858
- if ((error = config_file_read_buffer(entries, repo, file, level, depth,
859
- contents.ptr, contents.size)) < 0)
860
- goto out;
861
-
862
895
  out:
863
896
  git_buf_dispose(&contents);
864
897
  return error;
@@ -921,7 +954,7 @@ struct write_data {
921
954
  const char *section;
922
955
  const char *orig_name;
923
956
  const char *name;
924
- const git_regexp *preg;
957
+ const regex_t *preg;
925
958
  const char *value;
926
959
  };
927
960
 
@@ -1026,7 +1059,7 @@ static int write_on_variable(
1026
1059
 
1027
1060
  /* If we have a regex to match the value, see if it matches */
1028
1061
  if (has_matched && write_data->preg != NULL)
1029
- has_matched = (git_regexp_match(write_data->preg, var_value) == 0);
1062
+ has_matched = (regexec(write_data->preg, var_value, 0, NULL, 0) == 0);
1030
1063
 
1031
1064
  /* If this isn't the name/value we're looking for, simply dump the
1032
1065
  * existing data back out and continue on.
@@ -1087,33 +1120,39 @@ static int write_on_eof(
1087
1120
  /*
1088
1121
  * This is pretty much the parsing, except we write out anything we don't have
1089
1122
  */
1090
- static int config_file_write(config_file_backend *cfg, const char *orig_key, const char *key, const git_regexp *preg, const char* value)
1091
-
1123
+ static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const regex_t *preg, const char* value)
1092
1124
  {
1093
- char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
1094
- git_buf buf = GIT_BUF_INIT, contents = GIT_BUF_INIT;
1095
- git_config_parser parser = GIT_CONFIG_PARSER_INIT;
1125
+ int result;
1126
+ char *orig_section, *section, *orig_name, *name, *ldot;
1096
1127
  git_filebuf file = GIT_FILEBUF_INIT;
1128
+ git_buf buf = GIT_BUF_INIT, contents = GIT_BUF_INIT;
1129
+ git_config_parser reader;
1097
1130
  struct write_data write_data;
1098
- int error;
1099
1131
 
1100
- memset(&write_data, 0, sizeof(write_data));
1132
+ memset(&reader, 0, sizeof(reader));
1133
+ reader.file = &cfg->file;
1101
1134
 
1102
1135
  if (cfg->locked) {
1103
- error = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content) == NULL ? "" : git_buf_cstr(&cfg->locked_content));
1136
+ result = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content) == NULL ? "" : git_buf_cstr(&cfg->locked_content));
1104
1137
  } else {
1105
- if ((error = git_filebuf_open(&file, cfg->file.path, GIT_FILEBUF_HASH_CONTENTS,
1106
- GIT_CONFIG_FILE_MODE)) < 0)
1107
- goto done;
1138
+ /* Lock the file */
1139
+ if ((result = git_filebuf_open(
1140
+ &file, cfg->file.path, GIT_FILEBUF_HASH_CONTENTS, GIT_CONFIG_FILE_MODE)) < 0) {
1141
+ git_buf_dispose(&contents);
1142
+ return result;
1143
+ }
1108
1144
 
1109
1145
  /* We need to read in our own config file */
1110
- error = git_futils_readbuffer(&contents, cfg->file.path);
1146
+ result = git_futils_readbuffer(&contents, cfg->file.path);
1111
1147
  }
1112
- if (error < 0 && error != GIT_ENOTFOUND)
1113
- goto done;
1114
1148
 
1115
- if ((git_config_parser_init(&parser, cfg->file.path, contents.ptr, contents.size)) < 0)
1116
- goto done;
1149
+ /* Initialise the reading position */
1150
+ if (result == 0 || result == GIT_ENOTFOUND) {
1151
+ git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size);
1152
+ } else {
1153
+ git_filebuf_cleanup(&file);
1154
+ return -1; /* OS error when reading the file */
1155
+ }
1117
1156
 
1118
1157
  ldot = strrchr(key, '.');
1119
1158
  name = ldot + 1;
@@ -1126,16 +1165,30 @@ static int config_file_write(config_file_backend *cfg, const char *orig_key, con
1126
1165
  GIT_ERROR_CHECK_ALLOC(orig_section);
1127
1166
 
1128
1167
  write_data.buf = &buf;
1168
+ git_buf_init(&write_data.buffered_comment, 0);
1129
1169
  write_data.orig_section = orig_section;
1130
1170
  write_data.section = section;
1171
+ write_data.in_section = 0;
1172
+ write_data.preg_replaced = 0;
1131
1173
  write_data.orig_name = orig_name;
1132
1174
  write_data.name = name;
1133
1175
  write_data.preg = preg;
1134
1176
  write_data.value = value;
1135
1177
 
1136
- if ((error = git_config_parse(&parser, write_on_section, write_on_variable,
1137
- write_on_comment, write_on_eof, &write_data)) < 0)
1178
+ result = git_config_parse(&reader,
1179
+ write_on_section,
1180
+ write_on_variable,
1181
+ write_on_comment,
1182
+ write_on_eof,
1183
+ &write_data);
1184
+ git__free(section);
1185
+ git__free(orig_section);
1186
+ git_buf_dispose(&write_data.buffered_comment);
1187
+
1188
+ if (result < 0) {
1189
+ git_filebuf_cleanup(&file);
1138
1190
  goto done;
1191
+ }
1139
1192
 
1140
1193
  if (cfg->locked) {
1141
1194
  size_t len = buf.asize;
@@ -1144,22 +1197,12 @@ static int config_file_write(config_file_backend *cfg, const char *orig_key, con
1144
1197
  git_buf_attach(&cfg->locked_content, git_buf_detach(&buf), len);
1145
1198
  } else {
1146
1199
  git_filebuf_write(&file, git_buf_cstr(&buf), git_buf_len(&buf));
1147
-
1148
- if ((error = git_filebuf_commit(&file)) < 0)
1149
- goto done;
1150
-
1151
- if ((error = config_file_refresh_from_buffer(&cfg->parent, buf.ptr, buf.size)) < 0)
1152
- goto done;
1200
+ result = git_filebuf_commit(&file);
1153
1201
  }
1154
1202
 
1155
1203
  done:
1156
- git__free(section);
1157
- git__free(orig_section);
1158
- git_buf_dispose(&write_data.buffered_comment);
1159
1204
  git_buf_dispose(&buf);
1160
1205
  git_buf_dispose(&contents);
1161
- git_filebuf_cleanup(&file);
1162
- git_config_parser_dispose(&parser);
1163
-
1164
- return error;
1206
+ git_parse_ctx_clear(&reader.ctx);
1207
+ return result;
1165
1208
  }