rugged 0.28.4 → 0.28.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +0 -1
- data/vendor/libgit2/CMakeLists.txt +16 -36
- data/vendor/libgit2/COPYING +0 -28
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +1 -5
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +0 -6
- data/vendor/libgit2/deps/http-parser/http_parser.c +6 -11
- data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/regex/config.h +7 -0
- data/vendor/libgit2/deps/regex/regcomp.c +3857 -0
- data/vendor/libgit2/deps/regex/regex.c +92 -0
- data/vendor/libgit2/deps/regex/regex.h +582 -0
- data/vendor/libgit2/deps/regex/regex_internal.c +1744 -0
- data/vendor/libgit2/deps/regex/regex_internal.h +819 -0
- data/vendor/libgit2/deps/regex/regexec.c +4369 -0
- data/vendor/libgit2/deps/zlib/adler32.c +7 -0
- data/vendor/libgit2/deps/zlib/crc32.c +7 -0
- data/vendor/libgit2/include/git2.h +0 -2
- data/vendor/libgit2/include/git2/apply.h +2 -22
- data/vendor/libgit2/include/git2/attr.h +12 -19
- data/vendor/libgit2/include/git2/blame.h +2 -2
- data/vendor/libgit2/include/git2/blob.h +12 -44
- data/vendor/libgit2/include/git2/buffer.h +14 -20
- data/vendor/libgit2/include/git2/checkout.h +14 -46
- data/vendor/libgit2/include/git2/cherrypick.h +3 -3
- data/vendor/libgit2/include/git2/clone.h +2 -2
- data/vendor/libgit2/include/git2/commit.h +1 -23
- data/vendor/libgit2/include/git2/common.h +5 -7
- data/vendor/libgit2/include/git2/config.h +12 -12
- data/vendor/libgit2/include/git2/deprecated.h +3 -243
- data/vendor/libgit2/include/git2/describe.h +4 -4
- data/vendor/libgit2/include/git2/diff.h +14 -16
- data/vendor/libgit2/include/git2/filter.h +0 -8
- data/vendor/libgit2/include/git2/index.h +1 -2
- data/vendor/libgit2/include/git2/indexer.h +4 -48
- data/vendor/libgit2/include/git2/inttypes.h +309 -0
- data/vendor/libgit2/include/git2/merge.h +10 -6
- data/vendor/libgit2/include/git2/net.h +5 -0
- data/vendor/libgit2/include/git2/object.h +14 -2
- data/vendor/libgit2/include/git2/odb.h +2 -3
- data/vendor/libgit2/include/git2/odb_backend.h +4 -5
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +1 -12
- data/vendor/libgit2/include/git2/proxy.h +3 -5
- data/vendor/libgit2/include/git2/rebase.h +2 -46
- data/vendor/libgit2/include/git2/refs.h +0 -19
- data/vendor/libgit2/include/git2/remote.h +12 -35
- data/vendor/libgit2/include/git2/repository.h +2 -24
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +3 -3
- data/vendor/libgit2/include/git2/status.h +16 -25
- data/vendor/libgit2/include/git2/submodule.h +3 -20
- data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
- data/vendor/libgit2/include/git2/sys/odb_backend.h +4 -48
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +21 -57
- data/vendor/libgit2/include/git2/sys/repository.h +1 -5
- data/vendor/libgit2/include/git2/sys/time.h +31 -0
- data/vendor/libgit2/include/git2/sys/transport.h +2 -2
- data/vendor/libgit2/include/git2/tag.h +2 -11
- data/vendor/libgit2/include/git2/trace.h +2 -2
- data/vendor/libgit2/include/git2/transport.h +340 -11
- data/vendor/libgit2/include/git2/tree.h +1 -1
- data/vendor/libgit2/include/git2/types.h +89 -4
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/include/git2/worktree.h +5 -5
- data/vendor/libgit2/libgit2.pc.in +13 -0
- data/vendor/libgit2/src/CMakeLists.txt +222 -88
- data/vendor/libgit2/src/alloc.c +14 -2
- data/vendor/libgit2/src/apply.c +30 -60
- data/vendor/libgit2/src/attr.c +64 -70
- data/vendor/libgit2/src/attr_file.c +96 -189
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +46 -44
- data/vendor/libgit2/src/attrcache.h +1 -2
- data/vendor/libgit2/src/blame.c +5 -17
- data/vendor/libgit2/src/blame.h +1 -1
- data/vendor/libgit2/src/blame_git.c +7 -21
- data/vendor/libgit2/src/blob.c +17 -81
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +5 -29
- data/vendor/libgit2/src/buffer.c +7 -14
- data/vendor/libgit2/src/cache.c +33 -26
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +0 -5
- data/vendor/libgit2/src/checkout.c +16 -26
- data/vendor/libgit2/src/cherrypick.c +3 -9
- data/vendor/libgit2/src/clone.c +7 -29
- data/vendor/libgit2/src/clone.h +0 -4
- data/vendor/libgit2/src/commit.c +21 -69
- data/vendor/libgit2/src/commit.h +0 -6
- data/vendor/libgit2/src/commit_list.c +76 -28
- data/vendor/libgit2/src/commit_list.h +2 -2
- data/vendor/libgit2/src/common.h +75 -3
- data/vendor/libgit2/src/config.c +40 -31
- data/vendor/libgit2/src/config.h +6 -7
- data/vendor/libgit2/src/config_backend.h +0 -12
- data/vendor/libgit2/src/config_cache.c +39 -39
- data/vendor/libgit2/src/config_entries.c +99 -69
- data/vendor/libgit2/src/config_entries.h +0 -1
- data/vendor/libgit2/src/config_file.c +380 -337
- data/vendor/libgit2/src/config_mem.c +16 -12
- data/vendor/libgit2/src/config_parse.c +29 -49
- data/vendor/libgit2/src/config_parse.h +12 -13
- data/vendor/libgit2/src/crlf.c +14 -14
- data/vendor/libgit2/src/describe.c +20 -21
- data/vendor/libgit2/src/diff.c +58 -43
- data/vendor/libgit2/src/diff.h +1 -2
- data/vendor/libgit2/src/diff_driver.c +38 -37
- data/vendor/libgit2/src/diff_file.c +7 -9
- data/vendor/libgit2/src/diff_file.h +1 -1
- data/vendor/libgit2/src/diff_generate.c +85 -135
- data/vendor/libgit2/src/diff_generate.h +2 -2
- data/vendor/libgit2/src/diff_parse.c +1 -1
- data/vendor/libgit2/src/diff_print.c +13 -25
- data/vendor/libgit2/src/diff_stats.c +1 -1
- data/vendor/libgit2/src/diff_tform.c +4 -4
- data/vendor/libgit2/src/errors.c +22 -12
- data/vendor/libgit2/src/features.h.in +2 -9
- data/vendor/libgit2/src/fetch.c +2 -7
- data/vendor/libgit2/src/fetchhead.c +1 -1
- data/vendor/libgit2/src/filebuf.c +10 -6
- data/vendor/libgit2/src/filebuf.h +2 -2
- data/vendor/libgit2/src/{futils.c → fileops.c} +17 -21
- data/vendor/libgit2/src/{futils.h → fileops.h} +5 -5
- data/vendor/libgit2/src/filter.c +8 -16
- data/vendor/libgit2/src/fnmatch.c +248 -0
- data/vendor/libgit2/src/fnmatch.h +48 -0
- data/vendor/libgit2/src/global.c +40 -12
- data/vendor/libgit2/src/global.h +2 -0
- data/vendor/libgit2/src/hash.c +0 -61
- data/vendor/libgit2/src/hash.h +21 -19
- data/vendor/libgit2/src/hash/{sha1/collisiondetect.c → hash_collisiondetect.h} +17 -14
- data/vendor/libgit2/src/hash/{sha1/common_crypto.c → hash_common_crypto.h} +19 -15
- data/vendor/libgit2/src/hash/{sha1/generic.c → hash_generic.c} +10 -22
- data/vendor/libgit2/src/hash/{sha1/generic.h → hash_generic.h} +14 -4
- data/vendor/libgit2/src/hash/{sha1/mbedtls.c → hash_mbedtls.c} +7 -15
- data/vendor/libgit2/src/hash/{sha1/mbedtls.h → hash_mbedtls.h} +11 -6
- data/vendor/libgit2/src/hash/{sha1/openssl.c → hash_openssl.h} +18 -14
- data/vendor/libgit2/src/hash/{sha1/win32.c → hash_win32.c} +24 -34
- data/vendor/libgit2/src/hash/{sha1/win32.h → hash_win32.h} +19 -6
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.c +3 -14
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.h +0 -0
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.c +0 -0
- data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.h +0 -0
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/idxmap.c +65 -91
- data/vendor/libgit2/src/idxmap.h +15 -151
- data/vendor/libgit2/src/ignore.c +38 -32
- data/vendor/libgit2/src/index.c +43 -66
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +70 -69
- data/vendor/libgit2/src/integer.h +4 -39
- data/vendor/libgit2/src/iterator.c +22 -27
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +44 -58
- data/vendor/libgit2/src/merge_driver.c +4 -4
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +23 -18
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/netops.c +165 -55
- data/vendor/libgit2/src/netops.h +25 -3
- data/vendor/libgit2/src/notes.c +2 -2
- data/vendor/libgit2/src/object.c +2 -2
- data/vendor/libgit2/src/object.h +0 -2
- data/vendor/libgit2/src/odb.c +23 -41
- data/vendor/libgit2/src/odb.h +2 -3
- data/vendor/libgit2/src/odb_loose.c +10 -17
- data/vendor/libgit2/src/odb_mempack.c +23 -10
- data/vendor/libgit2/src/odb_pack.c +4 -4
- data/vendor/libgit2/src/offmap.c +55 -43
- data/vendor/libgit2/src/offmap.h +24 -102
- data/vendor/libgit2/src/oid.c +1 -6
- data/vendor/libgit2/src/oidmap.c +57 -39
- data/vendor/libgit2/src/oidmap.h +19 -99
- data/vendor/libgit2/src/pack-objects.c +32 -25
- data/vendor/libgit2/src/pack-objects.h +1 -1
- data/vendor/libgit2/src/pack.c +47 -45
- data/vendor/libgit2/src/pack.h +14 -12
- data/vendor/libgit2/src/parse.c +0 -10
- data/vendor/libgit2/src/parse.h +3 -3
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +31 -124
- data/vendor/libgit2/src/path.c +6 -43
- data/vendor/libgit2/src/path.h +0 -2
- data/vendor/libgit2/src/pathspec.c +13 -13
- data/vendor/libgit2/src/pool.c +22 -26
- data/vendor/libgit2/src/pool.h +7 -7
- data/vendor/libgit2/src/posix.c +7 -7
- data/vendor/libgit2/src/posix.h +1 -12
- data/vendor/libgit2/src/proxy.c +2 -7
- data/vendor/libgit2/src/push.c +5 -10
- data/vendor/libgit2/src/reader.c +2 -2
- data/vendor/libgit2/src/rebase.c +7 -66
- data/vendor/libgit2/src/refdb.c +0 -12
- data/vendor/libgit2/src/refdb_fs.c +165 -214
- data/vendor/libgit2/src/reflog.c +13 -11
- data/vendor/libgit2/src/refs.c +18 -24
- data/vendor/libgit2/src/refspec.c +16 -9
- data/vendor/libgit2/src/remote.c +52 -50
- data/vendor/libgit2/src/remote.h +2 -2
- data/vendor/libgit2/src/repository.c +100 -115
- data/vendor/libgit2/src/repository.h +40 -49
- data/vendor/libgit2/src/revert.c +3 -8
- data/vendor/libgit2/src/revparse.c +19 -18
- data/vendor/libgit2/src/revwalk.c +30 -63
- data/vendor/libgit2/src/revwalk.h +0 -20
- data/vendor/libgit2/src/settings.c +0 -5
- data/vendor/libgit2/src/sortedcache.c +26 -12
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +65 -45
- data/vendor/libgit2/src/status.c +9 -15
- data/vendor/libgit2/src/{allocators/stdalloc.c → stdalloc.c} +4 -3
- data/vendor/libgit2/src/{allocators/stdalloc.h → stdalloc.h} +4 -4
- data/vendor/libgit2/src/streams/openssl.c +0 -20
- data/vendor/libgit2/src/streams/socket.c +2 -2
- data/vendor/libgit2/src/strmap.c +84 -37
- data/vendor/libgit2/src/strmap.h +33 -105
- data/vendor/libgit2/src/submodule.c +70 -102
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +1 -11
- data/vendor/libgit2/src/tag.c +2 -10
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +2 -2
- data/vendor/libgit2/src/trailer.c +32 -46
- data/vendor/libgit2/src/transaction.c +9 -10
- data/vendor/libgit2/src/transports/auth.c +9 -10
- data/vendor/libgit2/src/transports/auth.h +4 -11
- data/vendor/libgit2/src/transports/auth_negotiate.c +9 -23
- data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
- data/vendor/libgit2/src/transports/cred.c +6 -6
- data/vendor/libgit2/src/{allocators/win32_crtdbg.h → transports/cred.h} +4 -5
- data/vendor/libgit2/src/transports/git.c +16 -11
- data/vendor/libgit2/src/transports/http.c +276 -419
- data/vendor/libgit2/src/transports/http.h +1 -1
- data/vendor/libgit2/src/transports/local.c +9 -9
- data/vendor/libgit2/src/transports/smart.c +17 -17
- data/vendor/libgit2/src/transports/smart.h +2 -2
- data/vendor/libgit2/src/transports/smart_protocol.c +60 -36
- data/vendor/libgit2/src/transports/ssh.c +36 -46
- data/vendor/libgit2/src/transports/winhttp.c +207 -231
- data/vendor/libgit2/src/tree-cache.c +7 -14
- data/vendor/libgit2/src/tree.c +24 -10
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +11 -1
- data/vendor/libgit2/src/userdiff.h +1 -3
- data/vendor/libgit2/src/util.c +53 -51
- data/vendor/libgit2/src/util.h +21 -16
- data/vendor/libgit2/src/win32/map.c +5 -3
- data/vendor/libgit2/src/win32/path_w32.c +2 -12
- data/vendor/libgit2/src/win32/path_w32.h +29 -0
- data/vendor/libgit2/src/win32/posix.h +4 -1
- data/vendor/libgit2/src/win32/posix_w32.c +5 -40
- data/vendor/libgit2/src/win32/precompiled.h +2 -0
- data/vendor/libgit2/src/win32/thread.c +10 -5
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -7
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +93 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +2 -0
- data/vendor/libgit2/src/win32/w32_stack.c +9 -4
- data/vendor/libgit2/src/win32/w32_stack.h +3 -3
- data/vendor/libgit2/src/win32/w32_util.c +0 -31
- data/vendor/libgit2/src/win32/w32_util.h +32 -6
- data/vendor/libgit2/src/worktree.c +22 -36
- data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +0 -12
- data/vendor/libgit2/src/xdiff/xpatience.c +0 -3
- metadata +34 -98
- data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +0 -28
- data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +0 -38
- data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +0 -37
- data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +0 -110
- data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +0 -53
- data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +0 -124
- data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +0 -66
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +0 -21
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -33
- data/vendor/libgit2/deps/ntlmclient/crypt.h +0 -64
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +0 -120
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +0 -18
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -145
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +0 -18
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +0 -130
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +0 -21
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +0 -1420
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +0 -174
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +0 -320
- data/vendor/libgit2/deps/ntlmclient/unicode.h +0 -36
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +0 -445
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +0 -201
- data/vendor/libgit2/deps/ntlmclient/utf8.h +0 -1257
- data/vendor/libgit2/deps/ntlmclient/util.c +0 -21
- data/vendor/libgit2/deps/ntlmclient/util.h +0 -14
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
- data/vendor/libgit2/deps/pcre/COPYING +0 -5
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
- data/vendor/libgit2/deps/pcre/config.h.in +0 -57
- data/vendor/libgit2/deps/pcre/pcre.h +0 -641
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
- data/vendor/libgit2/deps/pcre/pcre_chartables.c +0 -198
- data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9800
- data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
- data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +0 -3676
- data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
- data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
- data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
- data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
- data/vendor/libgit2/deps/pcre/pcre_newline.c +0 -210
- data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +0 -94
- data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
- data/vendor/libgit2/deps/pcre/pcre_refcount.c +0 -92
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
- data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
- data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
- data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
- data/vendor/libgit2/deps/pcre/pcreposix.c +0 -421
- data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
- data/vendor/libgit2/deps/pcre/ucp.h +0 -224
- data/vendor/libgit2/include/git2/cert.h +0 -135
- data/vendor/libgit2/include/git2/cred.h +0 -308
- data/vendor/libgit2/include/git2/sys/cred.h +0 -90
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/config_snapshot.c +0 -206
- data/vendor/libgit2/src/errors.h +0 -81
- data/vendor/libgit2/src/hash/sha1.h +0 -38
- data/vendor/libgit2/src/hash/sha1/collisiondetect.h +0 -19
- data/vendor/libgit2/src/hash/sha1/common_crypto.h +0 -19
- data/vendor/libgit2/src/hash/sha1/openssl.h +0 -19
- data/vendor/libgit2/src/net.c +0 -184
- data/vendor/libgit2/src/net.h +0 -36
- data/vendor/libgit2/src/regexp.c +0 -221
- data/vendor/libgit2/src/regexp.h +0 -97
- data/vendor/libgit2/src/transports/auth_ntlm.c +0 -223
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -35
- data/vendor/libgit2/src/wildmatch.c +0 -320
- data/vendor/libgit2/src/wildmatch.h +0 -23
- 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 "
|
|
19
|
-
|
|
20
|
-
#include
|
|
21
|
-
#include
|
|
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
|
-
}
|
|
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
|
-
|
|
58
|
+
const char *file_path;
|
|
52
59
|
git_config_entries *entries;
|
|
53
60
|
git_config_level_t level;
|
|
54
61
|
unsigned int depth;
|
|
55
|
-
}
|
|
62
|
+
} diskfile_parse_state;
|
|
56
63
|
|
|
57
|
-
static int
|
|
58
|
-
static int
|
|
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
|
|
81
|
+
static git_config_entries *diskfile_entries_take(diskfile_header *h)
|
|
68
82
|
{
|
|
69
|
-
|
|
83
|
+
git_config_entries *entries;
|
|
70
84
|
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
90
|
+
entries = h->entries;
|
|
91
|
+
git_config_entries_incref(entries);
|
|
78
92
|
|
|
79
|
-
git_mutex_unlock(&
|
|
93
|
+
git_mutex_unlock(&h->values_mutex);
|
|
80
94
|
|
|
81
|
-
return
|
|
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
|
|
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 =
|
|
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
|
|
136
|
+
static int config_is_modified(int *modified, struct config_file *file)
|
|
123
137
|
{
|
|
124
|
-
|
|
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 =
|
|
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
|
|
168
|
+
static int config_refresh(git_config_backend *cfg)
|
|
159
169
|
{
|
|
160
|
-
|
|
161
|
-
git_config_entries *
|
|
162
|
-
|
|
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
|
-
|
|
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
|
-
|
|
176
|
-
|
|
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
|
-
|
|
186
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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 (
|
|
215
|
-
|
|
195
|
+
if ((error = config_read(entries, b->header.repo, &b->file, b->header.level, 0)) < 0)
|
|
196
|
+
goto out;
|
|
216
197
|
|
|
217
|
-
if ((error =
|
|
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
|
-
|
|
221
|
-
|
|
203
|
+
tmp = b->header.entries;
|
|
204
|
+
b->header.entries = entries;
|
|
205
|
+
entries = tmp;
|
|
222
206
|
|
|
223
|
-
|
|
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
|
|
215
|
+
static void backend_free(git_config_backend *_backend)
|
|
236
216
|
{
|
|
237
|
-
|
|
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
|
|
228
|
+
static int config_iterator_new(
|
|
249
229
|
git_config_iterator **iter,
|
|
250
|
-
struct git_config_backend
|
|
230
|
+
struct git_config_backend* backend)
|
|
251
231
|
{
|
|
252
|
-
|
|
253
|
-
git_config_entries *
|
|
232
|
+
diskfile_header *bh = (diskfile_header *) backend;
|
|
233
|
+
git_config_entries *entries;
|
|
254
234
|
int error;
|
|
255
235
|
|
|
256
|
-
if ((error =
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
|
248
|
+
static int config_set(git_config_backend *cfg, const char *name, const char *value)
|
|
270
249
|
{
|
|
271
|
-
|
|
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 ((
|
|
286
|
-
return
|
|
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 =
|
|
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
|
|
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
|
|
302
|
+
static int config_get(git_config_backend *cfg, const char *key, git_config_entry **out)
|
|
327
303
|
{
|
|
328
|
-
|
|
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 =
|
|
309
|
+
if (!h->parent.readonly && ((error = config_refresh(cfg)) < 0))
|
|
334
310
|
return error;
|
|
335
311
|
|
|
336
|
-
if ((
|
|
337
|
-
return
|
|
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 =
|
|
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
|
|
327
|
+
static int config_set_multivar(
|
|
352
328
|
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
|
|
353
329
|
{
|
|
354
|
-
|
|
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
|
-
|
|
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
|
|
368
|
-
if ((result =
|
|
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
|
-
|
|
355
|
+
regfree(&preg);
|
|
374
356
|
|
|
375
357
|
return result;
|
|
376
358
|
}
|
|
377
359
|
|
|
378
|
-
static int
|
|
360
|
+
static int config_delete(git_config_backend *cfg, const char *name)
|
|
379
361
|
{
|
|
380
|
-
|
|
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 ((
|
|
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 =
|
|
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
|
|
393
|
+
static int config_delete_multivar(git_config_backend *cfg, const char *name, const char *regexp)
|
|
409
394
|
{
|
|
410
|
-
|
|
395
|
+
diskfile_backend *b = (diskfile_backend *)cfg;
|
|
411
396
|
git_config_entries *entries = NULL;
|
|
412
397
|
git_config_entry *entry = NULL;
|
|
413
|
-
|
|
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 ((
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
431
|
+
regfree(&preg);
|
|
439
432
|
return result;
|
|
440
433
|
}
|
|
441
434
|
|
|
442
|
-
static int
|
|
435
|
+
static int config_lock(git_config_backend *_cfg)
|
|
443
436
|
{
|
|
444
|
-
|
|
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
|
|
454
|
+
static int config_unlock(git_config_backend *_cfg, int success)
|
|
462
455
|
{
|
|
463
|
-
|
|
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
|
-
|
|
473
|
+
diskfile_backend *backend;
|
|
481
474
|
|
|
482
|
-
backend = git__calloc(1, sizeof(
|
|
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 =
|
|
493
|
-
backend->parent.get =
|
|
494
|
-
backend->parent.set =
|
|
495
|
-
backend->parent.set_multivar =
|
|
496
|
-
backend->parent.del =
|
|
497
|
-
backend->parent.del_multivar =
|
|
498
|
-
backend->parent.iterator =
|
|
499
|
-
backend->parent.snapshot =
|
|
500
|
-
backend->parent.lock =
|
|
501
|
-
backend->parent.unlock =
|
|
502
|
-
backend->parent.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(
|
|
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,
|
|
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(
|
|
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 =
|
|
577
|
-
|
|
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 *
|
|
701
|
+
const char *value,
|
|
592
702
|
bool case_insensitive)
|
|
593
703
|
{
|
|
594
|
-
git_buf
|
|
595
|
-
int error;
|
|
596
|
-
|
|
597
|
-
if (
|
|
598
|
-
git_path_dirname_r(&
|
|
599
|
-
git_buf_joinpath(&
|
|
600
|
-
} else if (
|
|
601
|
-
git_sysdir_expand_global_file(&
|
|
602
|
-
else if (!git_path_is_absolute(
|
|
603
|
-
git_buf_joinpath(&
|
|
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(&
|
|
715
|
+
git_buf_sets(&path, value);
|
|
606
716
|
|
|
607
|
-
if (
|
|
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 ((
|
|
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
|
-
|
|
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(&
|
|
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(
|
|
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->
|
|
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
|
-
|
|
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(
|
|
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
|
|
854
|
+
static int config_read(
|
|
796
855
|
git_config_entries *entries,
|
|
797
856
|
const git_repository *repo,
|
|
798
|
-
|
|
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
|
-
|
|
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.
|
|
815
|
-
git_parse_ctx_init(&reader.ctx,
|
|
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.
|
|
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
|
|
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 = (
|
|
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
|
|
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
|
-
|
|
1094
|
-
|
|
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(&
|
|
1132
|
+
memset(&reader, 0, sizeof(reader));
|
|
1133
|
+
reader.file = &cfg->file;
|
|
1101
1134
|
|
|
1102
1135
|
if (cfg->locked) {
|
|
1103
|
-
|
|
1136
|
+
result = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content) == NULL ? "" : git_buf_cstr(&cfg->locked_content));
|
|
1104
1137
|
} else {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
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
|
-
|
|
1146
|
+
result = git_futils_readbuffer(&contents, cfg->file.path);
|
|
1111
1147
|
}
|
|
1112
|
-
if (error < 0 && error != GIT_ENOTFOUND)
|
|
1113
|
-
goto done;
|
|
1114
1148
|
|
|
1115
|
-
|
|
1116
|
-
|
|
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
|
-
|
|
1137
|
-
|
|
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
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
return error;
|
|
1206
|
+
git_parse_ctx_clear(&reader.ctx);
|
|
1207
|
+
return result;
|
|
1165
1208
|
}
|