rugged 1.6.3 → 1.9.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/ext/rugged/rugged_allocator.c +0 -54
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +25 -17
- data/vendor/libgit2/COPYING +195 -1
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/{FindIconv.cmake → FindIntlIconv.cmake} +6 -0
- data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +4 -4
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +23 -8
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +34 -6
- data/vendor/libgit2/cmake/SelectHashes.cmake +32 -11
- data/vendor/libgit2/cmake/SelectRegex.cmake +6 -1
- data/vendor/libgit2/cmake/SelectSSH.cmake +22 -17
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +4 -0
- data/vendor/libgit2/deps/llhttp/CMakeLists.txt +8 -0
- data/vendor/libgit2/deps/llhttp/LICENSE-MIT +22 -0
- data/vendor/libgit2/deps/llhttp/api.c +510 -0
- data/vendor/libgit2/deps/llhttp/http.c +170 -0
- data/vendor/libgit2/deps/llhttp/llhttp.c +10168 -0
- data/vendor/libgit2/deps/llhttp/llhttp.h +897 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +1 -1
- data/vendor/libgit2/deps/ntlmclient/crypt_builtin_md4.c +311 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +2 -1
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +21 -21
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +5 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +2 -1
- data/vendor/libgit2/deps/ntlmclient/utf8.h +1176 -721
- data/vendor/libgit2/deps/ntlmclient/util.h +11 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +22 -20
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -1
- data/vendor/libgit2/deps/zlib/LICENSE +22 -0
- data/vendor/libgit2/deps/zlib/adler32.c +5 -27
- data/vendor/libgit2/deps/zlib/crc32.c +94 -167
- data/vendor/libgit2/deps/zlib/deflate.c +358 -435
- data/vendor/libgit2/deps/zlib/deflate.h +41 -10
- data/vendor/libgit2/deps/zlib/gzguts.h +13 -18
- data/vendor/libgit2/deps/zlib/infback.c +17 -30
- data/vendor/libgit2/deps/zlib/inffast.c +1 -4
- data/vendor/libgit2/deps/zlib/inffast.h +1 -1
- data/vendor/libgit2/deps/zlib/inflate.c +36 -102
- data/vendor/libgit2/deps/zlib/inftrees.c +6 -11
- data/vendor/libgit2/deps/zlib/inftrees.h +6 -6
- data/vendor/libgit2/deps/zlib/trees.c +287 -352
- data/vendor/libgit2/deps/zlib/zconf.h +23 -14
- data/vendor/libgit2/deps/zlib/zlib.h +202 -202
- data/vendor/libgit2/deps/zlib/zutil.c +18 -44
- data/vendor/libgit2/deps/zlib/zutil.h +13 -33
- data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
- data/vendor/libgit2/include/git2/apply.h +27 -6
- data/vendor/libgit2/include/git2/attr.h +17 -4
- data/vendor/libgit2/include/git2/blame.h +133 -28
- data/vendor/libgit2/include/git2/blob.h +71 -28
- data/vendor/libgit2/include/git2/branch.h +22 -15
- data/vendor/libgit2/include/git2/buffer.h +6 -4
- data/vendor/libgit2/include/git2/cert.h +2 -1
- data/vendor/libgit2/include/git2/checkout.h +83 -32
- data/vendor/libgit2/include/git2/cherrypick.h +10 -3
- data/vendor/libgit2/include/git2/clone.h +25 -9
- data/vendor/libgit2/include/git2/commit.h +132 -3
- data/vendor/libgit2/include/git2/common.h +138 -56
- data/vendor/libgit2/include/git2/config.h +93 -23
- data/vendor/libgit2/include/git2/credential.h +30 -2
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +133 -3
- data/vendor/libgit2/include/git2/describe.h +13 -1
- data/vendor/libgit2/include/git2/diff.h +77 -9
- data/vendor/libgit2/include/git2/email.h +9 -29
- data/vendor/libgit2/include/git2/errors.h +49 -74
- data/vendor/libgit2/include/git2/filter.h +14 -7
- data/vendor/libgit2/include/git2/global.h +8 -1
- data/vendor/libgit2/include/git2/graph.h +3 -2
- data/vendor/libgit2/include/git2/ignore.h +10 -0
- data/vendor/libgit2/include/git2/index.h +100 -6
- data/vendor/libgit2/include/git2/indexer.h +21 -4
- data/vendor/libgit2/include/git2/mailmap.h +7 -1
- data/vendor/libgit2/include/git2/merge.h +46 -1
- data/vendor/libgit2/include/git2/message.h +2 -2
- data/vendor/libgit2/include/git2/net.h +3 -1
- data/vendor/libgit2/include/git2/notes.h +9 -6
- data/vendor/libgit2/include/git2/object.h +9 -8
- data/vendor/libgit2/include/git2/odb.h +91 -49
- data/vendor/libgit2/include/git2/odb_backend.h +80 -52
- data/vendor/libgit2/include/git2/oid.h +24 -25
- data/vendor/libgit2/include/git2/oidarray.h +7 -1
- data/vendor/libgit2/include/git2/pack.h +13 -1
- data/vendor/libgit2/include/git2/patch.h +2 -3
- data/vendor/libgit2/include/git2/pathspec.h +9 -0
- data/vendor/libgit2/include/git2/proxy.h +10 -0
- data/vendor/libgit2/include/git2/rebase.h +9 -6
- data/vendor/libgit2/include/git2/refdb.h +2 -2
- data/vendor/libgit2/include/git2/reflog.h +3 -2
- data/vendor/libgit2/include/git2/refs.h +9 -6
- data/vendor/libgit2/include/git2/refspec.h +14 -4
- data/vendor/libgit2/include/git2/remote.h +112 -18
- data/vendor/libgit2/include/git2/repository.h +61 -15
- data/vendor/libgit2/include/git2/reset.h +16 -3
- data/vendor/libgit2/include/git2/revert.h +9 -4
- data/vendor/libgit2/include/git2/revparse.h +3 -3
- data/vendor/libgit2/include/git2/revwalk.h +3 -2
- data/vendor/libgit2/include/git2/signature.h +46 -1
- data/vendor/libgit2/include/git2/stash.h +17 -3
- data/vendor/libgit2/include/git2/status.h +10 -6
- data/vendor/libgit2/include/git2/stdint.h +87 -85
- data/vendor/libgit2/include/git2/strarray.h +2 -3
- data/vendor/libgit2/include/git2/submodule.h +20 -9
- data/vendor/libgit2/include/git2/sys/alloc.h +12 -34
- data/vendor/libgit2/include/git2/sys/commit.h +77 -3
- data/vendor/libgit2/include/git2/sys/commit_graph.h +109 -58
- data/vendor/libgit2/include/git2/sys/config.h +80 -4
- data/vendor/libgit2/include/git2/sys/credential.h +4 -3
- data/vendor/libgit2/include/git2/sys/diff.h +21 -1
- data/vendor/libgit2/include/git2/sys/email.h +7 -0
- data/vendor/libgit2/include/git2/sys/errors.h +76 -0
- data/vendor/libgit2/include/git2/sys/filter.h +66 -3
- data/vendor/libgit2/include/git2/sys/hashsig.h +11 -0
- data/vendor/libgit2/include/git2/sys/index.h +3 -2
- data/vendor/libgit2/include/git2/sys/mempack.h +32 -2
- data/vendor/libgit2/include/git2/sys/merge.h +55 -7
- data/vendor/libgit2/include/git2/sys/midx.h +47 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -3
- data/vendor/libgit2/include/git2/sys/openssl.h +8 -1
- data/vendor/libgit2/include/git2/sys/path.h +12 -1
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -36
- data/vendor/libgit2/include/git2/sys/refs.h +3 -2
- data/vendor/libgit2/include/git2/sys/remote.h +8 -1
- data/vendor/libgit2/include/git2/sys/repository.h +63 -3
- data/vendor/libgit2/include/git2/sys/stream.h +25 -2
- data/vendor/libgit2/include/git2/sys/transport.h +44 -5
- data/vendor/libgit2/include/git2/tag.h +3 -1
- data/vendor/libgit2/include/git2/trace.h +9 -3
- data/vendor/libgit2/include/git2/transaction.h +3 -2
- data/vendor/libgit2/include/git2/transport.h +11 -3
- data/vendor/libgit2/include/git2/tree.h +16 -5
- data/vendor/libgit2/include/git2/types.h +19 -3
- data/vendor/libgit2/include/git2/version.h +44 -8
- data/vendor/libgit2/include/git2/worktree.h +19 -7
- data/vendor/libgit2/src/CMakeLists.txt +40 -15
- data/vendor/libgit2/src/cli/CMakeLists.txt +2 -2
- data/vendor/libgit2/src/cli/cmd.c +1 -1
- data/vendor/libgit2/src/cli/cmd.h +4 -0
- data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
- data/vendor/libgit2/src/cli/cmd_cat_file.c +6 -8
- data/vendor/libgit2/src/cli/cmd_clone.c +27 -13
- data/vendor/libgit2/src/cli/cmd_config.c +241 -0
- data/vendor/libgit2/src/cli/cmd_hash_object.c +6 -8
- data/vendor/libgit2/src/cli/cmd_help.c +6 -7
- data/vendor/libgit2/src/cli/cmd_index_pack.c +114 -0
- data/vendor/libgit2/src/cli/cmd_init.c +102 -0
- data/vendor/libgit2/src/cli/common.c +168 -0
- data/vendor/libgit2/src/cli/common.h +63 -0
- data/vendor/libgit2/src/cli/error.h +1 -1
- data/vendor/libgit2/src/cli/main.c +52 -24
- data/vendor/libgit2/src/cli/opt.c +29 -3
- data/vendor/libgit2/src/cli/opt.h +21 -3
- data/vendor/libgit2/src/cli/opt_usage.c +102 -33
- data/vendor/libgit2/src/cli/opt_usage.h +6 -1
- data/vendor/libgit2/src/cli/progress.c +60 -10
- data/vendor/libgit2/src/cli/progress.h +16 -4
- data/vendor/libgit2/src/cli/unix/sighandler.c +2 -1
- data/vendor/libgit2/src/cli/win32/precompiled.h +1 -1
- data/vendor/libgit2/src/cli/win32/sighandler.c +1 -1
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +27 -27
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +14 -16
- data/vendor/libgit2/src/libgit2/attr.c +30 -13
- data/vendor/libgit2/src/libgit2/attr_file.c +7 -2
- data/vendor/libgit2/src/libgit2/attr_file.h +2 -0
- data/vendor/libgit2/src/libgit2/attrcache.c +69 -33
- data/vendor/libgit2/src/libgit2/attrcache.h +5 -9
- data/vendor/libgit2/src/libgit2/blame.c +152 -59
- data/vendor/libgit2/src/libgit2/blame.h +1 -0
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cache.c +22 -17
- data/vendor/libgit2/src/libgit2/cache.h +7 -9
- data/vendor/libgit2/src/libgit2/checkout.c +34 -24
- data/vendor/libgit2/src/libgit2/checkout.h +0 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +4 -5
- data/vendor/libgit2/src/libgit2/clone.c +186 -164
- data/vendor/libgit2/src/libgit2/clone.h +4 -1
- data/vendor/libgit2/src/libgit2/commit.c +123 -9
- data/vendor/libgit2/src/libgit2/commit_graph.c +166 -88
- data/vendor/libgit2/src/libgit2/commit_graph.h +21 -6
- data/vendor/libgit2/src/libgit2/commit_list.c +12 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +394 -300
- data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
- data/vendor/libgit2/src/libgit2/config.h +9 -4
- data/vendor/libgit2/src/libgit2/config_backend.h +8 -10
- data/vendor/libgit2/src/libgit2/config_cache.c +4 -5
- data/vendor/libgit2/src/libgit2/config_file.c +113 -96
- data/vendor/libgit2/src/libgit2/config_list.c +285 -0
- data/vendor/libgit2/src/libgit2/config_list.h +32 -0
- data/vendor/libgit2/src/libgit2/config_mem.c +194 -40
- data/vendor/libgit2/src/libgit2/config_parse.c +10 -9
- data/vendor/libgit2/src/libgit2/config_snapshot.c +24 -31
- data/vendor/libgit2/src/libgit2/describe.c +34 -31
- data/vendor/libgit2/src/libgit2/diff.c +17 -8
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_driver.c +12 -19
- data/vendor/libgit2/src/libgit2/diff_driver.h +2 -2
- data/vendor/libgit2/src/libgit2/diff_file.c +7 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +39 -18
- data/vendor/libgit2/src/libgit2/diff_parse.c +22 -6
- data/vendor/libgit2/src/libgit2/diff_print.c +88 -13
- data/vendor/libgit2/src/libgit2/diff_tform.c +40 -12
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +5 -3
- data/vendor/libgit2/src/libgit2/fetch.c +39 -9
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/filter.c +5 -5
- data/vendor/libgit2/src/libgit2/git2.rc +3 -3
- data/vendor/libgit2/src/libgit2/grafts.c +270 -0
- data/vendor/libgit2/src/libgit2/grafts.h +35 -0
- data/vendor/libgit2/src/libgit2/graph.c +1 -1
- data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/ignore.c +9 -5
- data/vendor/libgit2/src/libgit2/index.c +392 -208
- data/vendor/libgit2/src/libgit2/index.h +16 -3
- data/vendor/libgit2/src/libgit2/index_map.c +95 -0
- data/vendor/libgit2/src/libgit2/index_map.h +28 -0
- data/vendor/libgit2/src/libgit2/indexer.c +44 -41
- data/vendor/libgit2/src/libgit2/iterator.c +34 -13
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +155 -331
- data/vendor/libgit2/src/libgit2/mailmap.c +1 -1
- data/vendor/libgit2/src/libgit2/merge.c +56 -46
- data/vendor/libgit2/src/libgit2/merge_driver.c +2 -2
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +86 -44
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +38 -45
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -0
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +42 -16
- data/vendor/libgit2/src/libgit2/object.h +6 -0
- data/vendor/libgit2/src/libgit2/odb.c +16 -9
- data/vendor/libgit2/src/libgit2/odb_mempack.c +49 -17
- data/vendor/libgit2/src/libgit2/odb_pack.c +28 -7
- data/vendor/libgit2/src/libgit2/oid.c +35 -2
- data/vendor/libgit2/src/libgit2/oid.h +11 -0
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +77 -43
- data/vendor/libgit2/src/libgit2/pack-objects.h +17 -6
- data/vendor/libgit2/src/libgit2/pack.c +33 -27
- data/vendor/libgit2/src/libgit2/pack.h +15 -10
- data/vendor/libgit2/src/libgit2/parse.c +7 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +18 -10
- data/vendor/libgit2/src/libgit2/path.c +1 -1
- data/vendor/libgit2/src/libgit2/pathspec.c +1 -1
- data/vendor/libgit2/src/libgit2/push.c +81 -30
- data/vendor/libgit2/src/libgit2/push.h +1 -0
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -84
- data/vendor/libgit2/src/libgit2/refdb_fs.c +146 -70
- data/vendor/libgit2/src/libgit2/reflog.c +1 -2
- data/vendor/libgit2/src/libgit2/reflog.h +2 -0
- data/vendor/libgit2/src/libgit2/refs.c +34 -8
- data/vendor/libgit2/src/libgit2/refs.h +6 -1
- data/vendor/libgit2/src/libgit2/refspec.c +28 -1
- data/vendor/libgit2/src/libgit2/refspec.h +8 -0
- data/vendor/libgit2/src/libgit2/remote.c +136 -67
- data/vendor/libgit2/src/libgit2/remote.h +1 -0
- data/vendor/libgit2/src/libgit2/repository.c +789 -330
- data/vendor/libgit2/src/libgit2/repository.h +22 -3
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +9 -13
- data/vendor/libgit2/src/libgit2/revparse.c +6 -3
- data/vendor/libgit2/src/libgit2/revwalk.c +36 -11
- data/vendor/libgit2/src/libgit2/revwalk.h +3 -3
- data/vendor/libgit2/src/libgit2/settings.c +468 -0
- data/vendor/libgit2/src/libgit2/settings.h +6 -2
- data/vendor/libgit2/src/libgit2/signature.c +132 -15
- data/vendor/libgit2/src/libgit2/signature.h +0 -1
- data/vendor/libgit2/src/libgit2/stash.c +9 -8
- data/vendor/libgit2/src/libgit2/status.c +1 -1
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +54 -61
- data/vendor/libgit2/src/libgit2/streams/openssl.c +40 -23
- data/vendor/libgit2/src/libgit2/streams/openssl.h +2 -0
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +4 -0
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.h +3 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +237 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +79 -19
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.c +106 -63
- data/vendor/libgit2/src/libgit2/submodule.h +9 -10
- data/vendor/libgit2/src/libgit2/tag.c +1 -1
- data/vendor/libgit2/src/libgit2/trailer.c +6 -6
- data/vendor/libgit2/src/libgit2/transaction.c +26 -20
- data/vendor/libgit2/src/libgit2/transaction.h +4 -1
- data/vendor/libgit2/src/libgit2/transport.c +4 -1
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/credential.c +1 -1
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +8 -4
- data/vendor/libgit2/src/libgit2/transports/http.h +0 -10
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +117 -72
- data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
- data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +21 -11
- data/vendor/libgit2/src/libgit2/transports/smart.c +50 -32
- data/vendor/libgit2/src/libgit2/transports/smart.h +26 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +139 -18
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +209 -57
- data/vendor/libgit2/src/libgit2/transports/ssh.c +41 -1103
- data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +347 -0
- data/vendor/libgit2/src/libgit2/transports/ssh_exec.h +26 -0
- data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.c +1126 -0
- data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +48 -21
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +35 -27
- data/vendor/libgit2/src/libgit2/tree.h +3 -2
- data/vendor/libgit2/src/libgit2/worktree.c +39 -27
- data/vendor/libgit2/src/util/CMakeLists.txt +4 -6
- data/vendor/libgit2/src/util/alloc.c +69 -7
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
- data/vendor/libgit2/src/{cli/cli.h → util/allocators/debugalloc.h} +6 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -115
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +24 -18
- data/vendor/libgit2/src/util/cc-compat.h +4 -0
- data/vendor/libgit2/src/util/ctype_compat.h +70 -0
- data/vendor/libgit2/src/util/date.c +22 -14
- data/vendor/libgit2/src/util/date.h +12 -0
- data/vendor/libgit2/src/util/errors.c +401 -0
- data/vendor/libgit2/src/{libgit2 → util}/errors.h +21 -17
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +16 -5
- data/vendor/libgit2/src/util/fs_path.h +23 -0
- data/vendor/libgit2/src/util/futils.c +14 -10
- data/vendor/libgit2/src/util/futils.h +13 -4
- data/vendor/libgit2/src/util/git2_features.h.in +21 -4
- data/vendor/libgit2/src/util/git2_util.h +6 -0
- data/vendor/libgit2/src/util/hash/openssl.c +152 -0
- data/vendor/libgit2/src/util/hash/openssl.h +17 -1
- data/vendor/libgit2/src/util/hash/sha.h +4 -1
- data/vendor/libgit2/src/util/hashmap.h +424 -0
- data/vendor/libgit2/src/util/hashmap_str.h +43 -0
- data/vendor/libgit2/src/util/integer.h +3 -1
- data/vendor/libgit2/src/util/net.c +318 -161
- data/vendor/libgit2/src/util/net.h +27 -0
- data/vendor/libgit2/src/util/pool.c +1 -1
- data/vendor/libgit2/src/util/pool.h +5 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +22 -0
- data/vendor/libgit2/src/util/pqueue.h +1 -1
- data/vendor/libgit2/src/util/process.h +222 -0
- data/vendor/libgit2/src/util/rand.c +6 -10
- data/vendor/libgit2/src/util/regexp.c +1 -1
- data/vendor/libgit2/src/util/sortedcache.c +14 -13
- data/vendor/libgit2/src/util/sortedcache.h +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/str.c +2 -2
- data/vendor/libgit2/src/util/strlist.c +108 -0
- data/vendor/libgit2/src/util/strlist.h +36 -0
- data/vendor/libgit2/src/util/unix/posix.h +0 -2
- data/vendor/libgit2/src/util/unix/process.c +629 -0
- data/vendor/libgit2/src/util/unix/realpath.c +23 -5
- data/vendor/libgit2/src/util/util.c +17 -12
- data/vendor/libgit2/src/util/util.h +28 -54
- data/vendor/libgit2/src/util/vector.c +3 -3
- data/vendor/libgit2/src/util/vector.h +2 -2
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +30 -7
- data/vendor/libgit2/src/util/win32/process.c +506 -0
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +72 -49
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -6
- data/vendor/libgit2/deps/http-parser/COPYING +0 -23
- data/vendor/libgit2/deps/http-parser/http_parser.c +0 -2182
- data/vendor/libgit2/deps/http-parser/http_parser.h +0 -305
- data/vendor/libgit2/deps/zlib/COPYING +0 -27
- data/vendor/libgit2/include/git2/sys/reflog.h +0 -21
- data/vendor/libgit2/src/libgit2/config_entries.c +0 -237
- data/vendor/libgit2/src/libgit2/config_entries.h +0 -24
- data/vendor/libgit2/src/libgit2/errors.c +0 -238
- data/vendor/libgit2/src/libgit2/idxmap.c +0 -157
- data/vendor/libgit2/src/libgit2/idxmap.h +0 -177
- data/vendor/libgit2/src/libgit2/libgit2.h +0 -15
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- data/vendor/libgit2/src/libgit2/offmap.c +0 -101
- data/vendor/libgit2/src/libgit2/offmap.h +0 -133
- data/vendor/libgit2/src/libgit2/oidmap.c +0 -107
- data/vendor/libgit2/src/libgit2/oidmap.h +0 -128
- data/vendor/libgit2/src/libgit2/threadstate.c +0 -84
- data/vendor/libgit2/src/libgit2/threadstate.h +0 -24
- data/vendor/libgit2/src/libgit2/transports/ssh.h +0 -14
- data/vendor/libgit2/src/util/khash.h +0 -615
- data/vendor/libgit2/src/util/strmap.c +0 -100
- data/vendor/libgit2/src/util/strmap.h +0 -131
- /data/vendor/libgit2/cmake/{FindHTTPParser.cmake → FindHTTP_Parser.cmake} +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -17,10 +17,10 @@
|
|
17
17
|
#include "pathspec.h"
|
18
18
|
#include "ignore.h"
|
19
19
|
#include "blob.h"
|
20
|
-
#include "idxmap.h"
|
21
20
|
#include "diff.h"
|
22
21
|
#include "varint.h"
|
23
22
|
#include "path.h"
|
23
|
+
#include "index_map.h"
|
24
24
|
|
25
25
|
#include "git2/odb.h"
|
26
26
|
#include "git2/oid.h"
|
@@ -32,8 +32,6 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr
|
|
32
32
|
unsigned int flags,
|
33
33
|
git_index_matched_path_cb cb, void *payload);
|
34
34
|
|
35
|
-
#define minimal_entry_size (offsetof(struct entry_short, path))
|
36
|
-
|
37
35
|
static const size_t INDEX_HEADER_SIZE = 12;
|
38
36
|
|
39
37
|
static const unsigned int INDEX_VERSION_NUMBER_DEFAULT = 2;
|
@@ -65,7 +63,7 @@ struct entry_time {
|
|
65
63
|
uint32_t nanoseconds;
|
66
64
|
};
|
67
65
|
|
68
|
-
struct
|
66
|
+
struct entry_common {
|
69
67
|
struct entry_time ctime;
|
70
68
|
struct entry_time mtime;
|
71
69
|
uint32_t dev;
|
@@ -74,25 +72,35 @@ struct entry_short {
|
|
74
72
|
uint32_t uid;
|
75
73
|
uint32_t gid;
|
76
74
|
uint32_t file_size;
|
77
|
-
unsigned char oid[GIT_OID_SHA1_SIZE];
|
78
|
-
uint16_t flags;
|
79
|
-
char path[1]; /* arbitrary length */
|
80
75
|
};
|
81
76
|
|
82
|
-
|
83
|
-
struct
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
77
|
+
#define entry_short(oid_size) \
|
78
|
+
struct { \
|
79
|
+
struct entry_common common; \
|
80
|
+
unsigned char oid[oid_size]; \
|
81
|
+
uint16_t flags; \
|
82
|
+
char path[1]; /* arbitrary length */ \
|
83
|
+
}
|
84
|
+
|
85
|
+
#define entry_long(oid_size) \
|
86
|
+
struct { \
|
87
|
+
struct entry_common common; \
|
88
|
+
unsigned char oid[oid_size]; \
|
89
|
+
uint16_t flags; \
|
90
|
+
uint16_t flags_extended; \
|
91
|
+
char path[1]; /* arbitrary length */ \
|
92
|
+
}
|
93
|
+
|
94
|
+
typedef entry_short(GIT_OID_SHA1_SIZE) index_entry_short_sha1;
|
95
|
+
typedef entry_long(GIT_OID_SHA1_SIZE) index_entry_long_sha1;
|
96
|
+
|
97
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
98
|
+
typedef entry_short(GIT_OID_SHA256_SIZE) index_entry_short_sha256;
|
99
|
+
typedef entry_long(GIT_OID_SHA256_SIZE) index_entry_long_sha256;
|
100
|
+
#endif
|
101
|
+
|
102
|
+
#undef entry_short
|
103
|
+
#undef entry_long
|
96
104
|
|
97
105
|
struct entry_srch_key {
|
98
106
|
const char *path;
|
@@ -115,40 +123,16 @@ struct reuc_entry_internal {
|
|
115
123
|
bool git_index__enforce_unsaved_safety = false;
|
116
124
|
|
117
125
|
/* local declarations */
|
118
|
-
static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size);
|
126
|
+
static int read_extension(size_t *read_len, git_index *index, size_t checksum_size, const char *buffer, size_t buffer_size);
|
119
127
|
static int read_header(struct index_header *dest, const void *buffer);
|
120
128
|
|
121
129
|
static int parse_index(git_index *index, const char *buffer, size_t buffer_size);
|
122
130
|
static bool is_index_extended(git_index *index);
|
123
|
-
static int write_index(unsigned char checksum[
|
131
|
+
static int write_index(unsigned char checksum[GIT_HASH_MAX_SIZE], size_t *checksum_size, git_index *index, git_filebuf *file);
|
124
132
|
|
125
133
|
static void index_entry_free(git_index_entry *entry);
|
126
134
|
static void index_entry_reuc_free(git_index_reuc_entry *reuc);
|
127
135
|
|
128
|
-
GIT_INLINE(int) index_map_set(git_idxmap *map, git_index_entry *e, bool ignore_case)
|
129
|
-
{
|
130
|
-
if (ignore_case)
|
131
|
-
return git_idxmap_icase_set((git_idxmap_icase *) map, e, e);
|
132
|
-
else
|
133
|
-
return git_idxmap_set(map, e, e);
|
134
|
-
}
|
135
|
-
|
136
|
-
GIT_INLINE(int) index_map_delete(git_idxmap *map, git_index_entry *e, bool ignore_case)
|
137
|
-
{
|
138
|
-
if (ignore_case)
|
139
|
-
return git_idxmap_icase_delete((git_idxmap_icase *) map, e);
|
140
|
-
else
|
141
|
-
return git_idxmap_delete(map, e);
|
142
|
-
}
|
143
|
-
|
144
|
-
GIT_INLINE(int) index_map_resize(git_idxmap *map, size_t count, bool ignore_case)
|
145
|
-
{
|
146
|
-
if (ignore_case)
|
147
|
-
return git_idxmap_icase_resize((git_idxmap_icase *) map, count);
|
148
|
-
else
|
149
|
-
return git_idxmap_resize(map, count);
|
150
|
-
}
|
151
|
-
|
152
136
|
int git_index_entry_srch(const void *key, const void *array_member)
|
153
137
|
{
|
154
138
|
const struct entry_srch_key *srch_key = key;
|
@@ -380,6 +364,7 @@ GIT_INLINE(int) index_find(
|
|
380
364
|
void git_index__set_ignore_case(git_index *index, bool ignore_case)
|
381
365
|
{
|
382
366
|
index->ignore_case = ignore_case;
|
367
|
+
index->entries_map.ignore_case = ignore_case;
|
383
368
|
|
384
369
|
if (ignore_case) {
|
385
370
|
index->entries_cmp_path = git__strcasecmp_cb;
|
@@ -401,7 +386,10 @@ void git_index__set_ignore_case(git_index *index, bool ignore_case)
|
|
401
386
|
git_vector_sort(&index->reuc);
|
402
387
|
}
|
403
388
|
|
404
|
-
int
|
389
|
+
int git_index__open(
|
390
|
+
git_index **index_out,
|
391
|
+
const char *index_path,
|
392
|
+
git_oid_t oid_type)
|
405
393
|
{
|
406
394
|
git_index *index;
|
407
395
|
int error = -1;
|
@@ -411,6 +399,9 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
411
399
|
index = git__calloc(1, sizeof(git_index));
|
412
400
|
GIT_ERROR_CHECK_ALLOC(index);
|
413
401
|
|
402
|
+
GIT_ASSERT_ARG(git_oid_type_is_valid(oid_type));
|
403
|
+
index->oid_type = oid_type;
|
404
|
+
|
414
405
|
if (git_pool_init(&index->tree_pool, 1) < 0)
|
415
406
|
goto fail;
|
416
407
|
|
@@ -425,7 +416,6 @@ int git_index_open(git_index **index_out, const char *index_path)
|
|
425
416
|
}
|
426
417
|
|
427
418
|
if (git_vector_init(&index->entries, 32, git_index_entry_cmp) < 0 ||
|
428
|
-
git_idxmap_new(&index->entries_map) < 0 ||
|
429
419
|
git_vector_init(&index->names, 8, conflict_name_cmp) < 0 ||
|
430
420
|
git_vector_init(&index->reuc, 8, reuc_cmp) < 0 ||
|
431
421
|
git_vector_init(&index->deleted, 8, git_index_entry_cmp) < 0)
|
@@ -451,10 +441,39 @@ fail:
|
|
451
441
|
return error;
|
452
442
|
}
|
453
443
|
|
444
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
445
|
+
int git_index_open(
|
446
|
+
git_index **index_out,
|
447
|
+
const char *index_path,
|
448
|
+
const git_index_options *opts)
|
449
|
+
{
|
450
|
+
return git_index__open(index_out, index_path,
|
451
|
+
opts && opts->oid_type ? opts->oid_type : GIT_OID_DEFAULT);
|
452
|
+
}
|
453
|
+
#else
|
454
|
+
int git_index_open(git_index **index_out, const char *index_path)
|
455
|
+
{
|
456
|
+
return git_index__open(index_out, index_path, GIT_OID_SHA1);
|
457
|
+
}
|
458
|
+
#endif
|
459
|
+
|
460
|
+
int git_index__new(git_index **out, git_oid_t oid_type)
|
461
|
+
{
|
462
|
+
return git_index__open(out, NULL, oid_type);
|
463
|
+
}
|
464
|
+
|
465
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
466
|
+
int git_index_new(git_index **out, const git_index_options *opts)
|
467
|
+
{
|
468
|
+
return git_index__new(out,
|
469
|
+
opts && opts->oid_type ? opts->oid_type : GIT_OID_DEFAULT);
|
470
|
+
}
|
471
|
+
#else
|
454
472
|
int git_index_new(git_index **out)
|
455
473
|
{
|
456
|
-
return
|
474
|
+
return git_index__new(out, GIT_OID_SHA1);
|
457
475
|
}
|
476
|
+
#endif
|
458
477
|
|
459
478
|
static void index_free(git_index *index)
|
460
479
|
{
|
@@ -465,11 +484,11 @@ static void index_free(git_index *index)
|
|
465
484
|
return;
|
466
485
|
|
467
486
|
git_index_clear(index);
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
487
|
+
git_index_entrymap_dispose(&index->entries_map);
|
488
|
+
git_vector_dispose(&index->entries);
|
489
|
+
git_vector_dispose(&index->names);
|
490
|
+
git_vector_dispose(&index->reuc);
|
491
|
+
git_vector_dispose(&index->deleted);
|
473
492
|
|
474
493
|
git__free(index->index_file_path);
|
475
494
|
|
@@ -510,7 +529,7 @@ static int index_remove_entry(git_index *index, size_t pos)
|
|
510
529
|
|
511
530
|
if (entry != NULL) {
|
512
531
|
git_tree_cache_invalidate_path(index->tree, entry->path);
|
513
|
-
|
532
|
+
git_index_entrymap_remove(&index->entries_map, entry);
|
514
533
|
}
|
515
534
|
|
516
535
|
error = git_vector_remove(&index->entries, pos);
|
@@ -538,7 +557,8 @@ int git_index_clear(git_index *index)
|
|
538
557
|
index->tree = NULL;
|
539
558
|
git_pool_clear(&index->tree_pool);
|
540
559
|
|
541
|
-
|
560
|
+
git_index_entrymap_clear(&index->entries_map);
|
561
|
+
|
542
562
|
while (!error && index->entries.length > 0)
|
543
563
|
error = index_remove_entry(index, index->entries.length - 1);
|
544
564
|
|
@@ -620,8 +640,8 @@ static int compare_checksum(git_index *index)
|
|
620
640
|
{
|
621
641
|
int fd;
|
622
642
|
ssize_t bytes_read;
|
623
|
-
unsigned char checksum[
|
624
|
-
size_t checksum_size =
|
643
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
644
|
+
size_t checksum_size = git_oid_size(index->oid_type);
|
625
645
|
|
626
646
|
if ((fd = p_open(index->index_file_path, O_RDONLY)) < 0)
|
627
647
|
return fd;
|
@@ -749,8 +769,10 @@ static int truncate_racily_clean(git_index *index)
|
|
749
769
|
diff_opts.pathspec.count = paths.length;
|
750
770
|
diff_opts.pathspec.strings = (char **)paths.contents;
|
751
771
|
|
752
|
-
if ((error = git_diff_index_to_workdir(&diff, INDEX_OWNER(index), index, &diff_opts)) < 0)
|
772
|
+
if ((error = git_diff_index_to_workdir(&diff, INDEX_OWNER(index), index, &diff_opts)) < 0) {
|
773
|
+
git_vector_dispose(&paths);
|
753
774
|
return error;
|
775
|
+
}
|
754
776
|
|
755
777
|
git_vector_foreach(&diff->deltas, i, delta) {
|
756
778
|
entry = (git_index_entry *)git_index_get_bypath(index, delta->old_file.path, 0);
|
@@ -766,7 +788,7 @@ static int truncate_racily_clean(git_index *index)
|
|
766
788
|
|
767
789
|
done:
|
768
790
|
git_diff_free(diff);
|
769
|
-
|
791
|
+
git_vector_dispose(&paths);
|
770
792
|
return 0;
|
771
793
|
}
|
772
794
|
|
@@ -867,14 +889,9 @@ const git_index_entry *git_index_get_bypath(
|
|
867
889
|
key.path = path;
|
868
890
|
GIT_INDEX_ENTRY_STAGE_SET(&key, stage);
|
869
891
|
|
870
|
-
if (index->
|
871
|
-
|
872
|
-
|
873
|
-
value = git_idxmap_get(index->entries_map, &key);
|
874
|
-
|
875
|
-
if (!value) {
|
876
|
-
git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
|
877
|
-
return NULL;
|
892
|
+
if (git_index_entrymap_get(&value, &index->entries_map, &key) != 0) {
|
893
|
+
git_error_set(GIT_ERROR_INDEX, "index does not contain '%s'", path);
|
894
|
+
return NULL;
|
878
895
|
}
|
879
896
|
|
880
897
|
return value;
|
@@ -1148,10 +1165,13 @@ static int has_dir_name(git_index *index,
|
|
1148
1165
|
size_t len, pos;
|
1149
1166
|
|
1150
1167
|
for (;;) {
|
1151
|
-
|
1152
|
-
|
1168
|
+
slash--;
|
1169
|
+
|
1153
1170
|
if (slash <= entry->path)
|
1154
1171
|
return 0;
|
1172
|
+
|
1173
|
+
if (*slash == '/')
|
1174
|
+
break;
|
1155
1175
|
}
|
1156
1176
|
len = slash - name;
|
1157
1177
|
|
@@ -1413,7 +1433,7 @@ static int index_insert(
|
|
1413
1433
|
* check for dups, this is actually cheaper in the long run.)
|
1414
1434
|
*/
|
1415
1435
|
if ((error = git_vector_insert_sorted(&index->entries, entry, index_no_dups)) < 0 ||
|
1416
|
-
(error =
|
1436
|
+
(error = git_index_entrymap_put(&index->entries_map, entry)) < 0)
|
1417
1437
|
goto out;
|
1418
1438
|
}
|
1419
1439
|
|
@@ -1572,15 +1592,17 @@ int git_index_add_bypath(git_index *index, const char *path)
|
|
1572
1592
|
|
1573
1593
|
if (ret == GIT_EDIRECTORY) {
|
1574
1594
|
git_submodule *sm;
|
1575
|
-
|
1595
|
+
git_error *last_error;
|
1576
1596
|
|
1577
|
-
|
1597
|
+
git_error_save(&last_error);
|
1578
1598
|
|
1579
1599
|
ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path);
|
1580
|
-
if (ret == GIT_ENOTFOUND)
|
1581
|
-
|
1600
|
+
if (ret == GIT_ENOTFOUND) {
|
1601
|
+
git_error_restore(last_error);
|
1602
|
+
return GIT_EDIRECTORY;
|
1603
|
+
}
|
1582
1604
|
|
1583
|
-
|
1605
|
+
git_error_free(last_error);
|
1584
1606
|
|
1585
1607
|
/*
|
1586
1608
|
* EEXISTS means that there is a repository at that path, but it's not known
|
@@ -1640,8 +1662,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1640
1662
|
return 0;
|
1641
1663
|
|
1642
1664
|
if (git_vector_size_hint(&index->entries, source_entries->length) < 0 ||
|
1643
|
-
|
1644
|
-
index->ignore_case) < 0)
|
1665
|
+
git_index_entrymap_resize(&index->entries_map, (size_t)(source_entries->length * 1.3)) < 0)
|
1645
1666
|
return -1;
|
1646
1667
|
|
1647
1668
|
git_vector_foreach(source_entries, i, source_entry) {
|
@@ -1654,10 +1675,8 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
|
|
1654
1675
|
entry->flags_extended |= GIT_INDEX_ENTRY_UPTODATE;
|
1655
1676
|
entry->mode = git_index__create_mode(entry->mode);
|
1656
1677
|
|
1657
|
-
if ((error = git_vector_insert(&index->entries, entry)) < 0
|
1658
|
-
|
1659
|
-
|
1660
|
-
if ((error = index_map_set(index->entries_map, entry, index->ignore_case)) < 0)
|
1678
|
+
if ((error = git_vector_insert(&index->entries, entry)) < 0 ||
|
1679
|
+
(error = git_index_entrymap_put(&index->entries_map, entry)) < 0)
|
1661
1680
|
break;
|
1662
1681
|
|
1663
1682
|
index->dirty = 1;
|
@@ -1700,7 +1719,7 @@ int git_index_remove(git_index *index, const char *path, int stage)
|
|
1700
1719
|
remove_key.path = path;
|
1701
1720
|
GIT_INDEX_ENTRY_STAGE_SET(&remove_key, stage);
|
1702
1721
|
|
1703
|
-
|
1722
|
+
git_index_entrymap_remove(&index->entries_map, &remove_key);
|
1704
1723
|
|
1705
1724
|
if (index_find(&position, index, path, 0, stage) < 0) {
|
1706
1725
|
git_error_set(
|
@@ -2306,6 +2325,7 @@ static int index_error_invalid(const char *message)
|
|
2306
2325
|
static int read_reuc(git_index *index, const char *buffer, size_t size)
|
2307
2326
|
{
|
2308
2327
|
const char *endptr;
|
2328
|
+
size_t oid_size = git_oid_size(index->oid_type);
|
2309
2329
|
size_t len;
|
2310
2330
|
int i;
|
2311
2331
|
|
@@ -2354,16 +2374,16 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
|
|
2354
2374
|
for (i = 0; i < 3; i++) {
|
2355
2375
|
if (!lost->mode[i])
|
2356
2376
|
continue;
|
2357
|
-
if (size <
|
2377
|
+
if (size < oid_size) {
|
2358
2378
|
index_entry_reuc_free(lost);
|
2359
2379
|
return index_error_invalid("reading reuc entry oid");
|
2360
2380
|
}
|
2361
2381
|
|
2362
|
-
if (git_oid__fromraw(&lost->oid[i], (const unsigned char *) buffer,
|
2382
|
+
if (git_oid__fromraw(&lost->oid[i], (const unsigned char *) buffer, index->oid_type) < 0)
|
2363
2383
|
return -1;
|
2364
2384
|
|
2365
|
-
size -=
|
2366
|
-
buffer +=
|
2385
|
+
size -= oid_size;
|
2386
|
+
buffer += oid_size;
|
2367
2387
|
}
|
2368
2388
|
|
2369
2389
|
/* entry was read successfully - insert into reuc vector */
|
@@ -2433,73 +2453,157 @@ out_err:
|
|
2433
2453
|
return 0;
|
2434
2454
|
}
|
2435
2455
|
|
2436
|
-
|
2456
|
+
GIT_INLINE(size_t) index_entry_path_offset(
|
2457
|
+
git_oid_t oid_type,
|
2458
|
+
uint32_t flags)
|
2459
|
+
{
|
2460
|
+
if (oid_type == GIT_OID_SHA1)
|
2461
|
+
return (flags & GIT_INDEX_ENTRY_EXTENDED) ?
|
2462
|
+
offsetof(index_entry_long_sha1, path) :
|
2463
|
+
offsetof(index_entry_short_sha1, path);
|
2464
|
+
|
2465
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2466
|
+
else if (oid_type == GIT_OID_SHA256)
|
2467
|
+
return (flags & GIT_INDEX_ENTRY_EXTENDED) ?
|
2468
|
+
offsetof(index_entry_long_sha256, path) :
|
2469
|
+
offsetof(index_entry_short_sha256, path);
|
2470
|
+
#endif
|
2471
|
+
|
2472
|
+
git_error_set(GIT_ERROR_INTERNAL, "invalid oid type");
|
2473
|
+
return 0;
|
2474
|
+
}
|
2475
|
+
|
2476
|
+
GIT_INLINE(size_t) index_entry_flags_offset(git_oid_t oid_type)
|
2477
|
+
{
|
2478
|
+
if (oid_type == GIT_OID_SHA1)
|
2479
|
+
return offsetof(index_entry_long_sha1, flags_extended);
|
2480
|
+
|
2481
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2482
|
+
else if (oid_type == GIT_OID_SHA256)
|
2483
|
+
return offsetof(index_entry_long_sha256, flags_extended);
|
2484
|
+
#endif
|
2485
|
+
|
2486
|
+
git_error_set(GIT_ERROR_INTERNAL, "invalid oid type");
|
2487
|
+
return 0;
|
2488
|
+
}
|
2489
|
+
|
2490
|
+
static size_t index_entry_size(
|
2491
|
+
size_t path_len,
|
2492
|
+
size_t varint_len,
|
2493
|
+
git_oid_t oid_type,
|
2494
|
+
uint32_t flags)
|
2437
2495
|
{
|
2496
|
+
size_t offset, size;
|
2497
|
+
|
2498
|
+
if (!(offset = index_entry_path_offset(oid_type, flags)))
|
2499
|
+
return 0;
|
2500
|
+
|
2438
2501
|
if (varint_len) {
|
2439
|
-
if (
|
2440
|
-
|
2441
|
-
|
2442
|
-
return
|
2502
|
+
if (GIT_ADD_SIZET_OVERFLOW(&size, offset, path_len) ||
|
2503
|
+
GIT_ADD_SIZET_OVERFLOW(&size, size, 1) ||
|
2504
|
+
GIT_ADD_SIZET_OVERFLOW(&size, size, varint_len))
|
2505
|
+
return 0;
|
2443
2506
|
} else {
|
2444
|
-
|
2445
|
-
|
2446
|
-
return
|
2447
|
-
|
2448
|
-
|
2449
|
-
#undef entry_size
|
2507
|
+
if (GIT_ADD_SIZET_OVERFLOW(&size, offset, path_len) ||
|
2508
|
+
GIT_ADD_SIZET_OVERFLOW(&size, size, 8))
|
2509
|
+
return 0;
|
2510
|
+
|
2511
|
+
size &= ~7;
|
2450
2512
|
}
|
2513
|
+
|
2514
|
+
return size;
|
2451
2515
|
}
|
2452
2516
|
|
2453
2517
|
static int read_entry(
|
2454
2518
|
git_index_entry **out,
|
2455
2519
|
size_t *out_size,
|
2456
2520
|
git_index *index,
|
2521
|
+
size_t checksum_size,
|
2457
2522
|
const void *buffer,
|
2458
2523
|
size_t buffer_size,
|
2459
2524
|
const char *last)
|
2460
2525
|
{
|
2461
|
-
size_t path_length, entry_size;
|
2526
|
+
size_t path_length, path_offset, entry_size;
|
2462
2527
|
const char *path_ptr;
|
2463
|
-
struct
|
2528
|
+
struct entry_common *source_common;
|
2529
|
+
index_entry_short_sha1 source_sha1;
|
2530
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2531
|
+
index_entry_short_sha256 source_sha256;
|
2532
|
+
#endif
|
2464
2533
|
git_index_entry entry = {{0}};
|
2465
2534
|
bool compressed = index->version >= INDEX_VERSION_NUMBER_COMP;
|
2466
2535
|
char *tmp_path = NULL;
|
2467
|
-
|
2536
|
+
|
2537
|
+
size_t minimal_entry_size = index_entry_path_offset(index->oid_type, 0);
|
2468
2538
|
|
2469
2539
|
if (checksum_size + minimal_entry_size > buffer_size)
|
2470
2540
|
return -1;
|
2471
2541
|
|
2472
2542
|
/* buffer is not guaranteed to be aligned */
|
2473
|
-
|
2474
|
-
|
2475
|
-
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2543
|
+
switch (index->oid_type) {
|
2544
|
+
case GIT_OID_SHA1:
|
2545
|
+
source_common = &source_sha1.common;
|
2546
|
+
memcpy(&source_sha1, buffer, sizeof(source_sha1));
|
2547
|
+
break;
|
2548
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2549
|
+
case GIT_OID_SHA256:
|
2550
|
+
source_common = &source_sha256.common;
|
2551
|
+
memcpy(&source_sha256, buffer, sizeof(source_sha256));
|
2552
|
+
break;
|
2553
|
+
#endif
|
2554
|
+
default:
|
2555
|
+
GIT_ASSERT(!"invalid oid type");
|
2556
|
+
}
|
2557
|
+
|
2558
|
+
entry.ctime.seconds = (git_time_t)ntohl(source_common->ctime.seconds);
|
2559
|
+
entry.ctime.nanoseconds = ntohl(source_common->ctime.nanoseconds);
|
2560
|
+
entry.mtime.seconds = (git_time_t)ntohl(source_common->mtime.seconds);
|
2561
|
+
entry.mtime.nanoseconds = ntohl(source_common->mtime.nanoseconds);
|
2562
|
+
entry.dev = ntohl(source_common->dev);
|
2563
|
+
entry.ino = ntohl(source_common->ino);
|
2564
|
+
entry.mode = ntohl(source_common->mode);
|
2565
|
+
entry.uid = ntohl(source_common->uid);
|
2566
|
+
entry.gid = ntohl(source_common->gid);
|
2567
|
+
entry.file_size = ntohl(source_common->file_size);
|
2568
|
+
|
2569
|
+
switch (index->oid_type) {
|
2570
|
+
case GIT_OID_SHA1:
|
2571
|
+
if (git_oid__fromraw(&entry.id, source_sha1.oid,
|
2572
|
+
GIT_OID_SHA1) < 0)
|
2573
|
+
return -1;
|
2574
|
+
entry.flags = ntohs(source_sha1.flags);
|
2575
|
+
break;
|
2576
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2577
|
+
case GIT_OID_SHA256:
|
2578
|
+
if (git_oid__fromraw(&entry.id, source_sha256.oid,
|
2579
|
+
GIT_OID_SHA256) < 0)
|
2580
|
+
return -1;
|
2581
|
+
entry.flags = ntohs(source_sha256.flags);
|
2582
|
+
break;
|
2583
|
+
#endif
|
2584
|
+
default:
|
2585
|
+
GIT_ASSERT(!"invalid oid type");
|
2586
|
+
}
|
2587
|
+
|
2588
|
+
if (!(path_offset = index_entry_path_offset(index->oid_type, entry.flags)))
|
2488
2589
|
return -1;
|
2489
2590
|
|
2591
|
+
|
2490
2592
|
if (entry.flags & GIT_INDEX_ENTRY_EXTENDED) {
|
2491
2593
|
uint16_t flags_raw;
|
2492
2594
|
size_t flags_offset;
|
2493
2595
|
|
2494
|
-
flags_offset =
|
2495
|
-
|
2496
|
-
|
2596
|
+
if (!(flags_offset = index_entry_flags_offset(index->oid_type)))
|
2597
|
+
return -1;
|
2598
|
+
|
2599
|
+
memcpy(&flags_raw, (const char *)buffer + flags_offset, sizeof(flags_raw));
|
2497
2600
|
flags_raw = ntohs(flags_raw);
|
2498
2601
|
|
2499
2602
|
memcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw));
|
2500
|
-
path_ptr = (const char *)
|
2501
|
-
} else
|
2502
|
-
path_ptr = (const char *)
|
2603
|
+
path_ptr = (const char *)buffer + path_offset;
|
2604
|
+
} else {
|
2605
|
+
path_ptr = (const char *)buffer + path_offset;
|
2606
|
+
}
|
2503
2607
|
|
2504
2608
|
if (!compressed) {
|
2505
2609
|
path_length = entry.flags & GIT_INDEX_ENTRY_NAMEMASK;
|
@@ -2511,12 +2615,12 @@ static int read_entry(
|
|
2511
2615
|
|
2512
2616
|
path_end = memchr(path_ptr, '\0', buffer_size);
|
2513
2617
|
if (path_end == NULL)
|
2514
|
-
return
|
2618
|
+
return index_error_invalid("invalid path name");
|
2515
2619
|
|
2516
2620
|
path_length = path_end - path_ptr;
|
2517
2621
|
}
|
2518
2622
|
|
2519
|
-
entry_size = index_entry_size(path_length, 0, entry.flags);
|
2623
|
+
entry_size = index_entry_size(path_length, 0, index->oid_type, entry.flags);
|
2520
2624
|
entry.path = (char *)path_ptr;
|
2521
2625
|
} else {
|
2522
2626
|
size_t varint_len, last_len, prefix_len, suffix_len, path_len;
|
@@ -2542,15 +2646,18 @@ static int read_entry(
|
|
2542
2646
|
|
2543
2647
|
memcpy(tmp_path, last, prefix_len);
|
2544
2648
|
memcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1);
|
2545
|
-
|
2649
|
+
|
2650
|
+
entry_size = index_entry_size(suffix_len, varint_len, index->oid_type, entry.flags);
|
2546
2651
|
entry.path = tmp_path;
|
2547
2652
|
}
|
2548
2653
|
|
2549
2654
|
if (entry_size == 0)
|
2550
2655
|
return -1;
|
2551
2656
|
|
2552
|
-
if (checksum_size + entry_size > buffer_size)
|
2657
|
+
if (checksum_size + entry_size > buffer_size) {
|
2658
|
+
git_error_set(GIT_ERROR_INTERNAL, "invalid index checksum");
|
2553
2659
|
return -1;
|
2660
|
+
}
|
2554
2661
|
|
2555
2662
|
if (index_entry_dup(out, index, &entry) < 0) {
|
2556
2663
|
git__free(tmp_path);
|
@@ -2579,11 +2686,10 @@ static int read_header(struct index_header *dest, const void *buffer)
|
|
2579
2686
|
return 0;
|
2580
2687
|
}
|
2581
2688
|
|
2582
|
-
static int read_extension(size_t *read_len, git_index *index, const char *buffer, size_t buffer_size)
|
2689
|
+
static int read_extension(size_t *read_len, git_index *index, size_t checksum_size, const char *buffer, size_t buffer_size)
|
2583
2690
|
{
|
2584
2691
|
struct index_extension dest;
|
2585
2692
|
size_t total_size;
|
2586
|
-
size_t checksum_size = GIT_HASH_SHA1_SIZE;
|
2587
2693
|
|
2588
2694
|
/* buffer is not guaranteed to be aligned */
|
2589
2695
|
memcpy(&dest, buffer, sizeof(struct index_extension));
|
@@ -2602,7 +2708,7 @@ static int read_extension(size_t *read_len, git_index *index, const char *buffer
|
|
2602
2708
|
if (dest.signature[0] >= 'A' && dest.signature[0] <= 'Z') {
|
2603
2709
|
/* tree cache */
|
2604
2710
|
if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
|
2605
|
-
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, &index->tree_pool) < 0)
|
2711
|
+
if (git_tree_cache_read(&index->tree, buffer + 8, dest.extension_size, index->oid_type, &index->tree_pool) < 0)
|
2606
2712
|
return -1;
|
2607
2713
|
} else if (memcmp(dest.signature, INDEX_EXT_UNMERGED_SIG, 4) == 0) {
|
2608
2714
|
if (read_reuc(index, buffer + 8, dest.extension_size) < 0)
|
@@ -2630,8 +2736,9 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2630
2736
|
int error = 0;
|
2631
2737
|
unsigned int i;
|
2632
2738
|
struct index_header header = { 0 };
|
2633
|
-
unsigned char checksum[
|
2634
|
-
|
2739
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
2740
|
+
unsigned char zero_checksum[GIT_HASH_MAX_SIZE] = { 0 };
|
2741
|
+
size_t checksum_size = git_hash_size(git_oid_algorithm(index->oid_type));
|
2635
2742
|
const char *last = NULL;
|
2636
2743
|
const char *empty = "";
|
2637
2744
|
|
@@ -2646,9 +2753,12 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2646
2753
|
if (buffer_size < INDEX_HEADER_SIZE + checksum_size)
|
2647
2754
|
return index_error_invalid("insufficient buffer space");
|
2648
2755
|
|
2649
|
-
/*
|
2650
|
-
* the
|
2651
|
-
|
2756
|
+
/*
|
2757
|
+
* Precalculate the hash of the files's contents -- we'll match
|
2758
|
+
* it to the provided checksum in the footer.
|
2759
|
+
*/
|
2760
|
+
git_hash_buf(checksum, buffer, buffer_size - checksum_size,
|
2761
|
+
git_oid_algorithm(index->oid_type));
|
2652
2762
|
|
2653
2763
|
/* Parse header */
|
2654
2764
|
if ((error = read_header(&header, buffer)) < 0)
|
@@ -2662,7 +2772,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2662
2772
|
|
2663
2773
|
GIT_ASSERT(!index->entries.length);
|
2664
2774
|
|
2665
|
-
if ((error =
|
2775
|
+
if ((error = git_index_entrymap_resize(&index->entries_map, header.entry_count)) < 0)
|
2666
2776
|
return error;
|
2667
2777
|
|
2668
2778
|
/* Parse all the entries */
|
@@ -2670,7 +2780,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2670
2780
|
git_index_entry *entry = NULL;
|
2671
2781
|
size_t entry_size;
|
2672
2782
|
|
2673
|
-
if ((error = read_entry(&entry, &entry_size, index, buffer, buffer_size, last)) < 0) {
|
2783
|
+
if ((error = read_entry(&entry, &entry_size, index, checksum_size, buffer, buffer_size, last)) < 0) {
|
2674
2784
|
error = index_error_invalid("invalid entry");
|
2675
2785
|
goto done;
|
2676
2786
|
}
|
@@ -2680,7 +2790,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2680
2790
|
goto done;
|
2681
2791
|
}
|
2682
2792
|
|
2683
|
-
if ((error =
|
2793
|
+
if ((error = git_index_entrymap_put(&index->entries_map, entry)) < 0) {
|
2684
2794
|
index_entry_free(entry);
|
2685
2795
|
goto done;
|
2686
2796
|
}
|
@@ -2701,7 +2811,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2701
2811
|
while (buffer_size > checksum_size) {
|
2702
2812
|
size_t extension_size;
|
2703
2813
|
|
2704
|
-
if ((error = read_extension(&extension_size, index, buffer, buffer_size)) < 0) {
|
2814
|
+
if ((error = read_extension(&extension_size, index, checksum_size, buffer, buffer_size)) < 0) {
|
2705
2815
|
goto done;
|
2706
2816
|
}
|
2707
2817
|
|
@@ -2714,8 +2824,14 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|
2714
2824
|
goto done;
|
2715
2825
|
}
|
2716
2826
|
|
2717
|
-
/*
|
2718
|
-
|
2827
|
+
/*
|
2828
|
+
* SHA-1 or SHA-256 (depending on the repository's object format)
|
2829
|
+
* over the content of the index file before this checksum.
|
2830
|
+
* Note: checksum may be 0 if the index was written by a client
|
2831
|
+
* where index.skipHash was set to true.
|
2832
|
+
*/
|
2833
|
+
if (memcmp(zero_checksum, buffer, checksum_size) != 0 &&
|
2834
|
+
memcmp(checksum, buffer, checksum_size) != 0) {
|
2719
2835
|
error = index_error_invalid(
|
2720
2836
|
"calculated checksum does not match expected");
|
2721
2837
|
goto done;
|
@@ -2754,16 +2870,40 @@ static bool is_index_extended(git_index *index)
|
|
2754
2870
|
return (extended > 0);
|
2755
2871
|
}
|
2756
2872
|
|
2757
|
-
static int write_disk_entry(
|
2873
|
+
static int write_disk_entry(
|
2874
|
+
git_index *index,
|
2875
|
+
git_filebuf *file,
|
2876
|
+
git_index_entry *entry,
|
2877
|
+
const char *last)
|
2758
2878
|
{
|
2759
2879
|
void *mem = NULL;
|
2760
|
-
struct
|
2761
|
-
size_t path_len, disk_size;
|
2880
|
+
struct entry_common *ondisk_common;
|
2881
|
+
size_t path_len, path_offset, disk_size;
|
2762
2882
|
int varint_len = 0;
|
2763
2883
|
char *path;
|
2764
2884
|
const char *path_start = entry->path;
|
2765
2885
|
size_t same_len = 0;
|
2766
2886
|
|
2887
|
+
index_entry_short_sha1 ondisk_sha1;
|
2888
|
+
index_entry_long_sha1 ondisk_ext_sha1;
|
2889
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2890
|
+
index_entry_short_sha256 ondisk_sha256;
|
2891
|
+
index_entry_long_sha256 ondisk_ext_sha256;
|
2892
|
+
#endif
|
2893
|
+
|
2894
|
+
switch (index->oid_type) {
|
2895
|
+
case GIT_OID_SHA1:
|
2896
|
+
ondisk_common = &ondisk_sha1.common;
|
2897
|
+
break;
|
2898
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2899
|
+
case GIT_OID_SHA256:
|
2900
|
+
ondisk_common = &ondisk_sha256.common;
|
2901
|
+
break;
|
2902
|
+
#endif
|
2903
|
+
default:
|
2904
|
+
GIT_ASSERT(!"invalid oid type");
|
2905
|
+
}
|
2906
|
+
|
2767
2907
|
path_len = ((struct entry_internal *)entry)->pathlen;
|
2768
2908
|
|
2769
2909
|
if (last) {
|
@@ -2780,9 +2920,9 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
|
|
2780
2920
|
varint_len = git_encode_varint(NULL, 0, strlen(last) - same_len);
|
2781
2921
|
}
|
2782
2922
|
|
2783
|
-
disk_size = index_entry_size(path_len, varint_len, entry->flags);
|
2923
|
+
disk_size = index_entry_size(path_len, varint_len, index->oid_type, entry->flags);
|
2784
2924
|
|
2785
|
-
if (git_filebuf_reserve(file, &mem, disk_size) < 0)
|
2925
|
+
if (!disk_size || git_filebuf_reserve(file, &mem, disk_size) < 0)
|
2786
2926
|
return -1;
|
2787
2927
|
|
2788
2928
|
memset(mem, 0x0, disk_size);
|
@@ -2797,35 +2937,77 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
|
|
2797
2937
|
*
|
2798
2938
|
* In 2038 I will be either too dead or too rich to care about this
|
2799
2939
|
*/
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2940
|
+
ondisk_common->ctime.seconds = htonl((uint32_t)entry->ctime.seconds);
|
2941
|
+
ondisk_common->mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
|
2942
|
+
ondisk_common->ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
|
2943
|
+
ondisk_common->mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
|
2944
|
+
ondisk_common->dev = htonl(entry->dev);
|
2945
|
+
ondisk_common->ino = htonl(entry->ino);
|
2946
|
+
ondisk_common->mode = htonl(entry->mode);
|
2947
|
+
ondisk_common->uid = htonl(entry->uid);
|
2948
|
+
ondisk_common->gid = htonl(entry->gid);
|
2949
|
+
ondisk_common->file_size = htonl((uint32_t)entry->file_size);
|
2950
|
+
|
2951
|
+
switch (index->oid_type) {
|
2952
|
+
case GIT_OID_SHA1:
|
2953
|
+
git_oid_raw_cpy(ondisk_sha1.oid, entry->id.id, GIT_OID_SHA1_SIZE);
|
2954
|
+
ondisk_sha1.flags = htons(entry->flags);
|
2955
|
+
break;
|
2956
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2957
|
+
case GIT_OID_SHA256:
|
2958
|
+
git_oid_raw_cpy(ondisk_sha256.oid, entry->id.id, GIT_OID_SHA256_SIZE);
|
2959
|
+
ondisk_sha256.flags = htons(entry->flags);
|
2960
|
+
break;
|
2961
|
+
#endif
|
2962
|
+
default:
|
2963
|
+
GIT_ASSERT(!"invalid oid type");
|
2964
|
+
}
|
2965
|
+
|
2966
|
+
path_offset = index_entry_path_offset(index->oid_type, entry->flags);
|
2812
2967
|
|
2813
2968
|
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
|
2814
|
-
|
2815
|
-
|
2816
|
-
memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short));
|
2817
|
-
ondisk_ext.flags_extended = htons(entry->flags_extended &
|
2969
|
+
struct entry_common *ondisk_ext;
|
2970
|
+
uint16_t flags_extended = htons(entry->flags_extended &
|
2818
2971
|
GIT_INDEX_ENTRY_EXTENDED_FLAGS);
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2972
|
+
|
2973
|
+
switch (index->oid_type) {
|
2974
|
+
case GIT_OID_SHA1:
|
2975
|
+
memcpy(&ondisk_ext_sha1, &ondisk_sha1,
|
2976
|
+
sizeof(index_entry_short_sha1));
|
2977
|
+
ondisk_ext_sha1.flags_extended = flags_extended;
|
2978
|
+
ondisk_ext = &ondisk_ext_sha1.common;
|
2979
|
+
break;
|
2980
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2981
|
+
case GIT_OID_SHA256:
|
2982
|
+
memcpy(&ondisk_ext_sha256, &ondisk_sha256,
|
2983
|
+
sizeof(index_entry_short_sha256));
|
2984
|
+
ondisk_ext_sha256.flags_extended = flags_extended;
|
2985
|
+
ondisk_ext = &ondisk_ext_sha256.common;
|
2986
|
+
break;
|
2987
|
+
#endif
|
2988
|
+
default:
|
2989
|
+
GIT_ASSERT(!"invalid oid type");
|
2990
|
+
}
|
2991
|
+
|
2992
|
+
memcpy(mem, ondisk_ext, path_offset);
|
2822
2993
|
} else {
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2994
|
+
switch (index->oid_type) {
|
2995
|
+
case GIT_OID_SHA1:
|
2996
|
+
memcpy(mem, &ondisk_sha1, path_offset);
|
2997
|
+
break;
|
2998
|
+
#ifdef GIT_EXPERIMENTAL_SHA256
|
2999
|
+
case GIT_OID_SHA256:
|
3000
|
+
memcpy(mem, &ondisk_sha256, path_offset);
|
3001
|
+
break;
|
3002
|
+
#endif
|
3003
|
+
default:
|
3004
|
+
GIT_ASSERT(!"invalid oid type");
|
3005
|
+
}
|
2827
3006
|
}
|
2828
3007
|
|
3008
|
+
path = (char *)mem + path_offset;
|
3009
|
+
disk_size -= path_offset;
|
3010
|
+
|
2829
3011
|
if (last) {
|
2830
3012
|
varint_len = git_encode_varint((unsigned char *) path,
|
2831
3013
|
disk_size, strlen(last) - same_len);
|
@@ -2877,14 +3059,14 @@ static int write_entries(git_index *index, git_filebuf *file)
|
|
2877
3059
|
last = "";
|
2878
3060
|
|
2879
3061
|
git_vector_foreach(entries, i, entry) {
|
2880
|
-
if ((error = write_disk_entry(file, entry, last)) < 0)
|
3062
|
+
if ((error = write_disk_entry(index, file, entry, last)) < 0)
|
2881
3063
|
break;
|
2882
3064
|
if (index->version >= INDEX_VERSION_NUMBER_COMP)
|
2883
3065
|
last = entry->path;
|
2884
3066
|
}
|
2885
3067
|
|
2886
3068
|
done:
|
2887
|
-
|
3069
|
+
git_vector_dispose(&case_sorted);
|
2888
3070
|
return error;
|
2889
3071
|
}
|
2890
3072
|
|
@@ -2955,8 +3137,9 @@ done:
|
|
2955
3137
|
return error;
|
2956
3138
|
}
|
2957
3139
|
|
2958
|
-
static int create_reuc_extension_data(git_str *reuc_buf, git_index_reuc_entry *reuc)
|
3140
|
+
static int create_reuc_extension_data(git_str *reuc_buf, git_index *index, git_index_reuc_entry *reuc)
|
2959
3141
|
{
|
3142
|
+
size_t oid_size = git_oid_size(index->oid_type);
|
2960
3143
|
int i;
|
2961
3144
|
int error = 0;
|
2962
3145
|
|
@@ -2970,7 +3153,7 @@ static int create_reuc_extension_data(git_str *reuc_buf, git_index_reuc_entry *r
|
|
2970
3153
|
}
|
2971
3154
|
|
2972
3155
|
for (i = 0; i < 3; i++) {
|
2973
|
-
if (reuc->mode[i] && (error = git_str_put(reuc_buf, (char *)&reuc->oid[i].id,
|
3156
|
+
if (reuc->mode[i] && (error = git_str_put(reuc_buf, (char *)&reuc->oid[i].id, oid_size)) < 0)
|
2974
3157
|
return error;
|
2975
3158
|
}
|
2976
3159
|
|
@@ -2987,7 +3170,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
|
|
2987
3170
|
int error = 0;
|
2988
3171
|
|
2989
3172
|
git_vector_foreach(out, i, reuc) {
|
2990
|
-
if ((error = create_reuc_extension_data(&reuc_buf, reuc)) < 0)
|
3173
|
+
if ((error = create_reuc_extension_data(&reuc_buf, index, reuc)) < 0)
|
2991
3174
|
goto done;
|
2992
3175
|
}
|
2993
3176
|
|
@@ -3036,7 +3219,7 @@ static void clear_uptodate(git_index *index)
|
|
3036
3219
|
}
|
3037
3220
|
|
3038
3221
|
static int write_index(
|
3039
|
-
unsigned char checksum[
|
3222
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE],
|
3040
3223
|
size_t *checksum_size,
|
3041
3224
|
git_index *index,
|
3042
3225
|
git_filebuf *file)
|
@@ -3048,7 +3231,9 @@ static int write_index(
|
|
3048
3231
|
GIT_ASSERT_ARG(index);
|
3049
3232
|
GIT_ASSERT_ARG(file);
|
3050
3233
|
|
3051
|
-
|
3234
|
+
GIT_ASSERT(index->oid_type);
|
3235
|
+
|
3236
|
+
*checksum_size = git_hash_size(git_oid_algorithm(index->oid_type));
|
3052
3237
|
|
3053
3238
|
if (index->version <= INDEX_VERSION_NUMBER_EXT) {
|
3054
3239
|
is_extended = is_index_extended(index);
|
@@ -3157,14 +3342,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3157
3342
|
{
|
3158
3343
|
int error = 0;
|
3159
3344
|
git_vector entries = GIT_VECTOR_INIT;
|
3160
|
-
|
3345
|
+
git_index_entrymap entries_map = GIT_INDEX_ENTRYMAP_INIT;
|
3161
3346
|
read_tree_data data;
|
3162
3347
|
size_t i;
|
3163
3348
|
git_index_entry *e;
|
3164
3349
|
|
3165
|
-
if (git_idxmap_new(&entries_map) < 0)
|
3166
|
-
return -1;
|
3167
|
-
|
3168
3350
|
git_vector_set_cmp(&entries, index->entries._cmp); /* match sort */
|
3169
3351
|
|
3170
3352
|
data.index = index;
|
@@ -3180,11 +3362,11 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3180
3362
|
if ((error = git_tree_walk(tree, GIT_TREEWALK_POST, read_tree_cb, &data)) < 0)
|
3181
3363
|
goto cleanup;
|
3182
3364
|
|
3183
|
-
if ((error =
|
3365
|
+
if ((error = git_index_entrymap_resize(&entries_map, entries.length)) < 0)
|
3184
3366
|
goto cleanup;
|
3185
3367
|
|
3186
3368
|
git_vector_foreach(&entries, i, e) {
|
3187
|
-
if ((error =
|
3369
|
+
if ((error = git_index_entrymap_put(&entries_map, e)) < 0) {
|
3188
3370
|
git_error_set(GIT_ERROR_INDEX, "failed to insert entry into map");
|
3189
3371
|
return error;
|
3190
3372
|
}
|
@@ -3194,22 +3376,22 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
|
|
3194
3376
|
|
3195
3377
|
git_vector_sort(&entries);
|
3196
3378
|
|
3197
|
-
if ((error = git_index_clear(index)) < 0)
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
}
|
3379
|
+
if ((error = git_index_clear(index)) < 0)
|
3380
|
+
goto cleanup;
|
3381
|
+
|
3382
|
+
git_vector_swap(&entries, &index->entries);
|
3383
|
+
git_index_entrymap_swap(&entries_map, &index->entries_map);
|
3203
3384
|
|
3204
3385
|
index->dirty = 1;
|
3205
3386
|
|
3206
3387
|
cleanup:
|
3207
|
-
|
3208
|
-
|
3388
|
+
git_vector_dispose(&entries);
|
3389
|
+
git_index_entrymap_dispose(&entries_map);
|
3390
|
+
|
3209
3391
|
if (error < 0)
|
3210
3392
|
return error;
|
3211
3393
|
|
3212
|
-
error = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool);
|
3394
|
+
error = git_tree_cache_read_tree(&index->tree, tree, index->oid_type, &index->tree_pool);
|
3213
3395
|
|
3214
3396
|
return error;
|
3215
3397
|
}
|
@@ -3221,7 +3403,7 @@ static int git_index_read_iterator(
|
|
3221
3403
|
{
|
3222
3404
|
git_vector new_entries = GIT_VECTOR_INIT,
|
3223
3405
|
remove_entries = GIT_VECTOR_INIT;
|
3224
|
-
|
3406
|
+
git_index_entrymap new_entries_map = GIT_INDEX_ENTRYMAP_INIT;
|
3225
3407
|
git_iterator *index_iterator = NULL;
|
3226
3408
|
git_iterator_options opts = GIT_ITERATOR_OPTIONS_INIT;
|
3227
3409
|
const git_index_entry *old_entry, *new_entry;
|
@@ -3232,12 +3414,11 @@ static int git_index_read_iterator(
|
|
3232
3414
|
GIT_ASSERT((new_iterator->flags & GIT_ITERATOR_DONT_IGNORE_CASE));
|
3233
3415
|
|
3234
3416
|
if ((error = git_vector_init(&new_entries, new_length_hint, index->entries._cmp)) < 0 ||
|
3235
|
-
(error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0
|
3236
|
-
(error = git_idxmap_new(&new_entries_map)) < 0)
|
3417
|
+
(error = git_vector_init(&remove_entries, index->entries.length, NULL)) < 0)
|
3237
3418
|
goto done;
|
3238
3419
|
|
3239
|
-
if (new_length_hint &&
|
3240
|
-
|
3420
|
+
if (new_length_hint &&
|
3421
|
+
(error = git_index_entrymap_resize(&new_entries_map, new_length_hint)) < 0)
|
3241
3422
|
goto done;
|
3242
3423
|
|
3243
3424
|
opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE |
|
@@ -3302,8 +3483,7 @@ static int git_index_read_iterator(
|
|
3302
3483
|
|
3303
3484
|
if (add_entry) {
|
3304
3485
|
if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
|
3305
|
-
error =
|
3306
|
-
index->ignore_case);
|
3486
|
+
error = git_index_entrymap_put(&new_entries_map, add_entry);
|
3307
3487
|
}
|
3308
3488
|
|
3309
3489
|
if (remove_entry && error >= 0)
|
@@ -3332,7 +3512,7 @@ static int git_index_read_iterator(
|
|
3332
3512
|
goto done;
|
3333
3513
|
|
3334
3514
|
git_vector_swap(&new_entries, &index->entries);
|
3335
|
-
|
3515
|
+
git_index_entrymap_swap(&index->entries_map, &new_entries_map);
|
3336
3516
|
|
3337
3517
|
git_vector_foreach(&remove_entries, i, entry) {
|
3338
3518
|
if (index->tree)
|
@@ -3347,9 +3527,9 @@ static int git_index_read_iterator(
|
|
3347
3527
|
error = 0;
|
3348
3528
|
|
3349
3529
|
done:
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3530
|
+
git_index_entrymap_dispose(&new_entries_map);
|
3531
|
+
git_vector_dispose(&new_entries);
|
3532
|
+
git_vector_dispose(&remove_entries);
|
3353
3533
|
git_iterator_free(index_iterator);
|
3354
3534
|
return error;
|
3355
3535
|
}
|
@@ -3650,7 +3830,7 @@ int git_index_snapshot_new(git_vector *snap, git_index *index)
|
|
3650
3830
|
|
3651
3831
|
void git_index_snapshot_release(git_vector *snap, git_index *index)
|
3652
3832
|
{
|
3653
|
-
|
3833
|
+
git_vector_dispose(snap);
|
3654
3834
|
|
3655
3835
|
git_atomic32_dec(&index->readers);
|
3656
3836
|
|
@@ -3668,19 +3848,23 @@ int git_indexwriter_init(
|
|
3668
3848
|
git_indexwriter *writer,
|
3669
3849
|
git_index *index)
|
3670
3850
|
{
|
3671
|
-
int error;
|
3851
|
+
int filebuf_hash, error;
|
3672
3852
|
|
3673
3853
|
GIT_REFCOUNT_INC(index);
|
3674
3854
|
|
3675
3855
|
writer->index = index;
|
3676
3856
|
|
3857
|
+
filebuf_hash = git_filebuf_hash_flags(git_oid_algorithm(index->oid_type));
|
3858
|
+
GIT_ASSERT(filebuf_hash);
|
3859
|
+
|
3677
3860
|
if (!index->index_file_path)
|
3678
3861
|
return create_index_error(-1,
|
3679
3862
|
"failed to write index: The index is in-memory only");
|
3680
3863
|
|
3681
|
-
if ((error = git_filebuf_open(
|
3682
|
-
|
3683
|
-
|
3864
|
+
if ((error = git_filebuf_open(&writer->file,
|
3865
|
+
index->index_file_path,
|
3866
|
+
git_filebuf_hash_flags(filebuf_hash),
|
3867
|
+
GIT_INDEX_FILE_MODE)) < 0) {
|
3684
3868
|
if (error == GIT_ELOCKED)
|
3685
3869
|
git_error_set(GIT_ERROR_INDEX, "the index is locked; this might be due to a concurrent or crashed process");
|
3686
3870
|
|
@@ -3712,7 +3896,7 @@ int git_indexwriter_init_for_operation(
|
|
3712
3896
|
|
3713
3897
|
int git_indexwriter_commit(git_indexwriter *writer)
|
3714
3898
|
{
|
3715
|
-
unsigned char checksum[
|
3899
|
+
unsigned char checksum[GIT_HASH_MAX_SIZE];
|
3716
3900
|
size_t checksum_size;
|
3717
3901
|
int error;
|
3718
3902
|
|