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/ignore.c
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
#include "attrcache.h"
|
13
13
|
#include "path.h"
|
14
14
|
#include "config.h"
|
15
|
-
#include "
|
15
|
+
#include "wildmatch.h"
|
16
16
|
|
17
17
|
#define GIT_IGNORE_INTERNAL "[internal]exclude"
|
18
18
|
|
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
|
|
101
101
|
*/
|
102
102
|
static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
|
103
103
|
{
|
104
|
-
int error = 0,
|
104
|
+
int error = 0, wildmatch_flags;
|
105
105
|
size_t i;
|
106
106
|
git_attr_fnmatch *rule;
|
107
107
|
char *path;
|
@@ -109,9 +109,9 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
|
|
109
109
|
|
110
110
|
*out = 0;
|
111
111
|
|
112
|
-
|
112
|
+
wildmatch_flags = WM_PATHNAME;
|
113
113
|
if (match->flags & GIT_ATTR_FNMATCH_ICASE)
|
114
|
-
|
114
|
+
wildmatch_flags |= WM_CASEFOLD;
|
115
115
|
|
116
116
|
/* path of the file relative to the workdir, so we match the rules in subdirs */
|
117
117
|
if (match->containing_dir) {
|
@@ -141,13 +141,8 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
|
|
141
141
|
if (git_buf_oom(&buf))
|
142
142
|
goto out;
|
143
143
|
|
144
|
-
if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {
|
145
|
-
giterr_set(GITERR_INVALID, "error matching pattern");
|
146
|
-
goto out;
|
147
|
-
}
|
148
|
-
|
149
144
|
/* if we found a match, we want to keep this rule */
|
150
|
-
if (
|
145
|
+
if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
|
151
146
|
*out = 1;
|
152
147
|
error = 0;
|
153
148
|
goto out;
|
@@ -158,20 +153,22 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
|
|
158
153
|
|
159
154
|
out:
|
160
155
|
git__free(path);
|
161
|
-
|
156
|
+
git_buf_dispose(&buf);
|
162
157
|
return error;
|
163
158
|
}
|
164
159
|
|
165
160
|
static int parse_ignore_file(
|
166
|
-
git_repository *repo, git_attr_file *attrs, const char *data)
|
161
|
+
git_repository *repo, git_attr_file *attrs, const char *data, bool allow_macros)
|
167
162
|
{
|
168
163
|
int error = 0;
|
169
164
|
int ignore_case = false;
|
170
165
|
const char *scan = data, *context = NULL;
|
171
166
|
git_attr_fnmatch *match = NULL;
|
172
167
|
|
173
|
-
|
174
|
-
|
168
|
+
GIT_UNUSED(allow_macros);
|
169
|
+
|
170
|
+
if (git_repository__configmap_lookup(&ignore_case, repo, GIT_CONFIGMAP_IGNORECASE) < 0)
|
171
|
+
git_error_clear();
|
175
172
|
|
176
173
|
/* if subdir file path, convert context for file paths */
|
177
174
|
if (attrs->entry &&
|
@@ -180,7 +177,7 @@ static int parse_ignore_file(
|
|
180
177
|
context = attrs->entry->path;
|
181
178
|
|
182
179
|
if (git_mutex_lock(&attrs->lock) < 0) {
|
183
|
-
|
180
|
+
git_error_set(GIT_ERROR_OS, "failed to lock ignore file");
|
184
181
|
return -1;
|
185
182
|
}
|
186
183
|
|
@@ -193,9 +190,7 @@ static int parse_ignore_file(
|
|
193
190
|
}
|
194
191
|
|
195
192
|
match->flags =
|
196
|
-
GIT_ATTR_FNMATCH_ALLOWSPACE |
|
197
|
-
GIT_ATTR_FNMATCH_ALLOWNEG |
|
198
|
-
GIT_ATTR_FNMATCH_NOLEADINGDIR;
|
193
|
+
GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG;
|
199
194
|
|
200
195
|
if (!(error = git_attr_fnmatch__parse(
|
201
196
|
match, &attrs->pool, context, &scan)))
|
@@ -246,9 +241,8 @@ static int push_ignore_file(
|
|
246
241
|
int error = 0;
|
247
242
|
git_attr_file *file = NULL;
|
248
243
|
|
249
|
-
error = git_attr_cache__get(
|
250
|
-
|
251
|
-
base, filename, parse_ignore_file);
|
244
|
+
error = git_attr_cache__get(&file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE,
|
245
|
+
base, filename, parse_ignore_file, false);
|
252
246
|
if (error < 0)
|
253
247
|
return error;
|
254
248
|
|
@@ -274,12 +268,12 @@ static int get_internal_ignores(git_attr_file **out, git_repository *repo)
|
|
274
268
|
if ((error = git_attr_cache__init(repo)) < 0)
|
275
269
|
return error;
|
276
270
|
|
277
|
-
error = git_attr_cache__get(
|
278
|
-
|
271
|
+
error = git_attr_cache__get(out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL,
|
272
|
+
GIT_IGNORE_INTERNAL, NULL, false);
|
279
273
|
|
280
274
|
/* if internal rules list is empty, insert default rules */
|
281
275
|
if (!error && !(*out)->rules.length)
|
282
|
-
error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES);
|
276
|
+
error = parse_ignore_file(repo, *out, GIT_IGNORE_DEFAULT_RULES, false);
|
283
277
|
|
284
278
|
return error;
|
285
279
|
}
|
@@ -299,8 +293,8 @@ int git_ignore__for_path(
|
|
299
293
|
ignores->repo = repo;
|
300
294
|
|
301
295
|
/* Read the ignore_case flag */
|
302
|
-
if ((error =
|
303
|
-
&ignores->ignore_case, repo,
|
296
|
+
if ((error = git_repository__configmap_lookup(
|
297
|
+
&ignores->ignore_case, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
|
304
298
|
goto cleanup;
|
305
299
|
|
306
300
|
if ((error = git_attr_cache__init(repo)) < 0)
|
@@ -315,7 +309,7 @@ int git_ignore__for_path(
|
|
315
309
|
(error = git_path_to_dir(&local)) < 0 ||
|
316
310
|
(error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0)
|
317
311
|
{;} /* Nothing, we just want to stop on the first error */
|
318
|
-
|
312
|
+
git_buf_dispose(&local);
|
319
313
|
} else {
|
320
314
|
error = git_buf_joinpath(&ignores->dir, path, "");
|
321
315
|
}
|
@@ -337,16 +331,13 @@ int git_ignore__for_path(
|
|
337
331
|
goto cleanup;
|
338
332
|
}
|
339
333
|
|
340
|
-
if
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
infopath.ptr, GIT_IGNORE_FILE_INREPO);
|
348
|
-
if (error < 0)
|
349
|
-
goto cleanup;
|
334
|
+
/* load .git/info/exclude if possible */
|
335
|
+
if ((error = git_repository_item_path(&infopath, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
|
336
|
+
(error = push_ignore_file(ignores, &ignores->ign_global, infopath.ptr, GIT_IGNORE_FILE_INREPO)) < 0) {
|
337
|
+
if (error != GIT_ENOTFOUND)
|
338
|
+
goto cleanup;
|
339
|
+
error = 0;
|
340
|
+
}
|
350
341
|
|
351
342
|
/* load core.excludesfile */
|
352
343
|
if (git_repository_attr_cache(repo)->cfg_excl_file != NULL)
|
@@ -355,7 +346,7 @@ int git_ignore__for_path(
|
|
355
346
|
git_repository_attr_cache(repo)->cfg_excl_file);
|
356
347
|
|
357
348
|
cleanup:
|
358
|
-
|
349
|
+
git_buf_dispose(&infopath);
|
359
350
|
if (error < 0)
|
360
351
|
git_ignore__free(ignores);
|
361
352
|
|
@@ -427,7 +418,7 @@ void git_ignore__free(git_ignores *ignores)
|
|
427
418
|
}
|
428
419
|
git_vector_free(&ignores->ign_global);
|
429
420
|
|
430
|
-
|
421
|
+
git_buf_dispose(&ignores->dir);
|
431
422
|
}
|
432
423
|
|
433
424
|
static bool ignore_lookup_in_rules(
|
@@ -453,7 +444,7 @@ static bool ignore_lookup_in_rules(
|
|
453
444
|
int git_ignore__lookup(
|
454
445
|
int *out, git_ignores *ignores, const char *pathname, git_dir_flag dir_flag)
|
455
446
|
{
|
456
|
-
|
447
|
+
size_t i;
|
457
448
|
git_attr_file *file;
|
458
449
|
git_attr_path path;
|
459
450
|
|
@@ -467,8 +458,11 @@ int git_ignore__lookup(
|
|
467
458
|
if (ignore_lookup_in_rules(out, ignores->ign_internal, &path))
|
468
459
|
goto cleanup;
|
469
460
|
|
470
|
-
/* next process files in the path
|
471
|
-
|
461
|
+
/* next process files in the path.
|
462
|
+
* this process has to process ignores in reverse order
|
463
|
+
* to ensure correct prioritization of rules
|
464
|
+
*/
|
465
|
+
git_vector_rforeach(&ignores->ign_path, i, file) {
|
472
466
|
if (ignore_lookup_in_rules(out, file, &path))
|
473
467
|
goto cleanup;
|
474
468
|
}
|
@@ -492,7 +486,7 @@ int git_ignore_add_rule(git_repository *repo, const char *rules)
|
|
492
486
|
if ((error = get_internal_ignores(&ign_internal, repo)) < 0)
|
493
487
|
return error;
|
494
488
|
|
495
|
-
error = parse_ignore_file(repo, ign_internal, rules);
|
489
|
+
error = parse_ignore_file(repo, ign_internal, rules, false);
|
496
490
|
git_attr_file__free(ign_internal);
|
497
491
|
|
498
492
|
return error;
|
@@ -508,7 +502,7 @@ int git_ignore_clear_internal_rules(git_repository *repo)
|
|
508
502
|
|
509
503
|
if (!(error = git_attr_file__clear_rules(ign_internal, true)))
|
510
504
|
error = parse_ignore_file(
|
511
|
-
|
505
|
+
repo, ign_internal, GIT_IGNORE_DEFAULT_RULES, false);
|
512
506
|
|
513
507
|
git_attr_file__free(ign_internal);
|
514
508
|
return error;
|
@@ -534,7 +528,9 @@ int git_ignore_path_is_ignored(
|
|
534
528
|
memset(&path, 0, sizeof(path));
|
535
529
|
memset(&ignores, 0, sizeof(ignores));
|
536
530
|
|
537
|
-
if (
|
531
|
+
if (!git__suffixcmp(pathname, "/"))
|
532
|
+
dir_flag = GIT_DIR_FLAG_TRUE;
|
533
|
+
else if (git_repository_is_bare(repo))
|
538
534
|
dir_flag = GIT_DIR_FLAG_FALSE;
|
539
535
|
|
540
536
|
if ((error = git_attr_path__init(&path, pathname, workdir, dir_flag)) < 0 ||
|
@@ -624,7 +620,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
|
|
624
620
|
break;
|
625
621
|
|
626
622
|
if (ignored) {
|
627
|
-
|
623
|
+
git_error_set(GIT_ERROR_INVALID, "pathspec contains ignored file '%s'",
|
628
624
|
filename);
|
629
625
|
error = GIT_EINVALIDSPEC;
|
630
626
|
break;
|
@@ -632,7 +628,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
|
|
632
628
|
}
|
633
629
|
|
634
630
|
git_index_free(idx);
|
635
|
-
|
631
|
+
git_buf_dispose(&path);
|
636
632
|
|
637
633
|
return error;
|
638
634
|
}
|
data/vendor/libgit2/src/index.c
CHANGED
@@ -29,23 +29,23 @@
|
|
29
29
|
|
30
30
|
#define INSERT_IN_MAP_EX(idx, map, e, err) do { \
|
31
31
|
if ((idx)->ignore_case) \
|
32
|
-
|
32
|
+
(err) = git_idxmap_icase_set((git_idxmap_icase *) (map), (e), (e)); \
|
33
33
|
else \
|
34
|
-
|
34
|
+
(err) = git_idxmap_set((map), (e), (e)); \
|
35
35
|
} while (0)
|
36
36
|
|
37
37
|
#define INSERT_IN_MAP(idx, e, err) INSERT_IN_MAP_EX(idx, (idx)->entries_map, e, err)
|
38
38
|
|
39
|
-
#define LOOKUP_IN_MAP(
|
39
|
+
#define LOOKUP_IN_MAP(v, idx, k) do { \
|
40
40
|
if ((idx)->ignore_case) \
|
41
|
-
(
|
41
|
+
(v) = git_idxmap_icase_get((git_idxmap_icase *) index->entries_map, (k)); \
|
42
42
|
else \
|
43
|
-
(
|
43
|
+
(v) = git_idxmap_get(index->entries_map, (k)); \
|
44
44
|
} while (0)
|
45
45
|
|
46
46
|
#define DELETE_IN_MAP(idx, e) do { \
|
47
47
|
if ((idx)->ignore_case) \
|
48
|
-
git_idxmap_icase_delete((
|
48
|
+
git_idxmap_icase_delete((git_idxmap_icase *) (idx)->entries_map, (e)); \
|
49
49
|
else \
|
50
50
|
git_idxmap_delete((idx)->entries_map, (e)); \
|
51
51
|
} while (0)
|
@@ -135,8 +135,10 @@ struct reuc_entry_internal {
|
|
135
135
|
char path[GIT_FLEX_ARRAY];
|
136
136
|
};
|
137
137
|
|
138
|
+
bool git_index__enforce_unsaved_safety = false;
|
139
|
+
|
138
140
|
/* local declarations */
|
139
|
-
static
|
141
|
+
static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size);
|
140
142
|
static int read_header(struct index_header *dest, const void *buffer);
|
141
143
|
|
142
144
|
static int parse_index(git_index *index, const char *buffer, size_t buffer_size);
|
@@ -166,7 +168,7 @@ int git_index_entry_srch(const void *key, const void *array_member)
|
|
166
168
|
return 1;
|
167
169
|
|
168
170
|
if (srch_key->stage != GIT_INDEX_STAGE_ANY)
|
169
|
-
return srch_key->stage -
|
171
|
+
return srch_key->stage - GIT_INDEX_ENTRY_STAGE(&entry->entry);
|
170
172
|
|
171
173
|
return 0;
|
172
174
|
}
|
@@ -192,7 +194,7 @@ int git_index_entry_isrch(const void *key, const void *array_member)
|
|
192
194
|
return 1;
|
193
195
|
|
194
196
|
if (srch_key->stage != GIT_INDEX_STAGE_ANY)
|
195
|
-
return srch_key->stage -
|
197
|
+
return srch_key->stage - GIT_INDEX_ENTRY_STAGE(&entry->entry);
|
196
198
|
|
197
199
|
return 0;
|
198
200
|
}
|
@@ -220,7 +222,7 @@ int git_index_entry_cmp(const void *a, const void *b)
|
|
220
222
|
diff = strcmp(entry_a->path, entry_b->path);
|
221
223
|
|
222
224
|
if (diff == 0)
|
223
|
-
diff = (
|
225
|
+
diff = (GIT_INDEX_ENTRY_STAGE(entry_a) - GIT_INDEX_ENTRY_STAGE(entry_b));
|
224
226
|
|
225
227
|
return diff;
|
226
228
|
}
|
@@ -234,7 +236,7 @@ int git_index_entry_icmp(const void *a, const void *b)
|
|
234
236
|
diff = strcasecmp(entry_a->path, entry_b->path);
|
235
237
|
|
236
238
|
if (diff == 0)
|
237
|
-
diff = (
|
239
|
+
diff = (GIT_INDEX_ENTRY_STAGE(entry_a) - GIT_INDEX_ENTRY_STAGE(entry_b));
|
238
240
|
|
239
241
|
return diff;
|
240
242
|
}
|
@@ -406,7 +408,7 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
406
408
|
assert(index_out);
|
407
409
|
|
408
410
|
index = git__calloc(1, sizeof(git_index));
|
409
|
-
|
411
|
+
GIT_ERROR_CHECK_ALLOC(index);
|
410
412
|
|
411
413
|
git_pool_init(&index->tree_pool, 1);
|
412
414
|
|
@@ -421,10 +423,10 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
421
423
|
}
|
422
424
|
|
423
425
|
if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 ||
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
426
|
+
git_idxmap_new(&index->entries_map) < 0 ||
|
427
|
+
git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
|
428
|
+
git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
|
429
|
+
git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
|
428
430
|
goto fail;
|
429
431
|
|
430
432
|
index->entries_cmp_path = git__strcmp_cb;
|
@@ -516,6 +518,8 @@ static int index_remove_entry(git_index *index, size_t pos)
|
|
516
518
|
} else {
|
517
519
|
index_entry_free(entry);
|
518
520
|
}
|
521
|
+
|
522
|
+
index->dirty = 1;
|
519
523
|
}
|
520
524
|
|
521
525
|
return error;
|
@@ -527,6 +531,7 @@ int git_index_clear(git_index *index)
|
|
527
531
|
|
528
532
|
assert(index);
|
529
533
|
|
534
|
+
index->dirty = 1;
|
530
535
|
index->tree = NULL;
|
531
536
|
git_pool_clear(&index->tree_pool);
|
532
537
|
|
@@ -545,7 +550,7 @@ int git_index_clear(git_index *index)
|
|
545
550
|
|
546
551
|
static int create_index_error(int error, const char *msg)
|
547
552
|
{
|
548
|
-
|
553
|
+
git_error_set_str(GIT_ERROR_INDEX, msg);
|
549
554
|
return error;
|
550
555
|
}
|
551
556
|
|
@@ -557,7 +562,7 @@ int git_index_set_caps(git_index *index, int caps)
|
|
557
562
|
|
558
563
|
old_ignore_case = index->ignore_case;
|
559
564
|
|
560
|
-
if (caps ==
|
565
|
+
if (caps == GIT_INDEX_CAPABILITY_FROM_OWNER) {
|
561
566
|
git_repository *repo = INDEX_OWNER(index);
|
562
567
|
int val;
|
563
568
|
|
@@ -565,17 +570,17 @@ int git_index_set_caps(git_index *index, int caps)
|
|
565
570
|
return create_index_error(
|
566
571
|
-1, "cannot access repository to set index caps");
|
567
572
|
|
568
|
-
if (!
|
573
|
+
if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_IGNORECASE))
|
569
574
|
index->ignore_case = (val != 0);
|
570
|
-
if (!
|
575
|
+
if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_FILEMODE))
|
571
576
|
index->distrust_filemode = (val == 0);
|
572
|
-
if (!
|
577
|
+
if (!git_repository__configmap_lookup(&val, repo, GIT_CONFIGMAP_SYMLINKS))
|
573
578
|
index->no_symlinks = (val == 0);
|
574
579
|
}
|
575
580
|
else {
|
576
|
-
index->ignore_case = ((caps &
|
577
|
-
index->distrust_filemode = ((caps &
|
578
|
-
index->no_symlinks = ((caps &
|
581
|
+
index->ignore_case = ((caps & GIT_INDEX_CAPABILITY_IGNORE_CASE) != 0);
|
582
|
+
index->distrust_filemode = ((caps & GIT_INDEX_CAPABILITY_NO_FILEMODE) != 0);
|
583
|
+
index->no_symlinks = ((caps & GIT_INDEX_CAPABILITY_NO_SYMLINKS) != 0);
|
579
584
|
}
|
580
585
|
|
581
586
|
if (old_ignore_case != index->ignore_case) {
|
@@ -587,9 +592,9 @@ int git_index_set_caps(git_index *index, int caps)
|
|
587
592
|
|
588
593
|
int git_index_caps(const git_index *index)
|
589
594
|
{
|
590
|
-
return ((index->ignore_case ?
|
591
|
-
(index->distrust_filemode ?
|
592
|
-
(index->no_symlinks ?
|
595
|
+
return ((index->ignore_case ? GIT_INDEX_CAPABILITY_IGNORE_CASE : 0) |
|
596
|
+
(index->distrust_filemode ? GIT_INDEX_CAPABILITY_NO_FILEMODE : 0) |
|
597
|
+
(index->no_symlinks ? GIT_INDEX_CAPABILITY_NO_SYMLINKS : 0));
|
593
598
|
}
|
594
599
|
|
595
600
|
const git_oid *git_index_checksum(git_index *index)
|
@@ -611,7 +616,7 @@ static int compare_checksum(git_index *index)
|
|
611
616
|
|
612
617
|
if (p_lseek(fd, -20, SEEK_END) < 0) {
|
613
618
|
p_close(fd);
|
614
|
-
|
619
|
+
git_error_set(GIT_ERROR_OS, "failed to seek to end of file");
|
615
620
|
return -1;
|
616
621
|
}
|
617
622
|
|
@@ -637,19 +642,22 @@ int git_index_read(git_index *index, int force)
|
|
637
642
|
index->on_disk = git_path_exists(index->index_file_path);
|
638
643
|
|
639
644
|
if (!index->on_disk) {
|
640
|
-
if (force)
|
641
|
-
return
|
645
|
+
if (force && (error = git_index_clear(index)) < 0)
|
646
|
+
return error;
|
647
|
+
|
648
|
+
index->dirty = 0;
|
642
649
|
return 0;
|
643
650
|
}
|
644
651
|
|
645
652
|
if ((updated = git_futils_filestamp_check(&stamp, index->index_file_path) < 0) ||
|
646
653
|
((updated = compare_checksum(index)) < 0)) {
|
647
|
-
|
648
|
-
|
654
|
+
git_error_set(
|
655
|
+
GIT_ERROR_INDEX,
|
649
656
|
"failed to read index: '%s' no longer exists",
|
650
657
|
index->index_file_path);
|
651
658
|
return updated;
|
652
659
|
}
|
660
|
+
|
653
661
|
if (!updated && !force)
|
654
662
|
return 0;
|
655
663
|
|
@@ -665,19 +673,32 @@ int git_index_read(git_index *index, int force)
|
|
665
673
|
if (!error)
|
666
674
|
error = parse_index(index, buffer.ptr, buffer.size);
|
667
675
|
|
668
|
-
if (!error)
|
676
|
+
if (!error) {
|
669
677
|
git_futils_filestamp_set(&index->stamp, &stamp);
|
678
|
+
index->dirty = 0;
|
679
|
+
}
|
670
680
|
|
671
|
-
|
681
|
+
git_buf_dispose(&buffer);
|
672
682
|
return error;
|
673
683
|
}
|
674
684
|
|
685
|
+
int git_index_read_safely(git_index *index)
|
686
|
+
{
|
687
|
+
if (git_index__enforce_unsaved_safety && index->dirty) {
|
688
|
+
git_error_set(GIT_ERROR_INDEX,
|
689
|
+
"the index has unsaved changes that would be overwritten by this operation");
|
690
|
+
return GIT_EINDEXDIRTY;
|
691
|
+
}
|
692
|
+
|
693
|
+
return git_index_read(index, false);
|
694
|
+
}
|
695
|
+
|
675
696
|
int git_index__changed_relative_to(
|
676
697
|
git_index *index, const git_oid *checksum)
|
677
698
|
{
|
678
699
|
/* attempt to update index (ignoring errors) */
|
679
700
|
if (git_index_read(index, false) < 0)
|
680
|
-
|
701
|
+
git_error_clear();
|
681
702
|
|
682
703
|
return !!git_oid_cmp(&index->checksum, checksum);
|
683
704
|
}
|
@@ -715,7 +736,7 @@ static int truncate_racily_clean(git_index *index)
|
|
715
736
|
|
716
737
|
diff_opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE | GIT_DIFF_IGNORE_SUBMODULES | GIT_DIFF_DISABLE_PATHSPEC_MATCH;
|
717
738
|
git_vector_foreach(&index->entries, i, entry) {
|
718
|
-
if ((entry->flags_extended &
|
739
|
+
if ((entry->flags_extended & GIT_INDEX_ENTRY_UPTODATE) == 0 &&
|
719
740
|
is_racy_entry(index, entry))
|
720
741
|
git_vector_insert(&paths, (char *)entry->path);
|
721
742
|
}
|
@@ -735,8 +756,10 @@ static int truncate_racily_clean(git_index *index)
|
|
735
756
|
/* Ensure that we have a stage 0 for this file (ie, it's not a
|
736
757
|
* conflict), otherwise smudging it is quite pointless.
|
737
758
|
*/
|
738
|
-
if (entry)
|
759
|
+
if (entry) {
|
739
760
|
entry->file_size = 0;
|
761
|
+
index->dirty = 1;
|
762
|
+
}
|
740
763
|
}
|
741
764
|
|
742
765
|
done:
|
@@ -758,7 +781,7 @@ int git_index_set_version(git_index *index, unsigned int version)
|
|
758
781
|
|
759
782
|
if (version < INDEX_VERSION_NUMBER_LB ||
|
760
783
|
version > INDEX_VERSION_NUMBER_UB) {
|
761
|
-
|
784
|
+
git_error_set(GIT_ERROR_INDEX, "invalid version number");
|
762
785
|
return -1;
|
763
786
|
}
|
764
787
|
|
@@ -774,8 +797,9 @@ int git_index_write(git_index *index)
|
|
774
797
|
|
775
798
|
truncate_racily_clean(index);
|
776
799
|
|
777
|
-
if ((error = git_indexwriter_init(&writer, index)) == 0
|
778
|
-
error = git_indexwriter_commit(&writer)
|
800
|
+
if ((error = git_indexwriter_init(&writer, index)) == 0 &&
|
801
|
+
(error = git_indexwriter_commit(&writer)) == 0)
|
802
|
+
index->dirty = 0;
|
779
803
|
|
780
804
|
git_indexwriter_cleanup(&writer);
|
781
805
|
|
@@ -827,21 +851,22 @@ const git_index_entry *git_index_get_byindex(
|
|
827
851
|
const git_index_entry *git_index_get_bypath(
|
828
852
|
git_index *index, const char *path, int stage)
|
829
853
|
{
|
830
|
-
khiter_t pos;
|
831
854
|
git_index_entry key = {{ 0 }};
|
855
|
+
git_index_entry *value;
|
832
856
|
|
833
857
|
assert(index);
|
834
858
|
|
835
859
|
key.path = path;
|
836
|
-
|
860
|
+
GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
|
837
861
|
|
838
|
-
LOOKUP_IN_MAP(
|
862
|
+
LOOKUP_IN_MAP(value, index, &key);
|
839
863
|
|
840
|
-
if (
|
841
|
-
|
864
|
+
if (!value) {
|
865
|
+
git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
|
866
|
+
return NULL;
|
867
|
+
}
|
842
868
|
|
843
|
-
|
844
|
-
return NULL;
|
869
|
+
return value;
|
845
870
|
}
|
846
871
|
|
847
872
|
void git_index_entry__init_from_stat(
|
@@ -866,12 +891,12 @@ static void index_entry_adjust_namemask(
|
|
866
891
|
git_index_entry *entry,
|
867
892
|
size_t path_length)
|
868
893
|
{
|
869
|
-
entry->flags &= ~
|
894
|
+
entry->flags &= ~GIT_INDEX_ENTRY_NAMEMASK;
|
870
895
|
|
871
|
-
if (path_length <
|
872
|
-
entry->flags |= path_length &
|
896
|
+
if (path_length < GIT_INDEX_ENTRY_NAMEMASK)
|
897
|
+
entry->flags |= path_length & GIT_INDEX_ENTRY_NAMEMASK;
|
873
898
|
else
|
874
|
-
entry->flags |=
|
899
|
+
entry->flags |= GIT_INDEX_ENTRY_NAMEMASK;
|
875
900
|
}
|
876
901
|
|
877
902
|
/* When `from_workdir` is true, we will validate the paths to avoid placing
|
@@ -902,14 +927,14 @@ static int index_entry_create(
|
|
902
927
|
mode = st->st_mode;
|
903
928
|
|
904
929
|
if (!git_path_isvalid(repo, path, mode, path_valid_flags)) {
|
905
|
-
|
930
|
+
git_error_set(GIT_ERROR_INDEX, "invalid path: '%s'", path);
|
906
931
|
return -1;
|
907
932
|
}
|
908
933
|
|
909
|
-
|
910
|
-
|
934
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(struct entry_internal), pathlen);
|
935
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
911
936
|
entry = git__calloc(1, alloclen);
|
912
|
-
|
937
|
+
GIT_ERROR_CHECK_ALLOC(entry);
|
913
938
|
|
914
939
|
entry->pathlen = pathlen;
|
915
940
|
memcpy(entry->path, path, pathlen);
|
@@ -949,7 +974,7 @@ static int index_entry_init(
|
|
949
974
|
return -1;
|
950
975
|
|
951
976
|
error = git_path_lstat(path.ptr, &st);
|
952
|
-
|
977
|
+
git_buf_dispose(&path);
|
953
978
|
|
954
979
|
if (error < 0)
|
955
980
|
return error;
|
@@ -1006,7 +1031,7 @@ static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
|
|
1006
1031
|
assert(reuc_out && path);
|
1007
1032
|
|
1008
1033
|
*reuc_out = reuc = reuc_entry_alloc(path);
|
1009
|
-
|
1034
|
+
GIT_ERROR_CHECK_ALLOC(reuc);
|
1010
1035
|
|
1011
1036
|
if ((reuc->mode[0] = ancestor_mode) > 0) {
|
1012
1037
|
assert(ancestor_oid);
|
@@ -1054,7 +1079,7 @@ static void index_entry_cpy_nocache(
|
|
1054
1079
|
git_oid_cpy(&tgt->id, &src->id);
|
1055
1080
|
tgt->mode = src->mode;
|
1056
1081
|
tgt->flags = src->flags;
|
1057
|
-
tgt->flags_extended = (src->flags_extended &
|
1082
|
+
tgt->flags_extended = (src->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS);
|
1058
1083
|
}
|
1059
1084
|
|
1060
1085
|
static int index_entry_dup_nocache(
|
@@ -1072,9 +1097,8 @@ static int index_entry_dup_nocache(
|
|
1072
1097
|
static int has_file_name(git_index *index,
|
1073
1098
|
const git_index_entry *entry, size_t pos, int ok_to_replace)
|
1074
1099
|
{
|
1075
|
-
int retval = 0;
|
1076
1100
|
size_t len = strlen(entry->path);
|
1077
|
-
int stage =
|
1101
|
+
int stage = GIT_INDEX_ENTRY_STAGE(entry);
|
1078
1102
|
const char *name = entry->path;
|
1079
1103
|
|
1080
1104
|
while (pos < index->entries.length) {
|
@@ -1084,18 +1108,17 @@ static int has_file_name(git_index *index,
|
|
1084
1108
|
break;
|
1085
1109
|
if (memcmp(name, p->path, len))
|
1086
1110
|
break;
|
1087
|
-
if (
|
1111
|
+
if (GIT_INDEX_ENTRY_STAGE(&p->entry) != stage)
|
1088
1112
|
continue;
|
1089
1113
|
if (p->path[len] != '/')
|
1090
1114
|
continue;
|
1091
|
-
retval = -1;
|
1092
1115
|
if (!ok_to_replace)
|
1093
|
-
|
1116
|
+
return -1;
|
1094
1117
|
|
1095
1118
|
if (index_remove_entry(index, --pos) < 0)
|
1096
1119
|
break;
|
1097
1120
|
}
|
1098
|
-
return
|
1121
|
+
return 0;
|
1099
1122
|
}
|
1100
1123
|
|
1101
1124
|
/*
|
@@ -1105,8 +1128,7 @@ static int has_file_name(git_index *index,
|
|
1105
1128
|
static int has_dir_name(git_index *index,
|
1106
1129
|
const git_index_entry *entry, int ok_to_replace)
|
1107
1130
|
{
|
1108
|
-
int
|
1109
|
-
int stage = GIT_IDXENTRY_STAGE(entry);
|
1131
|
+
int stage = GIT_INDEX_ENTRY_STAGE(entry);
|
1110
1132
|
const char *name = entry->path;
|
1111
1133
|
const char *slash = name + strlen(name);
|
1112
1134
|
|
@@ -1117,14 +1139,13 @@ static int has_dir_name(git_index *index,
|
|
1117
1139
|
if (*--slash == '/')
|
1118
1140
|
break;
|
1119
1141
|
if (slash <= entry->path)
|
1120
|
-
return
|
1142
|
+
return 0;
|
1121
1143
|
}
|
1122
1144
|
len = slash - name;
|
1123
1145
|
|
1124
1146
|
if (!index_find(&pos, index, name, len, stage)) {
|
1125
|
-
retval = -1;
|
1126
1147
|
if (!ok_to_replace)
|
1127
|
-
|
1148
|
+
return -1;
|
1128
1149
|
|
1129
1150
|
if (index_remove_entry(index, pos) < 0)
|
1130
1151
|
break;
|
@@ -1144,22 +1165,20 @@ static int has_dir_name(git_index *index,
|
|
1144
1165
|
memcmp(p->path, name, len))
|
1145
1166
|
break; /* not our subdirectory */
|
1146
1167
|
|
1147
|
-
if (
|
1148
|
-
return
|
1168
|
+
if (GIT_INDEX_ENTRY_STAGE(&p->entry) == stage)
|
1169
|
+
return 0;
|
1149
1170
|
}
|
1150
1171
|
}
|
1151
1172
|
|
1152
|
-
return
|
1173
|
+
return 0;
|
1153
1174
|
}
|
1154
1175
|
|
1155
1176
|
static int check_file_directory_collision(git_index *index,
|
1156
1177
|
git_index_entry *entry, size_t pos, int ok_to_replace)
|
1157
1178
|
{
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
if (retval) {
|
1162
|
-
giterr_set(GITERR_INDEX,
|
1179
|
+
if (has_file_name(index, entry, pos, ok_to_replace) < 0 ||
|
1180
|
+
has_dir_name(index, entry, ok_to_replace) < 0) {
|
1181
|
+
git_error_set(GIT_ERROR_INDEX,
|
1163
1182
|
"'%s' appears as both a file and a directory", entry->path);
|
1164
1183
|
return -1;
|
1165
1184
|
}
|
@@ -1204,7 +1223,7 @@ static int canonicalize_directory_path(
|
|
1204
1223
|
&pos, &index->entries, index->entries_search_path, search);
|
1205
1224
|
|
1206
1225
|
while ((match = git_vector_get(&index->entries, pos))) {
|
1207
|
-
if (
|
1226
|
+
if (GIT_INDEX_ENTRY_STAGE(match) != 0) {
|
1208
1227
|
/* conflicts do not contribute to canonical paths */
|
1209
1228
|
} else if (strncmp(search, match->path, search_len) == 0) {
|
1210
1229
|
/* prefer an exact match to the input filename */
|
@@ -1241,8 +1260,8 @@ static int index_no_dups(void **old, void *new)
|
|
1241
1260
|
{
|
1242
1261
|
const git_index_entry *entry = new;
|
1243
1262
|
GIT_UNUSED(old);
|
1244
|
-
|
1245
|
-
entry->path,
|
1263
|
+
git_error_set(GIT_ERROR_INDEX, "'%s' appears multiple times at stage %d",
|
1264
|
+
entry->path, GIT_INDEX_ENTRY_STAGE(entry));
|
1246
1265
|
return GIT_EEXISTS;
|
1247
1266
|
}
|
1248
1267
|
|
@@ -1258,7 +1277,7 @@ static void index_existing_and_best(
|
|
1258
1277
|
int error;
|
1259
1278
|
|
1260
1279
|
error = index_find(&pos,
|
1261
|
-
index, entry->path, 0,
|
1280
|
+
index, entry->path, 0, GIT_INDEX_ENTRY_STAGE(entry));
|
1262
1281
|
|
1263
1282
|
if (error == 0) {
|
1264
1283
|
*existing = index->entries.contents[pos];
|
@@ -1271,7 +1290,7 @@ static void index_existing_and_best(
|
|
1271
1290
|
*existing_position = 0;
|
1272
1291
|
*best = NULL;
|
1273
1292
|
|
1274
|
-
if (
|
1293
|
+
if (GIT_INDEX_ENTRY_STAGE(entry) == 0) {
|
1275
1294
|
for (; pos < index->entries.length; pos++) {
|
1276
1295
|
int (*strcomp)(const char *a, const char *b) =
|
1277
1296
|
index->ignore_case ? git__strcasecmp : git__strcmp;
|
@@ -1281,7 +1300,7 @@ static void index_existing_and_best(
|
|
1281
1300
|
if (strcomp(entry->path, e->path) != 0)
|
1282
1301
|
break;
|
1283
1302
|
|
1284
|
-
if (
|
1303
|
+
if (GIT_INDEX_ENTRY_STAGE(e) == GIT_INDEX_STAGE_ANCESTOR) {
|
1285
1304
|
*best = e;
|
1286
1305
|
continue;
|
1287
1306
|
} else {
|
@@ -1313,57 +1332,58 @@ static int index_insert(
|
|
1313
1332
|
bool trust_mode,
|
1314
1333
|
bool trust_id)
|
1315
1334
|
{
|
1316
|
-
int error = 0;
|
1317
|
-
size_t path_length, position;
|
1318
1335
|
git_index_entry *existing, *best, *entry;
|
1336
|
+
size_t path_length, position;
|
1337
|
+
int error;
|
1319
1338
|
|
1320
1339
|
assert(index && entry_ptr);
|
1321
1340
|
|
1322
1341
|
entry = *entry_ptr;
|
1323
1342
|
|
1324
|
-
/*
|
1343
|
+
/* Make sure that the path length flag is correct */
|
1325
1344
|
path_length = ((struct entry_internal *)entry)->pathlen;
|
1326
1345
|
index_entry_adjust_namemask(entry, path_length);
|
1327
1346
|
|
1328
|
-
/*
|
1329
|
-
entry->flags_extended |=
|
1347
|
+
/* This entry is now up-to-date and should not be checked for raciness */
|
1348
|
+
entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
|
1330
1349
|
|
1331
1350
|
git_vector_sort(&index->entries);
|
1332
1351
|
|
1333
|
-
/*
|
1352
|
+
/*
|
1353
|
+
* Look if an entry with this path already exists, either staged, or (if
|
1334
1354
|
* this entry is a regular staged item) as the "ours" side of a conflict.
|
1335
1355
|
*/
|
1336
1356
|
index_existing_and_best(&existing, &position, &best, index, entry);
|
1337
1357
|
|
1338
|
-
/*
|
1358
|
+
/* Update the file mode */
|
1339
1359
|
entry->mode = trust_mode ?
|
1340
1360
|
git_index__create_mode(entry->mode) :
|
1341
1361
|
index_merge_mode(index, best, entry->mode);
|
1342
1362
|
|
1343
|
-
/*
|
1344
|
-
if (!trust_path)
|
1345
|
-
|
1363
|
+
/* Canonicalize the directory name */
|
1364
|
+
if (!trust_path && (error = canonicalize_directory_path(index, entry, best)) < 0)
|
1365
|
+
goto out;
|
1346
1366
|
|
1347
|
-
/*
|
1348
|
-
if (!
|
1349
|
-
|
1367
|
+
/* Ensure that the given id exists (unless it's a submodule) */
|
1368
|
+
if (!trust_id && INDEX_OWNER(index) &&
|
1369
|
+
(entry->mode & GIT_FILEMODE_COMMIT) != GIT_FILEMODE_COMMIT) {
|
1350
1370
|
|
1351
1371
|
if (!git_object__is_valid(INDEX_OWNER(index), &entry->id,
|
1352
|
-
|
1372
|
+
git_object__type_from_filemode(entry->mode))) {
|
1353
1373
|
error = -1;
|
1374
|
+
goto out;
|
1375
|
+
}
|
1354
1376
|
}
|
1355
1377
|
|
1356
|
-
/*
|
1357
|
-
if (
|
1358
|
-
|
1378
|
+
/* Look for tree / blob name collisions, removing conflicts if requested */
|
1379
|
+
if ((error = check_file_directory_collision(index, entry, position, replace)) < 0)
|
1380
|
+
goto out;
|
1359
1381
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
/* if we are replacing an existing item, overwrite the existing entry
|
1382
|
+
/*
|
1383
|
+
* If we are replacing an existing item, overwrite the existing entry
|
1364
1384
|
* and return it in place of the passed in one.
|
1365
1385
|
*/
|
1366
|
-
|
1386
|
+
if (existing) {
|
1367
1387
|
if (replace) {
|
1368
1388
|
index_entry_cpy(existing, entry);
|
1369
1389
|
|
@@ -1372,20 +1392,22 @@ static int index_insert(
|
|
1372
1392
|
}
|
1373
1393
|
|
1374
1394
|
index_entry_free(entry);
|
1375
|
-
*entry_ptr =
|
1376
|
-
}
|
1377
|
-
|
1378
|
-
|
1395
|
+
*entry_ptr = existing;
|
1396
|
+
} else {
|
1397
|
+
/*
|
1398
|
+
* If replace is not requested or no existing entry exists, insert
|
1379
1399
|
* at the sorted position. (Since we re-sort after each insert to
|
1380
1400
|
* check for dups, this is actually cheaper in the long run.)
|
1381
1401
|
*/
|
1382
|
-
error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)
|
1402
|
+
if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0)
|
1403
|
+
goto out;
|
1383
1404
|
|
1384
|
-
|
1385
|
-
INSERT_IN_MAP(index, entry, &error);
|
1386
|
-
}
|
1405
|
+
INSERT_IN_MAP(index, entry, error);
|
1387
1406
|
}
|
1388
1407
|
|
1408
|
+
index->dirty = 1;
|
1409
|
+
|
1410
|
+
out:
|
1389
1411
|
if (error < 0) {
|
1390
1412
|
index_entry_free(*entry_ptr);
|
1391
1413
|
*entry_ptr = NULL;
|
@@ -1432,7 +1454,7 @@ GIT_INLINE(bool) valid_filemode(const int filemode)
|
|
1432
1454
|
return (is_file_or_link(filemode) || filemode == GIT_FILEMODE_COMMIT);
|
1433
1455
|
}
|
1434
1456
|
|
1435
|
-
int
|
1457
|
+
int git_index_add_from_buffer(
|
1436
1458
|
git_index *index, const git_index_entry *source_entry,
|
1437
1459
|
const void *buffer, size_t len)
|
1438
1460
|
{
|
@@ -1448,21 +1470,26 @@ int git_index_add_frombuffer(
|
|
1448
1470
|
"Index is not backed up by an existing repository.");
|
1449
1471
|
|
1450
1472
|
if (!is_file_or_link(source_entry->mode)) {
|
1451
|
-
|
1473
|
+
git_error_set(GIT_ERROR_INDEX, "invalid filemode");
|
1474
|
+
return -1;
|
1475
|
+
}
|
1476
|
+
|
1477
|
+
if (len > UINT32_MAX) {
|
1478
|
+
git_error_set(GIT_ERROR_INDEX, "buffer is too large");
|
1452
1479
|
return -1;
|
1453
1480
|
}
|
1454
1481
|
|
1455
1482
|
if (index_entry_dup(&entry, index, source_entry) < 0)
|
1456
1483
|
return -1;
|
1457
1484
|
|
1458
|
-
error =
|
1485
|
+
error = git_blob_create_from_buffer(&id, INDEX_OWNER(index), buffer, len);
|
1459
1486
|
if (error < 0) {
|
1460
1487
|
index_entry_free(entry);
|
1461
1488
|
return error;
|
1462
1489
|
}
|
1463
1490
|
|
1464
1491
|
git_oid_cpy(&entry->id, &id);
|
1465
|
-
entry->file_size = len;
|
1492
|
+
entry->file_size = (uint32_t)len;
|
1466
1493
|
|
1467
1494
|
if ((error = index_insert(index, &entry, 1, true, true, true)) < 0)
|
1468
1495
|
return error;
|
@@ -1489,7 +1516,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
|
|
1489
1516
|
return error;
|
1490
1517
|
|
1491
1518
|
if ((error = p_stat(abspath.ptr, &st)) < 0) {
|
1492
|
-
|
1519
|
+
git_error_set(GIT_ERROR_OS, "failed to stat repository dir");
|
1493
1520
|
return -1;
|
1494
1521
|
}
|
1495
1522
|
|
@@ -1509,7 +1536,7 @@ static int add_repo_as_submodule(git_index_entry **out, git_index *index, const
|
|
1509
1536
|
|
1510
1537
|
git_reference_free(head);
|
1511
1538
|
git_repository_free(sub);
|
1512
|
-
|
1539
|
+
git_buf_dispose(&abspath);
|
1513
1540
|
|
1514
1541
|
*out = entry;
|
1515
1542
|
return 0;
|
@@ -1533,13 +1560,13 @@ int git_index_add_bypath(git_index *index, const char *path)
|
|
1533
1560
|
git_submodule *sm;
|
1534
1561
|
git_error_state err;
|
1535
1562
|
|
1536
|
-
|
1563
|
+
git_error_state_capture(&err, ret);
|
1537
1564
|
|
1538
1565
|
ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path);
|
1539
1566
|
if (ret == GIT_ENOTFOUND)
|
1540
|
-
return
|
1567
|
+
return git_error_state_restore(&err);
|
1541
1568
|
|
1542
|
-
|
1569
|
+
git_error_state_free(&err);
|
1543
1570
|
|
1544
1571
|
/*
|
1545
1572
|
* EEXISTS means that there is a repository at that path, but it's not known
|
@@ -1581,7 +1608,7 @@ int git_index_remove_bypath(git_index *index, const char *path)
|
|
1581
1608
|
return ret;
|
1582
1609
|
|
1583
1610
|
if (ret == GIT_ENOTFOUND)
|
1584
|
-
|
1611
|
+
git_error_clear();
|
1585
1612
|
|
1586
1613
|
return 0;
|
1587
1614
|
}
|
@@ -1597,8 +1624,9 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1597
1624
|
if (!source_entries->length)
|
1598
1625
|
return 0;
|
1599
1626
|
|
1600
|
-
git_vector_size_hint(&index->entries, source_entries->length)
|
1601
|
-
|
1627
|
+
if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
|
1628
|
+
git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3)) < 0)
|
1629
|
+
return -1;
|
1602
1630
|
|
1603
1631
|
git_vector_foreach(source_entries, i, source_entry) {
|
1604
1632
|
git_index_entry *entry = NULL;
|
@@ -1607,15 +1635,17 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1607
1635
|
break;
|
1608
1636
|
|
1609
1637
|
index_entry_adjust_namemask(entry, ((struct entry_internal *)entry)->pathlen);
|
1610
|
-
entry->flags_extended |=
|
1638
|
+
entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
|
1611
1639
|
entry->mode = git_index__create_mode(entry->mode);
|
1612
1640
|
|
1613
1641
|
if ((ret = git_vector_insert(&index->entries, entry)) < 0)
|
1614
1642
|
break;
|
1615
1643
|
|
1616
|
-
INSERT_IN_MAP(index, entry,
|
1644
|
+
INSERT_IN_MAP(index, entry, ret);
|
1617
1645
|
if (ret < 0)
|
1618
1646
|
break;
|
1647
|
+
|
1648
|
+
index->dirty = 1;
|
1619
1649
|
}
|
1620
1650
|
|
1621
1651
|
if (!ret)
|
@@ -1633,7 +1663,7 @@ int git_index_add(git_index *index, const git_index_entry *source_entry)
|
|
1633
1663
|
assert(index && source_entry && source_entry->path);
|
1634
1664
|
|
1635
1665
|
if (!valid_filemode(source_entry->mode)) {
|
1636
|
-
|
1666
|
+
git_error_set(GIT_ERROR_INDEX, "invalid entry mode");
|
1637
1667
|
return -1;
|
1638
1668
|
}
|
1639
1669
|
|
@@ -1652,13 +1682,13 @@ int git_index_remove(git_index *index, const char *path, int stage)
|
|
1652
1682
|
git_index_entry remove_key = {{ 0 }};
|
1653
1683
|
|
1654
1684
|
remove_key.path = path;
|
1655
|
-
|
1685
|
+
GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
|
1656
1686
|
|
1657
1687
|
DELETE_IN_MAP(index, &remove_key);
|
1658
1688
|
|
1659
1689
|
if (index_find(&position, index, path, 0, stage) < 0) {
|
1660
|
-
|
1661
|
-
|
1690
|
+
git_error_set(
|
1691
|
+
GIT_ERROR_INDEX, "index does not contain %s at stage %d", path, stage);
|
1662
1692
|
error = GIT_ENOTFOUND;
|
1663
1693
|
} else {
|
1664
1694
|
error = index_remove_entry(index, position);
|
@@ -1683,7 +1713,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
|
|
1683
1713
|
if (!entry || git__prefixcmp(entry->path, pfx.ptr) != 0)
|
1684
1714
|
break;
|
1685
1715
|
|
1686
|
-
if (
|
1716
|
+
if (GIT_INDEX_ENTRY_STAGE(entry) != stage) {
|
1687
1717
|
++pos;
|
1688
1718
|
continue;
|
1689
1719
|
}
|
@@ -1693,7 +1723,7 @@ int git_index_remove_directory(git_index *index, const char *dir, int stage)
|
|
1693
1723
|
/* removed entry at 'pos' so we don't need to increment */
|
1694
1724
|
}
|
1695
1725
|
|
1696
|
-
|
1726
|
+
git_buf_dispose(&pfx);
|
1697
1727
|
|
1698
1728
|
return error;
|
1699
1729
|
}
|
@@ -1730,7 +1760,7 @@ int git_index_find(size_t *at_pos, git_index *index, const char *path)
|
|
1730
1760
|
|
1731
1761
|
if (git_vector_bsearch2(
|
1732
1762
|
&pos, &index->entries, index->entries_search_path, path) < 0) {
|
1733
|
-
|
1763
|
+
git_error_set(GIT_ERROR_INDEX, "index does not contain %s", path);
|
1734
1764
|
return GIT_ENOTFOUND;
|
1735
1765
|
}
|
1736
1766
|
|
@@ -1772,7 +1802,7 @@ int git_index_conflict_add(git_index *index,
|
|
1772
1802
|
/* Validate entries */
|
1773
1803
|
for (i = 0; i < 3; i++) {
|
1774
1804
|
if (entries[i] && !valid_filemode(entries[i]->mode)) {
|
1775
|
-
|
1805
|
+
git_error_set(GIT_ERROR_INDEX, "invalid filemode for stage %d entry",
|
1776
1806
|
i + 1);
|
1777
1807
|
ret = -1;
|
1778
1808
|
goto on_error;
|
@@ -1788,7 +1818,7 @@ int git_index_conflict_add(git_index *index,
|
|
1788
1818
|
if (ret != GIT_ENOTFOUND)
|
1789
1819
|
goto on_error;
|
1790
1820
|
|
1791
|
-
|
1821
|
+
git_error_clear();
|
1792
1822
|
ret = 0;
|
1793
1823
|
}
|
1794
1824
|
}
|
@@ -1799,7 +1829,7 @@ int git_index_conflict_add(git_index *index,
|
|
1799
1829
|
continue;
|
1800
1830
|
|
1801
1831
|
/* Make sure stage is correct */
|
1802
|
-
|
1832
|
+
GIT_INDEX_ENTRY_STAGE_SET(entries[i], i + 1);
|
1803
1833
|
|
1804
1834
|
if ((ret = index_insert(index, &entries[i], 1, true, true, false)) < 0)
|
1805
1835
|
goto on_error;
|
@@ -1842,7 +1872,7 @@ static int index_conflict__get_byindex(
|
|
1842
1872
|
if (path && index->entries_cmp_path(conflict_entry->path, path) != 0)
|
1843
1873
|
break;
|
1844
1874
|
|
1845
|
-
stage =
|
1875
|
+
stage = GIT_INDEX_ENTRY_STAGE(conflict_entry);
|
1846
1876
|
path = conflict_entry->path;
|
1847
1877
|
|
1848
1878
|
switch (stage) {
|
@@ -1909,7 +1939,7 @@ static int index_conflict_remove(git_index *index, const char *path)
|
|
1909
1939
|
index->entries_cmp_path(conflict_entry->path, path) != 0)
|
1910
1940
|
break;
|
1911
1941
|
|
1912
|
-
if (
|
1942
|
+
if (GIT_INDEX_ENTRY_STAGE(conflict_entry) == 0) {
|
1913
1943
|
pos++;
|
1914
1944
|
continue;
|
1915
1945
|
}
|
@@ -1941,13 +1971,58 @@ int git_index_has_conflicts(const git_index *index)
|
|
1941
1971
|
assert(index);
|
1942
1972
|
|
1943
1973
|
git_vector_foreach(&index->entries, i, entry) {
|
1944
|
-
if (
|
1974
|
+
if (GIT_INDEX_ENTRY_STAGE(entry) > 0)
|
1945
1975
|
return 1;
|
1946
1976
|
}
|
1947
1977
|
|
1948
1978
|
return 0;
|
1949
1979
|
}
|
1950
1980
|
|
1981
|
+
int git_index_iterator_new(
|
1982
|
+
git_index_iterator **iterator_out,
|
1983
|
+
git_index *index)
|
1984
|
+
{
|
1985
|
+
git_index_iterator *it;
|
1986
|
+
int error;
|
1987
|
+
|
1988
|
+
assert(iterator_out && index);
|
1989
|
+
|
1990
|
+
it = git__calloc(1, sizeof(git_index_iterator));
|
1991
|
+
GIT_ERROR_CHECK_ALLOC(it);
|
1992
|
+
|
1993
|
+
if ((error = git_index_snapshot_new(&it->snap, index)) < 0) {
|
1994
|
+
git__free(it);
|
1995
|
+
return error;
|
1996
|
+
}
|
1997
|
+
|
1998
|
+
it->index = index;
|
1999
|
+
|
2000
|
+
*iterator_out = it;
|
2001
|
+
return 0;
|
2002
|
+
}
|
2003
|
+
|
2004
|
+
int git_index_iterator_next(
|
2005
|
+
const git_index_entry **out,
|
2006
|
+
git_index_iterator *it)
|
2007
|
+
{
|
2008
|
+
assert(out && it);
|
2009
|
+
|
2010
|
+
if (it->cur >= git_vector_length(&it->snap))
|
2011
|
+
return GIT_ITEROVER;
|
2012
|
+
|
2013
|
+
*out = (git_index_entry *)git_vector_get(&it->snap, it->cur++);
|
2014
|
+
return 0;
|
2015
|
+
}
|
2016
|
+
|
2017
|
+
void git_index_iterator_free(git_index_iterator *it)
|
2018
|
+
{
|
2019
|
+
if (it == NULL)
|
2020
|
+
return;
|
2021
|
+
|
2022
|
+
git_index_snapshot_release(&it->snap, it->index);
|
2023
|
+
git__free(it);
|
2024
|
+
}
|
2025
|
+
|
1951
2026
|
int git_index_conflict_iterator_new(
|
1952
2027
|
git_index_conflict_iterator **iterator_out,
|
1953
2028
|
git_index *index)
|
@@ -1957,7 +2032,7 @@ int git_index_conflict_iterator_new(
|
|
1957
2032
|
assert(iterator_out && index);
|
1958
2033
|
|
1959
2034
|
it = git__calloc(1, sizeof(git_index_conflict_iterator));
|
1960
|
-
|
2035
|
+
GIT_ERROR_CHECK_ALLOC(it);
|
1961
2036
|
|
1962
2037
|
it->index = index;
|
1963
2038
|
|
@@ -2043,7 +2118,7 @@ int git_index_name_add(git_index *index,
|
|
2043
2118
|
assert((ancestor && ours) || (ancestor && theirs) || (ours && theirs));
|
2044
2119
|
|
2045
2120
|
conflict_name = git__calloc(1, sizeof(git_index_name_entry));
|
2046
|
-
|
2121
|
+
GIT_ERROR_CHECK_ALLOC(conflict_name);
|
2047
2122
|
|
2048
2123
|
if ((ancestor && !(conflict_name->ancestor = git__strdup(ancestor))) ||
|
2049
2124
|
(ours && !(conflict_name->ours = git__strdup(ours))) ||
|
@@ -2054,6 +2129,7 @@ int git_index_name_add(git_index *index,
|
|
2054
2129
|
return -1;
|
2055
2130
|
}
|
2056
2131
|
|
2132
|
+
index->dirty = 1;
|
2057
2133
|
return 0;
|
2058
2134
|
}
|
2059
2135
|
|
@@ -2068,6 +2144,8 @@ void git_index_name_clear(git_index *index)
|
|
2068
2144
|
index_name_entry_free(conflict_name);
|
2069
2145
|
|
2070
2146
|
git_vector_clear(&index->names);
|
2147
|
+
|
2148
|
+
index->dirty = 1;
|
2071
2149
|
}
|
2072
2150
|
|
2073
2151
|
size_t git_index_reuc_entrycount(git_index *index)
|
@@ -2093,6 +2171,8 @@ static int index_reuc_insert(
|
|
2093
2171
|
assert(git_vector_is_sorted(&index->reuc));
|
2094
2172
|
|
2095
2173
|
res = git_vector_insert_sorted(&index->reuc, reuc, &index_reuc_on_dup);
|
2174
|
+
index->dirty = 1;
|
2175
|
+
|
2096
2176
|
return res == GIT_EEXISTS ? 0 : res;
|
2097
2177
|
}
|
2098
2178
|
|
@@ -2158,6 +2238,7 @@ int git_index_reuc_remove(git_index *index, size_t position)
|
|
2158
2238
|
if (!error)
|
2159
2239
|
index_entry_reuc_free(reuc);
|
2160
2240
|
|
2241
|
+
index->dirty = 1;
|
2161
2242
|
return error;
|
2162
2243
|
}
|
2163
2244
|
|
@@ -2171,11 +2252,13 @@ void git_index_reuc_clear(git_index *index)
|
|
2171
2252
|
index_entry_reuc_free(git__swap(index->reuc.contents[i], NULL));
|
2172
2253
|
|
2173
2254
|
git_vector_clear(&index->reuc);
|
2255
|
+
|
2256
|
+
index->dirty = 1;
|
2174
2257
|
}
|
2175
2258
|
|
2176
2259
|
static int index_error_invalid(const char *message)
|
2177
2260
|
{
|
2178
|
-
|
2261
|
+
git_error_set(GIT_ERROR_INDEX, "invalid data in index - %s", message);
|
2179
2262
|
return -1;
|
2180
2263
|
}
|
2181
2264
|
|
@@ -2198,7 +2281,7 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
|
|
2198
2281
|
return index_error_invalid("reading reuc entries");
|
2199
2282
|
|
2200
2283
|
lost = reuc_entry_alloc(buffer);
|
2201
|
-
|
2284
|
+
GIT_ERROR_CHECK_ALLOC(lost);
|
2202
2285
|
|
2203
2286
|
size -= len;
|
2204
2287
|
buffer += len;
|
@@ -2271,7 +2354,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|
2271
2354
|
ptr = NULL; \
|
2272
2355
|
else { \
|
2273
2356
|
ptr = git__malloc(len); \
|
2274
|
-
|
2357
|
+
GIT_ERROR_CHECK_ALLOC(ptr); \
|
2275
2358
|
memcpy(ptr, buffer, len); \
|
2276
2359
|
} \
|
2277
2360
|
\
|
@@ -2280,7 +2363,7 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|
2280
2363
|
|
2281
2364
|
while (size) {
|
2282
2365
|
git_index_name_entry *conflict_name = git__calloc(1, sizeof(git_index_name_entry));
|
2283
|
-
|
2366
|
+
GIT_ERROR_CHECK_ALLOC(conflict_name);
|
2284
2367
|
|
2285
2368
|
read_conflict_name(conflict_name->ancestor);
|
2286
2369
|
read_conflict_name(conflict_name->ours);
|
@@ -2310,13 +2393,13 @@ out_err:
|
|
2310
2393
|
static size_t index_entry_size(size_t path_len, size_t varint_len, uint32_t flags)
|
2311
2394
|
{
|
2312
2395
|
if (varint_len) {
|
2313
|
-
if (flags &
|
2396
|
+
if (flags & GIT_INDEX_ENTRY_EXTENDED)
|
2314
2397
|
return offsetof(struct entry_long, path) + path_len + 1 + varint_len;
|
2315
2398
|
else
|
2316
2399
|
return offsetof(struct entry_short, path) + path_len + 1 + varint_len;
|
2317
2400
|
} else {
|
2318
2401
|
#define entry_size(type,len) ((offsetof(type, path) + (len) + 8) & ~7)
|
2319
|
-
if (flags &
|
2402
|
+
if (flags & GIT_INDEX_ENTRY_EXTENDED)
|
2320
2403
|
return entry_size(struct entry_long, path_len);
|
2321
2404
|
else
|
2322
2405
|
return entry_size(struct entry_short, path_len);
|
@@ -2358,7 +2441,7 @@ static int read_entry(
|
|
2358
2441
|
git_oid_cpy(&entry.id, &source.oid);
|
2359
2442
|
entry.flags = ntohs(source.flags);
|
2360
2443
|
|
2361
|
-
if (entry.flags &
|
2444
|
+
if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
|
2362
2445
|
uint16_t flags_raw;
|
2363
2446
|
size_t flags_offset;
|
2364
2447
|
|
@@ -2373,7 +2456,7 @@ static int read_entry(
|
|
2373
2456
|
path_ptr = (const char *) buffer + offsetof(struct entry_short, path);
|
2374
2457
|
|
2375
2458
|
if (!compressed) {
|
2376
|
-
path_length = entry.flags &
|
2459
|
+
path_length = entry.flags & GIT_INDEX_ENTRY_NAMEMASK;
|
2377
2460
|
|
2378
2461
|
/* if this is a very long string, we must find its
|
2379
2462
|
* real length without overflowing */
|
@@ -2399,17 +2482,17 @@ static int read_entry(
|
|
2399
2482
|
if (varint_len == 0 || last_len < strip_len)
|
2400
2483
|
return index_error_invalid("incorrect prefix length");
|
2401
2484
|
|
2402
|
-
prefix_len = last_len - strip_len;
|
2485
|
+
prefix_len = last_len - (size_t)strip_len;
|
2403
2486
|
suffix_len = strlen(path_ptr + varint_len);
|
2404
2487
|
|
2405
|
-
|
2406
|
-
|
2488
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len);
|
2489
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&path_len, path_len, 1);
|
2407
2490
|
|
2408
2491
|
if (path_len > GIT_PATH_MAX)
|
2409
2492
|
return index_error_invalid("unreasonable path length");
|
2410
2493
|
|
2411
2494
|
tmp_path = git__malloc(path_len);
|
2412
|
-
|
2495
|
+
GIT_ERROR_CHECK_ALLOC(tmp_path);
|
2413
2496
|
|
2414
2497
|
memcpy(tmp_path, last, prefix_len);
|
2415
2498
|
memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1);
|
@@ -2450,7 +2533,7 @@ static int read_header(struct index_header *dest, const void *buffer)
|
|
2450
2533
|
return 0;
|
2451
2534
|
}
|
2452
2535
|
|
2453
|
-
static
|
2536
|
+
static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size)
|
2454
2537
|
{
|
2455
2538
|
struct index_extension dest;
|
2456
2539
|
size_t total_size;
|
@@ -2463,31 +2546,36 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
|
|
2463
2546
|
|
2464
2547
|
if (dest.extension_size > total_size ||
|
2465
2548
|
buffer_size < total_size ||
|
2466
|
-
buffer_size - total_size < INDEX_FOOTER_SIZE)
|
2467
|
-
|
2549
|
+
buffer_size - total_size < INDEX_FOOTER_SIZE) {
|
2550
|
+
index_error_invalid("extension is truncated");
|
2551
|
+
return -1;
|
2552
|
+
}
|
2468
2553
|
|
2469
2554
|
/* optional extension */
|
2470
2555
|
if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
|
2471
2556
|
/* tree cache */
|
2472
2557
|
if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
|
2473
2558
|
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0)
|
2474
|
-
return
|
2559
|
+
return -1;
|
2475
2560
|
} else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
|
2476
2561
|
if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
|
2477
|
-
return
|
2562
|
+
return -1;
|
2478
2563
|
} else if (memcmp(dest.signature, INDEX_EXT_CONFLICT_NAME_SIG, 4) == 0) {
|
2479
2564
|
if (read_conflict_names(index, buffer + 8, dest.extension_size) < 0)
|
2480
|
-
return
|
2565
|
+
return -1;
|
2481
2566
|
}
|
2482
2567
|
/* else, unsupported extension. We cannot parse this, but we can skip
|
2483
2568
|
* it by returning `total_size */
|
2484
2569
|
} else {
|
2485
2570
|
/* we cannot handle non-ignorable extensions;
|
2486
2571
|
* in fact they aren't even defined in the standard */
|
2487
|
-
|
2572
|
+
git_error_set(GIT_ERROR_INDEX, "unsupported mandatory extension: '%.4s'", dest.signature);
|
2573
|
+
return -1;
|
2488
2574
|
}
|
2489
2575
|
|
2490
|
-
|
2576
|
+
*read_len = total_size;
|
2577
|
+
|
2578
|
+
return 0;
|
2491
2579
|
}
|
2492
2580
|
|
2493
2581
|
static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
@@ -2526,10 +2614,12 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2526
2614
|
|
2527
2615
|
assert(!index->entries.length);
|
2528
2616
|
|
2529
|
-
if (index->ignore_case
|
2530
|
-
|
2531
|
-
|
2532
|
-
|
2617
|
+
if (index->ignore_case &&
|
2618
|
+
(error = git_idxmap_icase_resize((git_idxmap_icase *) index->entries_map,
|
2619
|
+
header.entry_count)) < 0)
|
2620
|
+
return error;
|
2621
|
+
else if ((error = git_idxmap_resize(index->entries_map, header.entry_count)) < 0)
|
2622
|
+
return error;
|
2533
2623
|
|
2534
2624
|
/* Parse all the entries */
|
2535
2625
|
for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
|
@@ -2546,7 +2636,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2546
2636
|
goto done;
|
2547
2637
|
}
|
2548
2638
|
|
2549
|
-
INSERT_IN_MAP(index, entry,
|
2639
|
+
INSERT_IN_MAP(index, entry, error);
|
2550
2640
|
|
2551
2641
|
if (error < 0) {
|
2552
2642
|
index_entry_free(entry);
|
@@ -2569,11 +2659,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2569
2659
|
while (buffer_size > INDEX_FOOTER_SIZE) {
|
2570
2660
|
size_t extension_size;
|
2571
2661
|
|
2572
|
-
|
2573
|
-
|
2574
|
-
/* see if we have read any bytes from the extension */
|
2575
|
-
if (extension_size == 0) {
|
2576
|
-
error = index_error_invalid("extension is truncated");
|
2662
|
+
if ((error = read_extension(&extension_size, index, buffer, buffer_size)) < 0) {
|
2577
2663
|
goto done;
|
2578
2664
|
}
|
2579
2665
|
|
@@ -2605,6 +2691,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2605
2691
|
git_vector_set_sorted(&index->entries, !index->ignore_case);
|
2606
2692
|
git_vector_sort(&index->entries);
|
2607
2693
|
|
2694
|
+
index->dirty = 0;
|
2608
2695
|
done:
|
2609
2696
|
return error;
|
2610
2697
|
}
|
@@ -2617,10 +2704,10 @@ static bool is_index_extended(git_index *index)
|
|
2617
2704
|
extended = 0;
|
2618
2705
|
|
2619
2706
|
git_vector_foreach(&index->entries, i, entry) {
|
2620
|
-
entry->flags &= ~
|
2621
|
-
if (entry->flags_extended &
|
2707
|
+
entry->flags &= ~GIT_INDEX_ENTRY_EXTENDED;
|
2708
|
+
if (entry->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS) {
|
2622
2709
|
extended++;
|
2623
|
-
entry->flags |=
|
2710
|
+
entry->flags |= GIT_INDEX_ENTRY_EXTENDED;
|
2624
2711
|
}
|
2625
2712
|
}
|
2626
2713
|
|
@@ -2630,7 +2717,7 @@ static bool is_index_extended(git_index *index)
|
|
2630
2717
|
static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const char *last)
|
2631
2718
|
{
|
2632
2719
|
void *mem = NULL;
|
2633
|
-
struct entry_short
|
2720
|
+
struct entry_short ondisk;
|
2634
2721
|
size_t path_len, disk_size;
|
2635
2722
|
int varint_len = 0;
|
2636
2723
|
char *path;
|
@@ -2658,9 +2745,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
|
|
2658
2745
|
if (git_filebuf_reserve(file, &mem, disk_size) < 0)
|
2659
2746
|
return -1;
|
2660
2747
|
|
2661
|
-
|
2662
|
-
|
2663
|
-
memset(ondisk, 0x0, disk_size);
|
2748
|
+
memset(mem, 0x0, disk_size);
|
2664
2749
|
|
2665
2750
|
/**
|
2666
2751
|
* Yes, we have to truncate.
|
@@ -2672,30 +2757,32 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
|
|
2672
2757
|
*
|
2673
2758
|
* In 2038 I will be either too dead or too rich to care about this
|
2674
2759
|
*/
|
2675
|
-
ondisk
|
2676
|
-
ondisk
|
2677
|
-
ondisk
|
2678
|
-
ondisk
|
2679
|
-
ondisk
|
2680
|
-
ondisk
|
2681
|
-
ondisk
|
2682
|
-
ondisk
|
2683
|
-
ondisk
|
2684
|
-
ondisk
|
2685
|
-
|
2686
|
-
git_oid_cpy(&ondisk
|
2687
|
-
|
2688
|
-
ondisk
|
2689
|
-
|
2690
|
-
if (entry->flags &
|
2691
|
-
struct entry_long
|
2692
|
-
ondisk_ext
|
2693
|
-
ondisk_ext
|
2694
|
-
|
2695
|
-
|
2760
|
+
ondisk.ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
|
2761
|
+
ondisk.mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
|
2762
|
+
ondisk.ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
|
2763
|
+
ondisk.mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
|
2764
|
+
ondisk.dev = htonl(entry->dev);
|
2765
|
+
ondisk.ino = htonl(entry->ino);
|
2766
|
+
ondisk.mode = htonl(entry->mode);
|
2767
|
+
ondisk.uid = htonl(entry->uid);
|
2768
|
+
ondisk.gid = htonl(entry->gid);
|
2769
|
+
ondisk.file_size = htonl((uint32_t)entry->file_size);
|
2770
|
+
|
2771
|
+
git_oid_cpy(&ondisk.oid, &entry->id);
|
2772
|
+
|
2773
|
+
ondisk.flags = htons(entry->flags);
|
2774
|
+
|
2775
|
+
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
|
2776
|
+
struct entry_long ondisk_ext;
|
2777
|
+
memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
|
2778
|
+
ondisk_ext.flags_extended = htons(entry->flags_extended &
|
2779
|
+
GIT_INDEX_ENTRY_EXTENDED_FLAGS);
|
2780
|
+
memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path));
|
2781
|
+
path = ((struct entry_long*)mem)->path;
|
2696
2782
|
disk_size -= offsetof(struct entry_long, path);
|
2697
2783
|
} else {
|
2698
|
-
|
2784
|
+
memcpy(mem, &ondisk, offsetof(struct entry_short, path));
|
2785
|
+
path = ((struct entry_short*)mem)->path;
|
2699
2786
|
disk_size -= offsetof(struct entry_short, path);
|
2700
2787
|
}
|
2701
2788
|
|
@@ -2820,7 +2907,7 @@ static int write_name_extension(git_index *index, git_filebuf *file)
|
|
2820
2907
|
|
2821
2908
|
error = write_extension(file, &extension, &name_buf);
|
2822
2909
|
|
2823
|
-
|
2910
|
+
git_buf_dispose(&name_buf);
|
2824
2911
|
|
2825
2912
|
done:
|
2826
2913
|
return error;
|
@@ -2868,7 +2955,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
|
|
2868
2955
|
|
2869
2956
|
error = write_extension(file, &extension, &reuc_buf);
|
2870
2957
|
|
2871
|
-
|
2958
|
+
git_buf_dispose(&reuc_buf);
|
2872
2959
|
|
2873
2960
|
done:
|
2874
2961
|
return error;
|
@@ -2892,7 +2979,7 @@ static int write_tree_extension(git_index *index, git_filebuf *file)
|
|
2892
2979
|
|
2893
2980
|
error = write_extension(file, &extension, &buf);
|
2894
2981
|
|
2895
|
-
|
2982
|
+
git_buf_dispose(&buf);
|
2896
2983
|
|
2897
2984
|
return error;
|
2898
2985
|
}
|
@@ -2903,7 +2990,7 @@ static void clear_uptodate(git_index *index)
|
|
2903
2990
|
size_t i;
|
2904
2991
|
|
2905
2992
|
git_vector_foreach(&index->entries, i, entry)
|
2906
|
-
entry->flags_extended &= ~
|
2993
|
+
entry->flags_extended &= ~GIT_INDEX_ENTRY_UPTODATE;
|
2907
2994
|
}
|
2908
2995
|
|
2909
2996
|
static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
|
@@ -2960,12 +3047,12 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file)
|
|
2960
3047
|
|
2961
3048
|
int git_index_entry_stage(const git_index_entry *entry)
|
2962
3049
|
{
|
2963
|
-
return
|
3050
|
+
return GIT_INDEX_ENTRY_STAGE(entry);
|
2964
3051
|
}
|
2965
3052
|
|
2966
3053
|
int git_index_entry_is_conflict(const git_index_entry *entry)
|
2967
3054
|
{
|
2968
|
-
return (
|
3055
|
+
return (GIT_INDEX_ENTRY_STAGE(entry) > 0);
|
2969
3056
|
}
|
2970
3057
|
|
2971
3058
|
typedef struct read_tree_data {
|
@@ -3009,7 +3096,7 @@ static int read_tree_cb(
|
|
3009
3096
|
}
|
3010
3097
|
|
3011
3098
|
index_entry_adjust_namemask(entry, path.size);
|
3012
|
-
|
3099
|
+
git_buf_dispose(&path);
|
3013
3100
|
|
3014
3101
|
if (git_vector_insert(data->new_entries, entry) < 0) {
|
3015
3102
|
index_entry_free(entry);
|
@@ -3028,7 +3115,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3028
3115
|
size_t i;
|
3029
3116
|
git_index_entry *e;
|
3030
3117
|
|
3031
|
-
if (
|
3118
|
+
if (git_idxmap_new(&entries_map) < 0)
|
3032
3119
|
return -1;
|
3033
3120
|
|
3034
3121
|
git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
|
@@ -3046,16 +3133,18 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3046
3133
|
if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
|
3047
3134
|
goto cleanup;
|
3048
3135
|
|
3049
|
-
if (index->ignore_case
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3136
|
+
if (index->ignore_case &&
|
3137
|
+
(error = git_idxmap_icase_resize((git_idxmap_icase *) entries_map,
|
3138
|
+
entries.length)) < 0)
|
3139
|
+
goto cleanup;
|
3140
|
+
else if ((error = git_idxmap_resize(entries_map, entries.length)) < 0)
|
3141
|
+
goto cleanup;
|
3053
3142
|
|
3054
3143
|
git_vector_foreach(&entries, i, e) {
|
3055
|
-
INSERT_IN_MAP_EX(index, entries_map, e,
|
3144
|
+
INSERT_IN_MAP_EX(index, entries_map, e, error);
|
3056
3145
|
|
3057
3146
|
if (error < 0) {
|
3058
|
-
|
3147
|
+
git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
|
3059
3148
|
return error;
|
3060
3149
|
}
|
3061
3150
|
}
|
@@ -3071,6 +3160,8 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3071
3160
|
entries_map = git__swap(index->entries_map, entries_map);
|
3072
3161
|
}
|
3073
3162
|
|
3163
|
+
index->dirty = 1;
|
3164
|
+
|
3074
3165
|
cleanup:
|
3075
3166
|
git_vector_free(&entries);
|
3076
3167
|
git_idxmap_free(entries_map);
|
@@ -3100,14 +3191,17 @@ static int git_index_read_iterator(
|
|
3100
3191
|
assert((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
|
3101
3192
|
|
3102
3193
|
if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
|
3103
|
-
|
3104
|
-
|
3194
|
+
(error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0 ||
|
3195
|
+
(error = git_idxmap_new(&new_entries_map)) < 0)
|
3105
3196
|
goto done;
|
3106
3197
|
|
3107
|
-
if (index->ignore_case && new_length_hint
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3198
|
+
if (index->ignore_case && new_length_hint &&
|
3199
|
+
(error = git_idxmap_icase_resize((git_idxmap_icase *) new_entries_map,
|
3200
|
+
new_length_hint)) < 0)
|
3201
|
+
goto done;
|
3202
|
+
else if (new_length_hint &&
|
3203
|
+
(error = git_idxmap_resize(new_entries_map, new_length_hint)) < 0)
|
3204
|
+
goto done;
|
3111
3205
|
|
3112
3206
|
opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
|
3113
3207
|
GIT_ITERATOR_INCLUDE_CONFLICTS;
|
@@ -3171,14 +3265,14 @@ static int git_index_read_iterator(
|
|
3171
3265
|
|
3172
3266
|
if (add_entry) {
|
3173
3267
|
if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
|
3174
|
-
INSERT_IN_MAP_EX(index, new_entries_map, add_entry,
|
3268
|
+
INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error);
|
3175
3269
|
}
|
3176
3270
|
|
3177
3271
|
if (remove_entry && error >= 0)
|
3178
3272
|
error = git_vector_insert(&remove_entries, remove_entry);
|
3179
3273
|
|
3180
3274
|
if (error < 0) {
|
3181
|
-
|
3275
|
+
git_error_set(GIT_ERROR_INDEX, "failed to insert entry");
|
3182
3276
|
goto done;
|
3183
3277
|
}
|
3184
3278
|
|
@@ -3210,6 +3304,7 @@ static int git_index_read_iterator(
|
|
3210
3304
|
|
3211
3305
|
clear_uptodate(index);
|
3212
3306
|
|
3307
|
+
index->dirty = 1;
|
3213
3308
|
error = 0;
|
3214
3309
|
|
3215
3310
|
done:
|
@@ -3286,7 +3381,7 @@ int git_index_add_all(
|
|
3286
3381
|
error = index_apply_to_wd_diff(index, INDEX_ACTION_ADDALL, paths, flags, cb, payload);
|
3287
3382
|
|
3288
3383
|
if (error)
|
3289
|
-
|
3384
|
+
git_error_set_after_callback(error);
|
3290
3385
|
|
3291
3386
|
cleanup:
|
3292
3387
|
git_iterator_free(wditer);
|
@@ -3388,7 +3483,7 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
|
|
3388
3483
|
git_diff_free(diff);
|
3389
3484
|
|
3390
3485
|
if (error) /* make sure error is set if callback stopped iteration */
|
3391
|
-
|
3486
|
+
git_error_set_after_callback(error);
|
3392
3487
|
|
3393
3488
|
cleanup:
|
3394
3489
|
git_pathspec__clear(&ps);
|
@@ -3445,7 +3540,7 @@ static int index_apply_to_all(
|
|
3445
3540
|
error = git_index_add_bypath(index, path.ptr);
|
3446
3541
|
|
3447
3542
|
if (error == GIT_ENOTFOUND) {
|
3448
|
-
|
3543
|
+
git_error_clear();
|
3449
3544
|
|
3450
3545
|
error = git_index_remove_bypath(index, path.ptr);
|
3451
3546
|
|
@@ -3458,13 +3553,13 @@ static int index_apply_to_all(
|
|
3458
3553
|
i--; /* back up foreach if we removed this */
|
3459
3554
|
break;
|
3460
3555
|
default:
|
3461
|
-
|
3556
|
+
git_error_set(GIT_ERROR_INVALID, "unknown index action %d", action);
|
3462
3557
|
error = -1;
|
3463
3558
|
break;
|
3464
3559
|
}
|
3465
3560
|
}
|
3466
3561
|
|
3467
|
-
|
3562
|
+
git_buf_dispose(&path);
|
3468
3563
|
git_pathspec__clear(&ps);
|
3469
3564
|
|
3470
3565
|
return error;
|
@@ -3480,7 +3575,7 @@ int git_index_remove_all(
|
|
3480
3575
|
index, INDEX_ACTION_REMOVE, pathspec, cb, payload);
|
3481
3576
|
|
3482
3577
|
if (error) /* make sure error is set if callback stopped iteration */
|
3483
|
-
|
3578
|
+
git_error_set_after_callback(error);
|
3484
3579
|
|
3485
3580
|
return error;
|
3486
3581
|
}
|
@@ -3493,7 +3588,7 @@ int git_index_update_all(
|
|
3493
3588
|
{
|
3494
3589
|
int error = index_apply_to_wd_diff(index, INDEX_ACTION_UPDATE, pathspec, 0, cb, payload);
|
3495
3590
|
if (error) /* make sure error is set if callback stopped iteration */
|
3496
|
-
|
3591
|
+
git_error_set_after_callback(error);
|
3497
3592
|
|
3498
3593
|
return error;
|
3499
3594
|
}
|
@@ -3549,7 +3644,7 @@ int git_indexwriter_init(
|
|
3549
3644
|
&writer->file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_INDEX_FILE_MODE)) < 0) {
|
3550
3645
|
|
3551
3646
|
if (error == GIT_ELOCKED)
|
3552
|
-
|
3647
|
+
git_error_set(GIT_ERROR_INDEX, "the index is locked; this might be due to a concurrent or crashed process");
|
3553
3648
|
|
3554
3649
|
return error;
|
3555
3650
|
}
|
@@ -3598,10 +3693,11 @@ int git_indexwriter_commit(git_indexwriter *writer)
|
|
3598
3693
|
|
3599
3694
|
if ((error = git_futils_filestamp_check(
|
3600
3695
|
&writer->index->stamp, writer->index->index_file_path)) < 0) {
|
3601
|
-
|
3696
|
+
git_error_set(GIT_ERROR_OS, "could not read index timestamp");
|
3602
3697
|
return -1;
|
3603
3698
|
}
|
3604
3699
|
|
3700
|
+
writer->index->dirty = 0;
|
3605
3701
|
writer->index->on_disk = 1;
|
3606
3702
|
git_oid_cpy(&writer->index->checksum, &checksum);
|
3607
3703
|
|
@@ -3618,3 +3714,12 @@ void git_indexwriter_cleanup(git_indexwriter *writer)
|
|
3618
3714
|
git_index_free(writer->index);
|
3619
3715
|
writer->index = NULL;
|
3620
3716
|
}
|
3717
|
+
|
3718
|
+
/* Deprecated functions */
|
3719
|
+
|
3720
|
+
int git_index_add_frombuffer(
|
3721
|
+
git_index *index, const git_index_entry *source_entry,
|
3722
|
+
const void *buffer, size_t len)
|
3723
|
+
{
|
3724
|
+
return git_index_add_from_buffer(index, source_entry, buffer, len);
|
3725
|
+
}
|