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
data/vendor/libgit2/src/commit.h
CHANGED
@@ -35,5 +35,12 @@ struct git_commit {
|
|
35
35
|
|
36
36
|
void git_commit__free(void *commit);
|
37
37
|
int git_commit__parse(void *commit, git_odb_object *obj);
|
38
|
+
int git_commit__parse_raw(void *commit, const char *data, size_t size);
|
39
|
+
|
40
|
+
typedef enum {
|
41
|
+
GIT_COMMIT_PARSE_QUICK = (1 << 0), /**< Only parse parents and committer info */
|
42
|
+
} git_commit__parse_flags;
|
43
|
+
|
44
|
+
int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned int flags);
|
38
45
|
|
39
46
|
#endif
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include "revwalk.h"
|
11
11
|
#include "pool.h"
|
12
12
|
#include "odb.h"
|
13
|
+
#include "commit.h"
|
13
14
|
|
14
15
|
int git_commit_list_time_cmp(const void *a, const void *b)
|
15
16
|
{
|
@@ -55,17 +56,6 @@ git_commit_list_node *git_commit_list_alloc_node(git_revwalk *walk)
|
|
55
56
|
return (git_commit_list_node *)git_pool_mallocz(&walk->commit_pool, 1);
|
56
57
|
}
|
57
58
|
|
58
|
-
static int commit_error(git_commit_list_node *commit, const char *msg)
|
59
|
-
{
|
60
|
-
char commit_oid[GIT_OID_HEXSZ + 1];
|
61
|
-
git_oid_fmt(commit_oid, &commit->oid);
|
62
|
-
commit_oid[GIT_OID_HEXSZ] = '\0';
|
63
|
-
|
64
|
-
giterr_set(GITERR_ODB, "failed to parse commit %s - %s", commit_oid, msg);
|
65
|
-
|
66
|
-
return -1;
|
67
|
-
}
|
68
|
-
|
69
59
|
static git_commit_list_node **alloc_parents(
|
70
60
|
git_revwalk *walk, git_commit_list_node *commit, size_t n_parents)
|
71
61
|
{
|
@@ -111,77 +101,42 @@ git_commit_list_node *git_commit_list_pop(git_commit_list **stack)
|
|
111
101
|
|
112
102
|
static int commit_quick_parse(
|
113
103
|
git_revwalk *walk,
|
114
|
-
git_commit_list_node *
|
115
|
-
|
116
|
-
size_t buffer_len)
|
104
|
+
git_commit_list_node *node,
|
105
|
+
git_odb_object *obj)
|
117
106
|
{
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
int64_t commit_time;
|
123
|
-
|
124
|
-
buffer += strlen("tree ") + GIT_OID_HEXSZ + 1;
|
125
|
-
|
126
|
-
parents_start = buffer;
|
127
|
-
while (buffer + parent_len < buffer_end && memcmp(buffer, "parent ", strlen("parent ")) == 0) {
|
128
|
-
parents++;
|
129
|
-
buffer += parent_len;
|
130
|
-
}
|
131
|
-
|
132
|
-
commit->parents = alloc_parents(walk, commit, parents);
|
133
|
-
GITERR_CHECK_ALLOC(commit->parents);
|
134
|
-
|
135
|
-
buffer = parents_start;
|
136
|
-
for (i = 0; i < parents; ++i) {
|
137
|
-
git_oid oid;
|
138
|
-
|
139
|
-
if (git_oid_fromstr(&oid, (const char *)buffer + strlen("parent ")) < 0)
|
140
|
-
return -1;
|
107
|
+
git_oid *parent_oid;
|
108
|
+
git_commit *commit;
|
109
|
+
int error;
|
110
|
+
size_t i;
|
141
111
|
|
142
|
-
|
143
|
-
|
144
|
-
|
112
|
+
commit = git__calloc(1, sizeof(*commit));
|
113
|
+
GIT_ERROR_CHECK_ALLOC(commit);
|
114
|
+
commit->object.repo = walk->repo;
|
145
115
|
|
146
|
-
|
116
|
+
if ((error = git_commit__parse_ext(commit, obj, GIT_COMMIT_PARSE_QUICK)) < 0) {
|
117
|
+
git__free(commit);
|
118
|
+
return error;
|
147
119
|
}
|
148
120
|
|
149
|
-
commit->
|
150
|
-
|
151
|
-
|
152
|
-
return
|
153
|
-
|
154
|
-
buffer++;
|
155
|
-
|
156
|
-
if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
|
157
|
-
return commit_error(commit, "object is corrupted");
|
158
|
-
|
159
|
-
/* Skip trailing spaces */
|
160
|
-
while (buffer > committer_start && git__isspace(*buffer))
|
161
|
-
buffer--;
|
162
|
-
|
163
|
-
/* Seek for the beginning of the pack of digits */
|
164
|
-
while (buffer > committer_start && git__isdigit(*buffer))
|
165
|
-
buffer--;
|
166
|
-
|
167
|
-
/* Skip potential timezone offset */
|
168
|
-
if ((buffer > committer_start) && (*buffer == '+' || *buffer == '-')) {
|
169
|
-
buffer--;
|
121
|
+
if (!git__is_uint16(git_array_size(commit->parent_ids))) {
|
122
|
+
git__free(commit);
|
123
|
+
git_error_set(GIT_ERROR_INVALID, "commit has more than 2^16 parents");
|
124
|
+
return -1;
|
125
|
+
}
|
170
126
|
|
171
|
-
|
172
|
-
|
127
|
+
node->time = commit->committer->when.time;
|
128
|
+
node->out_degree = (uint16_t) git_array_size(commit->parent_ids);
|
129
|
+
node->parents = alloc_parents(walk, node, node->out_degree);
|
130
|
+
GIT_ERROR_CHECK_ALLOC(node->parents);
|
173
131
|
|
174
|
-
|
175
|
-
|
132
|
+
git_array_foreach(commit->parent_ids, i, parent_oid) {
|
133
|
+
node->parents[i] = git_revwalk__commit_lookup(walk, parent_oid);
|
176
134
|
}
|
177
135
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
return commit_error(commit, "cannot parse commit time");
|
136
|
+
git_commit__free(commit);
|
137
|
+
|
138
|
+
node->parsed = 1;
|
182
139
|
|
183
|
-
commit->time = commit_time;
|
184
|
-
commit->parsed = 1;
|
185
140
|
return 0;
|
186
141
|
}
|
187
142
|
|
@@ -196,14 +151,11 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit)
|
|
196
151
|
if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0)
|
197
152
|
return error;
|
198
153
|
|
199
|
-
if (obj->cached.type !=
|
200
|
-
|
154
|
+
if (obj->cached.type != GIT_OBJECT_COMMIT) {
|
155
|
+
git_error_set(GIT_ERROR_INVALID, "object is no commit object");
|
201
156
|
error = -1;
|
202
157
|
} else
|
203
|
-
error = commit_quick_parse(
|
204
|
-
walk, commit,
|
205
|
-
(const uint8_t *)git_odb_object_data(obj),
|
206
|
-
git_odb_object_size(obj));
|
158
|
+
error = commit_quick_parse(walk, commit, obj);
|
207
159
|
|
208
160
|
git_odb_object_free(obj);
|
209
161
|
return error;
|
data/vendor/libgit2/src/common.h
CHANGED
@@ -17,8 +17,10 @@
|
|
17
17
|
/** Declare a function as always inlined. */
|
18
18
|
#if defined(_MSC_VER)
|
19
19
|
# define GIT_INLINE(type) static __inline type
|
20
|
+
#elif defined(__GNUC__)
|
21
|
+
# define GIT_INLINE(type) static __inline__ type
|
20
22
|
#else
|
21
|
-
# define GIT_INLINE(type) static
|
23
|
+
# define GIT_INLINE(type) static type
|
22
24
|
#endif
|
23
25
|
|
24
26
|
/** Support for gcc/clang __has_builtin intrinsic */
|
@@ -45,6 +47,7 @@
|
|
45
47
|
# include <ws2tcpip.h>
|
46
48
|
# include "win32/msvc-compat.h"
|
47
49
|
# include "win32/mingw-compat.h"
|
50
|
+
# include "win32/w32_common.h"
|
48
51
|
# include "win32/win32-compat.h"
|
49
52
|
# include "win32/error.h"
|
50
53
|
# include "win32/version.h"
|
@@ -74,10 +77,17 @@
|
|
74
77
|
|
75
78
|
#include "git2/types.h"
|
76
79
|
#include "git2/errors.h"
|
80
|
+
#include "errors.h"
|
77
81
|
#include "thread-utils.h"
|
78
82
|
#include "integer.h"
|
79
83
|
|
80
|
-
|
84
|
+
/*
|
85
|
+
* Include the declarations for deprecated functions; this ensures
|
86
|
+
* that they're decorated with the proper extern/visibility attributes.
|
87
|
+
*/
|
88
|
+
#include "git2/deprecated.h"
|
89
|
+
|
90
|
+
#include "posix.h"
|
81
91
|
|
82
92
|
#define DEFAULT_BUFSIZE 65536
|
83
93
|
#define FILEIO_BUFSIZE DEFAULT_BUFSIZE
|
@@ -87,97 +97,23 @@
|
|
87
97
|
/**
|
88
98
|
* Check a pointer allocation result, returning -1 if it failed.
|
89
99
|
*/
|
90
|
-
#define
|
100
|
+
#define GIT_ERROR_CHECK_ALLOC(ptr) if (ptr == NULL) { return -1; }
|
91
101
|
|
92
102
|
/**
|
93
103
|
* Check a buffer allocation result, returning -1 if it failed.
|
94
104
|
*/
|
95
|
-
#define
|
105
|
+
#define GIT_ERROR_CHECK_ALLOC_BUF(buf) if ((void *)(buf) == NULL || git_buf_oom(buf)) { return -1; }
|
96
106
|
|
97
107
|
/**
|
98
108
|
* Check a return value and propagate result if non-zero.
|
99
109
|
*/
|
100
|
-
#define
|
110
|
+
#define GIT_ERROR_CHECK_ERROR(code) \
|
101
111
|
do { int _err = (code); if (_err) return _err; } while (0)
|
102
112
|
|
103
|
-
/**
|
104
|
-
* Set the error message for this thread, formatting as needed.
|
105
|
-
*/
|
106
|
-
|
107
|
-
void giterr_set(int error_class, const char *string, ...) GIT_FORMAT_PRINTF(2, 3);
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Set the error message for a regex failure, using the internal regex
|
111
|
-
* error code lookup and return a libgit error code.
|
112
|
-
*/
|
113
|
-
int giterr_set_regex(const regex_t *regex, int error_code);
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Set error message for user callback if needed.
|
117
|
-
*
|
118
|
-
* If the error code in non-zero and no error message is set, this
|
119
|
-
* sets a generic error message.
|
120
|
-
*
|
121
|
-
* @return This always returns the `error_code` parameter.
|
122
|
-
*/
|
123
|
-
GIT_INLINE(int) giterr_set_after_callback_function(
|
124
|
-
int error_code, const char *action)
|
125
|
-
{
|
126
|
-
if (error_code) {
|
127
|
-
const git_error *e = giterr_last();
|
128
|
-
if (!e || !e->message)
|
129
|
-
giterr_set(e ? e->klass : GITERR_CALLBACK,
|
130
|
-
"%s callback returned %d", action, error_code);
|
131
|
-
}
|
132
|
-
return error_code;
|
133
|
-
}
|
134
|
-
|
135
|
-
#ifdef GIT_WIN32
|
136
|
-
#define giterr_set_after_callback(code) \
|
137
|
-
giterr_set_after_callback_function((code), __FUNCTION__)
|
138
|
-
#else
|
139
|
-
#define giterr_set_after_callback(code) \
|
140
|
-
giterr_set_after_callback_function((code), __func__)
|
141
|
-
#endif
|
142
|
-
|
143
|
-
/**
|
144
|
-
* Gets the system error code for this thread.
|
145
|
-
*/
|
146
|
-
int giterr_system_last(void);
|
147
|
-
|
148
|
-
/**
|
149
|
-
* Sets the system error code for this thread.
|
150
|
-
*/
|
151
|
-
void giterr_system_set(int code);
|
152
|
-
|
153
|
-
/**
|
154
|
-
* Structure to preserve libgit2 error state
|
155
|
-
*/
|
156
|
-
typedef struct {
|
157
|
-
int error_code;
|
158
|
-
unsigned int oom : 1;
|
159
|
-
git_error error_msg;
|
160
|
-
} git_error_state;
|
161
|
-
|
162
|
-
/**
|
163
|
-
* Capture current error state to restore later, returning error code.
|
164
|
-
* If `error_code` is zero, this does not clear the current error state.
|
165
|
-
* You must either restore this error state, or free it.
|
166
|
-
*/
|
167
|
-
extern int giterr_state_capture(git_error_state *state, int error_code);
|
168
|
-
|
169
|
-
/**
|
170
|
-
* Restore error state to a previous value, returning saved error code.
|
171
|
-
*/
|
172
|
-
extern int giterr_state_restore(git_error_state *state);
|
173
|
-
|
174
|
-
/** Free an error state. */
|
175
|
-
extern void giterr_state_free(git_error_state *state);
|
176
|
-
|
177
113
|
/**
|
178
114
|
* Check a versioned structure for validity
|
179
115
|
*/
|
180
|
-
GIT_INLINE(int)
|
116
|
+
GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int expected_max, const char *name)
|
181
117
|
{
|
182
118
|
unsigned int actual;
|
183
119
|
|
@@ -188,10 +124,10 @@ GIT_INLINE(int) giterr__check_version(const void *structure, unsigned int expect
|
|
188
124
|
if (actual > 0 && actual <= expected_max)
|
189
125
|
return 0;
|
190
126
|
|
191
|
-
|
127
|
+
git_error_set(GIT_ERROR_INVALID, "invalid version %d on %s", actual, name);
|
192
128
|
return -1;
|
193
129
|
}
|
194
|
-
#define
|
130
|
+
#define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
|
195
131
|
|
196
132
|
/**
|
197
133
|
* Initialize a structure with a version.
|
@@ -205,42 +141,42 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
|
|
205
141
|
|
206
142
|
#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \
|
207
143
|
TYPE _tmpl = TPL; \
|
208
|
-
|
144
|
+
GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \
|
209
145
|
memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0)
|
210
146
|
|
211
147
|
|
212
148
|
/** Check for additive overflow, setting an error if would occur. */
|
213
149
|
#define GIT_ADD_SIZET_OVERFLOW(out, one, two) \
|
214
|
-
(git__add_sizet_overflow(out, one, two) ? (
|
150
|
+
(git__add_sizet_overflow(out, one, two) ? (git_error_set_oom(), 1) : 0)
|
215
151
|
|
216
152
|
/** Check for additive overflow, setting an error if would occur. */
|
217
153
|
#define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \
|
218
|
-
(git__multiply_sizet_overflow(out, nelem, elsize) ? (
|
154
|
+
(git__multiply_sizet_overflow(out, nelem, elsize) ? (git_error_set_oom(), 1) : 0)
|
219
155
|
|
220
156
|
/** Check for additive overflow, failing if it would occur. */
|
221
|
-
#define
|
157
|
+
#define GIT_ERROR_CHECK_ALLOC_ADD(out, one, two) \
|
222
158
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; }
|
223
159
|
|
224
|
-
#define
|
160
|
+
#define GIT_ERROR_CHECK_ALLOC_ADD3(out, one, two, three) \
|
225
161
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
|
226
162
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; }
|
227
163
|
|
228
|
-
#define
|
164
|
+
#define GIT_ERROR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
|
229
165
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
|
230
166
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
|
231
167
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; }
|
232
168
|
|
233
|
-
#define
|
169
|
+
#define GIT_ERROR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \
|
234
170
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
|
235
171
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
|
236
172
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \
|
237
173
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; }
|
238
174
|
|
239
175
|
/** Check for multiplicative overflow, failing if it would occur. */
|
240
|
-
#define
|
176
|
+
#define GIT_ERROR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
|
241
177
|
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }
|
242
178
|
|
243
|
-
/* NOTE: other
|
179
|
+
/* NOTE: other git_error functions are in the public errors.h header file */
|
244
180
|
|
245
181
|
#include "util.h"
|
246
182
|
|
data/vendor/libgit2/src/config.c
CHANGED
@@ -7,13 +7,15 @@
|
|
7
7
|
|
8
8
|
#include "config.h"
|
9
9
|
|
10
|
-
#include "sysdir.h"
|
11
10
|
#include "git2/config.h"
|
12
11
|
#include "git2/sys/config.h"
|
13
|
-
|
12
|
+
|
14
13
|
#include "buf_text.h"
|
15
|
-
#include "
|
14
|
+
#include "config_backend.h"
|
15
|
+
#include "regexp.h"
|
16
|
+
#include "sysdir.h"
|
16
17
|
#include "transaction.h"
|
18
|
+
#include "vector.h"
|
17
19
|
#if GIT_WIN32
|
18
20
|
# include <windows.h>
|
19
21
|
#endif
|
@@ -31,30 +33,30 @@ void git_config_entry_free(git_config_entry *entry)
|
|
31
33
|
typedef struct {
|
32
34
|
git_refcount rc;
|
33
35
|
|
34
|
-
git_config_backend *
|
36
|
+
git_config_backend *backend;
|
35
37
|
git_config_level_t level;
|
36
|
-
}
|
38
|
+
} backend_internal;
|
37
39
|
|
38
|
-
static void
|
40
|
+
static void backend_internal_free(backend_internal *internal)
|
39
41
|
{
|
40
|
-
git_config_backend *
|
42
|
+
git_config_backend *backend;
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
backend = internal->backend;
|
45
|
+
backend->free(backend);
|
44
46
|
git__free(internal);
|
45
47
|
}
|
46
48
|
|
47
49
|
static void config_free(git_config *cfg)
|
48
50
|
{
|
49
51
|
size_t i;
|
50
|
-
|
52
|
+
backend_internal *internal;
|
51
53
|
|
52
|
-
for (i = 0; i < cfg->
|
53
|
-
internal = git_vector_get(&cfg->
|
54
|
-
GIT_REFCOUNT_DEC(internal,
|
54
|
+
for (i = 0; i < cfg->backends.length; ++i) {
|
55
|
+
internal = git_vector_get(&cfg->backends, i);
|
56
|
+
GIT_REFCOUNT_DEC(internal, backend_internal_free);
|
55
57
|
}
|
56
58
|
|
57
|
-
git_vector_free(&cfg->
|
59
|
+
git_vector_free(&cfg->backends);
|
58
60
|
|
59
61
|
git__memzero(cfg, sizeof(*cfg));
|
60
62
|
git__free(cfg);
|
@@ -70,8 +72,8 @@ void git_config_free(git_config *cfg)
|
|
70
72
|
|
71
73
|
static int config_backend_cmp(const void *a, const void *b)
|
72
74
|
{
|
73
|
-
const
|
74
|
-
const
|
75
|
+
const backend_internal *bk_a = (const backend_internal *)(a);
|
76
|
+
const backend_internal *bk_b = (const backend_internal *)(b);
|
75
77
|
|
76
78
|
return bk_b->level - bk_a->level;
|
77
79
|
}
|
@@ -81,11 +83,11 @@ int git_config_new(git_config **out)
|
|
81
83
|
git_config *cfg;
|
82
84
|
|
83
85
|
cfg = git__malloc(sizeof(git_config));
|
84
|
-
|
86
|
+
GIT_ERROR_CHECK_ALLOC(cfg);
|
85
87
|
|
86
88
|
memset(cfg, 0x0, sizeof(git_config));
|
87
89
|
|
88
|
-
if (git_vector_init(&cfg->
|
90
|
+
if (git_vector_init(&cfg->backends, 3, config_backend_cmp) < 0) {
|
89
91
|
git__free(cfg);
|
90
92
|
return -1;
|
91
93
|
}
|
@@ -110,11 +112,11 @@ int git_config_add_file_ondisk(
|
|
110
112
|
|
111
113
|
res = p_stat(path, &st);
|
112
114
|
if (res < 0 && errno != ENOENT && errno != ENOTDIR) {
|
113
|
-
|
115
|
+
git_error_set(GIT_ERROR_CONFIG, "failed to stat '%s'", path);
|
114
116
|
return -1;
|
115
117
|
}
|
116
118
|
|
117
|
-
if (
|
119
|
+
if (git_config_backend_from_file(&file, path) < 0)
|
118
120
|
return -1;
|
119
121
|
|
120
122
|
if ((res = git_config_add_backend(cfg, file, level, repo, force)) < 0) {
|
@@ -151,7 +153,7 @@ int git_config_snapshot(git_config **out, git_config *in)
|
|
151
153
|
{
|
152
154
|
int error = 0;
|
153
155
|
size_t i;
|
154
|
-
|
156
|
+
backend_internal *internal;
|
155
157
|
git_config *config;
|
156
158
|
|
157
159
|
*out = NULL;
|
@@ -159,10 +161,10 @@ int git_config_snapshot(git_config **out, git_config *in)
|
|
159
161
|
if (git_config_new(&config) < 0)
|
160
162
|
return -1;
|
161
163
|
|
162
|
-
git_vector_foreach(&in->
|
164
|
+
git_vector_foreach(&in->backends, i, internal) {
|
163
165
|
git_config_backend *b;
|
164
166
|
|
165
|
-
if ((error = internal->
|
167
|
+
if ((error = internal->backend->snapshot(&b, internal->backend)) < 0)
|
166
168
|
break;
|
167
169
|
|
168
170
|
if ((error = git_config_add_backend(config, b, internal->level, NULL, 0)) < 0) {
|
@@ -179,59 +181,59 @@ int git_config_snapshot(git_config **out, git_config *in)
|
|
179
181
|
return error;
|
180
182
|
}
|
181
183
|
|
182
|
-
static int
|
183
|
-
|
184
|
+
static int find_backend_by_level(
|
185
|
+
backend_internal **out,
|
184
186
|
const git_config *cfg,
|
185
187
|
git_config_level_t level)
|
186
188
|
{
|
187
189
|
int pos = -1;
|
188
|
-
|
190
|
+
backend_internal *internal;
|
189
191
|
size_t i;
|
190
192
|
|
191
|
-
/* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config
|
192
|
-
* which has the highest level. As config
|
193
|
-
* sorted by decreasing order of level, getting the
|
193
|
+
/* when passing GIT_CONFIG_HIGHEST_LEVEL, the idea is to get the config backend
|
194
|
+
* which has the highest level. As config backends are stored in a vector
|
195
|
+
* sorted by decreasing order of level, getting the backend at position 0
|
194
196
|
* will do the job.
|
195
197
|
*/
|
196
198
|
if (level == GIT_CONFIG_HIGHEST_LEVEL) {
|
197
199
|
pos = 0;
|
198
200
|
} else {
|
199
|
-
git_vector_foreach(&cfg->
|
201
|
+
git_vector_foreach(&cfg->backends, i, internal) {
|
200
202
|
if (internal->level == level)
|
201
203
|
pos = (int)i;
|
202
204
|
}
|
203
205
|
}
|
204
206
|
|
205
207
|
if (pos == -1) {
|
206
|
-
|
207
|
-
"no
|
208
|
+
git_error_set(GIT_ERROR_CONFIG,
|
209
|
+
"no configuration exists for the given level '%i'", (int)level);
|
208
210
|
return GIT_ENOTFOUND;
|
209
211
|
}
|
210
212
|
|
211
|
-
*
|
213
|
+
*out = git_vector_get(&cfg->backends, pos);
|
212
214
|
|
213
215
|
return 0;
|
214
216
|
}
|
215
217
|
|
216
218
|
static int duplicate_level(void **old_raw, void *new_raw)
|
217
219
|
{
|
218
|
-
|
220
|
+
backend_internal **old = (backend_internal **)old_raw;
|
219
221
|
|
220
222
|
GIT_UNUSED(new_raw);
|
221
223
|
|
222
|
-
|
224
|
+
git_error_set(GIT_ERROR_CONFIG, "there already exists a configuration for the given level (%i)", (int)(*old)->level);
|
223
225
|
return GIT_EEXISTS;
|
224
226
|
}
|
225
227
|
|
226
|
-
static void
|
228
|
+
static void try_remove_existing_backend(
|
227
229
|
git_config *cfg,
|
228
230
|
git_config_level_t level)
|
229
231
|
{
|
230
232
|
int pos = -1;
|
231
|
-
|
233
|
+
backend_internal *internal;
|
232
234
|
size_t i;
|
233
235
|
|
234
|
-
git_vector_foreach(&cfg->
|
236
|
+
git_vector_foreach(&cfg->backends, i, internal) {
|
235
237
|
if (internal->level == level)
|
236
238
|
pos = (int)i;
|
237
239
|
}
|
@@ -239,32 +241,32 @@ static void try_remove_existing_file_internal(
|
|
239
241
|
if (pos == -1)
|
240
242
|
return;
|
241
243
|
|
242
|
-
internal = git_vector_get(&cfg->
|
244
|
+
internal = git_vector_get(&cfg->backends, pos);
|
243
245
|
|
244
|
-
if (git_vector_remove(&cfg->
|
246
|
+
if (git_vector_remove(&cfg->backends, pos) < 0)
|
245
247
|
return;
|
246
248
|
|
247
|
-
GIT_REFCOUNT_DEC(internal,
|
249
|
+
GIT_REFCOUNT_DEC(internal, backend_internal_free);
|
248
250
|
}
|
249
251
|
|
250
252
|
static int git_config__add_internal(
|
251
253
|
git_config *cfg,
|
252
|
-
|
254
|
+
backend_internal *internal,
|
253
255
|
git_config_level_t level,
|
254
256
|
int force)
|
255
257
|
{
|
256
258
|
int result;
|
257
259
|
|
258
|
-
/* delete existing config
|
260
|
+
/* delete existing config backend for level if it exists */
|
259
261
|
if (force)
|
260
|
-
|
262
|
+
try_remove_existing_backend(cfg, level);
|
261
263
|
|
262
|
-
if ((result = git_vector_insert_sorted(&cfg->
|
264
|
+
if ((result = git_vector_insert_sorted(&cfg->backends,
|
263
265
|
internal, &duplicate_level)) < 0)
|
264
266
|
return result;
|
265
267
|
|
266
|
-
git_vector_sort(&cfg->
|
267
|
-
internal->
|
268
|
+
git_vector_sort(&cfg->backends);
|
269
|
+
internal->backend->cfg = cfg;
|
268
270
|
|
269
271
|
GIT_REFCOUNT_INC(internal);
|
270
272
|
|
@@ -285,10 +287,10 @@ int git_config_open_level(
|
|
285
287
|
git_config_level_t level)
|
286
288
|
{
|
287
289
|
git_config *cfg;
|
288
|
-
|
290
|
+
backend_internal *internal;
|
289
291
|
int res;
|
290
292
|
|
291
|
-
if ((res =
|
293
|
+
if ((res = find_backend_by_level(&internal, cfg_parent, level)) < 0)
|
292
294
|
return res;
|
293
295
|
|
294
296
|
if ((res = git_config_new(&cfg)) < 0)
|
@@ -306,27 +308,27 @@ int git_config_open_level(
|
|
306
308
|
|
307
309
|
int git_config_add_backend(
|
308
310
|
git_config *cfg,
|
309
|
-
git_config_backend *
|
311
|
+
git_config_backend *backend,
|
310
312
|
git_config_level_t level,
|
311
313
|
const git_repository *repo,
|
312
314
|
int force)
|
313
315
|
{
|
314
|
-
|
316
|
+
backend_internal *internal;
|
315
317
|
int result;
|
316
318
|
|
317
|
-
assert(cfg &&
|
319
|
+
assert(cfg && backend);
|
318
320
|
|
319
|
-
|
321
|
+
GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend");
|
320
322
|
|
321
|
-
if ((result =
|
323
|
+
if ((result = backend->open(backend, level, repo)) < 0)
|
322
324
|
return result;
|
323
325
|
|
324
|
-
internal = git__malloc(sizeof(
|
325
|
-
|
326
|
+
internal = git__malloc(sizeof(backend_internal));
|
327
|
+
GIT_ERROR_CHECK_ALLOC(internal);
|
326
328
|
|
327
|
-
memset(internal, 0x0, sizeof(
|
329
|
+
memset(internal, 0x0, sizeof(backend_internal));
|
328
330
|
|
329
|
-
internal->
|
331
|
+
internal->backend = backend;
|
330
332
|
internal->level = level;
|
331
333
|
|
332
334
|
if ((result = git_config__add_internal(cfg, internal, level, force)) < 0) {
|
@@ -345,17 +347,17 @@ typedef struct {
|
|
345
347
|
git_config_iterator parent;
|
346
348
|
git_config_iterator *current;
|
347
349
|
const git_config *cfg;
|
348
|
-
|
350
|
+
git_regexp regex;
|
349
351
|
size_t i;
|
350
352
|
} all_iter;
|
351
353
|
|
352
354
|
static int find_next_backend(size_t *out, const git_config *cfg, size_t i)
|
353
355
|
{
|
354
|
-
|
356
|
+
backend_internal *internal;
|
355
357
|
|
356
358
|
for (; i > 0; --i) {
|
357
|
-
internal = git_vector_get(&cfg->
|
358
|
-
if (!internal || !internal->
|
359
|
+
internal = git_vector_get(&cfg->backends, i - 1);
|
360
|
+
if (!internal || !internal->backend)
|
359
361
|
continue;
|
360
362
|
|
361
363
|
*out = i;
|
@@ -368,7 +370,7 @@ static int find_next_backend(size_t *out, const git_config *cfg, size_t i)
|
|
368
370
|
static int all_iter_next(git_config_entry **entry, git_config_iterator *_iter)
|
369
371
|
{
|
370
372
|
all_iter *iter = (all_iter *) _iter;
|
371
|
-
|
373
|
+
backend_internal *internal;
|
372
374
|
git_config_backend *backend;
|
373
375
|
size_t i;
|
374
376
|
int error = 0;
|
@@ -385,8 +387,8 @@ static int all_iter_next(git_config_entry **entry, git_config_iterator *_iter)
|
|
385
387
|
if (find_next_backend(&i, iter->cfg, iter->i) < 0)
|
386
388
|
return GIT_ITEROVER;
|
387
389
|
|
388
|
-
internal = git_vector_get(&iter->cfg->
|
389
|
-
backend = internal->
|
390
|
+
internal = git_vector_get(&iter->cfg->backends, i - 1);
|
391
|
+
backend = internal->backend;
|
390
392
|
iter->i = i - 1;
|
391
393
|
|
392
394
|
if (iter->current)
|
@@ -423,7 +425,7 @@ static int all_iter_glob_next(git_config_entry **entry, git_config_iterator *_it
|
|
423
425
|
*/
|
424
426
|
while ((error = all_iter_next(entry, _iter)) == 0) {
|
425
427
|
/* skip non-matching keys if regexp was provided */
|
426
|
-
if (
|
428
|
+
if (git_regexp_match(&iter->regex, (*entry)->name) != 0)
|
427
429
|
continue;
|
428
430
|
|
429
431
|
/* and simply return if we like the entry's name */
|
@@ -447,7 +449,7 @@ static void all_iter_glob_free(git_config_iterator *_iter)
|
|
447
449
|
{
|
448
450
|
all_iter *iter = (all_iter *) _iter;
|
449
451
|
|
450
|
-
|
452
|
+
git_regexp_dispose(&iter->regex);
|
451
453
|
all_iter_free(_iter);
|
452
454
|
}
|
453
455
|
|
@@ -456,12 +458,12 @@ int git_config_iterator_new(git_config_iterator **out, const git_config *cfg)
|
|
456
458
|
all_iter *iter;
|
457
459
|
|
458
460
|
iter = git__calloc(1, sizeof(all_iter));
|
459
|
-
|
461
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
460
462
|
|
461
463
|
iter->parent.free = all_iter_free;
|
462
464
|
iter->parent.next = all_iter_next;
|
463
465
|
|
464
|
-
iter->i = cfg->
|
466
|
+
iter->i = cfg->backends.length;
|
465
467
|
iter->cfg = cfg;
|
466
468
|
|
467
469
|
*out = (git_config_iterator *) iter;
|
@@ -478,17 +480,16 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
|
|
478
480
|
return git_config_iterator_new(out, cfg);
|
479
481
|
|
480
482
|
iter = git__calloc(1, sizeof(all_iter));
|
481
|
-
|
483
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
482
484
|
|
483
|
-
if ((result =
|
484
|
-
giterr_set_regex(&iter->regex, result);
|
485
|
+
if ((result = git_regexp_compile(&iter->regex, regexp, 0)) < 0) {
|
485
486
|
git__free(iter);
|
486
487
|
return -1;
|
487
488
|
}
|
488
489
|
|
489
490
|
iter->parent.next = all_iter_glob_next;
|
490
491
|
iter->parent.free = all_iter_glob_free;
|
491
|
-
iter->i = cfg->
|
492
|
+
iter->i = cfg->backends.length;
|
492
493
|
iter->cfg = cfg;
|
493
494
|
|
494
495
|
*out = (git_config_iterator *) iter;
|
@@ -510,18 +511,13 @@ int git_config_backend_foreach_match(
|
|
510
511
|
{
|
511
512
|
git_config_entry *entry;
|
512
513
|
git_config_iterator* iter;
|
513
|
-
|
514
|
+
git_regexp regex;
|
514
515
|
int error = 0;
|
515
516
|
|
516
517
|
assert(backend && cb);
|
517
518
|
|
518
|
-
if (regexp
|
519
|
-
|
520
|
-
giterr_set_regex(®ex, error);
|
521
|
-
regfree(®ex);
|
522
|
-
return -1;
|
523
|
-
}
|
524
|
-
}
|
519
|
+
if (regexp && git_regexp_compile(®ex, regexp, 0) < 0)
|
520
|
+
return -1;
|
525
521
|
|
526
522
|
if ((error = backend->iterator(&iter, backend)) < 0) {
|
527
523
|
iter = NULL;
|
@@ -530,18 +526,18 @@ int git_config_backend_foreach_match(
|
|
530
526
|
|
531
527
|
while (!(iter->next(&entry, iter) < 0)) {
|
532
528
|
/* skip non-matching keys if regexp was provided */
|
533
|
-
if (regexp &&
|
529
|
+
if (regexp && git_regexp_match(®ex, entry->name) != 0)
|
534
530
|
continue;
|
535
531
|
|
536
532
|
/* abort iterator on non-zero return value */
|
537
533
|
if ((error = cb(entry, payload)) != 0) {
|
538
|
-
|
534
|
+
git_error_set_after_callback(error);
|
539
535
|
break;
|
540
536
|
}
|
541
537
|
}
|
542
538
|
|
543
539
|
if (regexp != NULL)
|
544
|
-
|
540
|
+
git_regexp_dispose(®ex);
|
545
541
|
|
546
542
|
iter->free(iter);
|
547
543
|
|
@@ -563,7 +559,7 @@ int git_config_foreach_match(
|
|
563
559
|
|
564
560
|
while (!(error = git_config_next(&entry, iter))) {
|
565
561
|
if ((error = cb(entry, payload)) != 0) {
|
566
|
-
|
562
|
+
git_error_set_after_callback(error);
|
567
563
|
break;
|
568
564
|
}
|
569
565
|
}
|
@@ -594,38 +590,38 @@ static int get_backend_for_use(git_config_backend **out,
|
|
594
590
|
git_config *cfg, const char *name, backend_use use)
|
595
591
|
{
|
596
592
|
size_t i;
|
597
|
-
|
593
|
+
backend_internal *backend;
|
598
594
|
|
599
595
|
*out = NULL;
|
600
596
|
|
601
|
-
if (git_vector_length(&cfg->
|
602
|
-
|
603
|
-
"cannot %s value for '%s' when no config
|
597
|
+
if (git_vector_length(&cfg->backends) == 0) {
|
598
|
+
git_error_set(GIT_ERROR_CONFIG,
|
599
|
+
"cannot %s value for '%s' when no config backends exist",
|
604
600
|
uses[use], name);
|
605
601
|
return GIT_ENOTFOUND;
|
606
602
|
}
|
607
603
|
|
608
|
-
git_vector_foreach(&cfg->
|
609
|
-
if (!
|
610
|
-
*out =
|
604
|
+
git_vector_foreach(&cfg->backends, i, backend) {
|
605
|
+
if (!backend->backend->readonly) {
|
606
|
+
*out = backend->backend;
|
611
607
|
return 0;
|
612
608
|
}
|
613
609
|
}
|
614
610
|
|
615
|
-
|
616
|
-
"cannot %s value for '%s' when all config
|
611
|
+
git_error_set(GIT_ERROR_CONFIG,
|
612
|
+
"cannot %s value for '%s' when all config backends are readonly",
|
617
613
|
uses[use], name);
|
618
614
|
return GIT_ENOTFOUND;
|
619
615
|
}
|
620
616
|
|
621
617
|
int git_config_delete_entry(git_config *cfg, const char *name)
|
622
618
|
{
|
623
|
-
git_config_backend *
|
619
|
+
git_config_backend *backend;
|
624
620
|
|
625
|
-
if (get_backend_for_use(&
|
621
|
+
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
|
626
622
|
return GIT_ENOTFOUND;
|
627
623
|
|
628
|
-
return
|
624
|
+
return backend->del(backend, name);
|
629
625
|
}
|
630
626
|
|
631
627
|
int git_config_set_int64(git_config *cfg, const char *name, int64_t value)
|
@@ -648,20 +644,20 @@ int git_config_set_bool(git_config *cfg, const char *name, int value)
|
|
648
644
|
int git_config_set_string(git_config *cfg, const char *name, const char *value)
|
649
645
|
{
|
650
646
|
int error;
|
651
|
-
git_config_backend *
|
647
|
+
git_config_backend *backend;
|
652
648
|
|
653
649
|
if (!value) {
|
654
|
-
|
650
|
+
git_error_set(GIT_ERROR_CONFIG, "the value to set cannot be NULL");
|
655
651
|
return -1;
|
656
652
|
}
|
657
653
|
|
658
|
-
if (get_backend_for_use(&
|
654
|
+
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_SET) < 0)
|
659
655
|
return GIT_ENOTFOUND;
|
660
656
|
|
661
|
-
error =
|
657
|
+
error = backend->set(backend, name, value);
|
662
658
|
|
663
659
|
if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL)
|
664
|
-
|
660
|
+
git_repository__configmap_lookup_cache_clear(GIT_REFCOUNT_OWNER(cfg));
|
665
661
|
|
666
662
|
return error;
|
667
663
|
}
|
@@ -703,7 +699,7 @@ int git_config__update_entry(
|
|
703
699
|
|
704
700
|
static int config_error_notfound(const char *name)
|
705
701
|
{
|
706
|
-
|
702
|
+
git_error_set(GIT_ERROR_CONFIG, "config value '%s' was not found", name);
|
707
703
|
return GIT_ENOTFOUND;
|
708
704
|
}
|
709
705
|
|
@@ -724,7 +720,7 @@ static int get_entry(
|
|
724
720
|
const char *key = name;
|
725
721
|
char *normalized = NULL;
|
726
722
|
size_t i;
|
727
|
-
|
723
|
+
backend_internal *internal;
|
728
724
|
|
729
725
|
*out = NULL;
|
730
726
|
|
@@ -735,11 +731,11 @@ static int get_entry(
|
|
735
731
|
}
|
736
732
|
|
737
733
|
res = GIT_ENOTFOUND;
|
738
|
-
git_vector_foreach(&cfg->
|
739
|
-
if (!internal || !internal->
|
734
|
+
git_vector_foreach(&cfg->backends, i, internal) {
|
735
|
+
if (!internal || !internal->backend)
|
740
736
|
continue;
|
741
737
|
|
742
|
-
res = internal->
|
738
|
+
res = internal->backend->get(internal->backend, key, out);
|
743
739
|
if (res != GIT_ENOTFOUND)
|
744
740
|
break;
|
745
741
|
}
|
@@ -750,7 +746,7 @@ cleanup:
|
|
750
746
|
if (res == GIT_ENOTFOUND)
|
751
747
|
res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name);
|
752
748
|
else if (res && (want_errors == GET_NO_ERRORS)) {
|
753
|
-
|
749
|
+
git_error_clear();
|
754
750
|
res = 0;
|
755
751
|
}
|
756
752
|
|
@@ -777,7 +773,7 @@ int git_config_get_mapped(
|
|
777
773
|
int *out,
|
778
774
|
const git_config *cfg,
|
779
775
|
const char *name,
|
780
|
-
const
|
776
|
+
const git_configmap *maps,
|
781
777
|
size_t map_n)
|
782
778
|
{
|
783
779
|
git_config_entry *entry;
|
@@ -837,13 +833,13 @@ int git_config_get_bool(int *out, const git_config *cfg, const char *name)
|
|
837
833
|
static int is_readonly(const git_config *cfg)
|
838
834
|
{
|
839
835
|
size_t i;
|
840
|
-
|
836
|
+
backend_internal *internal;
|
841
837
|
|
842
|
-
git_vector_foreach(&cfg->
|
843
|
-
if (!internal || !internal->
|
838
|
+
git_vector_foreach(&cfg->backends, i, internal) {
|
839
|
+
if (!internal || !internal->backend)
|
844
840
|
continue;
|
845
841
|
|
846
|
-
if (!internal->
|
842
|
+
if (!internal->backend->readonly)
|
847
843
|
return 0;
|
848
844
|
}
|
849
845
|
|
@@ -871,7 +867,7 @@ int git_config_get_string(
|
|
871
867
|
int ret;
|
872
868
|
|
873
869
|
if (!is_readonly(cfg)) {
|
874
|
-
|
870
|
+
git_error_set(GIT_ERROR_CONFIG, "get_string called on a live config object");
|
875
871
|
return -1;
|
876
872
|
}
|
877
873
|
|
@@ -925,7 +921,7 @@ int git_config__get_bool_force(
|
|
925
921
|
get_entry(&entry, cfg, key, false, GET_NO_ERRORS);
|
926
922
|
|
927
923
|
if (entry && git_config_parse_bool(&val, entry->value) < 0)
|
928
|
-
|
924
|
+
git_error_clear();
|
929
925
|
|
930
926
|
git_config_entry_free(entry);
|
931
927
|
return val;
|
@@ -940,7 +936,7 @@ int git_config__get_int_force(
|
|
940
936
|
get_entry(&entry, cfg, key, false, GET_NO_ERRORS);
|
941
937
|
|
942
938
|
if (entry && git_config_parse_int32(&val, entry->value) < 0)
|
943
|
-
|
939
|
+
git_error_clear();
|
944
940
|
|
945
941
|
git_config_entry_free(entry);
|
946
942
|
return (int)val;
|
@@ -962,7 +958,7 @@ int git_config_get_multivar_foreach(
|
|
962
958
|
found = 1;
|
963
959
|
|
964
960
|
if ((err = cb(entry, payload)) != 0) {
|
965
|
-
|
961
|
+
git_error_set_after_callback(err);
|
966
962
|
break;
|
967
963
|
}
|
968
964
|
}
|
@@ -981,7 +977,7 @@ typedef struct {
|
|
981
977
|
git_config_iterator parent;
|
982
978
|
git_config_iterator *iter;
|
983
979
|
char *name;
|
984
|
-
|
980
|
+
git_regexp regex;
|
985
981
|
int have_regex;
|
986
982
|
} multivar_iter;
|
987
983
|
|
@@ -997,7 +993,7 @@ static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_it
|
|
997
993
|
if (!iter->have_regex)
|
998
994
|
return 0;
|
999
995
|
|
1000
|
-
if (
|
996
|
+
if (git_regexp_match(&iter->regex, (*entry)->value) == 0)
|
1001
997
|
return 0;
|
1002
998
|
}
|
1003
999
|
|
@@ -1012,7 +1008,7 @@ void multivar_iter_free(git_config_iterator *_iter)
|
|
1012
1008
|
|
1013
1009
|
git__free(iter->name);
|
1014
1010
|
if (iter->have_regex)
|
1015
|
-
|
1011
|
+
git_regexp_dispose(&iter->regex);
|
1016
1012
|
git__free(iter);
|
1017
1013
|
}
|
1018
1014
|
|
@@ -1026,19 +1022,14 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
|
|
1026
1022
|
return error;
|
1027
1023
|
|
1028
1024
|
iter = git__calloc(1, sizeof(multivar_iter));
|
1029
|
-
|
1025
|
+
GIT_ERROR_CHECK_ALLOC(iter);
|
1030
1026
|
|
1031
1027
|
if ((error = git_config__normalize_name(name, &iter->name)) < 0)
|
1032
1028
|
goto on_error;
|
1033
1029
|
|
1034
1030
|
if (regexp != NULL) {
|
1035
|
-
error =
|
1036
|
-
if (error != 0) {
|
1037
|
-
giterr_set_regex(&iter->regex, error);
|
1038
|
-
error = -1;
|
1039
|
-
regfree(&iter->regex);
|
1031
|
+
if ((error = git_regexp_compile(&iter->regex, regexp, 0)) < 0)
|
1040
1032
|
goto on_error;
|
1041
|
-
}
|
1042
1033
|
|
1043
1034
|
iter->have_regex = 1;
|
1044
1035
|
}
|
@@ -1060,22 +1051,22 @@ on_error:
|
|
1060
1051
|
|
1061
1052
|
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
|
1062
1053
|
{
|
1063
|
-
git_config_backend *
|
1054
|
+
git_config_backend *backend;
|
1064
1055
|
|
1065
|
-
if (get_backend_for_use(&
|
1056
|
+
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
|
1066
1057
|
return GIT_ENOTFOUND;
|
1067
1058
|
|
1068
|
-
return
|
1059
|
+
return backend->set_multivar(backend, name, regexp, value);
|
1069
1060
|
}
|
1070
1061
|
|
1071
1062
|
int git_config_delete_multivar(git_config *cfg, const char *name, const char *regexp)
|
1072
1063
|
{
|
1073
|
-
git_config_backend *
|
1064
|
+
git_config_backend *backend;
|
1074
1065
|
|
1075
|
-
if (get_backend_for_use(&
|
1066
|
+
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0)
|
1076
1067
|
return GIT_ENOTFOUND;
|
1077
1068
|
|
1078
|
-
return
|
1069
|
+
return backend->del_multivar(backend, name, regexp);
|
1079
1070
|
}
|
1080
1071
|
|
1081
1072
|
int git_config_next(git_config_entry **entry, git_config_iterator *iter)
|
@@ -1173,7 +1164,7 @@ int git_config_open_default(git_config **out)
|
|
1173
1164
|
error = git_config_add_file_ondisk(cfg, buf.ptr,
|
1174
1165
|
GIT_CONFIG_LEVEL_PROGRAMDATA, NULL, 0);
|
1175
1166
|
|
1176
|
-
|
1167
|
+
git_buf_dispose(&buf);
|
1177
1168
|
|
1178
1169
|
if (error) {
|
1179
1170
|
git_config_free(cfg);
|
@@ -1188,17 +1179,19 @@ int git_config_open_default(git_config **out)
|
|
1188
1179
|
int git_config_lock(git_transaction **out, git_config *cfg)
|
1189
1180
|
{
|
1190
1181
|
int error;
|
1191
|
-
git_config_backend *
|
1192
|
-
|
1182
|
+
git_config_backend *backend;
|
1183
|
+
backend_internal *internal;
|
1193
1184
|
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1185
|
+
assert(cfg);
|
1186
|
+
|
1187
|
+
internal = git_vector_get(&cfg->backends, 0);
|
1188
|
+
if (!internal || !internal->backend) {
|
1189
|
+
git_error_set(GIT_ERROR_CONFIG, "cannot lock; the config has no backends");
|
1197
1190
|
return -1;
|
1198
1191
|
}
|
1199
|
-
|
1192
|
+
backend = internal->backend;
|
1200
1193
|
|
1201
|
-
if ((error =
|
1194
|
+
if ((error = backend->lock(backend)) < 0)
|
1202
1195
|
return error;
|
1203
1196
|
|
1204
1197
|
return git_transaction_config_new(out, cfg);
|
@@ -1206,18 +1199,20 @@ int git_config_lock(git_transaction **out, git_config *cfg)
|
|
1206
1199
|
|
1207
1200
|
int git_config_unlock(git_config *cfg, int commit)
|
1208
1201
|
{
|
1209
|
-
git_config_backend *
|
1210
|
-
|
1202
|
+
git_config_backend *backend;
|
1203
|
+
backend_internal *internal;
|
1211
1204
|
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1205
|
+
assert(cfg);
|
1206
|
+
|
1207
|
+
internal = git_vector_get(&cfg->backends, 0);
|
1208
|
+
if (!internal || !internal->backend) {
|
1209
|
+
git_error_set(GIT_ERROR_CONFIG, "cannot lock; the config has no backends");
|
1215
1210
|
return -1;
|
1216
1211
|
}
|
1217
1212
|
|
1218
|
-
|
1213
|
+
backend = internal->backend;
|
1219
1214
|
|
1220
|
-
return
|
1215
|
+
return backend->unlock(backend, commit);
|
1221
1216
|
}
|
1222
1217
|
|
1223
1218
|
/***********
|
@@ -1226,7 +1221,7 @@ int git_config_unlock(git_config *cfg, int commit)
|
|
1226
1221
|
|
1227
1222
|
int git_config_lookup_map_value(
|
1228
1223
|
int *out,
|
1229
|
-
const
|
1224
|
+
const git_configmap *maps,
|
1230
1225
|
size_t map_n,
|
1231
1226
|
const char *value)
|
1232
1227
|
{
|
@@ -1236,27 +1231,27 @@ int git_config_lookup_map_value(
|
|
1236
1231
|
goto fail_parse;
|
1237
1232
|
|
1238
1233
|
for (i = 0; i < map_n; ++i) {
|
1239
|
-
const
|
1234
|
+
const git_configmap *m = maps + i;
|
1240
1235
|
|
1241
|
-
switch (m->
|
1242
|
-
case
|
1243
|
-
case
|
1236
|
+
switch (m->type) {
|
1237
|
+
case GIT_CONFIGMAP_FALSE:
|
1238
|
+
case GIT_CONFIGMAP_TRUE: {
|
1244
1239
|
int bool_val;
|
1245
1240
|
|
1246
1241
|
if (git__parse_bool(&bool_val, value) == 0 &&
|
1247
|
-
bool_val == (int)m->
|
1242
|
+
bool_val == (int)m->type) {
|
1248
1243
|
*out = m->map_value;
|
1249
1244
|
return 0;
|
1250
1245
|
}
|
1251
1246
|
break;
|
1252
1247
|
}
|
1253
1248
|
|
1254
|
-
case
|
1249
|
+
case GIT_CONFIGMAP_INT32:
|
1255
1250
|
if (git_config_parse_int32(out, value) == 0)
|
1256
1251
|
return 0;
|
1257
1252
|
break;
|
1258
1253
|
|
1259
|
-
case
|
1254
|
+
case GIT_CONFIGMAP_STRING:
|
1260
1255
|
if (strcasecmp(value, m->str_match) == 0) {
|
1261
1256
|
*out = m->map_value;
|
1262
1257
|
return 0;
|
@@ -1266,27 +1261,27 @@ int git_config_lookup_map_value(
|
|
1266
1261
|
}
|
1267
1262
|
|
1268
1263
|
fail_parse:
|
1269
|
-
|
1264
|
+
git_error_set(GIT_ERROR_CONFIG, "failed to map '%s'", value);
|
1270
1265
|
return -1;
|
1271
1266
|
}
|
1272
1267
|
|
1273
|
-
int git_config_lookup_map_enum(
|
1274
|
-
const
|
1268
|
+
int git_config_lookup_map_enum(git_configmap_t *type_out, const char **str_out,
|
1269
|
+
const git_configmap *maps, size_t map_n, int enum_val)
|
1275
1270
|
{
|
1276
1271
|
size_t i;
|
1277
1272
|
|
1278
1273
|
for (i = 0; i < map_n; i++) {
|
1279
|
-
const
|
1274
|
+
const git_configmap *m = &maps[i];
|
1280
1275
|
|
1281
1276
|
if (m->map_value != enum_val)
|
1282
1277
|
continue;
|
1283
1278
|
|
1284
|
-
*type_out = m->
|
1279
|
+
*type_out = m->type;
|
1285
1280
|
*str_out = m->str_match;
|
1286
1281
|
return 0;
|
1287
1282
|
}
|
1288
1283
|
|
1289
|
-
|
1284
|
+
git_error_set(GIT_ERROR_CONFIG, "invalid enum value");
|
1290
1285
|
return GIT_ENOTFOUND;
|
1291
1286
|
}
|
1292
1287
|
|
@@ -1300,7 +1295,7 @@ int git_config_parse_bool(int *out, const char *value)
|
|
1300
1295
|
return 0;
|
1301
1296
|
}
|
1302
1297
|
|
1303
|
-
|
1298
|
+
git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a boolean value", value);
|
1304
1299
|
return -1;
|
1305
1300
|
}
|
1306
1301
|
|
@@ -1343,7 +1338,7 @@ int git_config_parse_int64(int64_t *out, const char *value)
|
|
1343
1338
|
}
|
1344
1339
|
|
1345
1340
|
fail_parse:
|
1346
|
-
|
1341
|
+
git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as an integer", value ? value : "(null)");
|
1347
1342
|
return -1;
|
1348
1343
|
}
|
1349
1344
|
|
@@ -1363,7 +1358,7 @@ int git_config_parse_int32(int32_t *out, const char *value)
|
|
1363
1358
|
return 0;
|
1364
1359
|
|
1365
1360
|
fail_parse:
|
1366
|
-
|
1361
|
+
git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a 32-bit integer", value ? value : "(null)");
|
1367
1362
|
return -1;
|
1368
1363
|
}
|
1369
1364
|
|
@@ -1375,7 +1370,7 @@ int git_config_parse_path(git_buf *out, const char *value)
|
|
1375
1370
|
|
1376
1371
|
if (value[0] == '~') {
|
1377
1372
|
if (value[1] != '\0' && value[1] != '/') {
|
1378
|
-
|
1373
|
+
git_error_set(GIT_ERROR_CONFIG, "retrieving a homedir by name is not supported");
|
1379
1374
|
return -1;
|
1380
1375
|
}
|
1381
1376
|
|
@@ -1385,6 +1380,30 @@ int git_config_parse_path(git_buf *out, const char *value)
|
|
1385
1380
|
return git_buf_sets(out, value);
|
1386
1381
|
}
|
1387
1382
|
|
1383
|
+
static int normalize_section(char *start, char *end)
|
1384
|
+
{
|
1385
|
+
char *scan;
|
1386
|
+
|
1387
|
+
if (start == end)
|
1388
|
+
return GIT_EINVALIDSPEC;
|
1389
|
+
|
1390
|
+
/* Validate and downcase range */
|
1391
|
+
for (scan = start; *scan; ++scan) {
|
1392
|
+
if (end && scan >= end)
|
1393
|
+
break;
|
1394
|
+
if (isalnum(*scan))
|
1395
|
+
*scan = (char)git__tolower(*scan);
|
1396
|
+
else if (*scan != '-' || scan == start)
|
1397
|
+
return GIT_EINVALIDSPEC;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
if (scan == start)
|
1401
|
+
return GIT_EINVALIDSPEC;
|
1402
|
+
|
1403
|
+
return 0;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
|
1388
1407
|
/* Take something the user gave us and make it nice for our hash function */
|
1389
1408
|
int git_config__normalize_name(const char *in, char **out)
|
1390
1409
|
{
|
@@ -1393,7 +1412,7 @@ int git_config__normalize_name(const char *in, char **out)
|
|
1393
1412
|
assert(in && out);
|
1394
1413
|
|
1395
1414
|
name = git__strdup(in);
|
1396
|
-
|
1415
|
+
GIT_ERROR_CHECK_ALLOC(name);
|
1397
1416
|
|
1398
1417
|
fdot = strchr(name, '.');
|
1399
1418
|
ldot = strrchr(name, '.');
|
@@ -1402,8 +1421,8 @@ int git_config__normalize_name(const char *in, char **out)
|
|
1402
1421
|
goto invalid;
|
1403
1422
|
|
1404
1423
|
/* Validate and downcase up to first dot and after last dot */
|
1405
|
-
if (
|
1406
|
-
|
1424
|
+
if (normalize_section(name, fdot) < 0 ||
|
1425
|
+
normalize_section(ldot + 1, NULL) < 0)
|
1407
1426
|
goto invalid;
|
1408
1427
|
|
1409
1428
|
/* If there is a middle range, make sure it doesn't have newlines */
|
@@ -1416,7 +1435,7 @@ int git_config__normalize_name(const char *in, char **out)
|
|
1416
1435
|
|
1417
1436
|
invalid:
|
1418
1437
|
git__free(name);
|
1419
|
-
|
1438
|
+
git_error_set(GIT_ERROR_CONFIG, "invalid config item name '%s'", in);
|
1420
1439
|
return GIT_EINVALIDSPEC;
|
1421
1440
|
}
|
1422
1441
|
|
@@ -1475,11 +1494,10 @@ int git_config_rename_section(
|
|
1475
1494
|
goto cleanup;
|
1476
1495
|
|
1477
1496
|
if (new_section_name != NULL &&
|
1478
|
-
|
1479
|
-
replace.ptr, strchr(replace.ptr, '.'))) < 0)
|
1497
|
+
(error = normalize_section(replace.ptr, strchr(replace.ptr, '.'))) < 0)
|
1480
1498
|
{
|
1481
|
-
|
1482
|
-
|
1499
|
+
git_error_set(
|
1500
|
+
GIT_ERROR_CONFIG, "invalid config section '%s'", new_section_name);
|
1483
1501
|
goto cleanup;
|
1484
1502
|
}
|
1485
1503
|
|
@@ -1487,8 +1505,8 @@ int git_config_rename_section(
|
|
1487
1505
|
config, git_buf_cstr(&pattern), rename_config_entries_cb, &data);
|
1488
1506
|
|
1489
1507
|
cleanup:
|
1490
|
-
|
1491
|
-
|
1508
|
+
git_buf_dispose(&pattern);
|
1509
|
+
git_buf_dispose(&replace);
|
1492
1510
|
|
1493
1511
|
return error;
|
1494
1512
|
}
|