rugged 1.3.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -2
- data/ext/rugged/extconf.rb +6 -3
- data/ext/rugged/rugged.c +16 -0
- data/ext/rugged/rugged.h +4 -0
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +9 -2
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +28 -10
- data/ext/rugged/rugged_repo.c +7 -9
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_settings.c +5 -0
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +132 -288
- data/vendor/libgit2/COPYING +106 -19
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/AddClarTest.cmake +7 -0
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
- data/vendor/libgit2/cmake/FindPCRE.cmake +12 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
- data/vendor/libgit2/cmake/SelectHashes.cmake +91 -53
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +33 -31
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +3 -1
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/zlib/adler32.c +7 -0
- data/vendor/libgit2/deps/zlib/crc32.c +975 -288
- data/vendor/libgit2/deps/zlib/crc32.h +9441 -436
- data/vendor/libgit2/deps/zlib/deflate.c +83 -31
- data/vendor/libgit2/deps/zlib/deflate.h +12 -15
- data/vendor/libgit2/deps/zlib/gzguts.h +3 -2
- data/vendor/libgit2/deps/zlib/infback.c +2 -1
- data/vendor/libgit2/deps/zlib/inffast.c +14 -14
- data/vendor/libgit2/deps/zlib/inflate.c +39 -8
- data/vendor/libgit2/deps/zlib/inflate.h +3 -2
- data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
- data/vendor/libgit2/deps/zlib/trees.c +27 -48
- data/vendor/libgit2/deps/zlib/zlib.h +126 -100
- data/vendor/libgit2/deps/zlib/zutil.c +2 -2
- data/vendor/libgit2/deps/zlib/zutil.h +12 -9
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +11 -2
- data/vendor/libgit2/include/git2/blame.h +4 -1
- data/vendor/libgit2/include/git2/blob.h +14 -1
- data/vendor/libgit2/include/git2/branch.h +4 -2
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +5 -2
- data/vendor/libgit2/include/git2/clone.h +3 -3
- data/vendor/libgit2/include/git2/commit.h +2 -0
- data/vendor/libgit2/include/git2/common.h +38 -7
- data/vendor/libgit2/include/git2/config.h +25 -9
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +9 -1
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +18 -10
- data/vendor/libgit2/include/git2/email.h +1 -1
- data/vendor/libgit2/include/git2/errors.h +18 -3
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/filter.h +7 -2
- data/vendor/libgit2/include/git2/graph.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +11 -5
- data/vendor/libgit2/include/git2/indexer.h +48 -0
- data/vendor/libgit2/include/git2/merge.h +24 -4
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/object.h +49 -0
- data/vendor/libgit2/include/git2/odb.h +94 -13
- data/vendor/libgit2/include/git2/odb_backend.h +107 -19
- data/vendor/libgit2/include/git2/oid.h +115 -15
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +9 -1
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +2 -2
- data/vendor/libgit2/include/git2/remote.h +184 -37
- data/vendor/libgit2/include/git2/repository.h +34 -10
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +61 -7
- data/vendor/libgit2/include/git2/status.h +14 -5
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/submodule.h +7 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +3 -6
- data/vendor/libgit2/include/git2/sys/remote.h +46 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +46 -39
- data/vendor/libgit2/include/git2/tag.h +1 -0
- data/vendor/libgit2/include/git2/tree.h +4 -3
- data/vendor/libgit2/include/git2/types.h +7 -7
- data/vendor/libgit2/include/git2/version.h +27 -6
- data/vendor/libgit2/include/git2/worktree.h +12 -2
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +177 -419
- data/vendor/libgit2/src/README.md +12 -0
- data/vendor/libgit2/src/cli/CMakeLists.txt +57 -0
- data/vendor/libgit2/src/cli/README.md +26 -0
- data/vendor/libgit2/src/cli/cli.h +20 -0
- data/vendor/libgit2/src/cli/cmd.c +21 -0
- data/vendor/libgit2/src/cli/cmd.h +33 -0
- data/vendor/libgit2/src/cli/cmd_cat_file.c +204 -0
- data/vendor/libgit2/src/cli/cmd_clone.c +176 -0
- data/vendor/libgit2/src/cli/cmd_hash_object.c +154 -0
- data/vendor/libgit2/src/cli/cmd_help.c +86 -0
- data/vendor/libgit2/src/cli/error.h +51 -0
- data/vendor/libgit2/src/cli/main.c +106 -0
- data/vendor/libgit2/src/cli/opt.c +669 -0
- data/vendor/libgit2/src/cli/opt.h +349 -0
- data/vendor/libgit2/src/cli/opt_usage.c +194 -0
- data/vendor/libgit2/src/cli/opt_usage.h +35 -0
- data/vendor/libgit2/src/cli/progress.c +345 -0
- data/vendor/libgit2/src/cli/progress.h +117 -0
- data/vendor/libgit2/src/cli/sighandler.h +20 -0
- data/vendor/libgit2/src/cli/unix/sighandler.c +36 -0
- data/vendor/libgit2/src/cli/win32/precompiled.h +3 -0
- data/vendor/libgit2/src/cli/win32/sighandler.c +37 -0
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +141 -0
- data/vendor/libgit2/src/{annotated_commit.c → libgit2/annotated_commit.c} +1 -1
- data/vendor/libgit2/src/{annotated_commit.h → libgit2/annotated_commit.h} +2 -2
- data/vendor/libgit2/src/{apply.c → libgit2/apply.c} +18 -18
- data/vendor/libgit2/src/{apply.h → libgit2/apply.h} +2 -2
- data/vendor/libgit2/src/{attr.c → libgit2/attr.c} +18 -18
- data/vendor/libgit2/src/{attr_file.c → libgit2/attr_file.c} +18 -18
- data/vendor/libgit2/src/{attr_file.h → libgit2/attr_file.h} +4 -4
- data/vendor/libgit2/src/{attrcache.c → libgit2/attrcache.c} +18 -13
- data/vendor/libgit2/src/{blame.c → libgit2/blame.c} +2 -0
- data/vendor/libgit2/src/{blame_git.c → libgit2/blame_git.c} +1 -1
- data/vendor/libgit2/src/{blob.c → libgit2/blob.c} +38 -29
- data/vendor/libgit2/src/{blob.h → libgit2/blob.h} +3 -3
- data/vendor/libgit2/src/{branch.c → libgit2/branch.c} +164 -118
- data/vendor/libgit2/src/{branch.h → libgit2/branch.h} +15 -3
- data/vendor/libgit2/src/libgit2/buf.c +126 -0
- data/vendor/libgit2/src/libgit2/buf.h +50 -0
- data/vendor/libgit2/src/{checkout.c → libgit2/checkout.c} +74 -68
- data/vendor/libgit2/src/{cherrypick.c → libgit2/cherrypick.c} +13 -13
- data/vendor/libgit2/src/{clone.c → libgit2/clone.c} +96 -67
- data/vendor/libgit2/src/{commit.c → libgit2/commit.c} +178 -73
- data/vendor/libgit2/src/libgit2/commit.h +87 -0
- data/vendor/libgit2/src/{commit_graph.c → libgit2/commit_graph.c} +122 -89
- data/vendor/libgit2/src/{commit_graph.h → libgit2/commit_graph.h} +14 -4
- data/vendor/libgit2/src/{commit_list.c → libgit2/commit_list.c} +7 -4
- data/vendor/libgit2/src/libgit2/common.h +55 -0
- data/vendor/libgit2/src/{config.c → libgit2/config.c} +107 -71
- data/vendor/libgit2/src/{config.h → libgit2/config.h} +15 -2
- data/vendor/libgit2/src/{config_file.c → libgit2/config_file.c} +105 -93
- data/vendor/libgit2/src/{config_mem.c → libgit2/config_mem.c} +9 -9
- data/vendor/libgit2/src/{config_parse.c → libgit2/config_parse.c} +27 -23
- data/vendor/libgit2/src/{crlf.c → libgit2/crlf.c} +24 -21
- data/vendor/libgit2/src/{describe.c → libgit2/describe.c} +35 -27
- data/vendor/libgit2/src/{diff.c → libgit2/diff.c} +30 -9
- data/vendor/libgit2/src/{diff.h → libgit2/diff.h} +2 -4
- data/vendor/libgit2/src/{diff_driver.c → libgit2/diff_driver.c} +34 -36
- data/vendor/libgit2/src/{diff_driver.h → libgit2/diff_driver.h} +3 -3
- data/vendor/libgit2/src/{diff_file.c → libgit2/diff_file.c} +44 -26
- data/vendor/libgit2/src/{diff_generate.c → libgit2/diff_generate.c} +47 -18
- data/vendor/libgit2/src/{diff_generate.h → libgit2/diff_generate.h} +5 -3
- data/vendor/libgit2/src/{diff_print.c → libgit2/diff_print.c} +112 -100
- data/vendor/libgit2/src/{diff_stats.c → libgit2/diff_stats.c} +40 -29
- data/vendor/libgit2/src/libgit2/diff_stats.h +18 -0
- data/vendor/libgit2/src/{diff_tform.c → libgit2/diff_tform.c} +13 -8
- data/vendor/libgit2/src/{diff_xdiff.c → libgit2/diff_xdiff.c} +4 -8
- data/vendor/libgit2/src/{email.c → libgit2/email.c} +55 -39
- data/vendor/libgit2/src/{email.h → libgit2/email.h} +1 -1
- data/vendor/libgit2/src/{errors.c → libgit2/errors.c} +18 -18
- data/vendor/libgit2/src/{errors.h → libgit2/errors.h} +1 -2
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/{fetch.c → libgit2/fetch.c} +72 -27
- data/vendor/libgit2/src/{fetch.h → libgit2/fetch.h} +1 -1
- data/vendor/libgit2/src/{fetchhead.c → libgit2/fetchhead.c} +23 -23
- data/vendor/libgit2/src/{filter.c → libgit2/filter.c} +127 -53
- data/vendor/libgit2/src/{filter.h → libgit2/filter.h} +26 -5
- data/vendor/libgit2/src/{ident.c → libgit2/ident.c} +20 -20
- data/vendor/libgit2/src/{ignore.c → libgit2/ignore.c} +35 -34
- data/vendor/libgit2/src/{ignore.h → libgit2/ignore.h} +2 -2
- data/vendor/libgit2/src/{index.c → libgit2/index.c} +91 -90
- data/vendor/libgit2/src/{index.h → libgit2/index.h} +6 -3
- data/vendor/libgit2/src/{indexer.c → libgit2/indexer.c} +173 -92
- data/vendor/libgit2/src/{iterator.c → libgit2/iterator.c} +71 -61
- data/vendor/libgit2/src/{iterator.h → libgit2/iterator.h} +5 -5
- data/vendor/libgit2/src/{libgit2.c → libgit2/libgit2.c} +54 -11
- data/vendor/libgit2/src/{mailmap.c → libgit2/mailmap.c} +38 -36
- data/vendor/libgit2/src/{merge.c → libgit2/merge.c} +30 -30
- data/vendor/libgit2/src/{merge.h → libgit2/merge.h} +1 -14
- data/vendor/libgit2/src/{merge_driver.c → libgit2/merge_driver.c} +2 -2
- data/vendor/libgit2/src/{merge_file.c → libgit2/merge_file.c} +13 -3
- data/vendor/libgit2/src/{message.c → libgit2/message.c} +21 -10
- data/vendor/libgit2/src/{midx.c → libgit2/midx.c} +112 -92
- data/vendor/libgit2/src/{midx.h → libgit2/midx.h} +5 -4
- data/vendor/libgit2/src/{mwindow.c → libgit2/mwindow.c} +15 -12
- data/vendor/libgit2/src/{mwindow.h → libgit2/mwindow.h} +5 -2
- data/vendor/libgit2/src/{netops.c → libgit2/netops.c} +1 -2
- data/vendor/libgit2/src/{netops.h → libgit2/netops.h} +1 -1
- data/vendor/libgit2/src/{notes.c → libgit2/notes.c} +25 -34
- data/vendor/libgit2/src/{object.c → libgit2/object.c} +135 -30
- data/vendor/libgit2/src/{object.h → libgit2/object.h} +12 -3
- data/vendor/libgit2/src/{odb.c → libgit2/odb.c} +228 -81
- data/vendor/libgit2/src/{odb.h → libgit2/odb.h} +44 -5
- data/vendor/libgit2/src/{odb_loose.c → libgit2/odb_loose.c} +192 -134
- data/vendor/libgit2/src/{odb_mempack.c → libgit2/odb_mempack.c} +18 -5
- data/vendor/libgit2/src/{odb_pack.c → libgit2/odb_pack.c} +137 -85
- data/vendor/libgit2/src/{oid.c → libgit2/oid.c} +136 -90
- data/vendor/libgit2/src/libgit2/oid.h +273 -0
- data/vendor/libgit2/src/{oidmap.c → libgit2/oidmap.c} +1 -1
- data/vendor/libgit2/src/{pack-objects.c → libgit2/pack-objects.c} +56 -30
- data/vendor/libgit2/src/{pack-objects.h → libgit2/pack-objects.h} +11 -6
- data/vendor/libgit2/src/{pack.c → libgit2/pack.c} +114 -84
- data/vendor/libgit2/src/{pack.h → libgit2/pack.h} +31 -16
- data/vendor/libgit2/src/{parse.c → libgit2/parse.c} +4 -3
- data/vendor/libgit2/src/{patch.c → libgit2/patch.c} +3 -3
- data/vendor/libgit2/src/{patch.h → libgit2/patch.h} +1 -0
- data/vendor/libgit2/src/{patch_generate.c → libgit2/patch_generate.c} +27 -11
- data/vendor/libgit2/src/{patch_generate.h → libgit2/patch_generate.h} +5 -5
- data/vendor/libgit2/src/{patch_parse.c → libgit2/patch_parse.c} +29 -29
- data/vendor/libgit2/src/libgit2/path.c +375 -0
- data/vendor/libgit2/src/libgit2/path.h +68 -0
- data/vendor/libgit2/src/{pathspec.c → libgit2/pathspec.c} +6 -6
- data/vendor/libgit2/src/{pathspec.h → libgit2/pathspec.h} +2 -2
- data/vendor/libgit2/src/{proxy.c → libgit2/proxy.c} +4 -1
- data/vendor/libgit2/src/{proxy.h → libgit2/proxy.h} +1 -1
- data/vendor/libgit2/src/{push.c → libgit2/push.c} +43 -38
- data/vendor/libgit2/src/{push.h → libgit2/push.h} +4 -16
- data/vendor/libgit2/src/{reader.c → libgit2/reader.c} +9 -9
- data/vendor/libgit2/src/{reader.h → libgit2/reader.h} +2 -2
- data/vendor/libgit2/src/{rebase.c → libgit2/rebase.c} +119 -107
- data/vendor/libgit2/src/{refdb_fs.c → libgit2/refdb_fs.c} +506 -197
- data/vendor/libgit2/src/{reflog.c → libgit2/reflog.c} +7 -5
- data/vendor/libgit2/src/{reflog.h → libgit2/reflog.h} +1 -2
- data/vendor/libgit2/src/{refs.c → libgit2/refs.c} +34 -32
- data/vendor/libgit2/src/{refs.h → libgit2/refs.h} +2 -2
- data/vendor/libgit2/src/{refspec.c → libgit2/refspec.c} +32 -37
- data/vendor/libgit2/src/{refspec.h → libgit2/refspec.h} +5 -2
- data/vendor/libgit2/src/{remote.c → libgit2/remote.c} +718 -420
- data/vendor/libgit2/src/libgit2/remote.h +100 -0
- data/vendor/libgit2/src/{repository.c → libgit2/repository.c} +690 -366
- data/vendor/libgit2/src/{repository.h → libgit2/repository.h} +21 -9
- data/vendor/libgit2/src/{reset.c → libgit2/reset.c} +8 -5
- data/vendor/libgit2/src/{revert.c → libgit2/revert.c} +14 -14
- data/vendor/libgit2/src/{revparse.c → libgit2/revparse.c} +71 -42
- data/vendor/libgit2/src/{revwalk.c → libgit2/revwalk.c} +12 -8
- data/vendor/libgit2/src/{signature.c → libgit2/signature.c} +12 -6
- data/vendor/libgit2/src/{signature.h → libgit2/signature.h} +1 -1
- data/vendor/libgit2/src/{stash.c → libgit2/stash.c} +235 -61
- data/vendor/libgit2/src/{status.c → libgit2/status.c} +4 -1
- data/vendor/libgit2/src/{strarray.c → libgit2/strarray.c} +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.c +8 -6
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.c +1 -1
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.h +3 -3
- data/vendor/libgit2/src/{streams → libgit2/streams}/socket.c +4 -1
- data/vendor/libgit2/src/{submodule.c → libgit2/submodule.c} +177 -161
- data/vendor/libgit2/src/{submodule.h → libgit2/submodule.h} +1 -1
- data/vendor/libgit2/src/libgit2/sysdir.c +650 -0
- data/vendor/libgit2/src/{sysdir.h → libgit2/sysdir.h} +53 -18
- data/vendor/libgit2/src/{tag.c → libgit2/tag.c} +73 -42
- data/vendor/libgit2/src/{tag.h → libgit2/tag.h} +2 -2
- data/vendor/libgit2/src/{threadstate.c → libgit2/threadstate.c} +3 -3
- data/vendor/libgit2/src/{threadstate.h → libgit2/threadstate.h} +2 -2
- data/vendor/libgit2/src/{trace.c → libgit2/trace.c} +1 -14
- data/vendor/libgit2/src/{trace.h → libgit2/trace.h} +5 -22
- data/vendor/libgit2/src/{trailer.c → libgit2/trailer.c} +1 -1
- data/vendor/libgit2/src/{transaction.c → libgit2/transaction.c} +1 -1
- data/vendor/libgit2/src/{transport.c → libgit2/transport.c} +10 -10
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.c +7 -9
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.h +2 -3
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.c +12 -13
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.c +10 -10
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/{transports → libgit2/transports}/git.c +9 -11
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.c +41 -20
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.h +2 -3
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.c +75 -66
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.h +10 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/local.c +138 -116
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.c +92 -133
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.h +35 -32
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_pkt.c +177 -65
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_protocol.c +97 -49
- data/vendor/libgit2/src/{transports → libgit2/transports}/ssh.c +365 -198
- data/vendor/libgit2/src/{transports → libgit2/transports}/winhttp.c +58 -59
- data/vendor/libgit2/src/{tree-cache.c → libgit2/tree-cache.c} +8 -8
- data/vendor/libgit2/src/{tree-cache.h → libgit2/tree-cache.h} +2 -2
- data/vendor/libgit2/src/{tree.c → libgit2/tree.c} +93 -83
- data/vendor/libgit2/src/{tree.h → libgit2/tree.h} +4 -4
- data/vendor/libgit2/src/{worktree.c → libgit2/worktree.c} +121 -94
- data/vendor/libgit2/src/{worktree.h → libgit2/worktree.h} +1 -1
- data/vendor/libgit2/src/libgit2/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xdiff.h +15 -15
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xdiffi.c +134 -108
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xemit.c +23 -7
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xhistogram.c +87 -78
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xinclude.h +1 -12
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xmerge.c +104 -117
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xpatience.c +6 -17
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xprepare.c +15 -20
- data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xutils.c +18 -7
- data/vendor/libgit2/src/util/CMakeLists.txt +80 -0
- data/vendor/libgit2/src/{allocators → util/allocators}/failalloc.h +1 -1
- data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.h +1 -1
- data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{array.h → util/array.h} +1 -1
- data/vendor/libgit2/src/{assert_safe.h → util/assert_safe.h} +16 -0
- data/vendor/libgit2/src/{cc-compat.h → util/cc-compat.h} +1 -1
- data/vendor/libgit2/src/{date.c → util/date.c} +14 -20
- data/vendor/libgit2/src/util/date.h +33 -0
- data/vendor/libgit2/src/{filebuf.c → util/filebuf.c} +29 -29
- data/vendor/libgit2/src/{filebuf.h → util/filebuf.h} +2 -2
- data/vendor/libgit2/src/{path.c → util/fs_path.c} +580 -615
- data/vendor/libgit2/src/{path.h → util/fs_path.h} +234 -181
- data/vendor/libgit2/src/{futils.c → util/futils.c} +135 -90
- data/vendor/libgit2/src/{futils.h → util/futils.h} +28 -15
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +15 -1
- data/vendor/libgit2/src/{common.h → util/git2_util.h} +20 -59
- data/vendor/libgit2/src/util/hash/builtin.c +53 -0
- data/vendor/libgit2/src/{hash/sha1/openssl.h → util/hash/builtin.h} +6 -6
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.c +3 -3
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.h +3 -3
- data/vendor/libgit2/src/util/hash/common_crypto.c +112 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/common_crypto.h +11 -3
- data/vendor/libgit2/src/util/hash/mbedtls.c +92 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/mbedtls.h +14 -4
- data/vendor/libgit2/src/util/hash/openssl.c +195 -0
- data/vendor/libgit2/src/util/hash/openssl.h +45 -0
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +243 -0
- data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +601 -0
- data/vendor/libgit2/src/util/hash/sha.h +70 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.c +1 -1
- data/vendor/libgit2/src/util/hash/win32.c +549 -0
- data/vendor/libgit2/src/util/hash/win32.h +60 -0
- data/vendor/libgit2/src/util/hash.c +158 -0
- data/vendor/libgit2/src/util/hash.h +61 -0
- data/vendor/libgit2/src/{khash.h → util/khash.h} +1 -1
- data/vendor/libgit2/src/{map.h → util/map.h} +1 -1
- data/vendor/libgit2/src/util/net.c +1003 -0
- data/vendor/libgit2/src/{net.h → util/net.h} +18 -4
- data/vendor/libgit2/src/{pool.h → util/pool.h} +1 -1
- data/vendor/libgit2/src/{posix.c → util/posix.c} +3 -3
- data/vendor/libgit2/src/{posix.h → util/posix.h} +4 -1
- data/vendor/libgit2/src/{pqueue.h → util/pqueue.h} +2 -2
- data/vendor/libgit2/src/util/rand.c +234 -0
- data/vendor/libgit2/src/util/rand.h +37 -0
- data/vendor/libgit2/src/{regexp.c → util/regexp.c} +4 -4
- data/vendor/libgit2/src/{regexp.h → util/regexp.h} +1 -1
- data/vendor/libgit2/src/{runtime.c → util/runtime.c} +1 -1
- data/vendor/libgit2/src/{runtime.h → util/runtime.h} +1 -1
- data/vendor/libgit2/src/{sortedcache.c → util/sortedcache.c} +1 -1
- data/vendor/libgit2/src/{sortedcache.h → util/sortedcache.h} +2 -2
- data/vendor/libgit2/src/{buffer.c → util/str.c} +157 -151
- data/vendor/libgit2/src/util/str.h +357 -0
- data/vendor/libgit2/src/{strmap.h → util/strmap.h} +1 -1
- data/vendor/libgit2/src/{thread.c → util/thread.c} +1 -1
- data/vendor/libgit2/src/{thread.h → util/thread.h} +23 -22
- data/vendor/libgit2/src/{tsort.c → util/tsort.c} +1 -1
- data/vendor/libgit2/src/{unix → util/unix}/map.c +1 -3
- data/vendor/libgit2/src/{unix → util/unix}/posix.h +1 -4
- data/vendor/libgit2/src/{unix → util/unix}/realpath.c +1 -3
- data/vendor/libgit2/src/{utf8.c → util/utf8.c} +1 -1
- data/vendor/libgit2/src/{utf8.h → util/utf8.h} +1 -1
- data/vendor/libgit2/src/{util.c → util/util.c} +15 -15
- data/vendor/libgit2/src/{util.h → util/util.h} +4 -29
- data/vendor/libgit2/src/{varint.h → util/varint.h} +1 -1
- data/vendor/libgit2/src/{vector.h → util/vector.h} +2 -2
- data/vendor/libgit2/src/{wildmatch.h → util/wildmatch.h} +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/dir.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/error.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/map.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/path_w32.c +140 -9
- data/vendor/libgit2/src/{win32 → util/win32}/path_w32.h +3 -1
- data/vendor/libgit2/src/{win32 → util/win32}/posix.h +1 -2
- data/vendor/libgit2/src/{win32 → util/win32}/posix_w32.c +12 -28
- data/vendor/libgit2/src/util/win32/precompiled.c +1 -0
- data/vendor/libgit2/src/{win32 → util/win32}/precompiled.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/thread.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/utf-conv.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.c +2 -3
- data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.h +3 -4
- data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_util.h +1 -1
- data/vendor/libgit2/src/{zstream.c → util/zstream.c} +5 -5
- data/vendor/libgit2/src/{zstream.h → util/zstream.h} +5 -5
- metadata +402 -356
- data/vendor/libgit2/src/buffer.h +0 -374
- data/vendor/libgit2/src/commit.h +0 -46
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +0 -57
- data/vendor/libgit2/src/hash/sha1/generic.c +0 -300
- data/vendor/libgit2/src/hash/sha1/generic.h +0 -19
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
- data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
- data/vendor/libgit2/src/hash/sha1/win32.c +0 -333
- data/vendor/libgit2/src/hash/sha1/win32.h +0 -128
- data/vendor/libgit2/src/hash/sha1.h +0 -38
- data/vendor/libgit2/src/hash.c +0 -110
- data/vendor/libgit2/src/hash.h +0 -46
- data/vendor/libgit2/src/message.h +0 -17
- data/vendor/libgit2/src/net.c +0 -540
- data/vendor/libgit2/src/oid.h +0 -51
- data/vendor/libgit2/src/remote.h +0 -55
- data/vendor/libgit2/src/sysdir.c +0 -347
- data/vendor/libgit2/src/win32/findfile.c +0 -230
- data/vendor/libgit2/src/win32/findfile.h +0 -19
- /data/vendor/libgit2/src/{win32 → cli/win32}/precompiled.c +0 -0
- /data/vendor/libgit2/src/{attr.h → libgit2/attr.h} +0 -0
- /data/vendor/libgit2/src/{attrcache.h → libgit2/attrcache.h} +0 -0
- /data/vendor/libgit2/src/{blame.h → libgit2/blame.h} +0 -0
- /data/vendor/libgit2/src/{blame_git.h → libgit2/blame_git.h} +0 -0
- /data/vendor/libgit2/src/{cache.c → libgit2/cache.c} +0 -0
- /data/vendor/libgit2/src/{cache.h → libgit2/cache.h} +0 -0
- /data/vendor/libgit2/src/{checkout.h → libgit2/checkout.h} +0 -0
- /data/vendor/libgit2/src/{clone.h → libgit2/clone.h} +0 -0
- /data/vendor/libgit2/src/{commit_list.h → libgit2/commit_list.h} +0 -0
- /data/vendor/libgit2/src/{config_backend.h → libgit2/config_backend.h} +0 -0
- /data/vendor/libgit2/src/{config_cache.c → libgit2/config_cache.c} +0 -0
- /data/vendor/libgit2/src/{config_entries.c → libgit2/config_entries.c} +0 -0
- /data/vendor/libgit2/src/{config_entries.h → libgit2/config_entries.h} +0 -0
- /data/vendor/libgit2/src/{config_parse.h → libgit2/config_parse.h} +0 -0
- /data/vendor/libgit2/src/{config_snapshot.c → libgit2/config_snapshot.c} +0 -0
- /data/vendor/libgit2/src/{delta.c → libgit2/delta.c} +0 -0
- /data/vendor/libgit2/src/{delta.h → libgit2/delta.h} +0 -0
- /data/vendor/libgit2/src/{diff_file.h → libgit2/diff_file.h} +0 -0
- /data/vendor/libgit2/src/{diff_parse.c → libgit2/diff_parse.c} +0 -0
- /data/vendor/libgit2/src/{diff_parse.h → libgit2/diff_parse.h} +0 -0
- /data/vendor/libgit2/src/{diff_tform.h → libgit2/diff_tform.h} +0 -0
- /data/vendor/libgit2/src/{diff_xdiff.h → libgit2/diff_xdiff.h} +0 -0
- /data/vendor/libgit2/src/{fetchhead.h → libgit2/fetchhead.h} +0 -0
- /data/vendor/libgit2/src/{win32 → libgit2}/git2.rc +0 -0
- /data/vendor/libgit2/src/{graph.c → libgit2/graph.c} +0 -0
- /data/vendor/libgit2/src/{hashsig.c → libgit2/hashsig.c} +0 -0
- /data/vendor/libgit2/src/{idxmap.c → libgit2/idxmap.c} +0 -0
- /data/vendor/libgit2/src/{idxmap.h → libgit2/idxmap.h} +0 -0
- /data/vendor/libgit2/src/{indexer.h → libgit2/indexer.h} +0 -0
- /data/vendor/libgit2/src/{libgit2.h → libgit2/libgit2.h} +0 -0
- /data/vendor/libgit2/src/{mailmap.h → libgit2/mailmap.h} +0 -0
- /data/vendor/libgit2/src/{merge_driver.h → libgit2/merge_driver.h} +0 -0
- /data/vendor/libgit2/src/{notes.h → libgit2/notes.h} +0 -0
- /data/vendor/libgit2/src/{object_api.c → libgit2/object_api.c} +0 -0
- /data/vendor/libgit2/src/{offmap.c → libgit2/offmap.c} +0 -0
- /data/vendor/libgit2/src/{offmap.h → libgit2/offmap.h} +0 -0
- /data/vendor/libgit2/src/{oidarray.c → libgit2/oidarray.c} +0 -0
- /data/vendor/libgit2/src/{oidarray.h → libgit2/oidarray.h} +0 -0
- /data/vendor/libgit2/src/{oidmap.h → libgit2/oidmap.h} +0 -0
- /data/vendor/libgit2/src/{parse.h → libgit2/parse.h} +0 -0
- /data/vendor/libgit2/src/{patch_parse.h → libgit2/patch_parse.h} +0 -0
- /data/vendor/libgit2/src/{refdb.c → libgit2/refdb.c} +0 -0
- /data/vendor/libgit2/src/{refdb.h → libgit2/refdb.h} +0 -0
- /data/vendor/libgit2/src/{repo_template.h → libgit2/repo_template.h} +0 -0
- /data/vendor/libgit2/src/{revwalk.h → libgit2/revwalk.h} +0 -0
- /data/vendor/libgit2/src/{settings.h → libgit2/settings.h} +0 -0
- /data/vendor/libgit2/src/{status.h → libgit2/status.h} +0 -0
- /data/vendor/libgit2/src/{stream.h → libgit2/stream.h} +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/socket.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.h +0 -0
- /data/vendor/libgit2/src/{transaction.h → libgit2/transaction.h} +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.h +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/credential.c +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/credential_helpers.c +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/ssh.h +0 -0
- /data/vendor/libgit2/src/{userdiff.h → libgit2/userdiff.h} +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xdiffi.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xemit.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xmacros.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xprepare.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xtypes.h +0 -0
- /data/vendor/libgit2/src/{xdiff → libgit2/xdiff}/xutils.h +0 -0
- /data/vendor/libgit2/src/{alloc.c → util/alloc.c} +0 -0
- /data/vendor/libgit2/src/{alloc.h → util/alloc.h} +0 -0
- /data/vendor/libgit2/src/{allocators → util/allocators}/failalloc.c +0 -0
- /data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.c +0 -0
- /data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.c +0 -0
- /data/vendor/libgit2/src/{bitvec.h → util/bitvec.h} +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.h +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.c +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.h +0 -0
- /data/vendor/libgit2/src/{integer.h → util/integer.h} +0 -0
- /data/vendor/libgit2/src/{pool.c → util/pool.c} +0 -0
- /data/vendor/libgit2/src/{pqueue.c → util/pqueue.c} +0 -0
- /data/vendor/libgit2/src/{strmap.c → util/strmap.c} +0 -0
- /data/vendor/libgit2/src/{strnlen.h → util/strnlen.h} +0 -0
- /data/vendor/libgit2/src/{unix → util/unix}/pthread.h +0 -0
- /data/vendor/libgit2/src/{varint.c → util/varint.c} +0 -0
- /data/vendor/libgit2/src/{vector.c → util/vector.c} +0 -0
- /data/vendor/libgit2/src/{wildmatch.c → util/wildmatch.c} +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/dir.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/error.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/mingw-compat.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/msvc-compat.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/reparse.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/thread.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/utf-conv.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/version.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/w32_common.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/w32_util.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/win32-compat.h +0 -0
@@ -18,6 +18,7 @@
|
|
18
18
|
#include "sortedcache.h"
|
19
19
|
#include "signature.h"
|
20
20
|
#include "wildmatch.h"
|
21
|
+
#include "path.h"
|
21
22
|
|
22
23
|
#include <git2/tag.h>
|
23
24
|
#include <git2/object.h>
|
@@ -34,7 +35,7 @@ enum {
|
|
34
35
|
PACKREF_HAS_PEEL = 1,
|
35
36
|
PACKREF_WAS_LOOSE = 2,
|
36
37
|
PACKREF_CANNOT_PEEL = 4,
|
37
|
-
PACKREF_SHADOWED = 8
|
38
|
+
PACKREF_SHADOWED = 8
|
38
39
|
};
|
39
40
|
|
40
41
|
enum {
|
@@ -59,29 +60,36 @@ typedef struct refdb_fs_backend {
|
|
59
60
|
/* path to common objects' directory */
|
60
61
|
char *commonpath;
|
61
62
|
|
62
|
-
|
63
|
+
git_oid_t oid_type;
|
64
|
+
|
65
|
+
int fsync : 1,
|
66
|
+
sorted : 1;
|
63
67
|
int peeling_mode;
|
64
68
|
git_iterator_flag_t iterator_flags;
|
65
69
|
uint32_t direach_flags;
|
66
|
-
|
70
|
+
git_sortedcache *refcache;
|
71
|
+
git_map packed_refs_map;
|
72
|
+
git_mutex prlock; /* protect packed_refs_map */
|
73
|
+
git_futils_filestamp packed_refs_stamp;
|
67
74
|
} refdb_fs_backend;
|
68
75
|
|
69
76
|
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
|
77
|
+
static char *packed_set_peeling_mode(char *data, size_t data_sz, refdb_fs_backend *backend);
|
70
78
|
|
71
79
|
GIT_INLINE(int) loose_path(
|
72
|
-
|
80
|
+
git_str *out,
|
73
81
|
const char *base,
|
74
82
|
const char *refname)
|
75
83
|
{
|
76
|
-
if (
|
84
|
+
if (git_str_joinpath(out, base, refname) < 0)
|
77
85
|
return -1;
|
78
86
|
|
79
|
-
return
|
87
|
+
return git_fs_path_validate_str_length_with_suffix(out,
|
80
88
|
CONST_STRLEN(".lock"));
|
81
89
|
}
|
82
90
|
|
83
91
|
GIT_INLINE(int) reflog_path(
|
84
|
-
|
92
|
+
git_str *out,
|
85
93
|
git_repository *repo,
|
86
94
|
const char *refname)
|
87
95
|
{
|
@@ -91,7 +99,7 @@ GIT_INLINE(int) reflog_path(
|
|
91
99
|
base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
|
92
100
|
repo->commondir;
|
93
101
|
|
94
|
-
if ((error =
|
102
|
+
if ((error = git_str_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
|
95
103
|
return error;
|
96
104
|
|
97
105
|
return loose_path(out, out->ptr, refname);
|
@@ -106,7 +114,8 @@ static int packref_cmp(const void *a_, const void *b_)
|
|
106
114
|
static int packed_reload(refdb_fs_backend *backend)
|
107
115
|
{
|
108
116
|
int error;
|
109
|
-
|
117
|
+
git_str packedrefs = GIT_STR_INIT;
|
118
|
+
size_t oid_hexsize = git_oid_hexsize(backend->oid_type);
|
110
119
|
char *scan, *eof, *eol;
|
111
120
|
|
112
121
|
if (!backend->gitpath)
|
@@ -133,31 +142,12 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
133
142
|
|
134
143
|
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
|
135
144
|
|
136
|
-
scan =
|
145
|
+
scan = packedrefs.ptr;
|
137
146
|
eof = scan + packedrefs.size;
|
138
147
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
static const char *traits_header = "# pack-refs with: ";
|
143
|
-
|
144
|
-
if (git__prefixcmp(scan, traits_header) == 0) {
|
145
|
-
scan += strlen(traits_header);
|
146
|
-
eol = strchr(scan, '\n');
|
147
|
-
|
148
|
-
if (!eol)
|
149
|
-
goto parse_failed;
|
150
|
-
*eol = '\0';
|
151
|
-
|
152
|
-
if (strstr(scan, " fully-peeled ") != NULL) {
|
153
|
-
backend->peeling_mode = PEELING_FULL;
|
154
|
-
} else if (strstr(scan, " peeled ") != NULL) {
|
155
|
-
backend->peeling_mode = PEELING_STANDARD;
|
156
|
-
}
|
157
|
-
|
158
|
-
scan = eol + 1;
|
159
|
-
}
|
160
|
-
}
|
148
|
+
scan = packed_set_peeling_mode(scan, packedrefs.size, backend);
|
149
|
+
if (!scan)
|
150
|
+
goto parse_failed;
|
161
151
|
|
162
152
|
while (scan < eof && *scan == '#') {
|
163
153
|
if (!(eol = strchr(scan, '\n')))
|
@@ -171,9 +161,9 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
171
161
|
|
172
162
|
/* parse "<OID> <refname>\n" */
|
173
163
|
|
174
|
-
if (
|
164
|
+
if (git_oid__fromstr(&oid, scan, backend->oid_type) < 0)
|
175
165
|
goto parse_failed;
|
176
|
-
scan +=
|
166
|
+
scan += oid_hexsize;
|
177
167
|
|
178
168
|
if (*scan++ != ' ')
|
179
169
|
goto parse_failed;
|
@@ -192,9 +182,9 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
192
182
|
/* look for optional "^<OID>\n" */
|
193
183
|
|
194
184
|
if (*scan == '^') {
|
195
|
-
if (
|
185
|
+
if (git_oid__fromstr(&oid, scan + 1, backend->oid_type) < 0)
|
196
186
|
goto parse_failed;
|
197
|
-
scan +=
|
187
|
+
scan += oid_hexsize + 1;
|
198
188
|
|
199
189
|
if (scan < eof) {
|
200
190
|
if (!(eol = strchr(scan, '\n')))
|
@@ -212,7 +202,7 @@ static int packed_reload(refdb_fs_backend *backend)
|
|
212
202
|
}
|
213
203
|
|
214
204
|
git_sortedcache_wunlock(backend->refcache);
|
215
|
-
|
205
|
+
git_str_dispose(&packedrefs);
|
216
206
|
|
217
207
|
return 0;
|
218
208
|
|
@@ -221,25 +211,29 @@ parse_failed:
|
|
221
211
|
|
222
212
|
GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
|
223
213
|
git_sortedcache_wunlock(backend->refcache);
|
224
|
-
|
214
|
+
git_str_dispose(&packedrefs);
|
225
215
|
|
226
216
|
return -1;
|
227
217
|
}
|
228
218
|
|
229
219
|
static int loose_parse_oid(
|
230
|
-
git_oid *oid,
|
220
|
+
git_oid *oid,
|
221
|
+
const char *filename,
|
222
|
+
git_str *file_content,
|
223
|
+
git_oid_t oid_type)
|
231
224
|
{
|
232
|
-
const char *str =
|
225
|
+
const char *str = git_str_cstr(file_content);
|
226
|
+
size_t oid_hexsize = git_oid_hexsize(oid_type);
|
233
227
|
|
234
|
-
if (
|
228
|
+
if (git_str_len(file_content) < oid_hexsize)
|
235
229
|
goto corrupted;
|
236
230
|
|
237
231
|
/* we need to get 40 OID characters from the file */
|
238
|
-
if (
|
232
|
+
if (git_oid__fromstr(oid, str, oid_type) < 0)
|
239
233
|
goto corrupted;
|
240
234
|
|
241
235
|
/* If the file is longer than 40 chars, the 41st must be a space */
|
242
|
-
str +=
|
236
|
+
str += oid_hexsize;
|
243
237
|
if (*str == '\0' || git__isspace(*str))
|
244
238
|
return 0;
|
245
239
|
|
@@ -248,13 +242,13 @@ corrupted:
|
|
248
242
|
return -1;
|
249
243
|
}
|
250
244
|
|
251
|
-
static int loose_readbuffer(
|
245
|
+
static int loose_readbuffer(git_str *buf, const char *base, const char *path)
|
252
246
|
{
|
253
247
|
int error;
|
254
248
|
|
255
249
|
if ((error = loose_path(buf, base, path)) < 0 ||
|
256
250
|
(error = git_futils_readbuffer(buf, buf->ptr)) < 0)
|
257
|
-
|
251
|
+
git_str_dispose(buf);
|
258
252
|
|
259
253
|
return error;
|
260
254
|
}
|
@@ -262,7 +256,7 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
|
|
262
256
|
static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
263
257
|
{
|
264
258
|
int error = 0;
|
265
|
-
|
259
|
+
git_str ref_file = GIT_STR_INIT;
|
266
260
|
struct packref *ref = NULL;
|
267
261
|
git_oid oid;
|
268
262
|
|
@@ -275,11 +269,11 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
|
275
269
|
}
|
276
270
|
|
277
271
|
/* skip symbolic refs */
|
278
|
-
if (!git__prefixcmp(
|
272
|
+
if (!git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF))
|
279
273
|
goto done;
|
280
274
|
|
281
275
|
/* parse OID from file */
|
282
|
-
if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
|
276
|
+
if ((error = loose_parse_oid(&oid, name, &ref_file, backend->oid_type)) < 0)
|
283
277
|
goto done;
|
284
278
|
|
285
279
|
if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
|
@@ -295,11 +289,11 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
|
|
295
289
|
git_sortedcache_wunlock(backend->refcache);
|
296
290
|
|
297
291
|
done:
|
298
|
-
|
292
|
+
git_str_dispose(&ref_file);
|
299
293
|
return error;
|
300
294
|
}
|
301
295
|
|
302
|
-
static int _dirent_loose_load(void *payload,
|
296
|
+
static int _dirent_loose_load(void *payload, git_str *full_path)
|
303
297
|
{
|
304
298
|
refdb_fs_backend *backend = payload;
|
305
299
|
const char *file_path;
|
@@ -307,8 +301,8 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
|
|
307
301
|
if (git__suffixcmp(full_path->ptr, ".lock") == 0)
|
308
302
|
return 0;
|
309
303
|
|
310
|
-
if (
|
311
|
-
int error =
|
304
|
+
if (git_fs_path_isdir(full_path->ptr)) {
|
305
|
+
int error = git_fs_path_direach(
|
312
306
|
full_path, backend->direach_flags, _dirent_loose_load, backend);
|
313
307
|
/* Race with the filesystem, ignore it */
|
314
308
|
if (error == GIT_ENOTFOUND) {
|
@@ -333,9 +327,9 @@ static int _dirent_loose_load(void *payload, git_buf *full_path)
|
|
333
327
|
static int packed_loadloose(refdb_fs_backend *backend)
|
334
328
|
{
|
335
329
|
int error;
|
336
|
-
|
330
|
+
git_str refs_path = GIT_STR_INIT;
|
337
331
|
|
338
|
-
if (
|
332
|
+
if (git_str_joinpath(&refs_path, backend->gitpath, GIT_REFS_DIR) < 0)
|
339
333
|
return -1;
|
340
334
|
|
341
335
|
/*
|
@@ -343,10 +337,10 @@ static int packed_loadloose(refdb_fs_backend *backend)
|
|
343
337
|
* This will overwrite any old packed entries with their
|
344
338
|
* updated loose versions
|
345
339
|
*/
|
346
|
-
error =
|
340
|
+
error = git_fs_path_direach(
|
347
341
|
&refs_path, backend->direach_flags, _dirent_loose_load, backend);
|
348
342
|
|
349
|
-
|
343
|
+
git_str_dispose(&refs_path);
|
350
344
|
|
351
345
|
return error;
|
352
346
|
}
|
@@ -357,7 +351,7 @@ static int refdb_fs_backend__exists(
|
|
357
351
|
const char *ref_name)
|
358
352
|
{
|
359
353
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
360
|
-
|
354
|
+
git_str ref_path = GIT_STR_INIT;
|
361
355
|
int error;
|
362
356
|
|
363
357
|
GIT_ASSERT_ARG(backend);
|
@@ -367,7 +361,7 @@ static int refdb_fs_backend__exists(
|
|
367
361
|
if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
|
368
362
|
goto out;
|
369
363
|
|
370
|
-
if (
|
364
|
+
if (git_fs_path_isfile(ref_path.ptr)) {
|
371
365
|
*exists = 1;
|
372
366
|
goto out;
|
373
367
|
}
|
@@ -381,18 +375,18 @@ static int refdb_fs_backend__exists(
|
|
381
375
|
}
|
382
376
|
|
383
377
|
out:
|
384
|
-
|
378
|
+
git_str_dispose(&ref_path);
|
385
379
|
return error;
|
386
380
|
}
|
387
381
|
|
388
|
-
static const char *loose_parse_symbolic(
|
382
|
+
static const char *loose_parse_symbolic(git_str *file_content)
|
389
383
|
{
|
390
384
|
const unsigned int header_len = (unsigned int)strlen(GIT_SYMREF);
|
391
385
|
const char *refname_start;
|
392
386
|
|
393
387
|
refname_start = (const char *)file_content->ptr;
|
394
388
|
|
395
|
-
if (
|
389
|
+
if (git_str_len(file_content) < header_len + 1) {
|
396
390
|
git_error_set(GIT_ERROR_REFERENCE, "corrupted loose reference file");
|
397
391
|
return NULL;
|
398
392
|
}
|
@@ -424,7 +418,7 @@ static int loose_lookup(
|
|
424
418
|
refdb_fs_backend *backend,
|
425
419
|
const char *ref_name)
|
426
420
|
{
|
427
|
-
|
421
|
+
git_str ref_file = GIT_STR_INIT;
|
428
422
|
int error = 0;
|
429
423
|
const char *ref_dir;
|
430
424
|
|
@@ -438,10 +432,10 @@ static int loose_lookup(
|
|
438
432
|
|
439
433
|
if ((error = loose_readbuffer(&ref_file, ref_dir, ref_name)) < 0)
|
440
434
|
/* cannot read loose ref file - gah */;
|
441
|
-
else if (git__prefixcmp(
|
435
|
+
else if (git__prefixcmp(git_str_cstr(&ref_file), GIT_SYMREF) == 0) {
|
442
436
|
const char *target;
|
443
437
|
|
444
|
-
|
438
|
+
git_str_rtrim(&ref_file);
|
445
439
|
|
446
440
|
if (!(target = loose_parse_symbolic(&ref_file)))
|
447
441
|
error = -1;
|
@@ -450,12 +444,12 @@ static int loose_lookup(
|
|
450
444
|
} else {
|
451
445
|
git_oid oid;
|
452
446
|
|
453
|
-
if (!(error = loose_parse_oid(&oid, ref_name, &ref_file)) &&
|
447
|
+
if (!(error = loose_parse_oid(&oid, ref_name, &ref_file, backend->oid_type)) &&
|
454
448
|
out != NULL)
|
455
449
|
*out = git_reference__alloc(ref_name, &oid, NULL);
|
456
450
|
}
|
457
451
|
|
458
|
-
|
452
|
+
git_str_dispose(&ref_file);
|
459
453
|
return error;
|
460
454
|
}
|
461
455
|
|
@@ -465,10 +459,203 @@ static int ref_error_notfound(const char *name)
|
|
465
459
|
return GIT_ENOTFOUND;
|
466
460
|
}
|
467
461
|
|
468
|
-
static
|
469
|
-
|
470
|
-
|
471
|
-
|
462
|
+
static char *packed_set_peeling_mode(
|
463
|
+
char *data,
|
464
|
+
size_t data_sz,
|
465
|
+
refdb_fs_backend *backend)
|
466
|
+
{
|
467
|
+
static const char *traits_header = "# pack-refs with:";
|
468
|
+
char *eol;
|
469
|
+
backend->peeling_mode = PEELING_NONE;
|
470
|
+
|
471
|
+
if (git__prefixncmp(data, data_sz, traits_header) == 0) {
|
472
|
+
size_t hdr_sz = strlen(traits_header);
|
473
|
+
const char *sorted = " sorted ";
|
474
|
+
const char *peeled = " peeled ";
|
475
|
+
const char *fully_peeled = " fully-peeled ";
|
476
|
+
data += hdr_sz;
|
477
|
+
data_sz -= hdr_sz;
|
478
|
+
|
479
|
+
eol = memchr(data, '\n', data_sz);
|
480
|
+
|
481
|
+
if (!eol)
|
482
|
+
return NULL;
|
483
|
+
|
484
|
+
if (git__memmem(data, eol - data, fully_peeled, strlen(fully_peeled)))
|
485
|
+
backend->peeling_mode = PEELING_FULL;
|
486
|
+
else if (git__memmem(data, eol - data, peeled, strlen(peeled)))
|
487
|
+
backend->peeling_mode = PEELING_STANDARD;
|
488
|
+
|
489
|
+
backend->sorted = NULL != git__memmem(data, eol - data, sorted, strlen(sorted));
|
490
|
+
|
491
|
+
return eol + 1;
|
492
|
+
}
|
493
|
+
return data;
|
494
|
+
}
|
495
|
+
|
496
|
+
static void packed_map_free(refdb_fs_backend *backend)
|
497
|
+
{
|
498
|
+
if (backend->packed_refs_map.data) {
|
499
|
+
#ifdef GIT_WIN32
|
500
|
+
git__free(backend->packed_refs_map.data);
|
501
|
+
#else
|
502
|
+
git_futils_mmap_free(&backend->packed_refs_map);
|
503
|
+
#endif
|
504
|
+
backend->packed_refs_map.data = NULL;
|
505
|
+
backend->packed_refs_map.len = 0;
|
506
|
+
git_futils_filestamp_set(&backend->packed_refs_stamp, NULL);
|
507
|
+
}
|
508
|
+
}
|
509
|
+
|
510
|
+
static int packed_map_check(refdb_fs_backend *backend)
|
511
|
+
{
|
512
|
+
int error = 0;
|
513
|
+
git_file fd = -1;
|
514
|
+
struct stat st;
|
515
|
+
|
516
|
+
if ((error = git_mutex_lock(&backend->prlock)) < 0)
|
517
|
+
return error;
|
518
|
+
|
519
|
+
if (backend->packed_refs_map.data &&
|
520
|
+
!git_futils_filestamp_check(
|
521
|
+
&backend->packed_refs_stamp, backend->refcache->path)) {
|
522
|
+
git_mutex_unlock(&backend->prlock);
|
523
|
+
return error;
|
524
|
+
}
|
525
|
+
packed_map_free(backend);
|
526
|
+
|
527
|
+
fd = git_futils_open_ro(backend->refcache->path);
|
528
|
+
if (fd < 0) {
|
529
|
+
git_mutex_unlock(&backend->prlock);
|
530
|
+
if (fd == GIT_ENOTFOUND) {
|
531
|
+
git_error_clear();
|
532
|
+
return 0;
|
533
|
+
}
|
534
|
+
return fd;
|
535
|
+
}
|
536
|
+
|
537
|
+
if (p_fstat(fd, &st) < 0) {
|
538
|
+
p_close(fd);
|
539
|
+
git_mutex_unlock(&backend->prlock);
|
540
|
+
git_error_set(GIT_ERROR_OS, "unable to stat packed-refs '%s'", backend->refcache->path);
|
541
|
+
return -1;
|
542
|
+
}
|
543
|
+
|
544
|
+
if (st.st_size == 0) {
|
545
|
+
p_close(fd);
|
546
|
+
git_mutex_unlock(&backend->prlock);
|
547
|
+
return 0;
|
548
|
+
}
|
549
|
+
|
550
|
+
git_futils_filestamp_set_from_stat(&backend->packed_refs_stamp, &st);
|
551
|
+
|
552
|
+
#ifdef GIT_WIN32
|
553
|
+
/* on windows, we copy the entire file into memory rather than using
|
554
|
+
* mmap() because using mmap() on windows also locks the file and this
|
555
|
+
* map is long-lived. */
|
556
|
+
backend->packed_refs_map.len = (size_t)st.st_size;
|
557
|
+
backend->packed_refs_map.data =
|
558
|
+
git__malloc(backend->packed_refs_map.len);
|
559
|
+
GIT_ERROR_CHECK_ALLOC(backend->packed_refs_map.data);
|
560
|
+
{
|
561
|
+
ssize_t bytesread =
|
562
|
+
p_read(fd, backend->packed_refs_map.data,
|
563
|
+
backend->packed_refs_map.len);
|
564
|
+
error = (bytesread == (ssize_t)backend->packed_refs_map.len) ? 0 : -1;
|
565
|
+
}
|
566
|
+
#else
|
567
|
+
error = git_futils_mmap_ro(&backend->packed_refs_map, fd, 0, (size_t)st.st_size);
|
568
|
+
#endif
|
569
|
+
p_close(fd);
|
570
|
+
if (error < 0) {
|
571
|
+
git_mutex_unlock(&backend->prlock);
|
572
|
+
return error;
|
573
|
+
}
|
574
|
+
|
575
|
+
packed_set_peeling_mode(
|
576
|
+
backend->packed_refs_map.data, backend->packed_refs_map.len,
|
577
|
+
backend);
|
578
|
+
|
579
|
+
git_mutex_unlock(&backend->prlock);
|
580
|
+
return error;
|
581
|
+
}
|
582
|
+
|
583
|
+
/*
|
584
|
+
* Find beginning of packed-ref record pointed to by p.
|
585
|
+
* buf - a lower-bound pointer to some memory buffer
|
586
|
+
* p - an upper-bound pointer to the same memory buffer
|
587
|
+
*/
|
588
|
+
static const char *start_of_record(const char *buf, const char *p)
|
589
|
+
{
|
590
|
+
const char *nl = p;
|
591
|
+
while (true) {
|
592
|
+
nl = git__memrchr(buf, '\n', nl - buf);
|
593
|
+
if (!nl)
|
594
|
+
return buf;
|
595
|
+
|
596
|
+
if (nl[1] == '^' && nl > buf)
|
597
|
+
--nl;
|
598
|
+
else
|
599
|
+
break;
|
600
|
+
};
|
601
|
+
return nl + 1;
|
602
|
+
}
|
603
|
+
|
604
|
+
/*
|
605
|
+
* Find end of packed-ref record pointed to by p.
|
606
|
+
* end - an upper-bound pointer to some memory buffer
|
607
|
+
* p - a lower-bound pointer to the same memory buffer
|
608
|
+
*/
|
609
|
+
static const char *end_of_record(const char *p, const char *end)
|
610
|
+
{
|
611
|
+
while (1) {
|
612
|
+
size_t sz = end - p;
|
613
|
+
p = memchr(p, '\n', sz);
|
614
|
+
if (!p)
|
615
|
+
return end;
|
616
|
+
++p;
|
617
|
+
if (p < end && p[0] == '^')
|
618
|
+
++p;
|
619
|
+
else
|
620
|
+
break;
|
621
|
+
}
|
622
|
+
return p;
|
623
|
+
}
|
624
|
+
|
625
|
+
static int cmp_record_to_refname(
|
626
|
+
const char *rec,
|
627
|
+
size_t data_end,
|
628
|
+
const char *ref_name,
|
629
|
+
git_oid_t oid_type)
|
630
|
+
{
|
631
|
+
const size_t ref_len = strlen(ref_name);
|
632
|
+
int cmp_val;
|
633
|
+
const char *end;
|
634
|
+
size_t oid_hexsize = git_oid_hexsize(oid_type);
|
635
|
+
|
636
|
+
rec += oid_hexsize + 1; /* <oid> + space */
|
637
|
+
|
638
|
+
/* an incomplete (corrupt) record is treated as less than ref_name */
|
639
|
+
if (data_end < oid_hexsize + 3)
|
640
|
+
return -1;
|
641
|
+
|
642
|
+
data_end -= oid_hexsize + 1;
|
643
|
+
|
644
|
+
end = memchr(rec, '\n', data_end);
|
645
|
+
if (end)
|
646
|
+
data_end = end - rec;
|
647
|
+
|
648
|
+
cmp_val = memcmp(rec, ref_name, min(ref_len, data_end));
|
649
|
+
|
650
|
+
if (cmp_val == 0 && data_end != ref_len)
|
651
|
+
return (data_end > ref_len) ? 1 : -1;
|
652
|
+
return cmp_val;
|
653
|
+
}
|
654
|
+
|
655
|
+
static int packed_unsorted_lookup(
|
656
|
+
git_reference **out,
|
657
|
+
refdb_fs_backend *backend,
|
658
|
+
const char *ref_name)
|
472
659
|
{
|
473
660
|
int error = 0;
|
474
661
|
struct packref *entry;
|
@@ -493,6 +680,86 @@ static int packed_lookup(
|
|
493
680
|
return error;
|
494
681
|
}
|
495
682
|
|
683
|
+
static int packed_lookup(
|
684
|
+
git_reference **out,
|
685
|
+
refdb_fs_backend *backend,
|
686
|
+
const char *ref_name)
|
687
|
+
{
|
688
|
+
int error = 0;
|
689
|
+
const char *left, *right, *data_end;
|
690
|
+
size_t oid_hexsize = git_oid_hexsize(backend->oid_type);
|
691
|
+
|
692
|
+
if ((error = packed_map_check(backend)) < 0)
|
693
|
+
return error;
|
694
|
+
|
695
|
+
if (!backend->sorted)
|
696
|
+
return packed_unsorted_lookup(out, backend, ref_name);
|
697
|
+
|
698
|
+
left = backend->packed_refs_map.data;
|
699
|
+
right = data_end = (const char *) backend->packed_refs_map.data +
|
700
|
+
backend->packed_refs_map.len;
|
701
|
+
|
702
|
+
while (left < right && *left == '#') {
|
703
|
+
if (!(left = memchr(left, '\n', data_end - left)))
|
704
|
+
goto parse_failed;
|
705
|
+
left++;
|
706
|
+
}
|
707
|
+
|
708
|
+
while (left < right) {
|
709
|
+
const char *mid, *rec;
|
710
|
+
int compare;
|
711
|
+
|
712
|
+
mid = left + (right - left) / 2;
|
713
|
+
rec = start_of_record(left, mid);
|
714
|
+
compare = cmp_record_to_refname(rec, data_end - rec, ref_name, backend->oid_type);
|
715
|
+
|
716
|
+
if (compare < 0) {
|
717
|
+
left = end_of_record(mid, right);
|
718
|
+
} else if (compare > 0) {
|
719
|
+
right = rec;
|
720
|
+
} else {
|
721
|
+
const char *eol;
|
722
|
+
git_oid oid, peel, *peel_ptr = NULL;
|
723
|
+
|
724
|
+
if (data_end - rec < (long)oid_hexsize ||
|
725
|
+
git_oid__fromstr(&oid, rec, backend->oid_type) < 0) {
|
726
|
+
goto parse_failed;
|
727
|
+
}
|
728
|
+
rec += oid_hexsize + 1;
|
729
|
+
if (!(eol = memchr(rec, '\n', data_end - rec))) {
|
730
|
+
goto parse_failed;
|
731
|
+
}
|
732
|
+
|
733
|
+
/* look for optional "^<OID>\n" */
|
734
|
+
|
735
|
+
if (eol + 1 < data_end) {
|
736
|
+
rec = eol + 1;
|
737
|
+
|
738
|
+
if (*rec == '^') {
|
739
|
+
rec++;
|
740
|
+
if (data_end - rec < (long)oid_hexsize ||
|
741
|
+
git_oid__fromstr(&peel, rec, backend->oid_type) < 0) {
|
742
|
+
goto parse_failed;
|
743
|
+
}
|
744
|
+
peel_ptr = &peel;
|
745
|
+
}
|
746
|
+
}
|
747
|
+
|
748
|
+
*out = git_reference__alloc(ref_name, &oid, peel_ptr);
|
749
|
+
if (!*out) {
|
750
|
+
return -1;
|
751
|
+
}
|
752
|
+
|
753
|
+
return 0;
|
754
|
+
}
|
755
|
+
}
|
756
|
+
return ref_error_notfound(ref_name);
|
757
|
+
|
758
|
+
parse_failed:
|
759
|
+
git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
|
760
|
+
return -1;
|
761
|
+
}
|
762
|
+
|
496
763
|
static int refdb_fs_backend__lookup(
|
497
764
|
git_reference **out,
|
498
765
|
git_refdb_backend *_backend,
|
@@ -512,7 +779,6 @@ static int refdb_fs_backend__lookup(
|
|
512
779
|
git_error_clear();
|
513
780
|
error = packed_lookup(out, backend, ref_name);
|
514
781
|
}
|
515
|
-
|
516
782
|
return error;
|
517
783
|
}
|
518
784
|
|
@@ -542,7 +808,7 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
|
|
542
808
|
static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
543
809
|
{
|
544
810
|
int error = 0;
|
545
|
-
|
811
|
+
git_str path = GIT_STR_INIT;
|
546
812
|
git_iterator *fsit = NULL;
|
547
813
|
git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
|
548
814
|
const git_index_entry *entry = NULL;
|
@@ -578,26 +844,26 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
|
578
844
|
}
|
579
845
|
}
|
580
846
|
|
581
|
-
if ((error =
|
582
|
-
(error =
|
583
|
-
|
847
|
+
if ((error = git_str_puts(&path, backend->commonpath)) < 0 ||
|
848
|
+
(error = git_str_put(&path, ref_prefix, ref_prefix_len)) < 0) {
|
849
|
+
git_str_dispose(&path);
|
584
850
|
return error;
|
585
851
|
}
|
586
852
|
|
587
853
|
if ((error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
|
588
|
-
|
854
|
+
git_str_dispose(&path);
|
589
855
|
return (iter->glob && error == GIT_ENOTFOUND)? 0 : error;
|
590
856
|
}
|
591
857
|
|
592
|
-
error =
|
858
|
+
error = git_str_sets(&path, ref_prefix);
|
593
859
|
|
594
860
|
while (!error && !git_iterator_advance(&entry, fsit)) {
|
595
861
|
const char *ref_name;
|
596
862
|
char *ref_dup;
|
597
863
|
|
598
|
-
|
599
|
-
|
600
|
-
ref_name =
|
864
|
+
git_str_truncate(&path, ref_prefix_len);
|
865
|
+
git_str_puts(&path, entry->path);
|
866
|
+
ref_name = git_str_cstr(&path);
|
601
867
|
|
602
868
|
if (git__suffixcmp(ref_name, ".lock") == 0 ||
|
603
869
|
(iter->glob && wildmatch(iter->glob, ref_name, 0) != 0))
|
@@ -611,7 +877,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
|
|
611
877
|
}
|
612
878
|
|
613
879
|
git_iterator_free(fsit);
|
614
|
-
|
880
|
+
git_str_dispose(&path);
|
615
881
|
|
616
882
|
return error;
|
617
883
|
}
|
@@ -810,14 +1076,14 @@ static int reference_path_available(
|
|
810
1076
|
static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *name)
|
811
1077
|
{
|
812
1078
|
int error, filebuf_flags;
|
813
|
-
|
1079
|
+
git_str ref_path = GIT_STR_INIT;
|
814
1080
|
const char *basedir;
|
815
1081
|
|
816
1082
|
GIT_ASSERT_ARG(file);
|
817
1083
|
GIT_ASSERT_ARG(backend);
|
818
1084
|
GIT_ASSERT_ARG(name);
|
819
1085
|
|
820
|
-
if (!
|
1086
|
+
if (!git_path_is_valid(backend->repo, name, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
|
821
1087
|
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
|
822
1088
|
return GIT_EINVALIDSPEC;
|
823
1089
|
}
|
@@ -845,7 +1111,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
|
|
845
1111
|
if (error == GIT_EDIRECTORY)
|
846
1112
|
git_error_set(GIT_ERROR_REFERENCE, "cannot lock ref '%s', there are refs beneath that folder", name);
|
847
1113
|
|
848
|
-
|
1114
|
+
git_str_dispose(&ref_path);
|
849
1115
|
return error;
|
850
1116
|
}
|
851
1117
|
|
@@ -855,7 +1121,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
|
|
855
1121
|
GIT_ASSERT_ARG(ref);
|
856
1122
|
|
857
1123
|
if (ref->type == GIT_REFERENCE_DIRECT) {
|
858
|
-
char oid[
|
1124
|
+
char oid[GIT_OID_MAX_HEXSIZE + 1];
|
859
1125
|
git_oid_nfmt(oid, sizeof(oid), &ref->target.oid);
|
860
1126
|
|
861
1127
|
git_filebuf_printf(file, "%s\n", oid);
|
@@ -971,7 +1237,7 @@ static int packed_find_peel(refdb_fs_backend *backend, struct packref *ref)
|
|
971
1237
|
*/
|
972
1238
|
static int packed_write_ref(struct packref *ref, git_filebuf *file)
|
973
1239
|
{
|
974
|
-
char oid[
|
1240
|
+
char oid[GIT_OID_MAX_HEXSIZE + 1];
|
975
1241
|
git_oid_nfmt(oid, sizeof(oid), &ref->oid);
|
976
1242
|
|
977
1243
|
/*
|
@@ -985,7 +1251,7 @@ static int packed_write_ref(struct packref *ref, git_filebuf *file)
|
|
985
1251
|
* The required peels have already been loaded into `ref->peel_target`.
|
986
1252
|
*/
|
987
1253
|
if (ref->flags & PACKREF_HAS_PEEL) {
|
988
|
-
char peel[
|
1254
|
+
char peel[GIT_OID_MAX_HEXSIZE + 1];
|
989
1255
|
git_oid_nfmt(peel, sizeof(peel), &ref->peel);
|
990
1256
|
|
991
1257
|
if (git_filebuf_printf(file, "%s %s\n^%s\n", oid, ref->name, peel) < 0)
|
@@ -1013,7 +1279,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
1013
1279
|
{
|
1014
1280
|
size_t i;
|
1015
1281
|
git_filebuf lock = GIT_FILEBUF_INIT;
|
1016
|
-
|
1282
|
+
git_str ref_content = GIT_STR_INIT;
|
1017
1283
|
int error = 0;
|
1018
1284
|
|
1019
1285
|
/* backend->refcache is already locked when this is called */
|
@@ -1034,7 +1300,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
1034
1300
|
continue;
|
1035
1301
|
|
1036
1302
|
if (error < 0) {
|
1037
|
-
|
1303
|
+
git_str_dispose(&ref_content);
|
1038
1304
|
git_error_set(GIT_ERROR_REFERENCE, "failed to lock loose reference '%s'", ref->name);
|
1039
1305
|
return error;
|
1040
1306
|
}
|
@@ -1049,7 +1315,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
1049
1315
|
continue;
|
1050
1316
|
|
1051
1317
|
/* Figure out the current id; if we find a bad ref file, skip it so we can do the rest */
|
1052
|
-
if (loose_parse_oid(¤t_id, lock.path_original, &ref_content) < 0)
|
1318
|
+
if (loose_parse_oid(¤t_id, lock.path_original, &ref_content, backend->oid_type) < 0)
|
1053
1319
|
continue;
|
1054
1320
|
|
1055
1321
|
/* If the ref moved since we packed it, we must not delete it */
|
@@ -1065,7 +1331,7 @@ static int packed_remove_loose(refdb_fs_backend *backend)
|
|
1065
1331
|
p_unlink(lock.path_original);
|
1066
1332
|
}
|
1067
1333
|
|
1068
|
-
|
1334
|
+
git_str_dispose(&ref_content);
|
1069
1335
|
git_filebuf_cleanup(&lock);
|
1070
1336
|
return 0;
|
1071
1337
|
}
|
@@ -1080,6 +1346,15 @@ static int packed_write(refdb_fs_backend *backend)
|
|
1080
1346
|
int error, open_flags = 0;
|
1081
1347
|
size_t i;
|
1082
1348
|
|
1349
|
+
/* take lock and close up packed-refs mmap if open */
|
1350
|
+
if ((error = git_mutex_lock(&backend->prlock)) < 0) {
|
1351
|
+
return error;
|
1352
|
+
}
|
1353
|
+
|
1354
|
+
packed_map_free(backend);
|
1355
|
+
|
1356
|
+
git_mutex_unlock(&backend->prlock);
|
1357
|
+
|
1083
1358
|
/* lock the cache to updates while we do this */
|
1084
1359
|
if ((error = git_sortedcache_wlock(refcache)) < 0)
|
1085
1360
|
return error;
|
@@ -1099,7 +1374,11 @@ static int packed_write(refdb_fs_backend *backend)
|
|
1099
1374
|
|
1100
1375
|
for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
|
1101
1376
|
struct packref *ref = git_sortedcache_entry(refcache, i);
|
1102
|
-
|
1377
|
+
|
1378
|
+
GIT_ASSERT_WITH_CLEANUP(ref, {
|
1379
|
+
error = -1;
|
1380
|
+
goto fail;
|
1381
|
+
});
|
1103
1382
|
|
1104
1383
|
if ((error = packed_find_peel(backend, ref)) < 0)
|
1105
1384
|
goto fail;
|
@@ -1333,41 +1612,41 @@ static int refdb_fs_backend__prune_refs(
|
|
1333
1612
|
const char *ref_name,
|
1334
1613
|
const char *prefix)
|
1335
1614
|
{
|
1336
|
-
|
1337
|
-
|
1615
|
+
git_str relative_path = GIT_STR_INIT;
|
1616
|
+
git_str base_path = GIT_STR_INIT;
|
1338
1617
|
size_t commonlen;
|
1339
1618
|
int error;
|
1340
1619
|
|
1341
1620
|
GIT_ASSERT_ARG(backend);
|
1342
1621
|
GIT_ASSERT_ARG(ref_name);
|
1343
1622
|
|
1344
|
-
if ((error =
|
1623
|
+
if ((error = git_str_sets(&relative_path, ref_name)) < 0)
|
1345
1624
|
goto cleanup;
|
1346
1625
|
|
1347
|
-
|
1348
|
-
if ((commonlen =
|
1349
|
-
(commonlen =
|
1350
|
-
(commonlen =
|
1626
|
+
git_fs_path_squash_slashes(&relative_path);
|
1627
|
+
if ((commonlen = git_fs_path_common_dirlen("refs/heads/", git_str_cstr(&relative_path))) == strlen("refs/heads/") ||
|
1628
|
+
(commonlen = git_fs_path_common_dirlen("refs/tags/", git_str_cstr(&relative_path))) == strlen("refs/tags/") ||
|
1629
|
+
(commonlen = git_fs_path_common_dirlen("refs/remotes/", git_str_cstr(&relative_path))) == strlen("refs/remotes/")) {
|
1351
1630
|
|
1352
|
-
|
1631
|
+
git_str_truncate(&relative_path, commonlen);
|
1353
1632
|
|
1354
1633
|
if (prefix)
|
1355
|
-
error =
|
1634
|
+
error = git_str_join3(&base_path, '/',
|
1356
1635
|
backend->commonpath, prefix,
|
1357
|
-
|
1636
|
+
git_str_cstr(&relative_path));
|
1358
1637
|
else
|
1359
|
-
error =
|
1638
|
+
error = git_str_joinpath(&base_path,
|
1360
1639
|
backend->commonpath,
|
1361
|
-
|
1640
|
+
git_str_cstr(&relative_path));
|
1362
1641
|
|
1363
1642
|
if (!error)
|
1364
|
-
error =
|
1643
|
+
error = git_path_validate_str_length(NULL, &base_path);
|
1365
1644
|
|
1366
1645
|
if (error < 0)
|
1367
1646
|
goto cleanup;
|
1368
1647
|
|
1369
1648
|
error = git_futils_rmdir_r(ref_name + commonlen,
|
1370
|
-
|
1649
|
+
git_str_cstr(&base_path),
|
1371
1650
|
GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
|
1372
1651
|
|
1373
1652
|
if (error == GIT_ENOTFOUND)
|
@@ -1375,8 +1654,8 @@ static int refdb_fs_backend__prune_refs(
|
|
1375
1654
|
}
|
1376
1655
|
|
1377
1656
|
cleanup:
|
1378
|
-
|
1379
|
-
|
1657
|
+
git_str_dispose(&relative_path);
|
1658
|
+
git_str_dispose(&base_path);
|
1380
1659
|
return error;
|
1381
1660
|
}
|
1382
1661
|
|
@@ -1405,7 +1684,7 @@ static int refdb_fs_backend__delete(
|
|
1405
1684
|
|
1406
1685
|
static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
|
1407
1686
|
{
|
1408
|
-
|
1687
|
+
git_str path = GIT_STR_INIT;
|
1409
1688
|
int error = 0;
|
1410
1689
|
|
1411
1690
|
if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
|
@@ -1417,7 +1696,7 @@ static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
|
|
1417
1696
|
else if (error != 0)
|
1418
1697
|
error = -1;
|
1419
1698
|
|
1420
|
-
|
1699
|
+
git_str_dispose(&path);
|
1421
1700
|
|
1422
1701
|
return error;
|
1423
1702
|
}
|
@@ -1567,6 +1846,12 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
|
|
1567
1846
|
return;
|
1568
1847
|
|
1569
1848
|
git_sortedcache_free(backend->refcache);
|
1849
|
+
|
1850
|
+
git_mutex_lock(&backend->prlock);
|
1851
|
+
packed_map_free(backend);
|
1852
|
+
git_mutex_unlock(&backend->prlock);
|
1853
|
+
git_mutex_free(&backend->prlock);
|
1854
|
+
|
1570
1855
|
git__free(backend->gitpath);
|
1571
1856
|
git__free(backend->commonpath);
|
1572
1857
|
git__free(backend);
|
@@ -1574,17 +1859,17 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
|
|
1574
1859
|
|
1575
1860
|
static char *setup_namespace(git_repository *repo, const char *in)
|
1576
1861
|
{
|
1577
|
-
|
1862
|
+
git_str path = GIT_STR_INIT;
|
1578
1863
|
char *parts, *start, *end, *out = NULL;
|
1579
1864
|
|
1580
1865
|
if (!in)
|
1581
1866
|
goto done;
|
1582
1867
|
|
1583
|
-
|
1868
|
+
git_str_puts(&path, in);
|
1584
1869
|
|
1585
1870
|
/* if the repo is not namespaced, nothing else to do */
|
1586
1871
|
if (repo->namespace == NULL) {
|
1587
|
-
out =
|
1872
|
+
out = git_str_detach(&path);
|
1588
1873
|
goto done;
|
1589
1874
|
}
|
1590
1875
|
|
@@ -1599,27 +1884,30 @@ static char *setup_namespace(git_repository *repo, const char *in)
|
|
1599
1884
|
* refs under refs/namespaces/foo/refs/namespaces/bar/
|
1600
1885
|
*/
|
1601
1886
|
while ((start = git__strsep(&end, "/")) != NULL)
|
1602
|
-
|
1887
|
+
git_str_printf(&path, "refs/namespaces/%s/", start);
|
1603
1888
|
|
1604
|
-
|
1889
|
+
git_str_printf(&path, "refs/namespaces/%s/refs", end);
|
1605
1890
|
git__free(parts);
|
1606
1891
|
|
1607
1892
|
/* Make sure that the folder with the namespace exists */
|
1608
|
-
if (git_futils_mkdir_relative(
|
1893
|
+
if (git_futils_mkdir_relative(git_str_cstr(&path), in, 0777,
|
1609
1894
|
GIT_MKDIR_PATH, NULL) < 0)
|
1610
1895
|
goto done;
|
1611
1896
|
|
1612
1897
|
/* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
|
1613
|
-
|
1614
|
-
|
1615
|
-
out =
|
1898
|
+
git_str_rtruncate_at_char(&path, '/');
|
1899
|
+
git_str_putc(&path, '/');
|
1900
|
+
out = git_str_detach(&path);
|
1616
1901
|
|
1617
1902
|
done:
|
1618
|
-
|
1903
|
+
git_str_dispose(&path);
|
1619
1904
|
return out;
|
1620
1905
|
}
|
1621
1906
|
|
1622
|
-
static int reflog_alloc(
|
1907
|
+
static int reflog_alloc(
|
1908
|
+
git_reflog **reflog,
|
1909
|
+
const char *name,
|
1910
|
+
git_oid_t oid_type)
|
1623
1911
|
{
|
1624
1912
|
git_reflog *log;
|
1625
1913
|
|
@@ -1631,6 +1919,8 @@ static int reflog_alloc(git_reflog **reflog, const char *name)
|
|
1631
1919
|
log->ref_name = git__strdup(name);
|
1632
1920
|
GIT_ERROR_CHECK_ALLOC(log->ref_name);
|
1633
1921
|
|
1922
|
+
log->oid_type = oid_type;
|
1923
|
+
|
1634
1924
|
if (git_vector_init(&log->entries, 0, NULL) < 0) {
|
1635
1925
|
git__free(log->ref_name);
|
1636
1926
|
git__free(log);
|
@@ -1716,7 +2006,7 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
|
|
1716
2006
|
{
|
1717
2007
|
refdb_fs_backend *backend;
|
1718
2008
|
git_repository *repo;
|
1719
|
-
|
2009
|
+
git_str path = GIT_STR_INIT;
|
1720
2010
|
int error;
|
1721
2011
|
|
1722
2012
|
GIT_ASSERT_ARG(_backend && name);
|
@@ -1727,8 +2017,8 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
|
|
1727
2017
|
if ((error = reflog_path(&path, repo, name)) < 0)
|
1728
2018
|
return error;
|
1729
2019
|
|
1730
|
-
error = create_new_reflog_file(
|
1731
|
-
|
2020
|
+
error = create_new_reflog_file(git_str_cstr(&path));
|
2021
|
+
git_str_dispose(&path);
|
1732
2022
|
|
1733
2023
|
return error;
|
1734
2024
|
}
|
@@ -1736,15 +2026,15 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
|
|
1736
2026
|
static int has_reflog(git_repository *repo, const char *name)
|
1737
2027
|
{
|
1738
2028
|
int ret = 0;
|
1739
|
-
|
2029
|
+
git_str path = GIT_STR_INIT;
|
1740
2030
|
|
1741
2031
|
if (reflog_path(&path, repo, name) < 0)
|
1742
2032
|
goto cleanup;
|
1743
2033
|
|
1744
|
-
ret =
|
2034
|
+
ret = git_fs_path_isfile(git_str_cstr(&path));
|
1745
2035
|
|
1746
2036
|
cleanup:
|
1747
|
-
|
2037
|
+
git_str_dispose(&path);
|
1748
2038
|
return ret;
|
1749
2039
|
}
|
1750
2040
|
|
@@ -1760,11 +2050,14 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
|
|
1760
2050
|
return has_reflog(backend->repo, name);
|
1761
2051
|
}
|
1762
2052
|
|
1763
|
-
static int refdb_reflog_fs__read(
|
2053
|
+
static int refdb_reflog_fs__read(
|
2054
|
+
git_reflog **out,
|
2055
|
+
git_refdb_backend *_backend,
|
2056
|
+
const char *name)
|
1764
2057
|
{
|
1765
2058
|
int error = -1;
|
1766
|
-
|
1767
|
-
|
2059
|
+
git_str log_path = GIT_STR_INIT;
|
2060
|
+
git_str log_file = GIT_STR_INIT;
|
1768
2061
|
git_reflog *log = NULL;
|
1769
2062
|
git_repository *repo;
|
1770
2063
|
refdb_fs_backend *backend;
|
@@ -1776,22 +2069,22 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
|
|
1776
2069
|
backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
1777
2070
|
repo = backend->repo;
|
1778
2071
|
|
1779
|
-
if (reflog_alloc(&log, name) < 0)
|
2072
|
+
if (reflog_alloc(&log, name, backend->oid_type) < 0)
|
1780
2073
|
return -1;
|
1781
2074
|
|
1782
2075
|
if (reflog_path(&log_path, repo, name) < 0)
|
1783
2076
|
goto cleanup;
|
1784
2077
|
|
1785
|
-
error = git_futils_readbuffer(&log_file,
|
2078
|
+
error = git_futils_readbuffer(&log_file, git_str_cstr(&log_path));
|
1786
2079
|
if (error < 0 && error != GIT_ENOTFOUND)
|
1787
2080
|
goto cleanup;
|
1788
2081
|
|
1789
2082
|
if ((error == GIT_ENOTFOUND) &&
|
1790
|
-
((error = create_new_reflog_file(
|
2083
|
+
((error = create_new_reflog_file(git_str_cstr(&log_path))) < 0))
|
1791
2084
|
goto cleanup;
|
1792
2085
|
|
1793
2086
|
if ((error = reflog_parse(log,
|
1794
|
-
|
2087
|
+
git_str_cstr(&log_file), git_str_len(&log_file))) < 0)
|
1795
2088
|
goto cleanup;
|
1796
2089
|
|
1797
2090
|
*out = log;
|
@@ -1801,62 +2094,62 @@ cleanup:
|
|
1801
2094
|
git_reflog_free(log);
|
1802
2095
|
|
1803
2096
|
success:
|
1804
|
-
|
1805
|
-
|
2097
|
+
git_str_dispose(&log_file);
|
2098
|
+
git_str_dispose(&log_path);
|
1806
2099
|
|
1807
2100
|
return error;
|
1808
2101
|
}
|
1809
2102
|
|
1810
2103
|
static int serialize_reflog_entry(
|
1811
|
-
|
2104
|
+
git_str *buf,
|
1812
2105
|
const git_oid *oid_old,
|
1813
2106
|
const git_oid *oid_new,
|
1814
2107
|
const git_signature *committer,
|
1815
2108
|
const char *msg)
|
1816
2109
|
{
|
1817
|
-
char raw_old[
|
1818
|
-
char raw_new[
|
2110
|
+
char raw_old[GIT_OID_MAX_HEXSIZE + 1];
|
2111
|
+
char raw_new[GIT_OID_MAX_HEXSIZE + 1];
|
1819
2112
|
|
1820
|
-
git_oid_tostr(raw_old,
|
1821
|
-
git_oid_tostr(raw_new,
|
2113
|
+
git_oid_tostr(raw_old, GIT_OID_MAX_HEXSIZE + 1, oid_old);
|
2114
|
+
git_oid_tostr(raw_new, GIT_OID_MAX_HEXSIZE + 1, oid_new);
|
1822
2115
|
|
1823
|
-
|
2116
|
+
git_str_clear(buf);
|
1824
2117
|
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
2118
|
+
git_str_puts(buf, raw_old);
|
2119
|
+
git_str_putc(buf, ' ');
|
2120
|
+
git_str_puts(buf, raw_new);
|
1828
2121
|
|
1829
2122
|
git_signature__writebuf(buf, " ", committer);
|
1830
2123
|
|
1831
2124
|
/* drop trailing LF */
|
1832
|
-
|
2125
|
+
git_str_rtrim(buf);
|
1833
2126
|
|
1834
2127
|
if (msg) {
|
1835
2128
|
size_t i;
|
1836
2129
|
|
1837
|
-
|
1838
|
-
|
2130
|
+
git_str_putc(buf, '\t');
|
2131
|
+
git_str_puts(buf, msg);
|
1839
2132
|
|
1840
2133
|
for (i = 0; i < buf->size - 2; i++)
|
1841
2134
|
if (buf->ptr[i] == '\n')
|
1842
2135
|
buf->ptr[i] = ' ';
|
1843
|
-
|
2136
|
+
git_str_rtrim(buf);
|
1844
2137
|
}
|
1845
2138
|
|
1846
|
-
|
2139
|
+
git_str_putc(buf, '\n');
|
1847
2140
|
|
1848
|
-
return
|
2141
|
+
return git_str_oom(buf);
|
1849
2142
|
}
|
1850
2143
|
|
1851
2144
|
static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char *refname)
|
1852
2145
|
{
|
1853
2146
|
git_repository *repo;
|
1854
|
-
|
2147
|
+
git_str log_path = GIT_STR_INIT;
|
1855
2148
|
int error;
|
1856
2149
|
|
1857
2150
|
repo = backend->repo;
|
1858
2151
|
|
1859
|
-
if (!
|
2152
|
+
if (!git_path_is_valid(backend->repo, refname, 0, GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
|
1860
2153
|
git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
|
1861
2154
|
return GIT_EINVALIDSPEC;
|
1862
2155
|
}
|
@@ -1864,17 +2157,17 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
|
|
1864
2157
|
if (reflog_path(&log_path, repo, refname) < 0)
|
1865
2158
|
return -1;
|
1866
2159
|
|
1867
|
-
if (!
|
2160
|
+
if (!git_fs_path_isfile(git_str_cstr(&log_path))) {
|
1868
2161
|
git_error_set(GIT_ERROR_INVALID,
|
1869
2162
|
"log file for reference '%s' doesn't exist", refname);
|
1870
2163
|
error = -1;
|
1871
2164
|
goto cleanup;
|
1872
2165
|
}
|
1873
2166
|
|
1874
|
-
error = git_filebuf_open(file,
|
2167
|
+
error = git_filebuf_open(file, git_str_cstr(&log_path), 0, GIT_REFLOG_FILE_MODE);
|
1875
2168
|
|
1876
2169
|
cleanup:
|
1877
|
-
|
2170
|
+
git_str_dispose(&log_path);
|
1878
2171
|
|
1879
2172
|
return error;
|
1880
2173
|
}
|
@@ -1885,7 +2178,7 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
|
|
1885
2178
|
unsigned int i;
|
1886
2179
|
git_reflog_entry *entry;
|
1887
2180
|
refdb_fs_backend *backend;
|
1888
|
-
|
2181
|
+
git_str log = GIT_STR_INIT;
|
1889
2182
|
git_filebuf fbuf = GIT_FILEBUF_INIT;
|
1890
2183
|
|
1891
2184
|
GIT_ASSERT_ARG(_backend);
|
@@ -1911,17 +2204,23 @@ cleanup:
|
|
1911
2204
|
git_filebuf_cleanup(&fbuf);
|
1912
2205
|
|
1913
2206
|
success:
|
1914
|
-
|
2207
|
+
git_str_dispose(&log);
|
1915
2208
|
|
1916
2209
|
return error;
|
1917
2210
|
}
|
1918
2211
|
|
1919
2212
|
/* Append to the reflog, must be called under reference lock */
|
1920
|
-
static int reflog_append(
|
2213
|
+
static int reflog_append(
|
2214
|
+
refdb_fs_backend *backend,
|
2215
|
+
const git_reference *ref,
|
2216
|
+
const git_oid *old,
|
2217
|
+
const git_oid *new,
|
2218
|
+
const git_signature *who,
|
2219
|
+
const char *message)
|
1921
2220
|
{
|
1922
2221
|
int error, is_symbolic, open_flags;
|
1923
|
-
git_oid old_id
|
1924
|
-
|
2222
|
+
git_oid old_id, new_id;
|
2223
|
+
git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
|
1925
2224
|
git_repository *repo = backend->repo;
|
1926
2225
|
|
1927
2226
|
is_symbolic = ref->type == GIT_REFERENCE_SYMBOLIC;
|
@@ -1934,6 +2233,9 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1934
2233
|
|
1935
2234
|
/* From here on is_symbolic also means that it's HEAD */
|
1936
2235
|
|
2236
|
+
git_oid_clear(&old_id, backend->oid_type);
|
2237
|
+
git_oid_clear(&new_id, backend->oid_type);
|
2238
|
+
|
1937
2239
|
if (old) {
|
1938
2240
|
git_oid_cpy(&old_id, old);
|
1939
2241
|
} else {
|
@@ -1965,7 +2267,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1965
2267
|
if ((error = reflog_path(&path, repo, ref->name)) < 0)
|
1966
2268
|
goto cleanup;
|
1967
2269
|
|
1968
|
-
if (((error = git_futils_mkpath2file(
|
2270
|
+
if (((error = git_futils_mkpath2file(git_str_cstr(&path), 0777)) < 0) &&
|
1969
2271
|
(error != GIT_EEXISTS)) {
|
1970
2272
|
goto cleanup;
|
1971
2273
|
}
|
@@ -1973,11 +2275,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1973
2275
|
/* If the new branch matches part of the namespace of a previously deleted branch,
|
1974
2276
|
* there maybe an obsolete/unused directory (or directory hierarchy) in the way.
|
1975
2277
|
*/
|
1976
|
-
if (
|
1977
|
-
if ((error = git_futils_rmdir_r(
|
2278
|
+
if (git_fs_path_isdir(git_str_cstr(&path))) {
|
2279
|
+
if ((error = git_futils_rmdir_r(git_str_cstr(&path), NULL, GIT_RMDIR_SKIP_NONEMPTY)) < 0) {
|
1978
2280
|
if (error == GIT_ENOTFOUND)
|
1979
2281
|
error = 0;
|
1980
|
-
} else if (
|
2282
|
+
} else if (git_fs_path_isdir(git_str_cstr(&path))) {
|
1981
2283
|
git_error_set(GIT_ERROR_REFERENCE, "cannot create reflog at '%s', there are reflogs beneath that folder",
|
1982
2284
|
ref->name);
|
1983
2285
|
error = GIT_EDIRECTORY;
|
@@ -1992,11 +2294,11 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
|
|
1992
2294
|
if (backend->fsync)
|
1993
2295
|
open_flags |= O_FSYNC;
|
1994
2296
|
|
1995
|
-
error = git_futils_writebuffer(&buf,
|
2297
|
+
error = git_futils_writebuffer(&buf, git_str_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
|
1996
2298
|
|
1997
2299
|
cleanup:
|
1998
|
-
|
1999
|
-
|
2300
|
+
git_str_dispose(&buf);
|
2301
|
+
git_str_dispose(&path);
|
2000
2302
|
|
2001
2303
|
return error;
|
2002
2304
|
}
|
@@ -2004,10 +2306,10 @@ cleanup:
|
|
2004
2306
|
static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_name, const char *new_name)
|
2005
2307
|
{
|
2006
2308
|
int error = 0, fd;
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2309
|
+
git_str old_path = GIT_STR_INIT;
|
2310
|
+
git_str new_path = GIT_STR_INIT;
|
2311
|
+
git_str temp_path = GIT_STR_INIT;
|
2312
|
+
git_str normalized = GIT_STR_INIT;
|
2011
2313
|
git_repository *repo;
|
2012
2314
|
refdb_fs_backend *backend;
|
2013
2315
|
|
@@ -2022,16 +2324,16 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
2022
2324
|
&normalized, new_name, GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL)) < 0)
|
2023
2325
|
return error;
|
2024
2326
|
|
2025
|
-
if (
|
2327
|
+
if (git_str_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
|
2026
2328
|
return -1;
|
2027
2329
|
|
2028
|
-
if ((error = loose_path(&old_path,
|
2330
|
+
if ((error = loose_path(&old_path, git_str_cstr(&temp_path), old_name)) < 0)
|
2029
2331
|
return error;
|
2030
2332
|
|
2031
|
-
if ((error = loose_path(&new_path,
|
2333
|
+
if ((error = loose_path(&new_path, git_str_cstr(&temp_path), git_str_cstr(&normalized))) < 0)
|
2032
2334
|
return error;
|
2033
2335
|
|
2034
|
-
if (!
|
2336
|
+
if (!git_fs_path_exists(git_str_cstr(&old_path))) {
|
2035
2337
|
error = GIT_ENOTFOUND;
|
2036
2338
|
goto cleanup;
|
2037
2339
|
}
|
@@ -2043,43 +2345,43 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
|
|
2043
2345
|
* - a/b -> a/b/c
|
2044
2346
|
* - a/b/c/d -> a/b/c
|
2045
2347
|
*/
|
2046
|
-
if ((error = loose_path(&temp_path,
|
2348
|
+
if ((error = loose_path(&temp_path, git_str_cstr(&temp_path), "temp_reflog")) < 0)
|
2047
2349
|
return error;
|
2048
2350
|
|
2049
|
-
if ((fd = git_futils_mktmp(&temp_path,
|
2351
|
+
if ((fd = git_futils_mktmp(&temp_path, git_str_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
|
2050
2352
|
error = -1;
|
2051
2353
|
goto cleanup;
|
2052
2354
|
}
|
2053
2355
|
|
2054
2356
|
p_close(fd);
|
2055
2357
|
|
2056
|
-
if (p_rename(
|
2358
|
+
if (p_rename(git_str_cstr(&old_path), git_str_cstr(&temp_path)) < 0) {
|
2057
2359
|
git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
|
2058
2360
|
error = -1;
|
2059
2361
|
goto cleanup;
|
2060
2362
|
}
|
2061
2363
|
|
2062
|
-
if (
|
2063
|
-
(git_futils_rmdir_r(
|
2364
|
+
if (git_fs_path_isdir(git_str_cstr(&new_path)) &&
|
2365
|
+
(git_futils_rmdir_r(git_str_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
|
2064
2366
|
error = -1;
|
2065
2367
|
goto cleanup;
|
2066
2368
|
}
|
2067
2369
|
|
2068
|
-
if (git_futils_mkpath2file(
|
2370
|
+
if (git_futils_mkpath2file(git_str_cstr(&new_path), GIT_REFLOG_DIR_MODE) < 0) {
|
2069
2371
|
error = -1;
|
2070
2372
|
goto cleanup;
|
2071
2373
|
}
|
2072
2374
|
|
2073
|
-
if (p_rename(
|
2375
|
+
if (p_rename(git_str_cstr(&temp_path), git_str_cstr(&new_path)) < 0) {
|
2074
2376
|
git_error_set(GIT_ERROR_OS, "failed to rename reflog for %s", new_name);
|
2075
2377
|
error = -1;
|
2076
2378
|
}
|
2077
2379
|
|
2078
2380
|
cleanup:
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2381
|
+
git_str_dispose(&temp_path);
|
2382
|
+
git_str_dispose(&old_path);
|
2383
|
+
git_str_dispose(&new_path);
|
2384
|
+
git_str_dispose(&normalized);
|
2083
2385
|
|
2084
2386
|
return error;
|
2085
2387
|
}
|
@@ -2087,7 +2389,7 @@ cleanup:
|
|
2087
2389
|
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
|
2088
2390
|
{
|
2089
2391
|
refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
|
2090
|
-
|
2392
|
+
git_str path = GIT_STR_INIT;
|
2091
2393
|
int error;
|
2092
2394
|
|
2093
2395
|
GIT_ASSERT_ARG(_backend);
|
@@ -2096,7 +2398,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
|
|
2096
2398
|
if ((error = reflog_path(&path, backend->repo, name)) < 0)
|
2097
2399
|
goto out;
|
2098
2400
|
|
2099
|
-
if (!
|
2401
|
+
if (!git_fs_path_exists(path.ptr))
|
2100
2402
|
goto out;
|
2101
2403
|
|
2102
2404
|
if ((error = p_unlink(path.ptr)) < 0)
|
@@ -2105,7 +2407,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
|
|
2105
2407
|
error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
|
2106
2408
|
|
2107
2409
|
out:
|
2108
|
-
|
2410
|
+
git_str_dispose(&path);
|
2109
2411
|
|
2110
2412
|
return error;
|
2111
2413
|
}
|
@@ -2115,16 +2417,22 @@ int git_refdb_backend_fs(
|
|
2115
2417
|
git_repository *repository)
|
2116
2418
|
{
|
2117
2419
|
int t = 0;
|
2118
|
-
|
2420
|
+
git_str gitpath = GIT_STR_INIT;
|
2119
2421
|
refdb_fs_backend *backend;
|
2120
2422
|
|
2121
2423
|
backend = git__calloc(1, sizeof(refdb_fs_backend));
|
2122
2424
|
GIT_ERROR_CHECK_ALLOC(backend);
|
2425
|
+
if (git_mutex_init(&backend->prlock) < 0) {
|
2426
|
+
git__free(backend);
|
2427
|
+
return -1;
|
2428
|
+
}
|
2429
|
+
|
2123
2430
|
|
2124
2431
|
if (git_refdb_init_backend(&backend->parent, GIT_REFDB_BACKEND_VERSION) < 0)
|
2125
2432
|
goto fail;
|
2126
2433
|
|
2127
2434
|
backend->repo = repository;
|
2435
|
+
backend->oid_type = repository->oid_type;
|
2128
2436
|
|
2129
2437
|
if (repository->gitdir) {
|
2130
2438
|
backend->gitpath = setup_namespace(repository, repository->gitdir);
|
@@ -2140,21 +2448,21 @@ int git_refdb_backend_fs(
|
|
2140
2448
|
goto fail;
|
2141
2449
|
}
|
2142
2450
|
|
2143
|
-
if (
|
2451
|
+
if (git_str_joinpath(&gitpath, backend->commonpath, GIT_PACKEDREFS_FILE) < 0 ||
|
2144
2452
|
git_sortedcache_new(
|
2145
2453
|
&backend->refcache, offsetof(struct packref, name),
|
2146
|
-
NULL, NULL, packref_cmp,
|
2454
|
+
NULL, NULL, packref_cmp, git_str_cstr(&gitpath)) < 0)
|
2147
2455
|
goto fail;
|
2148
2456
|
|
2149
|
-
|
2457
|
+
git_str_dispose(&gitpath);
|
2150
2458
|
|
2151
2459
|
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_IGNORECASE) && t) {
|
2152
2460
|
backend->iterator_flags |= GIT_ITERATOR_IGNORE_CASE;
|
2153
|
-
backend->direach_flags |=
|
2461
|
+
backend->direach_flags |= GIT_FS_PATH_DIR_IGNORE_CASE;
|
2154
2462
|
}
|
2155
2463
|
if (!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_PRECOMPOSE) && t) {
|
2156
2464
|
backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
|
2157
|
-
backend->direach_flags |=
|
2465
|
+
backend->direach_flags |= GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE;
|
2158
2466
|
}
|
2159
2467
|
if ((!git_repository__configmap_lookup(&t, backend->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) ||
|
2160
2468
|
git_repository__fsync_gitdir)
|
@@ -2182,7 +2490,8 @@ int git_refdb_backend_fs(
|
|
2182
2490
|
return 0;
|
2183
2491
|
|
2184
2492
|
fail:
|
2185
|
-
|
2493
|
+
git_mutex_free(&backend->prlock);
|
2494
|
+
git_str_dispose(&gitpath);
|
2186
2495
|
git__free(backend->gitpath);
|
2187
2496
|
git__free(backend->commonpath);
|
2188
2497
|
git__free(backend);
|