rugged 1.0.0 → 1.2.0
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/LICENSE +1 -0
- data/README.md +3 -3
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_commit.c +1 -1
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_remote.c +32 -2
- data/ext/rugged/rugged_repo.c +13 -3
- data/lib/rugged/commit.rb +17 -4
- data/lib/rugged/repository.rb +7 -8
- data/lib/rugged/submodule_collection.rb +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +41 -74
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
- data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
- data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/deps/pcre/LICENCE +93 -0
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
- data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/apply.h +2 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +95 -42
- data/vendor/libgit2/include/git2/blob.h +31 -3
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +33 -6
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +248 -8
- data/vendor/libgit2/include/git2/diff.h +35 -20
- data/vendor/libgit2/include/git2/errors.h +8 -7
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +4 -5
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/pack.h +1 -1
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/strarray.h +6 -10
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +77 -44
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +21 -8
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +92 -42
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +44 -40
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +28 -15
- data/vendor/libgit2/src/blame_git.c +6 -3
- data/vendor/libgit2/src/blob.c +46 -24
- data/vendor/libgit2/src/branch.c +87 -37
- data/vendor/libgit2/src/buffer.c +339 -27
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +3 -24
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +97 -98
- data/vendor/libgit2/src/cherrypick.c +8 -2
- data/vendor/libgit2/src/clone.c +104 -29
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +26 -2
- data/vendor/libgit2/src/config.c +40 -22
- data/vendor/libgit2/src/config_cache.c +9 -4
- data/vendor/libgit2/src/config_entries.c +35 -27
- data/vendor/libgit2/src/config_file.c +25 -8
- data/vendor/libgit2/src/config_parse.c +5 -7
- data/vendor/libgit2/src/config_snapshot.c +2 -1
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +11 -4
- data/vendor/libgit2/src/diff.c +23 -19
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +5 -7
- data/vendor/libgit2/src/diff_generate.c +56 -28
- data/vendor/libgit2/src/diff_parse.c +2 -3
- data/vendor/libgit2/src/diff_print.c +81 -65
- data/vendor/libgit2/src/diff_stats.c +19 -16
- data/vendor/libgit2/src/diff_tform.c +13 -13
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +26 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +7 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +209 -113
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +8 -8
- data/vendor/libgit2/src/futils.h +4 -4
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/idxmap.c +0 -22
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +126 -84
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +60 -36
- data/vendor/libgit2/src/integer.h +79 -2
- data/vendor/libgit2/src/iterator.c +40 -28
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +125 -49
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +108 -46
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +15 -9
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +879 -0
- data/vendor/libgit2/src/midx.h +110 -0
- data/vendor/libgit2/src/mwindow.c +214 -95
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +133 -4
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +24 -15
- data/vendor/libgit2/src/odb.c +298 -57
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +31 -21
- data/vendor/libgit2/src/odb_mempack.c +3 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +7 -4
- data/vendor/libgit2/src/pack-objects.c +83 -69
- data/vendor/libgit2/src/pack.c +383 -150
- data/vendor/libgit2/src/pack.h +44 -9
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +3 -5
- data/vendor/libgit2/src/patch_parse.c +6 -3
- data/vendor/libgit2/src/path.c +102 -57
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +12 -11
- data/vendor/libgit2/src/pool.c +34 -22
- data/vendor/libgit2/src/pool.h +9 -1
- data/vendor/libgit2/src/posix.c +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- data/vendor/libgit2/src/proxy.c +2 -0
- data/vendor/libgit2/src/push.c +2 -0
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +95 -49
- data/vendor/libgit2/src/refdb.c +165 -13
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +144 -152
- data/vendor/libgit2/src/reflog.c +21 -20
- data/vendor/libgit2/src/refs.c +151 -231
- data/vendor/libgit2/src/refs.h +2 -20
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/regexp.c +2 -2
- data/vendor/libgit2/src/remote.c +312 -121
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +351 -189
- data/vendor/libgit2/src/repository.h +23 -29
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +8 -2
- data/vendor/libgit2/src/revparse.c +19 -13
- data/vendor/libgit2/src/revwalk.c +35 -20
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.c +2 -3
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +7 -3
- data/vendor/libgit2/src/status.c +9 -4
- data/vendor/libgit2/src/strarray.c +64 -0
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +113 -207
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +10 -9
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +134 -66
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +8 -26
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +49 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +21 -9
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +17 -7
- data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +84 -42
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +5 -5
- data/vendor/libgit2/src/transports/smart.c +14 -9
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +156 -88
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/posix.h +16 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +74 -183
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/git2.rc +18 -3
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +23 -25
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +77 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +37 -15
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +56 -38
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -361
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -246
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#include "diff_xdiff.h"
|
|
9
|
-
#include "util.h"
|
|
10
9
|
|
|
11
10
|
#include "git2/errors.h"
|
|
12
11
|
#include "diff.h"
|
|
@@ -128,7 +127,7 @@ static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len)
|
|
|
128
127
|
info->hunk.header_len = sizeof(info->hunk.header) - 1;
|
|
129
128
|
|
|
130
129
|
/* Sanitize the hunk header in case there is invalid Unicode */
|
|
131
|
-
buffer_len =
|
|
130
|
+
buffer_len = git_utf8_valid_buf_length(bufs[0].ptr, info->hunk.header_len);
|
|
132
131
|
/* Sanitizing the hunk header may delete the newline, so add it back again if there is room */
|
|
133
132
|
if (buffer_len < info->hunk.header_len) {
|
|
134
133
|
bufs[0].ptr[buffer_len] = '\n';
|
|
@@ -259,5 +258,8 @@ void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts)
|
|
|
259
258
|
if (flags & GIT_DIFF_MINIMAL)
|
|
260
259
|
xo->params.flags |= XDF_NEED_MINIMAL;
|
|
261
260
|
|
|
261
|
+
if (flags & GIT_DIFF_IGNORE_BLANK_LINES)
|
|
262
|
+
xo->params.flags |= XDF_IGNORE_BLANK_LINES;
|
|
263
|
+
|
|
262
264
|
xo->callback.outf = git_xdiff_cb;
|
|
263
265
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/* xdiff cannot cope with large files. these files should not be passed to
|
|
17
17
|
* xdiff. callers should treat these large files as binary.
|
|
18
18
|
*/
|
|
19
|
-
#define GIT_XDIFF_MAX_SIZE (
|
|
19
|
+
#define GIT_XDIFF_MAX_SIZE (INT64_C(1024) * 1024 * 1023)
|
|
20
20
|
|
|
21
21
|
/* A git_xdiff_output is a git_patch_generate_output with extra fields
|
|
22
22
|
* necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
|
data/vendor/libgit2/src/errors.c
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
#include "common.h"
|
|
9
9
|
|
|
10
|
-
#include "
|
|
10
|
+
#include "threadstate.h"
|
|
11
11
|
#include "posix.h"
|
|
12
12
|
#include "buffer.h"
|
|
13
|
+
#include "libgit2.h"
|
|
13
14
|
|
|
14
15
|
/********************************************
|
|
15
16
|
* New error handling
|
|
@@ -20,20 +21,25 @@ static git_error g_git_oom_error = {
|
|
|
20
21
|
GIT_ERROR_NOMEMORY
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
static git_error g_git_uninitialized_error = {
|
|
25
|
+
"libgit2 has not been initialized; you must call git_libgit2_init",
|
|
26
|
+
GIT_ERROR_INVALID
|
|
27
|
+
};
|
|
28
|
+
|
|
23
29
|
static void set_error_from_buffer(int error_class)
|
|
24
30
|
{
|
|
25
|
-
git_error *error = &
|
|
26
|
-
git_buf *buf = &
|
|
31
|
+
git_error *error = &GIT_THREADSTATE->error_t;
|
|
32
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
|
27
33
|
|
|
28
34
|
error->message = buf->ptr;
|
|
29
35
|
error->klass = error_class;
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
GIT_THREADSTATE->last_error = error;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
static void set_error(int error_class, char *string)
|
|
35
41
|
{
|
|
36
|
-
git_buf *buf = &
|
|
42
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
|
37
43
|
|
|
38
44
|
git_buf_clear(buf);
|
|
39
45
|
if (string) {
|
|
@@ -46,7 +52,7 @@ static void set_error(int error_class, char *string)
|
|
|
46
52
|
|
|
47
53
|
void git_error_set_oom(void)
|
|
48
54
|
{
|
|
49
|
-
|
|
55
|
+
GIT_THREADSTATE->last_error = &g_git_oom_error;
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
void git_error_set(int error_class, const char *fmt, ...)
|
|
@@ -64,7 +70,7 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
|
|
|
64
70
|
DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0;
|
|
65
71
|
#endif
|
|
66
72
|
int error_code = (error_class == GIT_ERROR_OS) ? errno : 0;
|
|
67
|
-
git_buf *buf = &
|
|
73
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
|
68
74
|
|
|
69
75
|
git_buf_clear(buf);
|
|
70
76
|
if (fmt) {
|
|
@@ -97,14 +103,9 @@ void git_error_vset(int error_class, const char *fmt, va_list ap)
|
|
|
97
103
|
|
|
98
104
|
int git_error_set_str(int error_class, const char *string)
|
|
99
105
|
{
|
|
100
|
-
git_buf *buf = &
|
|
106
|
+
git_buf *buf = &GIT_THREADSTATE->error_buf;
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!string) {
|
|
105
|
-
git_error_set(GIT_ERROR_INVALID, "unspecified caller error");
|
|
106
|
-
return -1;
|
|
107
|
-
}
|
|
108
|
+
GIT_ASSERT_ARG(string);
|
|
108
109
|
|
|
109
110
|
git_buf_clear(buf);
|
|
110
111
|
git_buf_puts(buf, string);
|
|
@@ -118,9 +119,9 @@ int git_error_set_str(int error_class, const char *string)
|
|
|
118
119
|
|
|
119
120
|
void git_error_clear(void)
|
|
120
121
|
{
|
|
121
|
-
if (
|
|
122
|
+
if (GIT_THREADSTATE->last_error != NULL) {
|
|
122
123
|
set_error(0, NULL);
|
|
123
|
-
|
|
124
|
+
GIT_THREADSTATE->last_error = NULL;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
errno = 0;
|
|
@@ -131,13 +132,17 @@ void git_error_clear(void)
|
|
|
131
132
|
|
|
132
133
|
const git_error *git_error_last(void)
|
|
133
134
|
{
|
|
134
|
-
return
|
|
135
|
+
/* If the library is not initialized, return a static error. */
|
|
136
|
+
if (!git_libgit2_init_count())
|
|
137
|
+
return &g_git_uninitialized_error;
|
|
138
|
+
|
|
139
|
+
return GIT_THREADSTATE->last_error;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
int git_error_state_capture(git_error_state *state, int error_code)
|
|
138
143
|
{
|
|
139
|
-
git_error *error =
|
|
140
|
-
git_buf *error_buf = &
|
|
144
|
+
git_error *error = GIT_THREADSTATE->last_error;
|
|
145
|
+
git_buf *error_buf = &GIT_THREADSTATE->error_buf;
|
|
141
146
|
|
|
142
147
|
memset(state, 0, sizeof(git_error_state));
|
|
143
148
|
|
|
@@ -210,6 +215,7 @@ void git_error_system_set(int code)
|
|
|
210
215
|
|
|
211
216
|
/* Deprecated error values and functions */
|
|
212
217
|
|
|
218
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
213
219
|
const git_error *giterr_last(void)
|
|
214
220
|
{
|
|
215
221
|
return git_error_last();
|
|
@@ -229,3 +235,4 @@ void giterr_set_oom(void)
|
|
|
229
235
|
{
|
|
230
236
|
git_error_set_oom();
|
|
231
237
|
}
|
|
238
|
+
#endif
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
#define INCLUDE_features_h__
|
|
3
3
|
|
|
4
4
|
#cmakedefine GIT_DEBUG_POOL 1
|
|
5
|
+
#cmakedefine GIT_DEBUG_STRICT_ALLOC 1
|
|
6
|
+
#cmakedefine GIT_DEBUG_STRICT_OPEN 1
|
|
7
|
+
|
|
5
8
|
#cmakedefine GIT_TRACE 1
|
|
6
9
|
#cmakedefine GIT_THREADS 1
|
|
7
|
-
#cmakedefine
|
|
10
|
+
#cmakedefine GIT_WIN32_LEAKCHECK 1
|
|
8
11
|
|
|
9
12
|
#cmakedefine GIT_ARCH_64 1
|
|
10
13
|
#cmakedefine GIT_ARCH_32 1
|
|
@@ -32,6 +35,7 @@
|
|
|
32
35
|
#cmakedefine GIT_WINHTTP 1
|
|
33
36
|
#cmakedefine GIT_HTTPS 1
|
|
34
37
|
#cmakedefine GIT_OPENSSL 1
|
|
38
|
+
#cmakedefine GIT_OPENSSL_DYNAMIC 1
|
|
35
39
|
#cmakedefine GIT_SECURE_TRANSPORT 1
|
|
36
40
|
#cmakedefine GIT_MBEDTLS 1
|
|
37
41
|
|
data/vendor/libgit2/src/fetch.c
CHANGED
|
@@ -21,9 +21,12 @@
|
|
|
21
21
|
|
|
22
22
|
static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
|
|
23
23
|
{
|
|
24
|
-
int match = 0;
|
|
24
|
+
int match = 0, valid;
|
|
25
25
|
|
|
26
|
-
if (
|
|
26
|
+
if (git_reference_name_is_valid(&valid, head->name) < 0)
|
|
27
|
+
return -1;
|
|
28
|
+
|
|
29
|
+
if (!valid)
|
|
27
30
|
return 0;
|
|
28
31
|
|
|
29
32
|
if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
|
|
@@ -155,7 +158,9 @@ int git_fetch_options_init(git_fetch_options *opts, unsigned int version)
|
|
|
155
158
|
return 0;
|
|
156
159
|
}
|
|
157
160
|
|
|
161
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
158
162
|
int git_fetch_init_options(git_fetch_options *opts, unsigned int version)
|
|
159
163
|
{
|
|
160
164
|
return git_fetch_options_init(opts, version);
|
|
161
165
|
}
|
|
166
|
+
#endif
|
|
@@ -73,7 +73,8 @@ int git_fetchhead_ref_create(
|
|
|
73
73
|
{
|
|
74
74
|
git_fetchhead_ref *fetchhead_ref;
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
GIT_ASSERT_ARG(out);
|
|
77
|
+
GIT_ASSERT_ARG(oid);
|
|
77
78
|
|
|
78
79
|
*out = NULL;
|
|
79
80
|
|
|
@@ -108,7 +109,8 @@ static int fetchhead_ref_write(
|
|
|
108
109
|
const char *type, *name;
|
|
109
110
|
int head = 0;
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
GIT_ASSERT_ARG(file);
|
|
113
|
+
GIT_ASSERT_ARG(fetchhead_ref);
|
|
112
114
|
|
|
113
115
|
git_oid_fmt(oid, &fetchhead_ref->oid);
|
|
114
116
|
oid[GIT_OID_HEXSZ] = '\0';
|
|
@@ -145,7 +147,8 @@ int git_fetchhead_write(git_repository *repo, git_vector *fetchhead_refs)
|
|
|
145
147
|
unsigned int i;
|
|
146
148
|
git_fetchhead_ref *fetchhead_ref;
|
|
147
149
|
|
|
148
|
-
|
|
150
|
+
GIT_ASSERT_ARG(repo);
|
|
151
|
+
GIT_ASSERT_ARG(fetchhead_refs);
|
|
149
152
|
|
|
150
153
|
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
|
|
151
154
|
return -1;
|
|
@@ -279,7 +282,8 @@ int git_repository_fetchhead_foreach(git_repository *repo,
|
|
|
279
282
|
size_t line_num = 0;
|
|
280
283
|
int error = 0;
|
|
281
284
|
|
|
282
|
-
|
|
285
|
+
GIT_ASSERT_ARG(repo);
|
|
286
|
+
GIT_ASSERT_ARG(cb);
|
|
283
287
|
|
|
284
288
|
if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0)
|
|
285
289
|
return -1;
|
|
@@ -184,7 +184,7 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
|
|
|
184
184
|
|
|
185
185
|
} while (zs->avail_out == 0);
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
GIT_ASSERT(zs->avail_in == 0);
|
|
188
188
|
|
|
189
189
|
if (file->compute_digest)
|
|
190
190
|
git_hash_update(&file->digest, source, len);
|
|
@@ -278,10 +278,9 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo
|
|
|
278
278
|
int compression, error = -1;
|
|
279
279
|
size_t path_len, alloc_len;
|
|
280
280
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
assert(file && path && file->buffer == NULL);
|
|
281
|
+
GIT_ASSERT_ARG(file);
|
|
282
|
+
GIT_ASSERT_ARG(path);
|
|
283
|
+
GIT_ASSERT(file->buffer == NULL);
|
|
285
284
|
|
|
286
285
|
memset(file, 0x0, sizeof(git_filebuf));
|
|
287
286
|
|
|
@@ -389,7 +388,9 @@ cleanup:
|
|
|
389
388
|
|
|
390
389
|
int git_filebuf_hash(git_oid *oid, git_filebuf *file)
|
|
391
390
|
{
|
|
392
|
-
|
|
391
|
+
GIT_ASSERT_ARG(oid);
|
|
392
|
+
GIT_ASSERT_ARG(file);
|
|
393
|
+
GIT_ASSERT_ARG(file->compute_digest);
|
|
393
394
|
|
|
394
395
|
flush_buffer(file);
|
|
395
396
|
|
|
@@ -415,7 +416,8 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path)
|
|
|
415
416
|
int git_filebuf_commit(git_filebuf *file)
|
|
416
417
|
{
|
|
417
418
|
/* temporary files cannot be committed */
|
|
418
|
-
|
|
419
|
+
GIT_ASSERT_ARG(file);
|
|
420
|
+
GIT_ASSERT(file->path_original);
|
|
419
421
|
|
|
420
422
|
file->flush_mode = Z_FINISH;
|
|
421
423
|
flush_buffer(file);
|
data/vendor/libgit2/src/filter.c
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#include "futils.h"
|
|
12
12
|
#include "hash.h"
|
|
13
13
|
#include "repository.h"
|
|
14
|
-
#include "
|
|
14
|
+
#include "runtime.h"
|
|
15
15
|
#include "git2/sys/filter.h"
|
|
16
16
|
#include "git2/config.h"
|
|
17
17
|
#include "blob.h"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
#include "array.h"
|
|
20
20
|
|
|
21
21
|
struct git_filter_source {
|
|
22
|
-
git_repository
|
|
23
|
-
const char
|
|
24
|
-
git_oid
|
|
25
|
-
uint16_t
|
|
26
|
-
git_filter_mode_t
|
|
27
|
-
|
|
22
|
+
git_repository *repo;
|
|
23
|
+
const char *path;
|
|
24
|
+
git_oid oid; /* zero if unknown (which is likely) */
|
|
25
|
+
uint16_t filemode; /* zero if unknown */
|
|
26
|
+
git_filter_mode_t mode;
|
|
27
|
+
git_filter_options options;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
typedef struct {
|
|
@@ -206,7 +206,8 @@ int git_filter_global_init(void)
|
|
|
206
206
|
GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
|
|
207
207
|
error = -1;
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
if (!error)
|
|
210
|
+
error = git_runtime_shutdown_register(git_filter_global_shutdown);
|
|
210
211
|
|
|
211
212
|
done:
|
|
212
213
|
if (error) {
|
|
@@ -266,7 +267,8 @@ int git_filter_register(
|
|
|
266
267
|
{
|
|
267
268
|
int error;
|
|
268
269
|
|
|
269
|
-
|
|
270
|
+
GIT_ASSERT_ARG(name);
|
|
271
|
+
GIT_ASSERT_ARG(filter);
|
|
270
272
|
|
|
271
273
|
if (git_rwlock_wrlock(&filter_registry.lock) < 0) {
|
|
272
274
|
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
|
|
@@ -293,7 +295,7 @@ int git_filter_unregister(const char *name)
|
|
|
293
295
|
git_filter_def *fdef;
|
|
294
296
|
int error = 0;
|
|
295
297
|
|
|
296
|
-
|
|
298
|
+
GIT_ASSERT_ARG(name);
|
|
297
299
|
|
|
298
300
|
/* cannot unregister default filters */
|
|
299
301
|
if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
|
|
@@ -395,7 +397,7 @@ git_filter_mode_t git_filter_source_mode(const git_filter_source *src)
|
|
|
395
397
|
|
|
396
398
|
uint32_t git_filter_source_flags(const git_filter_source *src)
|
|
397
399
|
{
|
|
398
|
-
return src->flags;
|
|
400
|
+
return src->options.flags;
|
|
399
401
|
}
|
|
400
402
|
|
|
401
403
|
static int filter_list_new(
|
|
@@ -415,7 +417,8 @@ static int filter_list_new(
|
|
|
415
417
|
fl->source.repo = src->repo;
|
|
416
418
|
fl->source.path = fl->path;
|
|
417
419
|
fl->source.mode = src->mode;
|
|
418
|
-
|
|
420
|
+
|
|
421
|
+
memcpy(&fl->source.options, &src->options, sizeof(git_filter_options));
|
|
419
422
|
|
|
420
423
|
*out = fl;
|
|
421
424
|
return 0;
|
|
@@ -424,25 +427,30 @@ static int filter_list_new(
|
|
|
424
427
|
static int filter_list_check_attributes(
|
|
425
428
|
const char ***out,
|
|
426
429
|
git_repository *repo,
|
|
427
|
-
|
|
430
|
+
git_filter_session *filter_session,
|
|
428
431
|
git_filter_def *fdef,
|
|
429
432
|
const git_filter_source *src)
|
|
430
433
|
{
|
|
431
434
|
const char **strs = git__calloc(fdef->nattrs, sizeof(const char *));
|
|
432
|
-
|
|
435
|
+
git_attr_options attr_opts = GIT_ATTR_OPTIONS_INIT;
|
|
433
436
|
size_t i;
|
|
434
437
|
int error;
|
|
435
438
|
|
|
436
439
|
GIT_ERROR_CHECK_ALLOC(strs);
|
|
437
440
|
|
|
438
|
-
if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
|
|
439
|
-
flags |= GIT_ATTR_CHECK_NO_SYSTEM;
|
|
441
|
+
if ((src->options.flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
|
|
442
|
+
attr_opts.flags |= GIT_ATTR_CHECK_NO_SYSTEM;
|
|
443
|
+
|
|
444
|
+
if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
|
|
445
|
+
attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_HEAD;
|
|
440
446
|
|
|
441
|
-
if ((src->flags &
|
|
442
|
-
flags |=
|
|
447
|
+
if ((src->options.flags & GIT_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) {
|
|
448
|
+
attr_opts.flags |= GIT_ATTR_CHECK_INCLUDE_COMMIT;
|
|
449
|
+
attr_opts.commit_id = src->options.commit_id;
|
|
450
|
+
}
|
|
443
451
|
|
|
444
452
|
error = git_attr_get_many_with_session(
|
|
445
|
-
strs, repo, attr_session,
|
|
453
|
+
strs, repo, filter_session->attr_session, &attr_opts, src->path, fdef->nattrs, fdef->attrs);
|
|
446
454
|
|
|
447
455
|
/* if no values were found but no matches are needed, it's okay! */
|
|
448
456
|
if (error == GIT_ENOTFOUND && !fdef->nmatches) {
|
|
@@ -487,17 +495,17 @@ int git_filter_list_new(
|
|
|
487
495
|
src.repo = repo;
|
|
488
496
|
src.path = NULL;
|
|
489
497
|
src.mode = mode;
|
|
490
|
-
src.flags = flags;
|
|
498
|
+
src.options.flags = flags;
|
|
491
499
|
return filter_list_new(out, &src);
|
|
492
500
|
}
|
|
493
501
|
|
|
494
|
-
int
|
|
502
|
+
int git_filter_list__load(
|
|
495
503
|
git_filter_list **filters,
|
|
496
504
|
git_repository *repo,
|
|
497
505
|
git_blob *blob, /* can be NULL */
|
|
498
506
|
const char *path,
|
|
499
507
|
git_filter_mode_t mode,
|
|
500
|
-
|
|
508
|
+
git_filter_session *filter_session)
|
|
501
509
|
{
|
|
502
510
|
int error = 0;
|
|
503
511
|
git_filter_list *fl = NULL;
|
|
@@ -514,7 +522,8 @@ int git_filter_list__load_ext(
|
|
|
514
522
|
src.repo = repo;
|
|
515
523
|
src.path = path;
|
|
516
524
|
src.mode = mode;
|
|
517
|
-
|
|
525
|
+
|
|
526
|
+
memcpy(&src.options, &filter_session->options, sizeof(git_filter_options));
|
|
518
527
|
|
|
519
528
|
if (blob)
|
|
520
529
|
git_oid_cpy(&src.oid, git_blob_id(blob));
|
|
@@ -528,7 +537,8 @@ int git_filter_list__load_ext(
|
|
|
528
537
|
|
|
529
538
|
if (fdef->nattrs > 0) {
|
|
530
539
|
error = filter_list_check_attributes(
|
|
531
|
-
&values, repo,
|
|
540
|
+
&values, repo,
|
|
541
|
+
filter_session, fdef, &src);
|
|
532
542
|
|
|
533
543
|
if (error == GIT_ENOTFOUND) {
|
|
534
544
|
error = 0;
|
|
@@ -555,7 +565,7 @@ int git_filter_list__load_ext(
|
|
|
555
565
|
if ((error = filter_list_new(&fl, &src)) < 0)
|
|
556
566
|
break;
|
|
557
567
|
|
|
558
|
-
fl->temp_buf =
|
|
568
|
+
fl->temp_buf = filter_session->temp_buf;
|
|
559
569
|
}
|
|
560
570
|
|
|
561
571
|
fe = git_array_alloc(fl->filters);
|
|
@@ -579,6 +589,23 @@ int git_filter_list__load_ext(
|
|
|
579
589
|
return error;
|
|
580
590
|
}
|
|
581
591
|
|
|
592
|
+
int git_filter_list_load_ext(
|
|
593
|
+
git_filter_list **filters,
|
|
594
|
+
git_repository *repo,
|
|
595
|
+
git_blob *blob, /* can be NULL */
|
|
596
|
+
const char *path,
|
|
597
|
+
git_filter_mode_t mode,
|
|
598
|
+
git_filter_options *opts)
|
|
599
|
+
{
|
|
600
|
+
git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
|
|
601
|
+
|
|
602
|
+
if (opts)
|
|
603
|
+
memcpy(&filter_session.options, opts, sizeof(git_filter_options));
|
|
604
|
+
|
|
605
|
+
return git_filter_list__load(
|
|
606
|
+
filters, repo, blob, path, mode, &filter_session);
|
|
607
|
+
}
|
|
608
|
+
|
|
582
609
|
int git_filter_list_load(
|
|
583
610
|
git_filter_list **filters,
|
|
584
611
|
git_repository *repo,
|
|
@@ -587,12 +614,12 @@ int git_filter_list_load(
|
|
|
587
614
|
git_filter_mode_t mode,
|
|
588
615
|
uint32_t flags)
|
|
589
616
|
{
|
|
590
|
-
|
|
617
|
+
git_filter_session filter_session = GIT_FILTER_SESSION_INIT;
|
|
591
618
|
|
|
592
|
-
|
|
619
|
+
filter_session.options.flags = flags;
|
|
593
620
|
|
|
594
|
-
return
|
|
595
|
-
filters, repo, blob, path, mode, &
|
|
621
|
+
return git_filter_list__load(
|
|
622
|
+
filters, repo, blob, path, mode, &filter_session);
|
|
596
623
|
}
|
|
597
624
|
|
|
598
625
|
void git_filter_list_free(git_filter_list *fl)
|
|
@@ -618,7 +645,7 @@ int git_filter_list_contains(
|
|
|
618
645
|
{
|
|
619
646
|
size_t i;
|
|
620
647
|
|
|
621
|
-
|
|
648
|
+
GIT_ASSERT_ARG(name);
|
|
622
649
|
|
|
623
650
|
if (!fl)
|
|
624
651
|
return 0;
|
|
@@ -639,7 +666,8 @@ int git_filter_list_push(
|
|
|
639
666
|
git_filter_def *fdef = NULL;
|
|
640
667
|
git_filter_entry *fe;
|
|
641
668
|
|
|
642
|
-
|
|
669
|
+
GIT_ASSERT_ARG(fl);
|
|
670
|
+
GIT_ASSERT_ARG(filter);
|
|
643
671
|
|
|
644
672
|
if (git_rwlock_rdlock(&filter_registry.lock) < 0) {
|
|
645
673
|
git_error_set(GIT_ERROR_OS, "failed to lock filter registry");
|
|
@@ -684,9 +712,8 @@ static int buf_stream_write(
|
|
|
684
712
|
git_writestream *s, const char *buffer, size_t len)
|
|
685
713
|
{
|
|
686
714
|
struct buf_stream *buf_stream = (struct buf_stream *)s;
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
assert(buf_stream->complete == 0);
|
|
715
|
+
GIT_ASSERT_ARG(buf_stream);
|
|
716
|
+
GIT_ASSERT(buf_stream->complete == 0);
|
|
690
717
|
|
|
691
718
|
return git_buf_put(buf_stream->target, buffer, len);
|
|
692
719
|
}
|
|
@@ -694,9 +721,9 @@ static int buf_stream_write(
|
|
|
694
721
|
static int buf_stream_close(git_writestream *s)
|
|
695
722
|
{
|
|
696
723
|
struct buf_stream *buf_stream = (struct buf_stream *)s;
|
|
697
|
-
|
|
724
|
+
GIT_ASSERT_ARG(buf_stream);
|
|
698
725
|
|
|
699
|
-
|
|
726
|
+
GIT_ASSERT(buf_stream->complete == 0);
|
|
700
727
|
buf_stream->complete = 1;
|
|
701
728
|
|
|
702
729
|
return 0;
|
|
@@ -719,27 +746,47 @@ static void buf_stream_init(struct buf_stream *writer, git_buf *target)
|
|
|
719
746
|
git_buf_clear(target);
|
|
720
747
|
}
|
|
721
748
|
|
|
722
|
-
int
|
|
723
|
-
git_buf *
|
|
749
|
+
int git_filter_list_apply_to_buffer(
|
|
750
|
+
git_buf *out,
|
|
751
|
+
git_filter_list *filters,
|
|
752
|
+
const char *in,
|
|
753
|
+
size_t in_len)
|
|
724
754
|
{
|
|
725
755
|
struct buf_stream writer;
|
|
726
756
|
int error;
|
|
727
757
|
|
|
728
|
-
git_buf_sanitize(
|
|
729
|
-
|
|
758
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
|
759
|
+
return error;
|
|
730
760
|
|
|
731
|
-
|
|
732
|
-
|
|
761
|
+
buf_stream_init(&writer, out);
|
|
762
|
+
|
|
763
|
+
if ((error = git_filter_list_stream_buffer(filters,
|
|
764
|
+
in, in_len, &writer.parent)) < 0)
|
|
765
|
+
return error;
|
|
766
|
+
|
|
767
|
+
GIT_ASSERT(writer.complete);
|
|
768
|
+
return error;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
int git_filter_list__convert_buf(
|
|
772
|
+
git_buf *out,
|
|
773
|
+
git_filter_list *filters,
|
|
774
|
+
git_buf *in)
|
|
775
|
+
{
|
|
776
|
+
int error;
|
|
777
|
+
|
|
778
|
+
if (!filters || git_filter_list_length(filters) == 0) {
|
|
779
|
+
git_buf_swap(out, in);
|
|
780
|
+
git_buf_dispose(in);
|
|
733
781
|
return 0;
|
|
734
782
|
}
|
|
735
783
|
|
|
736
|
-
|
|
784
|
+
error = git_filter_list_apply_to_buffer(out, filters,
|
|
785
|
+
in->ptr, in->size);
|
|
737
786
|
|
|
738
|
-
if (
|
|
739
|
-
|
|
740
|
-
return error;
|
|
787
|
+
if (!error)
|
|
788
|
+
git_buf_dispose(in);
|
|
741
789
|
|
|
742
|
-
assert(writer.complete);
|
|
743
790
|
return error;
|
|
744
791
|
}
|
|
745
792
|
|
|
@@ -758,7 +805,7 @@ int git_filter_list_apply_to_file(
|
|
|
758
805
|
filters, repo, path, &writer.parent)) < 0)
|
|
759
806
|
return error;
|
|
760
807
|
|
|
761
|
-
|
|
808
|
+
GIT_ASSERT(writer.complete);
|
|
762
809
|
return error;
|
|
763
810
|
}
|
|
764
811
|
|
|
@@ -789,13 +836,14 @@ int git_filter_list_apply_to_blob(
|
|
|
789
836
|
filters, blob, &writer.parent)) < 0)
|
|
790
837
|
return error;
|
|
791
838
|
|
|
792
|
-
|
|
839
|
+
GIT_ASSERT(writer.complete);
|
|
793
840
|
return error;
|
|
794
841
|
}
|
|
795
842
|
|
|
796
|
-
struct
|
|
843
|
+
struct buffered_stream {
|
|
797
844
|
git_writestream parent;
|
|
798
845
|
git_filter *filter;
|
|
846
|
+
int (*write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *);
|
|
799
847
|
const git_filter_source *source;
|
|
800
848
|
void **payload;
|
|
801
849
|
git_buf input;
|
|
@@ -804,89 +852,120 @@ struct proxy_stream {
|
|
|
804
852
|
git_writestream *target;
|
|
805
853
|
};
|
|
806
854
|
|
|
807
|
-
static int
|
|
855
|
+
static int buffered_stream_write(
|
|
808
856
|
git_writestream *s, const char *buffer, size_t len)
|
|
809
857
|
{
|
|
810
|
-
struct
|
|
811
|
-
|
|
858
|
+
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
|
|
859
|
+
GIT_ASSERT_ARG(buffered_stream);
|
|
812
860
|
|
|
813
|
-
return git_buf_put(&
|
|
861
|
+
return git_buf_put(&buffered_stream->input, buffer, len);
|
|
814
862
|
}
|
|
815
863
|
|
|
816
|
-
static int
|
|
864
|
+
static int buffered_stream_close(git_writestream *s)
|
|
817
865
|
{
|
|
818
|
-
struct
|
|
866
|
+
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
|
|
819
867
|
git_buf *writebuf;
|
|
820
868
|
git_error_state error_state = {0};
|
|
821
869
|
int error;
|
|
822
870
|
|
|
823
|
-
|
|
871
|
+
GIT_ASSERT_ARG(buffered_stream);
|
|
824
872
|
|
|
825
|
-
error =
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
&
|
|
830
|
-
|
|
873
|
+
error = buffered_stream->write_fn(
|
|
874
|
+
buffered_stream->filter,
|
|
875
|
+
buffered_stream->payload,
|
|
876
|
+
buffered_stream->output,
|
|
877
|
+
&buffered_stream->input,
|
|
878
|
+
buffered_stream->source);
|
|
831
879
|
|
|
832
880
|
if (error == GIT_PASSTHROUGH) {
|
|
833
|
-
writebuf = &
|
|
881
|
+
writebuf = &buffered_stream->input;
|
|
834
882
|
} else if (error == 0) {
|
|
835
|
-
git_buf_sanitize(
|
|
836
|
-
|
|
883
|
+
if ((error = git_buf_sanitize(buffered_stream->output)) < 0)
|
|
884
|
+
return error;
|
|
885
|
+
|
|
886
|
+
writebuf = buffered_stream->output;
|
|
837
887
|
} else {
|
|
838
888
|
/* close stream before erroring out taking care
|
|
839
889
|
* to preserve the original error */
|
|
840
890
|
git_error_state_capture(&error_state, error);
|
|
841
|
-
|
|
891
|
+
buffered_stream->target->close(buffered_stream->target);
|
|
842
892
|
git_error_state_restore(&error_state);
|
|
843
893
|
return error;
|
|
844
894
|
}
|
|
845
895
|
|
|
846
|
-
if ((error =
|
|
847
|
-
|
|
848
|
-
error =
|
|
896
|
+
if ((error = buffered_stream->target->write(
|
|
897
|
+
buffered_stream->target, writebuf->ptr, writebuf->size)) == 0)
|
|
898
|
+
error = buffered_stream->target->close(buffered_stream->target);
|
|
849
899
|
|
|
850
900
|
return error;
|
|
851
901
|
}
|
|
852
902
|
|
|
853
|
-
static void
|
|
903
|
+
static void buffered_stream_free(git_writestream *s)
|
|
854
904
|
{
|
|
855
|
-
struct
|
|
856
|
-
assert(proxy_stream);
|
|
905
|
+
struct buffered_stream *buffered_stream = (struct buffered_stream *)s;
|
|
857
906
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
907
|
+
if (buffered_stream) {
|
|
908
|
+
git_buf_dispose(&buffered_stream->input);
|
|
909
|
+
git_buf_dispose(&buffered_stream->temp_buf);
|
|
910
|
+
git__free(buffered_stream);
|
|
911
|
+
}
|
|
861
912
|
}
|
|
862
913
|
|
|
863
|
-
|
|
914
|
+
int git_filter_buffered_stream_new(
|
|
864
915
|
git_writestream **out,
|
|
865
916
|
git_filter *filter,
|
|
917
|
+
int (*write_fn)(git_filter *, void **, git_buf *, const git_buf *, const git_filter_source *),
|
|
866
918
|
git_buf *temp_buf,
|
|
867
919
|
void **payload,
|
|
868
920
|
const git_filter_source *source,
|
|
869
921
|
git_writestream *target)
|
|
870
922
|
{
|
|
871
|
-
struct
|
|
872
|
-
GIT_ERROR_CHECK_ALLOC(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
923
|
+
struct buffered_stream *buffered_stream = git__calloc(1, sizeof(struct buffered_stream));
|
|
924
|
+
GIT_ERROR_CHECK_ALLOC(buffered_stream);
|
|
925
|
+
|
|
926
|
+
buffered_stream->parent.write = buffered_stream_write;
|
|
927
|
+
buffered_stream->parent.close = buffered_stream_close;
|
|
928
|
+
buffered_stream->parent.free = buffered_stream_free;
|
|
929
|
+
buffered_stream->filter = filter;
|
|
930
|
+
buffered_stream->write_fn = write_fn;
|
|
931
|
+
buffered_stream->output = temp_buf ? temp_buf : &buffered_stream->temp_buf;
|
|
932
|
+
buffered_stream->payload = payload;
|
|
933
|
+
buffered_stream->source = source;
|
|
934
|
+
buffered_stream->target = target;
|
|
882
935
|
|
|
883
936
|
if (temp_buf)
|
|
884
937
|
git_buf_clear(temp_buf);
|
|
885
938
|
|
|
886
|
-
*out = (git_writestream *)
|
|
939
|
+
*out = (git_writestream *)buffered_stream;
|
|
887
940
|
return 0;
|
|
888
941
|
}
|
|
889
942
|
|
|
943
|
+
static int setup_stream(
|
|
944
|
+
git_writestream **out,
|
|
945
|
+
git_filter_entry *fe,
|
|
946
|
+
git_filter_list *filters,
|
|
947
|
+
git_writestream *last_stream)
|
|
948
|
+
{
|
|
949
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
950
|
+
GIT_ASSERT(fe->filter->stream || fe->filter->apply);
|
|
951
|
+
|
|
952
|
+
/*
|
|
953
|
+
* If necessary, create a stream that proxies the traditional
|
|
954
|
+
* application.
|
|
955
|
+
*/
|
|
956
|
+
if (!fe->filter->stream) {
|
|
957
|
+
/* Create a stream that proxies the one-shot apply */
|
|
958
|
+
return git_filter_buffered_stream_new(out,
|
|
959
|
+
fe->filter, fe->filter->apply, filters->temp_buf,
|
|
960
|
+
&fe->payload, &filters->source, last_stream);
|
|
961
|
+
}
|
|
962
|
+
#endif
|
|
963
|
+
|
|
964
|
+
GIT_ASSERT(fe->filter->stream);
|
|
965
|
+
return fe->filter->stream(out, fe->filter,
|
|
966
|
+
&fe->payload, &filters->source, last_stream);
|
|
967
|
+
}
|
|
968
|
+
|
|
890
969
|
static int stream_list_init(
|
|
891
970
|
git_writestream **out,
|
|
892
971
|
git_vector *streams,
|
|
@@ -908,22 +987,11 @@ static int stream_list_init(
|
|
|
908
987
|
for (i = 0; i < git_array_size(filters->filters); ++i) {
|
|
909
988
|
size_t filter_idx = (filters->source.mode == GIT_FILTER_TO_WORKTREE) ?
|
|
910
989
|
git_array_size(filters->filters) - 1 - i : i;
|
|
990
|
+
|
|
911
991
|
git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
|
|
912
992
|
git_writestream *filter_stream;
|
|
913
993
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
/* If necessary, create a stream that proxies the traditional
|
|
917
|
-
* application.
|
|
918
|
-
*/
|
|
919
|
-
if (fe->filter->stream)
|
|
920
|
-
error = fe->filter->stream(&filter_stream, fe->filter,
|
|
921
|
-
&fe->payload, &filters->source, last_stream);
|
|
922
|
-
else
|
|
923
|
-
/* Create a stream that proxies the one-shot apply */
|
|
924
|
-
error = proxy_stream_init(&filter_stream, fe->filter,
|
|
925
|
-
filters->temp_buf, &fe->payload, &filters->source,
|
|
926
|
-
last_stream);
|
|
994
|
+
error = setup_stream(&filter_stream, fe, filters, last_stream);
|
|
927
995
|
|
|
928
996
|
if (error < 0)
|
|
929
997
|
goto out;
|
|
@@ -941,7 +1009,7 @@ out:
|
|
|
941
1009
|
return error;
|
|
942
1010
|
}
|
|
943
1011
|
|
|
944
|
-
void
|
|
1012
|
+
static void filter_streams_free(git_vector *streams)
|
|
945
1013
|
{
|
|
946
1014
|
git_writestream *stream;
|
|
947
1015
|
size_t i;
|
|
@@ -967,8 +1035,10 @@ int git_filter_list_stream_file(
|
|
|
967
1035
|
|
|
968
1036
|
if ((error = stream_list_init(
|
|
969
1037
|
&stream_start, &filter_streams, filters, target)) < 0 ||
|
|
970
|
-
|
|
1038
|
+
(error = git_path_join_unrooted(&abspath, path, base, NULL)) < 0 ||
|
|
1039
|
+
(error = git_path_validate_workdir_buf(repo, &abspath)) < 0)
|
|
971
1040
|
goto done;
|
|
1041
|
+
|
|
972
1042
|
initialized = 1;
|
|
973
1043
|
|
|
974
1044
|
if ((fd = git_futils_open_ro(abspath.ptr)) < 0) {
|
|
@@ -990,35 +1060,33 @@ done:
|
|
|
990
1060
|
|
|
991
1061
|
if (fd >= 0)
|
|
992
1062
|
p_close(fd);
|
|
993
|
-
|
|
1063
|
+
filter_streams_free(&filter_streams);
|
|
994
1064
|
git_buf_dispose(&abspath);
|
|
995
1065
|
return error;
|
|
996
1066
|
}
|
|
997
1067
|
|
|
998
|
-
int
|
|
1068
|
+
int git_filter_list_stream_buffer(
|
|
999
1069
|
git_filter_list *filters,
|
|
1000
|
-
|
|
1070
|
+
const char *buffer,
|
|
1071
|
+
size_t len,
|
|
1001
1072
|
git_writestream *target)
|
|
1002
1073
|
{
|
|
1003
1074
|
git_vector filter_streams = GIT_VECTOR_INIT;
|
|
1004
1075
|
git_writestream *stream_start;
|
|
1005
1076
|
int error, initialized = 0;
|
|
1006
1077
|
|
|
1007
|
-
git_buf_sanitize(data);
|
|
1008
|
-
|
|
1009
1078
|
if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
|
|
1010
1079
|
goto out;
|
|
1011
1080
|
initialized = 1;
|
|
1012
1081
|
|
|
1013
|
-
if ((error = stream_start->write(
|
|
1014
|
-
stream_start, data->ptr, data->size)) < 0)
|
|
1082
|
+
if ((error = stream_start->write(stream_start, buffer, len)) < 0)
|
|
1015
1083
|
goto out;
|
|
1016
1084
|
|
|
1017
1085
|
out:
|
|
1018
1086
|
if (initialized)
|
|
1019
1087
|
error |= stream_start->close(stream_start);
|
|
1020
1088
|
|
|
1021
|
-
|
|
1089
|
+
filter_streams_free(&filter_streams);
|
|
1022
1090
|
return error;
|
|
1023
1091
|
}
|
|
1024
1092
|
|
|
@@ -1035,7 +1103,7 @@ int git_filter_list_stream_blob(
|
|
|
1035
1103
|
if (filters)
|
|
1036
1104
|
git_oid_cpy(&filters->source.oid, git_blob_id(blob));
|
|
1037
1105
|
|
|
1038
|
-
return
|
|
1106
|
+
return git_filter_list_stream_buffer(filters, in.ptr, in.size, target);
|
|
1039
1107
|
}
|
|
1040
1108
|
|
|
1041
1109
|
int git_filter_init(git_filter *filter, unsigned int version)
|
|
@@ -1043,3 +1111,31 @@ int git_filter_init(git_filter *filter, unsigned int version)
|
|
|
1043
1111
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);
|
|
1044
1112
|
return 0;
|
|
1045
1113
|
}
|
|
1114
|
+
|
|
1115
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
1116
|
+
|
|
1117
|
+
int git_filter_list_stream_data(
|
|
1118
|
+
git_filter_list *filters,
|
|
1119
|
+
git_buf *data,
|
|
1120
|
+
git_writestream *target)
|
|
1121
|
+
{
|
|
1122
|
+
int error;
|
|
1123
|
+
|
|
1124
|
+
if ((error = git_buf_sanitize(data)) < 0)
|
|
1125
|
+
return error;
|
|
1126
|
+
|
|
1127
|
+
return git_filter_list_stream_buffer(filters, data->ptr, data->size, target);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
int git_filter_list_apply_to_data(
|
|
1131
|
+
git_buf *tgt, git_filter_list *filters, git_buf *src)
|
|
1132
|
+
{
|
|
1133
|
+
int error;
|
|
1134
|
+
|
|
1135
|
+
if ((error = git_buf_sanitize(src)) < 0)
|
|
1136
|
+
return error;
|
|
1137
|
+
|
|
1138
|
+
return git_filter_list_apply_to_buffer(tgt, filters, src->ptr, src->size);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
#endif
|