rugged 0.27.9 → 0.27.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +98 -54
- data/vendor/libgit2/COPYING +28 -0
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +9 -8
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
- data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
- data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +110 -0
- data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +53 -0
- data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +124 -0
- data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +66 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +21 -0
- data/vendor/libgit2/deps/ntlmclient/compat.h +33 -0
- data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +1420 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
- data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
- data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
- data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
- data/vendor/libgit2/deps/pcre/COPYING +5 -0
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
- data/vendor/libgit2/deps/pcre/config.h.in +57 -0
- data/vendor/libgit2/deps/pcre/pcre.h +641 -0
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
- data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
- data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
- data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
- data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
- data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
- data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
- data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
- data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
- data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
- data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
- data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
- data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
- data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
- data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
- data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
- data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
- data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
- data/vendor/libgit2/deps/pcre/ucp.h +224 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +0 -7
- data/vendor/libgit2/include/git2.h +5 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +149 -0
- data/vendor/libgit2/include/git2/attr.h +38 -20
- data/vendor/libgit2/include/git2/blame.h +42 -25
- data/vendor/libgit2/include/git2/blob.h +45 -13
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +22 -16
- data/vendor/libgit2/include/git2/cert.h +135 -0
- data/vendor/libgit2/include/git2/checkout.h +65 -32
- data/vendor/libgit2/include/git2/cherrypick.h +9 -7
- data/vendor/libgit2/include/git2/clone.h +12 -10
- data/vendor/libgit2/include/git2/commit.h +53 -3
- data/vendor/libgit2/include/git2/common.h +60 -8
- data/vendor/libgit2/include/git2/config.h +30 -19
- data/vendor/libgit2/include/git2/cred.h +308 -0
- data/vendor/libgit2/include/git2/deprecated.h +493 -0
- data/vendor/libgit2/include/git2/describe.h +32 -9
- data/vendor/libgit2/include/git2/diff.h +208 -156
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/filter.h +8 -0
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +74 -52
- data/vendor/libgit2/include/git2/indexer.h +76 -6
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +35 -18
- data/vendor/libgit2/include/git2/net.h +0 -5
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +17 -29
- data/vendor/libgit2/include/git2/odb.h +12 -11
- data/vendor/libgit2/include/git2/odb_backend.h +10 -9
- data/vendor/libgit2/include/git2/oid.h +2 -2
- data/vendor/libgit2/include/git2/pack.h +14 -3
- data/vendor/libgit2/include/git2/proxy.h +14 -8
- data/vendor/libgit2/include/git2/rebase.h +53 -6
- data/vendor/libgit2/include/git2/refs.h +33 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +123 -24
- data/vendor/libgit2/include/git2/repository.h +76 -39
- data/vendor/libgit2/include/git2/revert.h +6 -4
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +15 -12
- data/vendor/libgit2/include/git2/status.h +33 -20
- data/vendor/libgit2/include/git2/submodule.h +30 -12
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/cred.h +90 -0
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -22
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +76 -40
- data/vendor/libgit2/include/git2/sys/repository.h +5 -1
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +129 -83
- data/vendor/libgit2/include/git2/tag.h +13 -4
- data/vendor/libgit2/include/git2/trace.h +2 -2
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +11 -311
- data/vendor/libgit2/include/git2/tree.h +4 -4
- data/vendor/libgit2/include/git2/types.h +33 -111
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +48 -13
- data/vendor/libgit2/src/CMakeLists.txt +96 -164
- data/vendor/libgit2/src/alloc.c +43 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +119 -0
- data/vendor/libgit2/src/{streams/curl.h → allocators/stdalloc.h} +5 -5
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
- data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +537 -31
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +81 -75
- data/vendor/libgit2/src/attr_file.c +207 -121
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +51 -53
- data/vendor/libgit2/src/attrcache.h +2 -1
- data/vendor/libgit2/src/blame.c +47 -20
- data/vendor/libgit2/src/blame.h +2 -1
- data/vendor/libgit2/src/blame_git.c +37 -20
- data/vendor/libgit2/src/blob.c +128 -42
- data/vendor/libgit2/src/blob.h +19 -2
- data/vendor/libgit2/src/branch.c +67 -43
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +69 -57
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +38 -45
- data/vendor/libgit2/src/cache.h +3 -3
- data/vendor/libgit2/src/cc-compat.h +20 -3
- data/vendor/libgit2/src/checkout.c +109 -90
- data/vendor/libgit2/src/cherrypick.c +15 -9
- data/vendor/libgit2/src/clone.c +49 -27
- data/vendor/libgit2/src/clone.h +4 -0
- data/vendor/libgit2/src/commit.c +117 -49
- data/vendor/libgit2/src/commit.h +7 -0
- data/vendor/libgit2/src/commit_list.c +30 -78
- data/vendor/libgit2/src/commit_list.h +2 -2
- data/vendor/libgit2/src/common.h +27 -91
- data/vendor/libgit2/src/config.c +194 -176
- data/vendor/libgit2/src/config.h +8 -20
- data/vendor/libgit2/src/config_backend.h +96 -0
- data/vendor/libgit2/src/config_cache.c +41 -35
- data/vendor/libgit2/src/config_entries.c +229 -0
- data/vendor/libgit2/src/config_entries.h +24 -0
- data/vendor/libgit2/src/config_file.c +439 -753
- data/vendor/libgit2/src/config_mem.c +220 -0
- data/vendor/libgit2/src/config_parse.c +114 -63
- data/vendor/libgit2/src/config_parse.h +17 -16
- data/vendor/libgit2/src/config_snapshot.c +206 -0
- data/vendor/libgit2/src/crlf.c +219 -190
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +42 -41
- data/vendor/libgit2/src/diff.c +53 -68
- data/vendor/libgit2/src/diff.h +2 -1
- data/vendor/libgit2/src/diff_driver.c +47 -49
- data/vendor/libgit2/src/diff_file.c +19 -17
- data/vendor/libgit2/src/diff_file.h +1 -1
- data/vendor/libgit2/src/diff_generate.c +162 -106
- data/vendor/libgit2/src/diff_generate.h +3 -3
- data/vendor/libgit2/src/diff_parse.c +4 -4
- data/vendor/libgit2/src/diff_print.c +42 -30
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +16 -16
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +51 -39
- data/vendor/libgit2/src/errors.h +81 -0
- data/vendor/libgit2/src/features.h.in +11 -3
- data/vendor/libgit2/src/fetch.c +10 -5
- data/vendor/libgit2/src/fetchhead.c +17 -17
- data/vendor/libgit2/src/filebuf.c +32 -36
- data/vendor/libgit2/src/filebuf.h +2 -2
- data/vendor/libgit2/src/filter.c +46 -38
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/{fileops.c → futils.c} +80 -73
- data/vendor/libgit2/src/{fileops.h → futils.h} +6 -6
- data/vendor/libgit2/src/global.c +48 -63
- data/vendor/libgit2/src/global.h +0 -2
- data/vendor/libgit2/src/hash.c +61 -0
- data/vendor/libgit2/src/hash.h +20 -19
- data/vendor/libgit2/src/hash/sha1.h +38 -0
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +48 -0
- data/vendor/libgit2/src/hash/sha1/collisiondetect.h +19 -0
- data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +17 -17
- data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
- data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
- data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -10
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +46 -0
- data/vendor/libgit2/src/hash/sha1/mbedtls.h +19 -0
- data/vendor/libgit2/src/hash/sha1/openssl.c +59 -0
- data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
- data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +47 -37
- data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
- data/vendor/libgit2/src/hashsig.c +5 -5
- data/vendor/libgit2/src/idxmap.c +107 -61
- data/vendor/libgit2/src/idxmap.h +153 -31
- data/vendor/libgit2/src/ignore.c +43 -47
- data/vendor/libgit2/src/index.c +337 -232
- data/vendor/libgit2/src/index.h +17 -1
- data/vendor/libgit2/src/indexer.c +346 -175
- data/vendor/libgit2/src/integer.h +71 -26
- data/vendor/libgit2/src/iterator.c +142 -70
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +144 -100
- data/vendor/libgit2/src/merge_driver.c +11 -11
- data/vendor/libgit2/src/merge_file.c +2 -2
- data/vendor/libgit2/src/mwindow.c +24 -29
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/net.c +184 -0
- data/vendor/libgit2/src/net.h +36 -0
- data/vendor/libgit2/src/netops.c +55 -156
- data/vendor/libgit2/src/netops.h +3 -23
- data/vendor/libgit2/src/notes.c +16 -11
- data/vendor/libgit2/src/object.c +120 -69
- data/vendor/libgit2/src/object.h +22 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +116 -93
- data/vendor/libgit2/src/odb.h +8 -7
- data/vendor/libgit2/src/odb_loose.c +62 -55
- data/vendor/libgit2/src/odb_mempack.c +21 -34
- data/vendor/libgit2/src/odb_pack.c +18 -14
- data/vendor/libgit2/src/offmap.c +53 -35
- data/vendor/libgit2/src/offmap.h +108 -21
- data/vendor/libgit2/src/oid.c +12 -7
- data/vendor/libgit2/src/oidmap.c +49 -47
- data/vendor/libgit2/src/oidmap.h +101 -24
- data/vendor/libgit2/src/pack-objects.c +88 -87
- data/vendor/libgit2/src/pack-objects.h +2 -8
- data/vendor/libgit2/src/pack.c +99 -101
- data/vendor/libgit2/src/pack.h +17 -19
- data/vendor/libgit2/src/parse.c +10 -0
- data/vendor/libgit2/src/parse.h +3 -3
- data/vendor/libgit2/src/patch.c +4 -4
- data/vendor/libgit2/src/patch_generate.c +20 -20
- data/vendor/libgit2/src/patch_parse.c +151 -63
- data/vendor/libgit2/src/path.c +169 -125
- data/vendor/libgit2/src/path.h +3 -71
- data/vendor/libgit2/src/pathspec.c +19 -19
- data/vendor/libgit2/src/pool.c +26 -22
- data/vendor/libgit2/src/pool.h +7 -7
- data/vendor/libgit2/src/posix.c +10 -10
- data/vendor/libgit2/src/posix.h +12 -1
- data/vendor/libgit2/src/proxy.c +8 -3
- data/vendor/libgit2/src/push.c +37 -31
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +115 -59
- data/vendor/libgit2/src/refdb.c +15 -3
- data/vendor/libgit2/src/refdb_fs.c +381 -254
- data/vendor/libgit2/src/reflog.c +13 -15
- data/vendor/libgit2/src/refs.c +118 -88
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +56 -37
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/regexp.c +221 -0
- data/vendor/libgit2/src/regexp.h +97 -0
- data/vendor/libgit2/src/remote.c +266 -215
- data/vendor/libgit2/src/remote.h +11 -2
- data/vendor/libgit2/src/repository.c +280 -225
- data/vendor/libgit2/src/repository.h +52 -40
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +14 -9
- data/vendor/libgit2/src/revparse.c +47 -48
- data/vendor/libgit2/src/revwalk.c +120 -57
- data/vendor/libgit2/src/revwalk.h +22 -1
- data/vendor/libgit2/src/settings.c +47 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +22 -36
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +125 -99
- data/vendor/libgit2/src/status.c +28 -22
- data/vendor/libgit2/src/stream.h +17 -2
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +224 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +55 -30
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +47 -74
- data/vendor/libgit2/src/strmap.h +108 -33
- data/vendor/libgit2/src/submodule.c +272 -216
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +29 -19
- data/vendor/libgit2/src/tag.c +41 -28
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/trailer.c +52 -38
- data/vendor/libgit2/src/transaction.c +30 -29
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +15 -11
- data/vendor/libgit2/src/transports/auth.h +10 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +33 -18
- data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
- data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
- data/vendor/libgit2/src/transports/auth_ntlm.h +35 -0
- data/vendor/libgit2/src/transports/cred.c +24 -24
- data/vendor/libgit2/src/transports/git.c +26 -31
- data/vendor/libgit2/src/transports/http.c +881 -348
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +35 -35
- data/vendor/libgit2/src/transports/smart.c +70 -47
- data/vendor/libgit2/src/transports/smart.h +3 -4
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +96 -116
- data/vendor/libgit2/src/transports/ssh.c +77 -66
- data/vendor/libgit2/src/transports/winhttp.c +318 -314
- data/vendor/libgit2/src/tree-cache.c +19 -12
- data/vendor/libgit2/src/tree.c +103 -142
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +3 -3
- data/vendor/libgit2/src/unix/posix.h +1 -11
- data/vendor/libgit2/src/userdiff.h +3 -1
- data/vendor/libgit2/src/util.c +70 -56
- data/vendor/libgit2/src/util.h +28 -156
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/wildmatch.c +320 -0
- data/vendor/libgit2/src/wildmatch.h +23 -0
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +9 -11
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +113 -9
- data/vendor/libgit2/src/win32/path_w32.h +18 -29
- data/vendor/libgit2/src/win32/posix.h +1 -4
- data/vendor/libgit2/src/win32/posix_w32.c +70 -45
- data/vendor/libgit2/src/win32/precompiled.h +0 -2
- data/vendor/libgit2/src/win32/thread.c +5 -10
- data/vendor/libgit2/src/win32/w32_buffer.c +9 -5
- data/vendor/libgit2/src/win32/w32_common.h +39 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +3 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +26 -75
- data/vendor/libgit2/src/win32/w32_stack.c +6 -11
- data/vendor/libgit2/src/win32/w32_stack.h +3 -3
- data/vendor/libgit2/src/win32/w32_util.c +27 -64
- data/vendor/libgit2/src/win32/w32_util.h +5 -49
- data/vendor/libgit2/src/worktree.c +95 -60
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +27 -15
- data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +122 -33
- data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
- data/vendor/libgit2/deps/regex/config.h +0 -7
- data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
- data/vendor/libgit2/deps/regex/regex.c +0 -92
- data/vendor/libgit2/deps/regex/regex.h +0 -582
- data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
- data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
- data/vendor/libgit2/deps/regex/regexec.c +0 -4369
- data/vendor/libgit2/include/git2/inttypes.h +0 -309
- data/vendor/libgit2/include/git2/sys/time.h +0 -31
- data/vendor/libgit2/libgit2.pc.in +0 -13
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/fnmatch.c +0 -248
- data/vendor/libgit2/src/fnmatch.h +0 -48
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +0 -47
- data/vendor/libgit2/src/hash/hash_openssl.h +0 -59
- data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -0,0 +1,24 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "common.h"
|
9
|
+
|
10
|
+
#include "git2/sys/config.h"
|
11
|
+
#include "config.h"
|
12
|
+
|
13
|
+
typedef struct git_config_entries git_config_entries;
|
14
|
+
|
15
|
+
int git_config_entries_new(git_config_entries **out);
|
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
|
+
void git_config_entries_incref(git_config_entries *entries);
|
19
|
+
void git_config_entries_free(git_config_entries *entries);
|
20
|
+
/* Add or append the new config option */
|
21
|
+
int git_config_entries_append(git_config_entries *entries, git_config_entry *entry);
|
22
|
+
int git_config_entries_get(git_config_entry **out, git_config_entries *entries, const char *key);
|
23
|
+
int git_config_entries_get_unique(git_config_entry **out, git_config_entries *entries, const char *key);
|
24
|
+
int git_config_entries_iterator_new(git_config_iterator **out, git_config_entries *entries);
|
@@ -5,93 +5,37 @@
|
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
7
|
|
8
|
-
#include "config_file.h"
|
9
|
-
|
10
8
|
#include "config.h"
|
11
|
-
|
12
|
-
#include "sysdir.h"
|
13
|
-
#include "buffer.h"
|
14
|
-
#include "buf_text.h"
|
9
|
+
|
15
10
|
#include "git2/config.h"
|
16
11
|
#include "git2/sys/config.h"
|
17
|
-
|
18
|
-
#include "strmap.h"
|
12
|
+
|
19
13
|
#include "array.h"
|
14
|
+
#include "buffer.h"
|
15
|
+
#include "config_backend.h"
|
16
|
+
#include "config_entries.h"
|
20
17
|
#include "config_parse.h"
|
21
|
-
|
22
|
-
#include
|
23
|
-
#include
|
24
|
-
#include
|
25
|
-
|
26
|
-
typedef struct cvar_t {
|
27
|
-
struct cvar_t *next;
|
28
|
-
git_config_entry *entry;
|
29
|
-
bool included; /* whether this is part of [include] */
|
30
|
-
} cvar_t;
|
31
|
-
|
32
|
-
typedef struct git_config_file_iter {
|
33
|
-
git_config_iterator parent;
|
34
|
-
git_strmap_iter iter;
|
35
|
-
cvar_t* next_var;
|
36
|
-
} git_config_file_iter;
|
18
|
+
#include "filebuf.h"
|
19
|
+
#include "regexp.h"
|
20
|
+
#include "sysdir.h"
|
21
|
+
#include "wildmatch.h"
|
37
22
|
|
38
23
|
/* Max depth for [include] directives */
|
39
24
|
#define MAX_INCLUDE_DEPTH 10
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#define CVAR_LIST_EMPTY(list) ((list)->head == NULL)
|
48
|
-
|
49
|
-
#define CVAR_LIST_APPEND(list, var) do {\
|
50
|
-
if (CVAR_LIST_EMPTY(list)) {\
|
51
|
-
CVAR_LIST_HEAD(list) = CVAR_LIST_TAIL(list) = var;\
|
52
|
-
} else {\
|
53
|
-
CVAR_LIST_NEXT(CVAR_LIST_TAIL(list)) = var;\
|
54
|
-
CVAR_LIST_TAIL(list) = var;\
|
55
|
-
}\
|
56
|
-
} while(0)
|
57
|
-
|
58
|
-
#define CVAR_LIST_REMOVE_HEAD(list) do {\
|
59
|
-
CVAR_LIST_HEAD(list) = CVAR_LIST_NEXT(CVAR_LIST_HEAD(list));\
|
60
|
-
} while(0)
|
61
|
-
|
62
|
-
#define CVAR_LIST_REMOVE_AFTER(var) do {\
|
63
|
-
CVAR_LIST_NEXT(var) = CVAR_LIST_NEXT(CVAR_LIST_NEXT(var));\
|
64
|
-
} while(0)
|
65
|
-
|
66
|
-
#define CVAR_LIST_FOREACH(list, iter)\
|
67
|
-
for ((iter) = CVAR_LIST_HEAD(list);\
|
68
|
-
(iter) != NULL;\
|
69
|
-
(iter) = CVAR_LIST_NEXT(iter))
|
70
|
-
|
71
|
-
/*
|
72
|
-
* Inspired by the FreeBSD functions
|
73
|
-
*/
|
74
|
-
#define CVAR_LIST_FOREACH_SAFE(start, iter, tmp)\
|
75
|
-
for ((iter) = CVAR_LIST_HEAD(vars);\
|
76
|
-
(iter) && (((tmp) = CVAR_LIST_NEXT(iter) || 1));\
|
77
|
-
(iter) = (tmp))
|
78
|
-
|
79
|
-
typedef struct {
|
80
|
-
git_atomic refcount;
|
81
|
-
git_strmap *values;
|
82
|
-
} refcounted_strmap;
|
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;
|
83
32
|
|
84
33
|
typedef struct {
|
85
34
|
git_config_backend parent;
|
86
|
-
/* mutex to coordinate accessing the values */
|
87
35
|
git_mutex values_mutex;
|
88
|
-
|
36
|
+
git_config_entries *entries;
|
89
37
|
const git_repository *repo;
|
90
38
|
git_config_level_t level;
|
91
|
-
} diskfile_header;
|
92
|
-
|
93
|
-
typedef struct {
|
94
|
-
diskfile_header header;
|
95
39
|
|
96
40
|
git_array_t(git_config_parser) readers;
|
97
41
|
|
@@ -99,158 +43,47 @@ typedef struct {
|
|
99
43
|
git_filebuf locked_buf;
|
100
44
|
git_buf locked_content;
|
101
45
|
|
102
|
-
|
103
|
-
}
|
46
|
+
config_file file;
|
47
|
+
} config_file_backend;
|
104
48
|
|
105
49
|
typedef struct {
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
50
|
+
const git_repository *repo;
|
51
|
+
config_file *file;
|
52
|
+
git_config_entries *entries;
|
53
|
+
git_config_level_t level;
|
54
|
+
unsigned int depth;
|
55
|
+
} config_file_parse_data;
|
110
56
|
|
111
|
-
static int
|
112
|
-
static int
|
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);
|
113
60
|
static char *escape_value(const char *ptr);
|
114
61
|
|
115
|
-
int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in);
|
116
|
-
static int config_snapshot(git_config_backend **out, git_config_backend *in);
|
117
|
-
|
118
|
-
static int config_error_readonly(void)
|
119
|
-
{
|
120
|
-
giterr_set(GITERR_CONFIG, "this backend is read-only");
|
121
|
-
return -1;
|
122
|
-
}
|
123
|
-
|
124
|
-
static void cvar_free(cvar_t *var)
|
125
|
-
{
|
126
|
-
if (var == NULL)
|
127
|
-
return;
|
128
|
-
|
129
|
-
git__free((char*)var->entry->name);
|
130
|
-
git__free((char *)var->entry->value);
|
131
|
-
git__free(var->entry);
|
132
|
-
git__free(var);
|
133
|
-
}
|
134
|
-
|
135
|
-
int git_config_file_normalize_section(char *start, char *end)
|
136
|
-
{
|
137
|
-
char *scan;
|
138
|
-
|
139
|
-
if (start == end)
|
140
|
-
return GIT_EINVALIDSPEC;
|
141
|
-
|
142
|
-
/* Validate and downcase range */
|
143
|
-
for (scan = start; *scan; ++scan) {
|
144
|
-
if (end && scan >= end)
|
145
|
-
break;
|
146
|
-
if (isalnum(*scan))
|
147
|
-
*scan = (char)git__tolower(*scan);
|
148
|
-
else if (*scan != '-' || scan == start)
|
149
|
-
return GIT_EINVALIDSPEC;
|
150
|
-
}
|
151
|
-
|
152
|
-
if (scan == start)
|
153
|
-
return GIT_EINVALIDSPEC;
|
154
|
-
|
155
|
-
return 0;
|
156
|
-
}
|
157
|
-
|
158
|
-
/* Add or append the new config option */
|
159
|
-
static int append_entry(git_strmap *values, cvar_t *var)
|
160
|
-
{
|
161
|
-
git_strmap_iter pos;
|
162
|
-
cvar_t *existing;
|
163
|
-
int error = 0;
|
164
|
-
|
165
|
-
pos = git_strmap_lookup_index(values, var->entry->name);
|
166
|
-
if (!git_strmap_valid_index(values, pos)) {
|
167
|
-
git_strmap_insert(values, var->entry->name, var, &error);
|
168
|
-
} else {
|
169
|
-
existing = git_strmap_value_at(values, pos);
|
170
|
-
while (existing->next != NULL) {
|
171
|
-
existing = existing->next;
|
172
|
-
}
|
173
|
-
existing->next = var;
|
174
|
-
}
|
175
|
-
|
176
|
-
if (error > 0)
|
177
|
-
error = 0;
|
178
|
-
|
179
|
-
return error;
|
180
|
-
}
|
181
|
-
|
182
|
-
static void free_vars(git_strmap *values)
|
183
|
-
{
|
184
|
-
cvar_t *var = NULL;
|
185
|
-
|
186
|
-
if (values == NULL)
|
187
|
-
return;
|
188
|
-
|
189
|
-
git_strmap_foreach_value(values, var,
|
190
|
-
while (var != NULL) {
|
191
|
-
cvar_t *next = CVAR_LIST_NEXT(var);
|
192
|
-
cvar_free(var);
|
193
|
-
var = next;
|
194
|
-
});
|
195
|
-
|
196
|
-
git_strmap_free(values);
|
197
|
-
}
|
198
|
-
|
199
|
-
static void refcounted_strmap_free(refcounted_strmap *map)
|
200
|
-
{
|
201
|
-
if (!map)
|
202
|
-
return;
|
203
|
-
|
204
|
-
if (git_atomic_dec(&map->refcount) != 0)
|
205
|
-
return;
|
206
|
-
|
207
|
-
free_vars(map->values);
|
208
|
-
git__free(map);
|
209
|
-
}
|
210
|
-
|
211
62
|
/**
|
212
63
|
* Take the current values map from the backend and increase its
|
213
64
|
* refcount. This is its own function to make sure we use the mutex to
|
214
65
|
* avoid the map pointer from changing under us.
|
215
66
|
*/
|
216
|
-
static
|
217
|
-
{
|
218
|
-
refcounted_strmap *map;
|
219
|
-
|
220
|
-
if (git_mutex_lock(&h->values_mutex) < 0) {
|
221
|
-
giterr_set(GITERR_OS, "failed to lock config backend");
|
222
|
-
return NULL;
|
223
|
-
}
|
224
|
-
|
225
|
-
map = h->values;
|
226
|
-
git_atomic_inc(&map->refcount);
|
227
|
-
|
228
|
-
git_mutex_unlock(&h->values_mutex);
|
229
|
-
|
230
|
-
return map;
|
231
|
-
}
|
232
|
-
|
233
|
-
static int refcounted_strmap_alloc(refcounted_strmap **out)
|
67
|
+
static int config_file_entries_take(git_config_entries **out, config_file_backend *b)
|
234
68
|
{
|
235
|
-
refcounted_strmap *map;
|
236
69
|
int error;
|
237
70
|
|
238
|
-
|
239
|
-
|
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;
|
74
|
+
}
|
240
75
|
|
241
|
-
|
76
|
+
git_config_entries_incref(b->entries);
|
77
|
+
*out = b->entries;
|
242
78
|
|
243
|
-
|
244
|
-
git__free(map);
|
245
|
-
else
|
246
|
-
*out = map;
|
79
|
+
git_mutex_unlock(&b->values_mutex);
|
247
80
|
|
248
|
-
return
|
81
|
+
return 0;
|
249
82
|
}
|
250
83
|
|
251
|
-
static void config_file_clear(
|
84
|
+
static void config_file_clear(config_file *file)
|
252
85
|
{
|
253
|
-
|
86
|
+
config_file *include;
|
254
87
|
uint32_t i;
|
255
88
|
|
256
89
|
if (file == NULL)
|
@@ -264,31 +97,31 @@ static void config_file_clear(struct config_file *file)
|
|
264
97
|
git__free(file->path);
|
265
98
|
}
|
266
99
|
|
267
|
-
static int
|
100
|
+
static int config_file_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
|
268
101
|
{
|
102
|
+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
|
269
103
|
int res;
|
270
|
-
diskfile_backend *b = (diskfile_backend *)cfg;
|
271
104
|
|
272
|
-
b->
|
273
|
-
b->
|
105
|
+
b->level = level;
|
106
|
+
b->repo = repo;
|
274
107
|
|
275
|
-
if ((res =
|
108
|
+
if ((res = git_config_entries_new(&b->entries)) < 0)
|
276
109
|
return res;
|
277
110
|
|
278
111
|
if (!git_path_exists(b->file.path))
|
279
112
|
return 0;
|
280
113
|
|
281
|
-
if (res < 0 || (res =
|
282
|
-
|
283
|
-
b->
|
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;
|
284
117
|
}
|
285
118
|
|
286
119
|
return res;
|
287
120
|
}
|
288
121
|
|
289
|
-
static int
|
122
|
+
static int config_file_is_modified(int *modified, config_file *file)
|
290
123
|
{
|
291
|
-
|
124
|
+
config_file *include;
|
292
125
|
git_buf buf = GIT_BUF_INIT;
|
293
126
|
git_oid hash;
|
294
127
|
uint32_t i;
|
@@ -296,6 +129,9 @@ static int config_is_modified(int *modified, struct config_file *file)
|
|
296
129
|
|
297
130
|
*modified = 0;
|
298
131
|
|
132
|
+
if (!git_futils_filestamp_check(&file->stamp, file->path))
|
133
|
+
goto check_includes;
|
134
|
+
|
299
135
|
if ((error = git_futils_readbuffer(&buf, file->path)) < 0)
|
300
136
|
goto out;
|
301
137
|
|
@@ -307,388 +143,305 @@ static int config_is_modified(int *modified, struct config_file *file)
|
|
307
143
|
goto out;
|
308
144
|
}
|
309
145
|
|
146
|
+
check_includes:
|
310
147
|
git_array_foreach(file->includes, i, include) {
|
311
|
-
if ((error =
|
148
|
+
if ((error = config_file_is_modified(modified, include)) < 0 || *modified)
|
312
149
|
goto out;
|
313
150
|
}
|
314
151
|
|
315
152
|
out:
|
316
|
-
|
153
|
+
git_buf_dispose(&buf);
|
317
154
|
|
318
155
|
return error;
|
319
156
|
}
|
320
157
|
|
321
|
-
static int
|
158
|
+
static int config_file_set_entries(git_config_backend *cfg, git_config_entries *entries)
|
322
159
|
{
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
int error
|
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;
|
327
164
|
uint32_t i;
|
328
165
|
|
329
|
-
if (b->
|
330
|
-
|
166
|
+
if (b->parent.readonly) {
|
167
|
+
git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
|
168
|
+
return -1;
|
169
|
+
}
|
331
170
|
|
332
|
-
|
333
|
-
|
171
|
+
git_array_foreach(b->file.includes, i, include)
|
172
|
+
config_file_clear(include);
|
173
|
+
git_array_clear(b->file.includes);
|
174
|
+
|
175
|
+
if ((error = git_mutex_lock(&b->values_mutex)) < 0) {
|
176
|
+
git_error_set(GIT_ERROR_OS, "failed to lock config backend");
|
334
177
|
goto out;
|
178
|
+
}
|
335
179
|
|
336
|
-
|
337
|
-
|
180
|
+
old = b->entries;
|
181
|
+
b->entries = entries;
|
338
182
|
|
339
|
-
|
340
|
-
goto out;
|
183
|
+
git_mutex_unlock(&b->values_mutex);
|
341
184
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
git_array_clear(b->file.includes);
|
185
|
+
out:
|
186
|
+
git_config_entries_free(old);
|
187
|
+
return error;
|
188
|
+
}
|
347
189
|
|
348
|
-
|
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;
|
195
|
+
|
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)
|
349
200
|
goto out;
|
350
201
|
|
351
|
-
|
352
|
-
|
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;
|
213
|
+
|
214
|
+
if (cfg->readonly)
|
215
|
+
return 0;
|
216
|
+
|
217
|
+
if ((error = config_file_is_modified(&modified, &b->file)) < 0 && error != GIT_ENOTFOUND)
|
353
218
|
goto out;
|
354
|
-
}
|
355
219
|
|
356
|
-
|
357
|
-
|
358
|
-
values = tmp;
|
220
|
+
if (!modified)
|
221
|
+
return 0;
|
359
222
|
|
360
|
-
|
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;
|
361
227
|
|
228
|
+
entries = NULL;
|
362
229
|
out:
|
363
|
-
|
230
|
+
git_config_entries_free(entries);
|
364
231
|
|
365
232
|
return (error == GIT_ENOTFOUND) ? 0 : error;
|
366
233
|
}
|
367
234
|
|
368
|
-
static void
|
235
|
+
static void config_file_free(git_config_backend *_backend)
|
369
236
|
{
|
370
|
-
|
237
|
+
config_file_backend *backend = GIT_CONTAINER_OF(_backend, config_file_backend, parent);
|
371
238
|
|
372
239
|
if (backend == NULL)
|
373
240
|
return;
|
374
241
|
|
375
242
|
config_file_clear(&backend->file);
|
376
|
-
|
377
|
-
git_mutex_free(&backend->
|
243
|
+
git_config_entries_free(backend->entries);
|
244
|
+
git_mutex_free(&backend->values_mutex);
|
378
245
|
git__free(backend);
|
379
246
|
}
|
380
247
|
|
381
|
-
static
|
382
|
-
git_config_iterator* iter)
|
383
|
-
{
|
384
|
-
iter->backend->free(iter->backend);
|
385
|
-
git__free(iter);
|
386
|
-
}
|
387
|
-
|
388
|
-
static int config_iterator_next(
|
389
|
-
git_config_entry **entry,
|
390
|
-
git_config_iterator *iter)
|
391
|
-
{
|
392
|
-
git_config_file_iter *it = (git_config_file_iter *) iter;
|
393
|
-
diskfile_header *h = (diskfile_header *) it->parent.backend;
|
394
|
-
git_strmap *values = h->values->values;
|
395
|
-
int err = 0;
|
396
|
-
cvar_t * var;
|
397
|
-
|
398
|
-
if (it->next_var == NULL) {
|
399
|
-
err = git_strmap_next((void**) &var, &(it->iter), values);
|
400
|
-
} else {
|
401
|
-
var = it->next_var;
|
402
|
-
}
|
403
|
-
|
404
|
-
if (err < 0) {
|
405
|
-
it->next_var = NULL;
|
406
|
-
return err;
|
407
|
-
}
|
408
|
-
|
409
|
-
*entry = var->entry;
|
410
|
-
it->next_var = CVAR_LIST_NEXT(var);
|
411
|
-
|
412
|
-
return 0;
|
413
|
-
}
|
414
|
-
|
415
|
-
static int config_iterator_new(
|
248
|
+
static int config_file_iterator(
|
416
249
|
git_config_iterator **iter,
|
417
|
-
struct git_config_backend*
|
250
|
+
struct git_config_backend *backend)
|
418
251
|
{
|
419
|
-
|
420
|
-
|
421
|
-
git_config_backend *snapshot;
|
422
|
-
diskfile_header *bh = (diskfile_header *) backend;
|
252
|
+
config_file_backend *b = GIT_CONTAINER_OF(backend, config_file_backend, parent);
|
253
|
+
git_config_entries *dupped = NULL, *entries = NULL;
|
423
254
|
int error;
|
424
255
|
|
425
|
-
if ((error =
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
it = git__calloc(1, sizeof(git_config_file_iter));
|
432
|
-
GITERR_CHECK_ALLOC(it);
|
433
|
-
|
434
|
-
h = (diskfile_header *)snapshot;
|
435
|
-
|
436
|
-
/* strmap_begin() is currently a macro returning 0 */
|
437
|
-
GIT_UNUSED(h);
|
438
|
-
|
439
|
-
it->parent.backend = snapshot;
|
440
|
-
it->iter = git_strmap_begin(h->values);
|
441
|
-
it->next_var = NULL;
|
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)
|
260
|
+
goto out;
|
442
261
|
|
443
|
-
|
444
|
-
it
|
445
|
-
|
262
|
+
out:
|
263
|
+
/* Let iterator delete duplicated entries when it's done */
|
264
|
+
git_config_entries_free(entries);
|
265
|
+
git_config_entries_free(dupped);
|
266
|
+
return error;
|
267
|
+
}
|
446
268
|
|
447
|
-
|
269
|
+
static int config_file_snapshot(git_config_backend **out, git_config_backend *backend)
|
270
|
+
{
|
271
|
+
return git_config_backend_snapshot(out, backend);
|
448
272
|
}
|
449
273
|
|
450
|
-
static int
|
274
|
+
static int config_file_set(git_config_backend *cfg, const char *name, const char *value)
|
451
275
|
{
|
452
|
-
|
453
|
-
|
454
|
-
|
276
|
+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
|
277
|
+
git_config_entries *entries;
|
278
|
+
git_config_entry *existing;
|
455
279
|
char *key, *esc_value = NULL;
|
456
|
-
|
457
|
-
int rval, ret;
|
458
|
-
|
459
|
-
if ((rval = git_config__normalize_name(name, &key)) < 0)
|
460
|
-
return rval;
|
461
|
-
|
462
|
-
if ((map = refcounted_strmap_take(&b->header)) == NULL)
|
463
|
-
return -1;
|
464
|
-
values = map->values;
|
280
|
+
int error;
|
465
281
|
|
466
|
-
|
467
|
-
|
468
|
-
* only has one value.
|
469
|
-
*/
|
470
|
-
pos = git_strmap_lookup_index(values, key);
|
471
|
-
if (git_strmap_valid_index(values, pos)) {
|
472
|
-
cvar_t *existing = git_strmap_value_at(values, pos);
|
282
|
+
if ((error = git_config__normalize_name(name, &key)) < 0)
|
283
|
+
return error;
|
473
284
|
|
474
|
-
|
475
|
-
|
476
|
-
ret = -1;
|
477
|
-
goto out;
|
478
|
-
}
|
285
|
+
if ((error = config_file_entries_take(&entries, b)) < 0)
|
286
|
+
return error;
|
479
287
|
|
480
|
-
|
481
|
-
|
482
|
-
|
288
|
+
/* Check whether we'd be modifying an included or multivar key */
|
289
|
+
if ((error = git_config_entries_get_unique(&existing, entries, key)) < 0) {
|
290
|
+
if (error != GIT_ENOTFOUND)
|
483
291
|
goto out;
|
484
|
-
|
485
|
-
|
292
|
+
error = 0;
|
293
|
+
} else if ((!existing->value && !value) ||
|
294
|
+
(existing->value && value && !strcmp(existing->value, value))) {
|
486
295
|
/* don't update if old and new values already match */
|
487
|
-
|
488
|
-
|
489
|
-
!strcmp(existing->entry->value, value))) {
|
490
|
-
ret = 0;
|
491
|
-
goto out;
|
492
|
-
}
|
296
|
+
error = 0;
|
297
|
+
goto out;
|
493
298
|
}
|
494
299
|
|
495
300
|
/* No early returns due to sanity checks, let's write it out and refresh */
|
496
|
-
|
497
301
|
if (value) {
|
498
302
|
esc_value = escape_value(value);
|
499
|
-
|
303
|
+
GIT_ERROR_CHECK_ALLOC(esc_value);
|
500
304
|
}
|
501
305
|
|
502
|
-
if ((
|
306
|
+
if ((error = config_file_write(b, name, key, NULL, esc_value)) < 0)
|
503
307
|
goto out;
|
504
308
|
|
505
|
-
ret = config_refresh(cfg);
|
506
|
-
|
507
309
|
out:
|
508
|
-
|
310
|
+
git_config_entries_free(entries);
|
509
311
|
git__free(esc_value);
|
510
312
|
git__free(key);
|
511
|
-
return
|
313
|
+
return error;
|
512
314
|
}
|
513
315
|
|
514
316
|
/* release the map containing the entry as an equivalent to freeing it */
|
515
|
-
static void
|
317
|
+
static void config_file_entry_free(git_config_entry *entry)
|
516
318
|
{
|
517
|
-
|
518
|
-
|
319
|
+
git_config_entries *entries = (git_config_entries *) entry->payload;
|
320
|
+
git_config_entries_free(entries);
|
519
321
|
}
|
520
322
|
|
521
323
|
/*
|
522
324
|
* Internal function that actually gets the value in string form
|
523
325
|
*/
|
524
|
-
static int
|
326
|
+
static int config_file_get(git_config_backend *cfg, const char *key, git_config_entry **out)
|
525
327
|
{
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
khiter_t pos;
|
530
|
-
cvar_t *var;
|
328
|
+
config_file_backend *h = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
|
329
|
+
git_config_entries *entries = NULL;
|
330
|
+
git_config_entry *entry;
|
531
331
|
int error = 0;
|
532
332
|
|
533
|
-
if (!h->parent.readonly && ((error =
|
333
|
+
if (!h->parent.readonly && ((error = config_file_refresh(cfg)) < 0))
|
534
334
|
return error;
|
535
335
|
|
536
|
-
if ((
|
537
|
-
return
|
538
|
-
values = map->values;
|
539
|
-
|
540
|
-
pos = git_strmap_lookup_index(values, key);
|
336
|
+
if ((error = config_file_entries_take(&entries, h)) < 0)
|
337
|
+
return error;
|
541
338
|
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
return GIT_ENOTFOUND;
|
339
|
+
if ((error = (git_config_entries_get(&entry, entries, key))) < 0) {
|
340
|
+
git_config_entries_free(entries);
|
341
|
+
return error;
|
546
342
|
}
|
547
343
|
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
*out = var->entry;
|
553
|
-
(*out)->free = release_map;
|
554
|
-
(*out)->payload = map;
|
344
|
+
entry->free = config_file_entry_free;
|
345
|
+
entry->payload = entries;
|
346
|
+
*out = entry;
|
555
347
|
|
556
|
-
return
|
348
|
+
return 0;
|
557
349
|
}
|
558
350
|
|
559
|
-
static int
|
351
|
+
static int config_file_set_multivar(
|
560
352
|
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
|
561
353
|
{
|
562
|
-
|
563
|
-
|
564
|
-
regex_t preg;
|
354
|
+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
|
355
|
+
git_regexp preg;
|
565
356
|
int result;
|
357
|
+
char *key;
|
566
358
|
|
567
359
|
assert(regexp);
|
568
360
|
|
569
361
|
if ((result = git_config__normalize_name(name, &key)) < 0)
|
570
362
|
return result;
|
571
363
|
|
572
|
-
result =
|
573
|
-
if (result != 0) {
|
574
|
-
giterr_set_regex(&preg, result);
|
575
|
-
result = -1;
|
364
|
+
if ((result = git_regexp_compile(&preg, regexp, 0)) < 0)
|
576
365
|
goto out;
|
577
|
-
}
|
578
366
|
|
579
|
-
/* If we do have it, set call
|
580
|
-
if ((result =
|
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)
|
581
369
|
goto out;
|
582
370
|
|
583
|
-
result = config_refresh(cfg);
|
584
|
-
|
585
371
|
out:
|
586
372
|
git__free(key);
|
587
|
-
|
373
|
+
git_regexp_dispose(&preg);
|
588
374
|
|
589
375
|
return result;
|
590
376
|
}
|
591
377
|
|
592
|
-
static int
|
378
|
+
static int config_file_delete(git_config_backend *cfg, const char *name)
|
593
379
|
{
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
char *key;
|
598
|
-
int
|
599
|
-
khiter_t pos;
|
600
|
-
|
601
|
-
if ((result = git_config__normalize_name(name, &key)) < 0)
|
602
|
-
return result;
|
603
|
-
|
604
|
-
if ((map = refcounted_strmap_take(&b->header)) == NULL)
|
605
|
-
return -1;
|
606
|
-
values = b->header.values->values;
|
607
|
-
|
608
|
-
pos = git_strmap_lookup_index(values, key);
|
609
|
-
git__free(key);
|
610
|
-
|
611
|
-
if (!git_strmap_valid_index(values, pos)) {
|
612
|
-
refcounted_strmap_free(map);
|
613
|
-
giterr_set(GITERR_CONFIG, "could not find key '%s' to delete", name);
|
614
|
-
return GIT_ENOTFOUND;
|
615
|
-
}
|
380
|
+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
|
381
|
+
git_config_entries *entries = NULL;
|
382
|
+
git_config_entry *entry;
|
383
|
+
char *key = NULL;
|
384
|
+
int error;
|
616
385
|
|
617
|
-
|
618
|
-
|
386
|
+
if ((error = git_config__normalize_name(name, &key)) < 0)
|
387
|
+
goto out;
|
619
388
|
|
620
|
-
if (
|
621
|
-
|
622
|
-
return -1;
|
623
|
-
}
|
389
|
+
if ((error = config_file_entries_take(&entries, b)) < 0)
|
390
|
+
goto out;
|
624
391
|
|
625
|
-
|
626
|
-
|
627
|
-
|
392
|
+
/* Check whether we'd be modifying an included or multivar key */
|
393
|
+
if ((error = git_config_entries_get_unique(&entry, entries, key)) < 0) {
|
394
|
+
if (error == GIT_ENOTFOUND)
|
395
|
+
git_error_set(GIT_ERROR_CONFIG, "could not find key '%s' to delete", name);
|
396
|
+
goto out;
|
628
397
|
}
|
629
398
|
|
630
|
-
if ((
|
631
|
-
|
399
|
+
if ((error = config_file_write(b, name, entry->name, NULL, NULL)) < 0)
|
400
|
+
goto out;
|
632
401
|
|
633
|
-
|
402
|
+
out:
|
403
|
+
git_config_entries_free(entries);
|
404
|
+
git__free(key);
|
405
|
+
return error;
|
634
406
|
}
|
635
407
|
|
636
|
-
static int
|
408
|
+
static int config_file_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
|
637
409
|
{
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
410
|
+
config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
|
411
|
+
git_config_entries *entries = NULL;
|
412
|
+
git_config_entry *entry = NULL;
|
413
|
+
git_regexp preg = GIT_REGEX_INIT;
|
414
|
+
char *key = NULL;
|
643
415
|
int result;
|
644
|
-
khiter_t pos;
|
645
416
|
|
646
417
|
if ((result = git_config__normalize_name(name, &key)) < 0)
|
647
|
-
|
648
|
-
|
649
|
-
if ((map = refcounted_strmap_take(&b->header)) == NULL)
|
650
|
-
return -1;
|
651
|
-
values = b->header.values->values;
|
652
|
-
|
653
|
-
pos = git_strmap_lookup_index(values, key);
|
654
|
-
|
655
|
-
if (!git_strmap_valid_index(values, pos)) {
|
656
|
-
refcounted_strmap_free(map);
|
657
|
-
git__free(key);
|
658
|
-
giterr_set(GITERR_CONFIG, "could not find key '%s' to delete", name);
|
659
|
-
return GIT_ENOTFOUND;
|
660
|
-
}
|
418
|
+
goto out;
|
661
419
|
|
662
|
-
|
420
|
+
if ((result = config_file_entries_take(&entries, b)) < 0)
|
421
|
+
goto out;
|
663
422
|
|
664
|
-
result =
|
665
|
-
|
666
|
-
|
667
|
-
result = -1;
|
423
|
+
if ((result = git_config_entries_get(&entry, entries, key)) < 0) {
|
424
|
+
if (result == GIT_ENOTFOUND)
|
425
|
+
git_error_set(GIT_ERROR_CONFIG, "could not find key '%s' to delete", name);
|
668
426
|
goto out;
|
669
427
|
}
|
670
428
|
|
671
|
-
if ((result =
|
429
|
+
if ((result = git_regexp_compile(&preg, regexp, 0)) < 0)
|
672
430
|
goto out;
|
673
431
|
|
674
|
-
result =
|
432
|
+
if ((result = config_file_write(b, name, key, &preg, NULL)) < 0)
|
433
|
+
goto out;
|
675
434
|
|
676
435
|
out:
|
436
|
+
git_config_entries_free(entries);
|
677
437
|
git__free(key);
|
678
|
-
|
438
|
+
git_regexp_dispose(&preg);
|
679
439
|
return result;
|
680
440
|
}
|
681
441
|
|
682
|
-
static int
|
683
|
-
{
|
684
|
-
diskfile_backend *b = (diskfile_backend *) in;
|
685
|
-
|
686
|
-
return git_config_file__snapshot(out, b);
|
687
|
-
}
|
688
|
-
|
689
|
-
static int config_lock(git_config_backend *_cfg)
|
442
|
+
static int config_file_lock(git_config_backend *_cfg)
|
690
443
|
{
|
691
|
-
|
444
|
+
config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
|
692
445
|
int error;
|
693
446
|
|
694
447
|
if ((error = git_filebuf_open(&cfg->locked_buf, cfg->file.path, 0, GIT_CONFIG_FILE_MODE)) < 0)
|
@@ -705,9 +458,9 @@ static int config_lock(git_config_backend *_cfg)
|
|
705
458
|
|
706
459
|
}
|
707
460
|
|
708
|
-
static int
|
461
|
+
static int config_file_unlock(git_config_backend *_cfg, int success)
|
709
462
|
{
|
710
|
-
|
463
|
+
config_file_backend *cfg = GIT_CONTAINER_OF(_cfg, config_file_backend, parent);
|
711
464
|
int error = 0;
|
712
465
|
|
713
466
|
if (success) {
|
@@ -716,153 +469,37 @@ static int config_unlock(git_config_backend *_cfg, int success)
|
|
716
469
|
}
|
717
470
|
|
718
471
|
git_filebuf_cleanup(&cfg->locked_buf);
|
719
|
-
|
472
|
+
git_buf_dispose(&cfg->locked_content);
|
720
473
|
cfg->locked = false;
|
721
474
|
|
722
475
|
return error;
|
723
476
|
}
|
724
477
|
|
725
|
-
int
|
478
|
+
int git_config_backend_from_file(git_config_backend **out, const char *path)
|
726
479
|
{
|
727
|
-
|
480
|
+
config_file_backend *backend;
|
728
481
|
|
729
|
-
backend = git__calloc(1, sizeof(
|
730
|
-
|
482
|
+
backend = git__calloc(1, sizeof(config_file_backend));
|
483
|
+
GIT_ERROR_CHECK_ALLOC(backend);
|
731
484
|
|
732
|
-
backend->
|
733
|
-
git_mutex_init(&backend->
|
485
|
+
backend->parent.version = GIT_CONFIG_BACKEND_VERSION;
|
486
|
+
git_mutex_init(&backend->values_mutex);
|
734
487
|
|
735
488
|
backend->file.path = git__strdup(path);
|
736
|
-
|
489
|
+
GIT_ERROR_CHECK_ALLOC(backend->file.path);
|
737
490
|
git_array_init(backend->file.includes);
|
738
491
|
|
739
|
-
backend->
|
740
|
-
backend->
|
741
|
-
backend->
|
742
|
-
backend->
|
743
|
-
backend->
|
744
|
-
backend->
|
745
|
-
backend->
|
746
|
-
backend->
|
747
|
-
backend->
|
748
|
-
backend->
|
749
|
-
backend->
|
750
|
-
|
751
|
-
*out = (git_config_backend *)backend;
|
752
|
-
|
753
|
-
return 0;
|
754
|
-
}
|
755
|
-
|
756
|
-
static int config_set_readonly(git_config_backend *cfg, const char *name, const char *value)
|
757
|
-
{
|
758
|
-
GIT_UNUSED(cfg);
|
759
|
-
GIT_UNUSED(name);
|
760
|
-
GIT_UNUSED(value);
|
761
|
-
|
762
|
-
return config_error_readonly();
|
763
|
-
}
|
764
|
-
|
765
|
-
static int config_set_multivar_readonly(
|
766
|
-
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
|
767
|
-
{
|
768
|
-
GIT_UNUSED(cfg);
|
769
|
-
GIT_UNUSED(name);
|
770
|
-
GIT_UNUSED(regexp);
|
771
|
-
GIT_UNUSED(value);
|
772
|
-
|
773
|
-
return config_error_readonly();
|
774
|
-
}
|
775
|
-
|
776
|
-
static int config_delete_multivar_readonly(git_config_backend *cfg, const char *name, const char *regexp)
|
777
|
-
{
|
778
|
-
GIT_UNUSED(cfg);
|
779
|
-
GIT_UNUSED(name);
|
780
|
-
GIT_UNUSED(regexp);
|
781
|
-
|
782
|
-
return config_error_readonly();
|
783
|
-
}
|
784
|
-
|
785
|
-
static int config_delete_readonly(git_config_backend *cfg, const char *name)
|
786
|
-
{
|
787
|
-
GIT_UNUSED(cfg);
|
788
|
-
GIT_UNUSED(name);
|
789
|
-
|
790
|
-
return config_error_readonly();
|
791
|
-
}
|
792
|
-
|
793
|
-
static int config_lock_readonly(git_config_backend *_cfg)
|
794
|
-
{
|
795
|
-
GIT_UNUSED(_cfg);
|
796
|
-
|
797
|
-
return config_error_readonly();
|
798
|
-
}
|
799
|
-
|
800
|
-
static int config_unlock_readonly(git_config_backend *_cfg, int success)
|
801
|
-
{
|
802
|
-
GIT_UNUSED(_cfg);
|
803
|
-
GIT_UNUSED(success);
|
804
|
-
|
805
|
-
return config_error_readonly();
|
806
|
-
}
|
807
|
-
|
808
|
-
static void backend_readonly_free(git_config_backend *_backend)
|
809
|
-
{
|
810
|
-
diskfile_backend *backend = (diskfile_backend *)_backend;
|
811
|
-
|
812
|
-
if (backend == NULL)
|
813
|
-
return;
|
814
|
-
|
815
|
-
refcounted_strmap_free(backend->header.values);
|
816
|
-
git_mutex_free(&backend->header.values_mutex);
|
817
|
-
git__free(backend);
|
818
|
-
}
|
819
|
-
|
820
|
-
static int config_readonly_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo)
|
821
|
-
{
|
822
|
-
diskfile_readonly_backend *b = (diskfile_readonly_backend *) cfg;
|
823
|
-
diskfile_backend *src = b->snapshot_from;
|
824
|
-
diskfile_header *src_header = &src->header;
|
825
|
-
refcounted_strmap *src_map;
|
826
|
-
int error;
|
827
|
-
|
828
|
-
if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0)
|
829
|
-
return error;
|
830
|
-
|
831
|
-
/* We're just copying data, don't care about the level or repo*/
|
832
|
-
GIT_UNUSED(level);
|
833
|
-
GIT_UNUSED(repo);
|
834
|
-
|
835
|
-
if ((src_map = refcounted_strmap_take(src_header)) == NULL)
|
836
|
-
return -1;
|
837
|
-
b->header.values = src_map;
|
838
|
-
|
839
|
-
return 0;
|
840
|
-
}
|
841
|
-
|
842
|
-
int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in)
|
843
|
-
{
|
844
|
-
diskfile_readonly_backend *backend;
|
845
|
-
|
846
|
-
backend = git__calloc(1, sizeof(diskfile_readonly_backend));
|
847
|
-
GITERR_CHECK_ALLOC(backend);
|
848
|
-
|
849
|
-
backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
|
850
|
-
git_mutex_init(&backend->header.values_mutex);
|
851
|
-
|
852
|
-
backend->snapshot_from = in;
|
853
|
-
|
854
|
-
backend->header.parent.readonly = 1;
|
855
|
-
backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION;
|
856
|
-
backend->header.parent.open = config_readonly_open;
|
857
|
-
backend->header.parent.get = config_get;
|
858
|
-
backend->header.parent.set = config_set_readonly;
|
859
|
-
backend->header.parent.set_multivar = config_set_multivar_readonly;
|
860
|
-
backend->header.parent.del = config_delete_readonly;
|
861
|
-
backend->header.parent.del_multivar = config_delete_multivar_readonly;
|
862
|
-
backend->header.parent.iterator = config_iterator_new;
|
863
|
-
backend->header.parent.lock = config_lock_readonly;
|
864
|
-
backend->header.parent.unlock = config_unlock_readonly;
|
865
|
-
backend->header.parent.free = backend_readonly_free;
|
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;
|
866
503
|
|
867
504
|
*out = (git_config_backend *)backend;
|
868
505
|
|
@@ -904,26 +541,15 @@ static char *escape_value(const char *ptr)
|
|
904
541
|
ptr++;
|
905
542
|
}
|
906
543
|
|
907
|
-
if (git_buf_oom(&buf))
|
908
|
-
git_buf_free(&buf);
|
544
|
+
if (git_buf_oom(&buf))
|
909
545
|
return NULL;
|
910
|
-
}
|
911
546
|
|
912
547
|
return git_buf_detach(&buf);
|
913
548
|
}
|
914
549
|
|
915
|
-
|
916
|
-
const git_repository *repo;
|
917
|
-
const char *file_path;
|
918
|
-
git_strmap *values;
|
919
|
-
git_config_level_t level;
|
920
|
-
int depth;
|
921
|
-
};
|
922
|
-
|
923
|
-
static int parse_include(git_config_parser *reader,
|
924
|
-
struct parse_data *parse_data, const char *file)
|
550
|
+
static int parse_include(config_file_parse_data *parse_data, const char *file)
|
925
551
|
{
|
926
|
-
|
552
|
+
config_file *include;
|
927
553
|
git_buf path = GIT_BUF_INIT;
|
928
554
|
char *dir;
|
929
555
|
int result;
|
@@ -931,7 +557,7 @@ static int parse_include(git_config_parser *reader,
|
|
931
557
|
if (!file)
|
932
558
|
return 0;
|
933
559
|
|
934
|
-
if ((result = git_path_dirname_r(&path,
|
560
|
+
if ((result = git_path_dirname_r(&path, parse_data->file->path)) < 0)
|
935
561
|
return result;
|
936
562
|
|
937
563
|
dir = git_buf_detach(&path);
|
@@ -941,16 +567,17 @@ static int parse_include(git_config_parser *reader,
|
|
941
567
|
if (result < 0)
|
942
568
|
return result;
|
943
569
|
|
944
|
-
include = git_array_alloc(
|
570
|
+
include = git_array_alloc(parse_data->file->includes);
|
571
|
+
GIT_ERROR_CHECK_ALLOC(include);
|
945
572
|
memset(include, 0, sizeof(*include));
|
946
573
|
git_array_init(include->includes);
|
947
574
|
include->path = git_buf_detach(&path);
|
948
575
|
|
949
|
-
result =
|
950
|
-
|
576
|
+
result = config_file_read(parse_data->entries, parse_data->repo, include,
|
577
|
+
parse_data->level, parse_data->depth+1);
|
951
578
|
|
952
579
|
if (result == GIT_ENOTFOUND) {
|
953
|
-
|
580
|
+
git_error_clear();
|
954
581
|
result = 0;
|
955
582
|
}
|
956
583
|
|
@@ -961,41 +588,41 @@ static int do_match_gitdir(
|
|
961
588
|
int *matches,
|
962
589
|
const git_repository *repo,
|
963
590
|
const char *cfg_file,
|
964
|
-
const char *
|
591
|
+
const char *condition,
|
965
592
|
bool case_insensitive)
|
966
593
|
{
|
967
|
-
git_buf
|
968
|
-
int error
|
969
|
-
|
970
|
-
if (
|
971
|
-
git_path_dirname_r(&
|
972
|
-
git_buf_joinpath(&
|
973
|
-
} else if (
|
974
|
-
git_sysdir_expand_global_file(&
|
975
|
-
else if (!git_path_is_absolute(
|
976
|
-
git_buf_joinpath(&
|
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);
|
977
604
|
else
|
978
|
-
git_buf_sets(&
|
605
|
+
git_buf_sets(&pattern, condition);
|
979
606
|
|
980
|
-
if (
|
607
|
+
if (git_path_is_dirsep(condition[strlen(condition) - 1]))
|
608
|
+
git_buf_puts(&pattern, "**");
|
609
|
+
|
610
|
+
if (git_buf_oom(&pattern)) {
|
981
611
|
error = -1;
|
982
612
|
goto out;
|
983
613
|
}
|
984
614
|
|
985
|
-
if (
|
986
|
-
git_buf_puts(&path, "**");
|
987
|
-
|
988
|
-
fnmatch_flags = FNM_PATHNAME|FNM_LEADING_DIR;
|
989
|
-
if (case_insensitive)
|
990
|
-
fnmatch_flags |= FNM_IGNORECASE;
|
991
|
-
|
992
|
-
if ((error = p_fnmatch(path.ptr, git_repository_path(repo), fnmatch_flags)) < 0)
|
615
|
+
if ((error = git_repository_item_path(&gitdir, repo, GIT_REPOSITORY_ITEM_GITDIR)) < 0)
|
993
616
|
goto out;
|
994
617
|
|
995
|
-
|
618
|
+
if (git_path_is_dirsep(gitdir.ptr[gitdir.size - 1]))
|
619
|
+
git_buf_truncate(&gitdir, gitdir.size - 1);
|
996
620
|
|
621
|
+
*matches = wildmatch(pattern.ptr, gitdir.ptr,
|
622
|
+
WM_PATHNAME | (case_insensitive ? WM_CASEFOLD : 0)) == WM_MATCH;
|
997
623
|
out:
|
998
|
-
|
624
|
+
git_buf_dispose(&pattern);
|
625
|
+
git_buf_dispose(&gitdir);
|
999
626
|
return error;
|
1000
627
|
}
|
1001
628
|
|
@@ -1017,16 +644,67 @@ static int conditional_match_gitdir_i(
|
|
1017
644
|
return do_match_gitdir(matches, repo, cfg_file, value, true);
|
1018
645
|
}
|
1019
646
|
|
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
|
+
|
1020
698
|
static const struct {
|
1021
699
|
const char *prefix;
|
1022
700
|
int (*matches)(int *matches, const git_repository *repo, const char *cfg, const char *value);
|
1023
701
|
} conditions[] = {
|
1024
702
|
{ "gitdir:", conditional_match_gitdir },
|
1025
|
-
{ "gitdir/i:", conditional_match_gitdir_i }
|
703
|
+
{ "gitdir/i:", conditional_match_gitdir_i },
|
704
|
+
{ "onbranch:", conditional_match_onbranch }
|
1026
705
|
};
|
1027
706
|
|
1028
|
-
static int parse_conditional_include(
|
1029
|
-
struct parse_data *parse_data, const char *section, const char *file)
|
707
|
+
static int parse_conditional_include(config_file_parse_data *parse_data, const char *section, const char *file)
|
1030
708
|
{
|
1031
709
|
char *condition;
|
1032
710
|
size_t i;
|
@@ -1044,12 +722,12 @@ static int parse_conditional_include(git_config_parser *reader,
|
|
1044
722
|
|
1045
723
|
if ((error = conditions[i].matches(&matches,
|
1046
724
|
parse_data->repo,
|
1047
|
-
parse_data->
|
725
|
+
parse_data->file->path,
|
1048
726
|
condition + strlen(conditions[i].prefix))) < 0)
|
1049
727
|
break;
|
1050
728
|
|
1051
729
|
if (matches)
|
1052
|
-
error = parse_include(
|
730
|
+
error = parse_include(parse_data, file);
|
1053
731
|
|
1054
732
|
break;
|
1055
733
|
}
|
@@ -1061,17 +739,19 @@ static int parse_conditional_include(git_config_parser *reader,
|
|
1061
739
|
static int read_on_variable(
|
1062
740
|
git_config_parser *reader,
|
1063
741
|
const char *current_section,
|
1064
|
-
char *var_name,
|
1065
|
-
char *var_value,
|
742
|
+
const char *var_name,
|
743
|
+
const char *var_value,
|
1066
744
|
const char *line,
|
1067
745
|
size_t line_len,
|
1068
746
|
void *data)
|
1069
747
|
{
|
1070
|
-
|
748
|
+
config_file_parse_data *parse_data = (config_file_parse_data *)data;
|
1071
749
|
git_buf buf = GIT_BUF_INIT;
|
1072
|
-
|
750
|
+
git_config_entry *entry;
|
751
|
+
const char *c;
|
1073
752
|
int result = 0;
|
1074
753
|
|
754
|
+
GIT_UNUSED(reader);
|
1075
755
|
GIT_UNUSED(line);
|
1076
756
|
GIT_UNUSED(line_len);
|
1077
757
|
|
@@ -1083,85 +763,104 @@ static int read_on_variable(
|
|
1083
763
|
git_buf_puts(&buf, current_section);
|
1084
764
|
git_buf_putc(&buf, '.');
|
1085
765
|
}
|
1086
|
-
git__strtolower(var_name);
|
1087
|
-
git_buf_puts(&buf, var_name);
|
1088
|
-
git__free(var_name);
|
1089
766
|
|
1090
|
-
|
1091
|
-
|
1092
|
-
return -1;
|
1093
|
-
}
|
767
|
+
for (c = var_name; *c; c++)
|
768
|
+
git_buf_putc(&buf, git__tolower(*c));
|
1094
769
|
|
1095
|
-
|
1096
|
-
|
1097
|
-
var->entry = git__calloc(1, sizeof(git_config_entry));
|
1098
|
-
GITERR_CHECK_ALLOC(var->entry);
|
770
|
+
if (git_buf_oom(&buf))
|
771
|
+
return -1;
|
1099
772
|
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
773
|
+
entry = git__calloc(1, sizeof(git_config_entry));
|
774
|
+
GIT_ERROR_CHECK_ALLOC(entry);
|
775
|
+
entry->name = git_buf_detach(&buf);
|
776
|
+
entry->value = var_value ? git__strdup(var_value) : NULL;
|
777
|
+
entry->level = parse_data->level;
|
778
|
+
entry->include_depth = parse_data->depth;
|
1104
779
|
|
1105
|
-
if ((result =
|
780
|
+
if ((result = git_config_entries_append(parse_data->entries, entry)) < 0)
|
1106
781
|
return result;
|
1107
782
|
|
1108
783
|
result = 0;
|
1109
784
|
|
1110
785
|
/* Add or append the new config option */
|
1111
|
-
if (!git__strcmp(
|
1112
|
-
result = parse_include(
|
1113
|
-
else if (!git__prefixcmp(
|
1114
|
-
!git__suffixcmp(
|
1115
|
-
result = parse_conditional_include(
|
1116
|
-
var->entry->name, var->entry->value);
|
1117
|
-
|
786
|
+
if (!git__strcmp(entry->name, "include.path"))
|
787
|
+
result = parse_include(parse_data, entry->value);
|
788
|
+
else if (!git__prefixcmp(entry->name, "includeif.") &&
|
789
|
+
!git__suffixcmp(entry->name, ".path"))
|
790
|
+
result = parse_conditional_include(parse_data, entry->name, entry->value);
|
1118
791
|
|
1119
792
|
return result;
|
1120
793
|
}
|
1121
794
|
|
1122
|
-
static int
|
1123
|
-
|
795
|
+
static int config_file_read_buffer(
|
796
|
+
git_config_entries *entries,
|
1124
797
|
const git_repository *repo,
|
1125
|
-
|
798
|
+
config_file *file,
|
1126
799
|
git_config_level_t level,
|
1127
|
-
int depth
|
800
|
+
int depth,
|
801
|
+
const char *buf,
|
802
|
+
size_t buflen)
|
1128
803
|
{
|
1129
|
-
|
804
|
+
config_file_parse_data parse_data;
|
1130
805
|
git_config_parser reader;
|
1131
|
-
git_buf contents = GIT_BUF_INIT;
|
1132
806
|
int error;
|
1133
807
|
|
1134
808
|
if (depth >= MAX_INCLUDE_DEPTH) {
|
1135
|
-
|
809
|
+
git_error_set(GIT_ERROR_CONFIG, "maximum config include depth reached");
|
1136
810
|
return -1;
|
1137
811
|
}
|
1138
812
|
|
1139
|
-
if ((error = git_futils_readbuffer(&contents, file->path)) < 0)
|
1140
|
-
goto out;
|
1141
|
-
|
1142
|
-
git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size);
|
1143
|
-
|
1144
|
-
if ((error = git_hash_buf(&file->checksum, contents.ptr, contents.size)) < 0)
|
1145
|
-
goto out;
|
1146
|
-
|
1147
813
|
/* Initialize the reading position */
|
1148
|
-
reader.
|
1149
|
-
git_parse_ctx_init(&reader.ctx,
|
814
|
+
reader.path = file->path;
|
815
|
+
git_parse_ctx_init(&reader.ctx, buf, buflen);
|
1150
816
|
|
1151
817
|
/* If the file is empty, there's nothing for us to do */
|
1152
|
-
if (!reader.ctx.content || *reader.ctx.content == '\0')
|
818
|
+
if (!reader.ctx.content || *reader.ctx.content == '\0') {
|
819
|
+
error = 0;
|
1153
820
|
goto out;
|
821
|
+
}
|
1154
822
|
|
1155
823
|
parse_data.repo = repo;
|
1156
|
-
parse_data.
|
1157
|
-
parse_data.
|
824
|
+
parse_data.file = file;
|
825
|
+
parse_data.entries = entries;
|
1158
826
|
parse_data.level = level;
|
1159
827
|
parse_data.depth = depth;
|
1160
828
|
|
1161
829
|
error = git_config_parse(&reader, NULL, read_on_variable, NULL, NULL, &parse_data);
|
1162
830
|
|
1163
831
|
out:
|
1164
|
-
|
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
|
+
out:
|
863
|
+
git_buf_dispose(&contents);
|
1165
864
|
return error;
|
1166
865
|
}
|
1167
866
|
|
@@ -1180,7 +879,7 @@ static int write_section(git_buf *fbuf, const char *key)
|
|
1180
879
|
char *escaped;
|
1181
880
|
git_buf_put(&buf, key, dot - key);
|
1182
881
|
escaped = escape_value(dot + 1);
|
1183
|
-
|
882
|
+
GIT_ERROR_CHECK_ALLOC(escaped);
|
1184
883
|
git_buf_printf(&buf, " \"%s\"", escaped);
|
1185
884
|
git__free(escaped);
|
1186
885
|
}
|
@@ -1190,7 +889,7 @@ static int write_section(git_buf *fbuf, const char *key)
|
|
1190
889
|
return -1;
|
1191
890
|
|
1192
891
|
result = git_buf_put(fbuf, git_buf_cstr(&buf), buf.size);
|
1193
|
-
|
892
|
+
git_buf_dispose(&buf);
|
1194
893
|
|
1195
894
|
return result;
|
1196
895
|
}
|
@@ -1222,7 +921,7 @@ struct write_data {
|
|
1222
921
|
const char *section;
|
1223
922
|
const char *orig_name;
|
1224
923
|
const char *name;
|
1225
|
-
const
|
924
|
+
const git_regexp *preg;
|
1226
925
|
const char *value;
|
1227
926
|
};
|
1228
927
|
|
@@ -1299,8 +998,8 @@ static int write_on_section(
|
|
1299
998
|
static int write_on_variable(
|
1300
999
|
git_config_parser *reader,
|
1301
1000
|
const char *current_section,
|
1302
|
-
char *var_name,
|
1303
|
-
char *var_value,
|
1001
|
+
const char *var_name,
|
1002
|
+
const char *var_value,
|
1304
1003
|
const char *line,
|
1305
1004
|
size_t line_len,
|
1306
1005
|
void *data)
|
@@ -1327,10 +1026,7 @@ static int write_on_variable(
|
|
1327
1026
|
|
1328
1027
|
/* If we have a regex to match the value, see if it matches */
|
1329
1028
|
if (has_matched && write_data->preg != NULL)
|
1330
|
-
has_matched = (
|
1331
|
-
|
1332
|
-
git__free(var_name);
|
1333
|
-
git__free(var_value);
|
1029
|
+
has_matched = (git_regexp_match(write_data->preg, var_value) == 0);
|
1334
1030
|
|
1335
1031
|
/* If this isn't the name/value we're looking for, simply dump the
|
1336
1032
|
* existing data back out and continue on.
|
@@ -1391,89 +1087,79 @@ static int write_on_eof(
|
|
1391
1087
|
/*
|
1392
1088
|
* This is pretty much the parsing, except we write out anything we don't have
|
1393
1089
|
*/
|
1394
|
-
static int
|
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
|
+
|
1395
1092
|
{
|
1396
|
-
|
1397
|
-
char *orig_section, *section, *orig_name, *name, *ldot;
|
1398
|
-
git_filebuf file = GIT_FILEBUF_INIT;
|
1093
|
+
char *orig_section = NULL, *section = NULL, *orig_name, *name, *ldot;
|
1399
1094
|
git_buf buf = GIT_BUF_INIT, contents = GIT_BUF_INIT;
|
1400
|
-
git_config_parser
|
1095
|
+
git_config_parser parser = GIT_CONFIG_PARSER_INIT;
|
1096
|
+
git_filebuf file = GIT_FILEBUF_INIT;
|
1401
1097
|
struct write_data write_data;
|
1098
|
+
int error;
|
1402
1099
|
|
1403
|
-
memset(&
|
1404
|
-
reader.file = &cfg->file;
|
1100
|
+
memset(&write_data, 0, sizeof(write_data));
|
1405
1101
|
|
1406
1102
|
if (cfg->locked) {
|
1407
|
-
|
1103
|
+
error = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content) == NULL ? "" : git_buf_cstr(&cfg->locked_content));
|
1408
1104
|
} else {
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
git_buf_free(&contents);
|
1413
|
-
return result;
|
1414
|
-
}
|
1105
|
+
if ((error = git_filebuf_open(&file, cfg->file.path, GIT_FILEBUF_HASH_CONTENTS,
|
1106
|
+
GIT_CONFIG_FILE_MODE)) < 0)
|
1107
|
+
goto done;
|
1415
1108
|
|
1416
1109
|
/* We need to read in our own config file */
|
1417
|
-
|
1110
|
+
error = git_futils_readbuffer(&contents, cfg->file.path);
|
1418
1111
|
}
|
1112
|
+
if (error < 0 && error != GIT_ENOTFOUND)
|
1113
|
+
goto done;
|
1419
1114
|
|
1420
|
-
|
1421
|
-
|
1422
|
-
git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size);
|
1423
|
-
} else {
|
1424
|
-
git_filebuf_cleanup(&file);
|
1425
|
-
return -1; /* OS error when reading the file */
|
1426
|
-
}
|
1115
|
+
if ((git_config_parser_init(&parser, cfg->file.path, contents.ptr, contents.size)) < 0)
|
1116
|
+
goto done;
|
1427
1117
|
|
1428
1118
|
ldot = strrchr(key, '.');
|
1429
1119
|
name = ldot + 1;
|
1430
1120
|
section = git__strndup(key, ldot - key);
|
1431
|
-
|
1121
|
+
GIT_ERROR_CHECK_ALLOC(section);
|
1432
1122
|
|
1433
1123
|
ldot = strrchr(orig_key, '.');
|
1434
1124
|
orig_name = ldot + 1;
|
1435
1125
|
orig_section = git__strndup(orig_key, ldot - orig_key);
|
1436
|
-
|
1126
|
+
GIT_ERROR_CHECK_ALLOC(orig_section);
|
1437
1127
|
|
1438
1128
|
write_data.buf = &buf;
|
1439
|
-
git_buf_init(&write_data.buffered_comment, 0);
|
1440
1129
|
write_data.orig_section = orig_section;
|
1441
1130
|
write_data.section = section;
|
1442
|
-
write_data.in_section = 0;
|
1443
|
-
write_data.preg_replaced = 0;
|
1444
1131
|
write_data.orig_name = orig_name;
|
1445
1132
|
write_data.name = name;
|
1446
1133
|
write_data.preg = preg;
|
1447
1134
|
write_data.value = value;
|
1448
1135
|
|
1449
|
-
|
1450
|
-
|
1451
|
-
write_on_variable,
|
1452
|
-
write_on_comment,
|
1453
|
-
write_on_eof,
|
1454
|
-
&write_data);
|
1455
|
-
git__free(section);
|
1456
|
-
git__free(orig_section);
|
1457
|
-
git_buf_free(&write_data.buffered_comment);
|
1458
|
-
|
1459
|
-
if (result < 0) {
|
1460
|
-
git_filebuf_cleanup(&file);
|
1136
|
+
if ((error = git_config_parse(&parser, write_on_section, write_on_variable,
|
1137
|
+
write_on_comment, write_on_eof, &write_data)) < 0)
|
1461
1138
|
goto done;
|
1462
|
-
}
|
1463
1139
|
|
1464
1140
|
if (cfg->locked) {
|
1465
1141
|
size_t len = buf.asize;
|
1466
1142
|
/* Update our copy with the modified contents */
|
1467
|
-
|
1143
|
+
git_buf_dispose(&cfg->locked_content);
|
1468
1144
|
git_buf_attach(&cfg->locked_content, git_buf_detach(&buf), len);
|
1469
1145
|
} else {
|
1470
1146
|
git_filebuf_write(&file, git_buf_cstr(&buf), git_buf_len(&buf));
|
1471
|
-
|
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;
|
1472
1153
|
}
|
1473
1154
|
|
1474
1155
|
done:
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1156
|
+
git__free(section);
|
1157
|
+
git__free(orig_section);
|
1158
|
+
git_buf_dispose(&write_data.buffered_comment);
|
1159
|
+
git_buf_dispose(&buf);
|
1160
|
+
git_buf_dispose(&contents);
|
1161
|
+
git_filebuf_cleanup(&file);
|
1162
|
+
git_config_parser_dispose(&parser);
|
1163
|
+
|
1164
|
+
return error;
|
1479
1165
|
}
|