rugged 1.3.1 → 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/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_allocator.c +0 -54
- 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/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +141 -289
- data/vendor/libgit2/COPYING +301 -20
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/AddClarTest.cmake +7 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -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 +17 -17
- data/vendor/libgit2/cmake/FindIntlIconv.cmake +51 -0
- data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
- 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 +34 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +129 -101
- data/vendor/libgit2/cmake/SelectHashes.cmake +113 -54
- data/vendor/libgit2/cmake/SelectRegex.cmake +56 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +46 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +38 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- 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 +33 -31
- 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 +7 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +25 -25
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- 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 +89 -88
- 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/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/deps/xdiff/git-xdiff.h +56 -0
- data/vendor/libgit2/{src → deps}/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/{src → deps}/xdiff/xdiffi.c +152 -125
- data/vendor/libgit2/{src → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src → deps}/xdiff/xemit.c +26 -10
- data/vendor/libgit2/{src → deps}/xdiff/xhistogram.c +92 -94
- data/vendor/libgit2/{src → deps}/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/{src → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src → deps}/xdiff/xmerge.c +126 -137
- data/vendor/libgit2/{src → deps}/xdiff/xpatience.c +26 -46
- data/vendor/libgit2/{src → deps}/xdiff/xprepare.c +24 -46
- data/vendor/libgit2/{src → deps}/xdiff/xutils.c +36 -8
- data/vendor/libgit2/{src → 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 +7 -22
- data/vendor/libgit2/deps/zlib/crc32.c +931 -317
- data/vendor/libgit2/deps/zlib/crc32.h +9441 -436
- data/vendor/libgit2/deps/zlib/deflate.c +428 -453
- data/vendor/libgit2/deps/zlib/deflate.h +51 -23
- data/vendor/libgit2/deps/zlib/gzguts.h +15 -19
- data/vendor/libgit2/deps/zlib/infback.c +19 -31
- data/vendor/libgit2/deps/zlib/inffast.c +15 -18
- data/vendor/libgit2/deps/zlib/inffast.h +1 -1
- data/vendor/libgit2/deps/zlib/inflate.c +75 -110
- data/vendor/libgit2/deps/zlib/inflate.h +3 -2
- 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 +294 -380
- data/vendor/libgit2/deps/zlib/zconf.h +23 -14
- data/vendor/libgit2/deps/zlib/zlib.h +310 -284
- data/vendor/libgit2/deps/zlib/zutil.c +20 -46
- data/vendor/libgit2/deps/zlib/zutil.h +24 -41
- data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
- data/vendor/libgit2/include/git2/apply.h +43 -8
- data/vendor/libgit2/include/git2/attr.h +28 -6
- data/vendor/libgit2/include/git2/blame.h +137 -29
- data/vendor/libgit2/include/git2/blob.h +85 -29
- data/vendor/libgit2/include/git2/branch.h +25 -16
- data/vendor/libgit2/include/git2/buffer.h +24 -82
- data/vendor/libgit2/include/git2/cert.h +4 -3
- data/vendor/libgit2/include/git2/checkout.h +88 -34
- data/vendor/libgit2/include/git2/cherrypick.h +10 -3
- data/vendor/libgit2/include/git2/clone.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +134 -3
- data/vendor/libgit2/include/git2/common.h +172 -59
- data/vendor/libgit2/include/git2/config.h +118 -32
- data/vendor/libgit2/include/git2/credential.h +32 -3
- data/vendor/libgit2/include/git2/credential_helpers.h +2 -0
- data/vendor/libgit2/include/git2/deprecated.h +141 -3
- data/vendor/libgit2/include/git2/describe.h +20 -3
- data/vendor/libgit2/include/git2/diff.h +95 -19
- data/vendor/libgit2/include/git2/email.h +10 -30
- data/vendor/libgit2/include/git2/errors.h +51 -61
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/filter.h +21 -9
- data/vendor/libgit2/include/git2/global.h +8 -1
- data/vendor/libgit2/include/git2/graph.h +4 -2
- data/vendor/libgit2/include/git2/ignore.h +11 -1
- data/vendor/libgit2/include/git2/index.h +111 -11
- data/vendor/libgit2/include/git2/indexer.h +67 -2
- data/vendor/libgit2/include/git2/mailmap.h +7 -1
- data/vendor/libgit2/include/git2/merge.h +70 -5
- data/vendor/libgit2/include/git2/message.h +4 -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 +57 -7
- data/vendor/libgit2/include/git2/odb.h +156 -33
- data/vendor/libgit2/include/git2/odb_backend.h +132 -16
- data/vendor/libgit2/include/git2/oid.h +116 -17
- data/vendor/libgit2/include/git2/oidarray.h +7 -1
- data/vendor/libgit2/include/git2/pack.h +37 -9
- data/vendor/libgit2/include/git2/patch.h +10 -3
- data/vendor/libgit2/include/git2/pathspec.h +10 -1
- data/vendor/libgit2/include/git2/proxy.h +11 -1
- data/vendor/libgit2/include/git2/rebase.h +18 -7
- data/vendor/libgit2/include/git2/refdb.h +5 -2
- data/vendor/libgit2/include/git2/reflog.h +4 -3
- data/vendor/libgit2/include/git2/refs.h +11 -8
- data/vendor/libgit2/include/git2/refspec.h +14 -4
- data/vendor/libgit2/include/git2/remote.h +295 -54
- data/vendor/libgit2/include/git2/repository.h +95 -25
- data/vendor/libgit2/include/git2/reset.h +18 -5
- data/vendor/libgit2/include/git2/revert.h +9 -4
- data/vendor/libgit2/include/git2/revparse.h +4 -4
- data/vendor/libgit2/include/git2/revwalk.h +7 -3
- data/vendor/libgit2/include/git2/signature.h +47 -2
- data/vendor/libgit2/include/git2/stash.h +78 -10
- data/vendor/libgit2/include/git2/status.h +24 -11
- data/vendor/libgit2/include/git2/stdint.h +87 -85
- data/vendor/libgit2/include/git2/strarray.h +2 -16
- data/vendor/libgit2/include/git2/submodule.h +27 -11
- 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 +110 -59
- 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 +10 -9
- 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 +53 -0
- data/vendor/libgit2/include/git2/sys/repository.h +63 -3
- data/vendor/libgit2/include/git2/sys/stream.h +26 -3
- data/vendor/libgit2/include/git2/sys/transport.h +87 -41
- data/vendor/libgit2/include/git2/tag.h +4 -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 +20 -8
- data/vendor/libgit2/include/git2/types.h +26 -10
- data/vendor/libgit2/include/git2/version.h +63 -6
- data/vendor/libgit2/include/git2/worktree.h +30 -8
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +203 -420
- data/vendor/libgit2/src/README.md +12 -0
- data/vendor/libgit2/src/cli/CMakeLists.txt +56 -0
- data/vendor/libgit2/src/cli/README.md +26 -0
- data/vendor/libgit2/src/{branch.h → cli/cmd.c} +10 -8
- data/vendor/libgit2/src/cli/cmd.h +37 -0
- data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
- data/vendor/libgit2/src/cli/cmd_cat_file.c +202 -0
- data/vendor/libgit2/src/cli/cmd_clone.c +190 -0
- data/vendor/libgit2/src/cli/cmd_config.c +241 -0
- data/vendor/libgit2/src/cli/cmd_hash_object.c +152 -0
- data/vendor/libgit2/src/cli/cmd_help.c +85 -0
- 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 +51 -0
- data/vendor/libgit2/src/cli/main.c +134 -0
- data/vendor/libgit2/src/cli/opt.c +695 -0
- data/vendor/libgit2/src/cli/opt.h +367 -0
- data/vendor/libgit2/src/cli/opt_usage.c +263 -0
- data/vendor/libgit2/src/cli/opt_usage.h +40 -0
- data/vendor/libgit2/src/cli/progress.c +395 -0
- data/vendor/libgit2/src/cli/progress.h +129 -0
- data/vendor/libgit2/src/cli/sighandler.h +20 -0
- data/vendor/libgit2/src/cli/unix/sighandler.c +37 -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 +140 -0
- data/vendor/libgit2/src/{annotated_commit.c → libgit2/annotated_commit.c} +2 -2
- data/vendor/libgit2/src/{annotated_commit.h → libgit2/annotated_commit.h} +2 -2
- data/vendor/libgit2/src/{apply.c → libgit2/apply.c} +32 -34
- data/vendor/libgit2/src/{apply.h → libgit2/apply.h} +2 -2
- data/vendor/libgit2/src/{attr.c → libgit2/attr.c} +48 -31
- data/vendor/libgit2/src/{attr_file.c → libgit2/attr_file.c} +25 -20
- data/vendor/libgit2/src/{attr_file.h → libgit2/attr_file.h} +6 -4
- data/vendor/libgit2/src/{attrcache.c → libgit2/attrcache.c} +87 -46
- data/vendor/libgit2/src/{attrcache.h → libgit2/attrcache.h} +5 -9
- data/vendor/libgit2/src/{blame.c → libgit2/blame.c} +152 -57
- data/vendor/libgit2/src/{blame.h → libgit2/blame.h} +1 -0
- data/vendor/libgit2/src/{blame_git.c → libgit2/blame_git.c} +1 -2
- 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/libgit2/branch.h +31 -0
- data/vendor/libgit2/src/libgit2/buf.c +126 -0
- data/vendor/libgit2/src/libgit2/buf.h +50 -0
- data/vendor/libgit2/src/{cache.c → libgit2/cache.c} +22 -17
- data/vendor/libgit2/src/{cache.h → libgit2/cache.h} +7 -9
- data/vendor/libgit2/src/{checkout.c → libgit2/checkout.c} +107 -91
- data/vendor/libgit2/src/{checkout.h → libgit2/checkout.h} +0 -2
- data/vendor/libgit2/src/{cherrypick.c → libgit2/cherrypick.c} +14 -15
- data/vendor/libgit2/src/{clone.c → libgit2/clone.c} +254 -203
- data/vendor/libgit2/src/{clone.h → libgit2/clone.h} +4 -1
- data/vendor/libgit2/src/{commit.c → libgit2/commit.c} +296 -77
- data/vendor/libgit2/src/libgit2/commit.h +87 -0
- data/vendor/libgit2/src/{commit_graph.c → libgit2/commit_graph.c} +246 -135
- data/vendor/libgit2/src/{commit_graph.h → libgit2/commit_graph.h} +33 -8
- data/vendor/libgit2/src/{commit_list.c → libgit2/commit_list.c} +17 -7
- data/vendor/libgit2/src/{commit_list.h → libgit2/commit_list.h} +1 -0
- data/vendor/libgit2/src/libgit2/common.h +55 -0
- data/vendor/libgit2/src/{config.c → libgit2/config.c} +490 -360
- data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
- data/vendor/libgit2/src/{config.h → libgit2/config.h} +24 -6
- data/vendor/libgit2/src/{config_backend.h → libgit2/config_backend.h} +8 -10
- data/vendor/libgit2/src/{config_cache.c → libgit2/config_cache.c} +4 -5
- data/vendor/libgit2/src/{config_file.c → libgit2/config_file.c} +212 -183
- 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 +374 -0
- data/vendor/libgit2/src/{config_parse.c → libgit2/config_parse.c} +37 -32
- data/vendor/libgit2/src/{config_snapshot.c → libgit2/config_snapshot.c} +24 -31
- data/vendor/libgit2/src/{crlf.c → libgit2/crlf.c} +24 -21
- data/vendor/libgit2/src/{describe.c → libgit2/describe.c} +62 -51
- data/vendor/libgit2/src/{diff.c → libgit2/diff.c} +44 -14
- data/vendor/libgit2/src/{diff.h → libgit2/diff.h} +8 -10
- data/vendor/libgit2/src/{diff_driver.c → libgit2/diff_driver.c} +46 -55
- data/vendor/libgit2/src/{diff_driver.h → libgit2/diff_driver.h} +5 -5
- data/vendor/libgit2/src/{diff_file.c → libgit2/diff_file.c} +45 -27
- data/vendor/libgit2/src/{diff_generate.c → libgit2/diff_generate.c} +70 -20
- data/vendor/libgit2/src/{diff_generate.h → libgit2/diff_generate.h} +5 -3
- data/vendor/libgit2/src/{diff_parse.c → libgit2/diff_parse.c} +22 -6
- data/vendor/libgit2/src/{diff_print.c → libgit2/diff_print.c} +192 -105
- 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} +49 -16
- data/vendor/libgit2/src/{diff_xdiff.c → libgit2/diff_xdiff.c} +4 -8
- data/vendor/libgit2/src/{diff_xdiff.h → libgit2/diff_xdiff.h} +1 -1
- data/vendor/libgit2/src/{email.c → libgit2/email.c} +58 -40
- data/vendor/libgit2/src/{email.h → libgit2/email.h} +1 -1
- data/vendor/libgit2/src/{transports/ssh.h → libgit2/experimental.h.in} +3 -4
- data/vendor/libgit2/src/{fetch.c → libgit2/fetch.c} +105 -30
- data/vendor/libgit2/src/{fetch.h → libgit2/fetch.h} +1 -3
- data/vendor/libgit2/src/{fetchhead.c → libgit2/fetchhead.c} +30 -28
- data/vendor/libgit2/src/{filter.c → libgit2/filter.c} +132 -58
- data/vendor/libgit2/src/{filter.h → libgit2/filter.h} +26 -5
- data/vendor/libgit2/src/{win32 → 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/{graph.c → libgit2/graph.c} +1 -1
- data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
- data/vendor/libgit2/src/{ident.c → libgit2/ident.c} +20 -20
- data/vendor/libgit2/src/{ignore.c → libgit2/ignore.c} +44 -39
- data/vendor/libgit2/src/{ignore.h → libgit2/ignore.h} +2 -2
- data/vendor/libgit2/src/{index.c → libgit2/index.c} +460 -276
- data/vendor/libgit2/src/{index.h → libgit2/index.h} +21 -5
- data/vendor/libgit2/src/libgit2/index_map.c +95 -0
- data/vendor/libgit2/src/libgit2/index_map.h +28 -0
- data/vendor/libgit2/src/{indexer.c → libgit2/indexer.c} +208 -124
- data/vendor/libgit2/src/{iterator.c → libgit2/iterator.c} +102 -71
- data/vendor/libgit2/src/{iterator.h → libgit2/iterator.h} +8 -5
- data/vendor/libgit2/src/libgit2/libgit2.c +268 -0
- data/vendor/libgit2/src/{mailmap.c → libgit2/mailmap.c} +39 -37
- data/vendor/libgit2/src/{merge.c → libgit2/merge.c} +83 -73
- data/vendor/libgit2/src/{merge.h → libgit2/merge.h} +1 -14
- data/vendor/libgit2/src/{merge_driver.c → libgit2/merge_driver.c} +4 -4
- data/vendor/libgit2/src/{merge_file.c → libgit2/merge_file.c} +13 -5
- data/vendor/libgit2/src/{message.c → libgit2/message.c} +21 -10
- data/vendor/libgit2/src/{midx.c → libgit2/midx.c} +174 -112
- data/vendor/libgit2/src/{midx.h → libgit2/midx.h} +17 -6
- data/vendor/libgit2/src/{mwindow.c → libgit2/mwindow.c} +53 -57
- data/vendor/libgit2/src/{mwindow.h → libgit2/mwindow.h} +9 -2
- data/vendor/libgit2/src/{notes.c → libgit2/notes.c} +29 -37
- data/vendor/libgit2/src/{object.c → libgit2/object.c} +166 -35
- data/vendor/libgit2/src/{object.h → libgit2/object.h} +17 -2
- data/vendor/libgit2/src/{odb.c → libgit2/odb.c} +261 -88
- 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} +67 -22
- data/vendor/libgit2/src/{odb_pack.c → libgit2/odb_pack.c} +162 -89
- data/vendor/libgit2/src/{oid.c → libgit2/oid.c} +171 -92
- data/vendor/libgit2/src/libgit2/oid.h +284 -0
- data/vendor/libgit2/src/libgit2/oidarray.c +89 -0
- data/vendor/libgit2/src/{oidarray.h → libgit2/oidarray.h} +5 -1
- data/vendor/libgit2/src/{pack-objects.c → libgit2/pack-objects.c} +126 -66
- data/vendor/libgit2/src/{pack-objects.h → libgit2/pack-objects.h} +28 -12
- data/vendor/libgit2/src/{pack.c → libgit2/pack.c} +146 -111
- data/vendor/libgit2/src/{pack.h → libgit2/pack.h} +45 -25
- data/vendor/libgit2/src/{parse.c → libgit2/parse.c} +8 -4
- data/vendor/libgit2/src/{parse.h → libgit2/parse.h} +1 -1
- data/vendor/libgit2/src/{patch.c → libgit2/patch.c} +3 -3
- data/vendor/libgit2/src/{patch.h → libgit2/patch.h} +8 -1
- data/vendor/libgit2/src/{patch_generate.c → libgit2/patch_generate.c} +51 -16
- data/vendor/libgit2/src/{patch_generate.h → libgit2/patch_generate.h} +5 -5
- data/vendor/libgit2/src/{patch_parse.c → libgit2/patch_parse.c} +42 -34
- 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} +7 -7
- 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} +116 -60
- data/vendor/libgit2/src/{push.h → libgit2/push.h} +5 -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} +147 -147
- data/vendor/libgit2/src/{refdb_fs.c → libgit2/refdb_fs.c} +639 -254
- data/vendor/libgit2/src/{reflog.c → libgit2/reflog.c} +8 -7
- data/vendor/libgit2/src/{reflog.h → libgit2/reflog.h} +3 -2
- data/vendor/libgit2/src/{refs.c → libgit2/refs.c} +67 -39
- data/vendor/libgit2/src/{refs.h → libgit2/refs.h} +8 -3
- data/vendor/libgit2/src/{refspec.c → libgit2/refspec.c} +60 -38
- data/vendor/libgit2/src/{refspec.h → libgit2/refspec.h} +13 -2
- data/vendor/libgit2/src/{remote.c → libgit2/remote.c} +821 -454
- data/vendor/libgit2/src/libgit2/remote.h +101 -0
- data/vendor/libgit2/src/{repository.c → libgit2/repository.c} +1377 -594
- data/vendor/libgit2/src/{repository.h → libgit2/repository.h} +43 -12
- data/vendor/libgit2/src/{reset.c → libgit2/reset.c} +8 -5
- data/vendor/libgit2/src/{revert.c → libgit2/revert.c} +18 -22
- data/vendor/libgit2/src/{revparse.c → libgit2/revparse.c} +76 -44
- data/vendor/libgit2/src/{revwalk.c → libgit2/revwalk.c} +48 -19
- data/vendor/libgit2/src/{revwalk.h → libgit2/revwalk.h} +3 -3
- data/vendor/libgit2/src/{libgit2.c → libgit2/settings.c} +162 -95
- data/vendor/libgit2/src/{settings.h → libgit2/settings.h} +6 -2
- data/vendor/libgit2/src/{signature.c → libgit2/signature.c} +144 -21
- data/vendor/libgit2/src/{signature.h → libgit2/signature.h} +1 -2
- data/vendor/libgit2/src/{stash.c → libgit2/stash.c} +243 -68
- data/vendor/libgit2/src/{status.c → libgit2/status.c} +5 -2
- 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 +62 -67
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.c +41 -24
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.h +2 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.c +11 -3
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.h +6 -3
- 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 +428 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/socket.h +3 -1
- data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.c +79 -19
- data/vendor/libgit2/src/{streams → libgit2/streams}/tls.c +5 -0
- data/vendor/libgit2/src/{submodule.c → libgit2/submodule.c} +279 -220
- data/vendor/libgit2/src/{submodule.h → libgit2/submodule.h} +10 -11
- data/vendor/libgit2/src/libgit2/sysdir.c +650 -0
- data/vendor/libgit2/src/{sysdir.h → libgit2/sysdir.h} +55 -18
- data/vendor/libgit2/src/{tag.c → libgit2/tag.c} +74 -43
- data/vendor/libgit2/src/{tag.h → libgit2/tag.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} +7 -7
- data/vendor/libgit2/src/{transaction.c → libgit2/transaction.c} +27 -21
- data/vendor/libgit2/src/{transaction.h → libgit2/transaction.h} +4 -1
- data/vendor/libgit2/src/{transport.c → libgit2/transport.c} +14 -11
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.c +7 -9
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.h +3 -5
- data/vendor/libgit2/src/{transports/auth_negotiate.c → libgit2/transports/auth_gssapi.c} +44 -45
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.h +1 -2
- data/vendor/libgit2/src/{transports/auth_ntlm.c → libgit2/transports/auth_ntlmclient.c} +22 -22
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/credential.c +1 -1
- data/vendor/libgit2/src/{transports → libgit2/transports}/git.c +16 -19
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.c +49 -24
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.h +0 -11
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.c +188 -134
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
- data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/local.c +159 -127
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.c +142 -165
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.h +56 -36
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_pkt.c +307 -74
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_protocol.c +297 -97
- data/vendor/libgit2/src/libgit2/transports/ssh.c +85 -0
- 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/{transports/ssh.c → libgit2/transports/ssh_libssh2.c} +414 -268
- data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/winhttp.c +101 -75
- data/vendor/libgit2/src/{tree-cache.c → libgit2/tree-cache.c} +30 -20
- data/vendor/libgit2/src/{tree-cache.h → libgit2/tree-cache.h} +7 -5
- data/vendor/libgit2/src/{tree.c → libgit2/tree.c} +128 -110
- data/vendor/libgit2/src/{tree.h → libgit2/tree.h} +7 -6
- data/vendor/libgit2/src/{worktree.c → libgit2/worktree.c} +160 -121
- data/vendor/libgit2/src/{worktree.h → libgit2/worktree.h} +1 -1
- data/vendor/libgit2/src/util/CMakeLists.txt +77 -0
- data/vendor/libgit2/src/{alloc.c → util/alloc.c} +69 -7
- data/vendor/libgit2/src/util/alloc.h +65 -0
- data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
- data/vendor/libgit2/src/util/allocators/debugalloc.h +17 -0
- data/vendor/libgit2/src/util/allocators/failalloc.c +32 -0
- data/vendor/libgit2/src/util/allocators/failalloc.h +17 -0
- data/vendor/libgit2/src/util/allocators/stdalloc.c +37 -0
- data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.h +1 -1
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +50 -0
- data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{array.h → util/array.h} +25 -19
- data/vendor/libgit2/src/{assert_safe.h → util/assert_safe.h} +16 -0
- data/vendor/libgit2/src/{cc-compat.h → util/cc-compat.h} +5 -1
- data/vendor/libgit2/src/util/ctype_compat.h +70 -0
- data/vendor/libgit2/src/{date.c → util/date.c} +35 -33
- data/vendor/libgit2/src/util/date.h +45 -0
- data/vendor/libgit2/src/util/errors.c +401 -0
- data/vendor/libgit2/src/{errors.h → util/errors.h} +22 -19
- data/vendor/libgit2/src/{filebuf.c → util/filebuf.c} +35 -30
- data/vendor/libgit2/src/{filebuf.h → util/filebuf.h} +21 -8
- data/vendor/libgit2/src/{path.c → util/fs_path.c} +591 -615
- data/vendor/libgit2/src/{path.h → util/fs_path.h} +257 -181
- data/vendor/libgit2/src/{futils.c → util/futils.c} +144 -95
- data/vendor/libgit2/src/{futils.h → util/futils.h} +40 -18
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +33 -2
- data/vendor/libgit2/src/{common.h → util/git2_util.h} +26 -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 +347 -0
- data/vendor/libgit2/src/util/hash/openssl.h +61 -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 +73 -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/util/hashmap.h +424 -0
- data/vendor/libgit2/src/util/hashmap_str.h +43 -0
- data/vendor/libgit2/src/{integer.h → util/integer.h} +3 -1
- data/vendor/libgit2/src/{map.h → util/map.h} +1 -1
- data/vendor/libgit2/src/util/net.c +1160 -0
- data/vendor/libgit2/src/{net.h → util/net.h} +45 -4
- data/vendor/libgit2/src/{pool.c → util/pool.c} +1 -1
- data/vendor/libgit2/src/{pool.h → util/pool.h} +6 -1
- data/vendor/libgit2/src/{posix.c → util/posix.c} +57 -3
- data/vendor/libgit2/src/{posix.h → util/posix.h} +26 -1
- data/vendor/libgit2/src/{pqueue.h → util/pqueue.h} +3 -3
- data/vendor/libgit2/src/util/process.h +222 -0
- data/vendor/libgit2/src/util/rand.c +230 -0
- data/vendor/libgit2/src/util/rand.h +37 -0
- data/vendor/libgit2/src/{regexp.c → util/regexp.c} +5 -5
- 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} +15 -14
- data/vendor/libgit2/src/{sortedcache.h → util/sortedcache.h} +5 -5
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/{buffer.c → util/str.c} +159 -153
- data/vendor/libgit2/src/util/str.h +357 -0
- data/vendor/libgit2/src/util/strlist.c +108 -0
- data/vendor/libgit2/src/util/strlist.h +36 -0
- 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 -6
- data/vendor/libgit2/src/util/unix/process.c +629 -0
- data/vendor/libgit2/src/{unix → util/unix}/realpath.c +24 -8
- 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} +24 -19
- data/vendor/libgit2/src/{util.h → util/util.h} +30 -81
- data/vendor/libgit2/src/{varint.h → util/varint.h} +1 -1
- data/vendor/libgit2/src/{vector.c → util/vector.c} +3 -3
- data/vendor/libgit2/src/{vector.h → util/vector.h} +4 -4
- 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.c +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 +148 -17
- 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 +42 -35
- 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/util/win32/process.c +506 -0
- data/vendor/libgit2/src/{win32 → util/win32}/thread.h +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +144 -0
- data/vendor/libgit2/src/util/win32/utf-conv.h +127 -0
- 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.c +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 +431 -362
- data/vendor/libgit2/cmake/FindIconv.cmake +0 -45
- 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/alloc.h +0 -40
- data/vendor/libgit2/src/allocators/failalloc.c +0 -92
- data/vendor/libgit2/src/allocators/failalloc.h +0 -23
- data/vendor/libgit2/src/allocators/stdalloc.c +0 -150
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +0 -118
- data/vendor/libgit2/src/buffer.h +0 -374
- data/vendor/libgit2/src/commit.h +0 -46
- data/vendor/libgit2/src/config_entries.c +0 -237
- data/vendor/libgit2/src/config_entries.h +0 -24
- data/vendor/libgit2/src/config_mem.c +0 -220
- data/vendor/libgit2/src/errors.c +0 -238
- 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/idxmap.c +0 -157
- data/vendor/libgit2/src/idxmap.h +0 -177
- data/vendor/libgit2/src/khash.h +0 -615
- data/vendor/libgit2/src/libgit2.h +0 -15
- data/vendor/libgit2/src/message.h +0 -17
- data/vendor/libgit2/src/net.c +0 -540
- data/vendor/libgit2/src/netops.c +0 -125
- data/vendor/libgit2/src/netops.h +0 -68
- data/vendor/libgit2/src/offmap.c +0 -101
- data/vendor/libgit2/src/offmap.h +0 -133
- data/vendor/libgit2/src/oid.h +0 -51
- data/vendor/libgit2/src/oidarray.c +0 -43
- data/vendor/libgit2/src/oidmap.c +0 -107
- data/vendor/libgit2/src/oidmap.h +0 -128
- data/vendor/libgit2/src/remote.h +0 -55
- data/vendor/libgit2/src/streams/socket.c +0 -239
- data/vendor/libgit2/src/strmap.c +0 -100
- data/vendor/libgit2/src/strmap.h +0 -131
- data/vendor/libgit2/src/sysdir.c +0 -347
- data/vendor/libgit2/src/threadstate.c +0 -84
- data/vendor/libgit2/src/threadstate.h +0 -24
- data/vendor/libgit2/src/win32/findfile.c +0 -230
- data/vendor/libgit2/src/win32/findfile.h +0 -19
- data/vendor/libgit2/src/win32/utf-conv.c +0 -146
- data/vendor/libgit2/src/win32/utf-conv.h +0 -60
- /data/vendor/libgit2/{src → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src → deps}/xdiff/xtypes.h +0 -0
- /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/{blame_git.h → libgit2/blame_git.h} +0 -0
- /data/vendor/libgit2/src/{config_parse.h → libgit2/config_parse.h} +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.h → libgit2/diff_parse.h} +0 -0
- /data/vendor/libgit2/src/{diff_tform.h → libgit2/diff_tform.h} +0 -0
- /data/vendor/libgit2/src/{fetchhead.h → libgit2/fetchhead.h} +0 -0
- /data/vendor/libgit2/src/{hashsig.c → libgit2/hashsig.c} +0 -0
- /data/vendor/libgit2/src/{indexer.h → libgit2/indexer.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/{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/{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_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}/stransport.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.h +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/credential_helpers.c +0 -0
- /data/vendor/libgit2/src/{userdiff.h → libgit2/userdiff.h} +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/{pqueue.c → util/pqueue.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/{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}/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}/version.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/w32_common.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/win32-compat.h +0 -0
@@ -5,10 +5,11 @@
|
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
6
6
|
*/
|
7
7
|
|
8
|
-
#include "
|
8
|
+
#include "fs_path.h"
|
9
9
|
|
10
|
+
#include "git2_util.h"
|
11
|
+
#include "futils.h"
|
10
12
|
#include "posix.h"
|
11
|
-
#include "repository.h"
|
12
13
|
#ifdef GIT_WIN32
|
13
14
|
#include "win32/posix.h"
|
14
15
|
#include "win32/w32_buffer.h"
|
@@ -21,6 +22,13 @@
|
|
21
22
|
#include <stdio.h>
|
22
23
|
#include <ctype.h>
|
23
24
|
|
25
|
+
#define ensure_error_set(code) do { \
|
26
|
+
const git_error *e = git_error_last(); \
|
27
|
+
if (!e || !e->message) \
|
28
|
+
git_error_set(e ? e->klass : GIT_ERROR_CALLBACK, \
|
29
|
+
"filesystem callback returned %d", code); \
|
30
|
+
} while(0)
|
31
|
+
|
24
32
|
static int dos_drive_prefix_length(const char *path)
|
25
33
|
{
|
26
34
|
int i;
|
@@ -93,7 +101,7 @@ static bool looks_like_network_computer_name(const char *path, int pos)
|
|
93
101
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
94
102
|
* SUCH DAMAGE.
|
95
103
|
*/
|
96
|
-
int
|
104
|
+
int git_fs_path_basename_r(git_str *buffer, const char *path)
|
97
105
|
{
|
98
106
|
const char *endp, *startp;
|
99
107
|
int len, result;
|
@@ -101,7 +109,7 @@ int git_path_basename_r(git_buf *buffer, const char *path)
|
|
101
109
|
/* Empty or NULL string gets treated as "." */
|
102
110
|
if (path == NULL || *path == '\0') {
|
103
111
|
startp = ".";
|
104
|
-
len
|
112
|
+
len = 1;
|
105
113
|
goto Exit;
|
106
114
|
}
|
107
115
|
|
@@ -113,7 +121,7 @@ int git_path_basename_r(git_buf *buffer, const char *path)
|
|
113
121
|
/* All slashes becomes "/" */
|
114
122
|
if (endp == path && *endp == '/') {
|
115
123
|
startp = "/";
|
116
|
-
len
|
124
|
+
len = 1;
|
117
125
|
goto Exit;
|
118
126
|
}
|
119
127
|
|
@@ -128,7 +136,7 @@ int git_path_basename_r(git_buf *buffer, const char *path)
|
|
128
136
|
Exit:
|
129
137
|
result = len;
|
130
138
|
|
131
|
-
if (buffer != NULL &&
|
139
|
+
if (buffer != NULL && git_str_set(buffer, startp, len) < 0)
|
132
140
|
return -1;
|
133
141
|
|
134
142
|
return result;
|
@@ -136,7 +144,7 @@ Exit:
|
|
136
144
|
|
137
145
|
/*
|
138
146
|
* Determine if the path is a Windows prefix and, if so, returns
|
139
|
-
* its actual
|
147
|
+
* its actual length. If it is not a prefix, returns -1.
|
140
148
|
*/
|
141
149
|
static int win32_prefix_length(const char *path, int len)
|
142
150
|
{
|
@@ -166,7 +174,7 @@ static int win32_prefix_length(const char *path, int len)
|
|
166
174
|
* Based on the Android implementation, BSD licensed.
|
167
175
|
* Check http://android.git.kernel.org/
|
168
176
|
*/
|
169
|
-
int
|
177
|
+
int git_fs_path_dirname_r(git_str *buffer, const char *path)
|
170
178
|
{
|
171
179
|
const char *endp;
|
172
180
|
int is_prefix = 0, len;
|
@@ -185,8 +193,7 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
|
|
185
193
|
|
186
194
|
if (endp - path + 1 > INT_MAX) {
|
187
195
|
git_error_set(GIT_ERROR_INVALID, "path too long");
|
188
|
-
|
189
|
-
goto Exit;
|
196
|
+
return -1;
|
190
197
|
}
|
191
198
|
|
192
199
|
if ((len = win32_prefix_length(path, (int)(endp - path + 1))) > 0) {
|
@@ -211,8 +218,7 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
|
|
211
218
|
|
212
219
|
if (endp - path + 1 > INT_MAX) {
|
213
220
|
git_error_set(GIT_ERROR_INVALID, "path too long");
|
214
|
-
|
215
|
-
goto Exit;
|
221
|
+
return -1;
|
216
222
|
}
|
217
223
|
|
218
224
|
if ((len = win32_prefix_length(path, (int)(endp - path + 1))) > 0) {
|
@@ -225,9 +231,9 @@ int git_path_dirname_r(git_buf *buffer, const char *path)
|
|
225
231
|
|
226
232
|
Exit:
|
227
233
|
if (buffer) {
|
228
|
-
if (
|
234
|
+
if (git_str_set(buffer, path, len) < 0)
|
229
235
|
return -1;
|
230
|
-
if (is_prefix &&
|
236
|
+
if (is_prefix && git_str_putc(buffer, '/') < 0)
|
231
237
|
return -1;
|
232
238
|
}
|
233
239
|
|
@@ -235,38 +241,38 @@ Exit:
|
|
235
241
|
}
|
236
242
|
|
237
243
|
|
238
|
-
char *
|
244
|
+
char *git_fs_path_dirname(const char *path)
|
239
245
|
{
|
240
|
-
|
246
|
+
git_str buf = GIT_STR_INIT;
|
241
247
|
char *dirname;
|
242
248
|
|
243
|
-
|
244
|
-
dirname =
|
245
|
-
|
249
|
+
git_fs_path_dirname_r(&buf, path);
|
250
|
+
dirname = git_str_detach(&buf);
|
251
|
+
git_str_dispose(&buf); /* avoid memleak if error occurs */
|
246
252
|
|
247
253
|
return dirname;
|
248
254
|
}
|
249
255
|
|
250
|
-
char *
|
256
|
+
char *git_fs_path_basename(const char *path)
|
251
257
|
{
|
252
|
-
|
258
|
+
git_str buf = GIT_STR_INIT;
|
253
259
|
char *basename;
|
254
260
|
|
255
|
-
|
256
|
-
basename =
|
257
|
-
|
261
|
+
git_fs_path_basename_r(&buf, path);
|
262
|
+
basename = git_str_detach(&buf);
|
263
|
+
git_str_dispose(&buf); /* avoid memleak if error occurs */
|
258
264
|
|
259
265
|
return basename;
|
260
266
|
}
|
261
267
|
|
262
|
-
size_t
|
268
|
+
size_t git_fs_path_basename_offset(git_str *buffer)
|
263
269
|
{
|
264
270
|
ssize_t slash;
|
265
271
|
|
266
272
|
if (!buffer || buffer->size <= 0)
|
267
273
|
return 0;
|
268
274
|
|
269
|
-
slash =
|
275
|
+
slash = git_str_rfind_next(buffer, '/');
|
270
276
|
|
271
277
|
if (slash >= 0 && buffer->ptr[slash] == '/')
|
272
278
|
return (size_t)(slash + 1);
|
@@ -274,7 +280,7 @@ size_t git_path_basename_offset(git_buf *buffer)
|
|
274
280
|
return 0;
|
275
281
|
}
|
276
282
|
|
277
|
-
int
|
283
|
+
int git_fs_path_root(const char *path)
|
278
284
|
{
|
279
285
|
int offset = 0, prefix_len;
|
280
286
|
|
@@ -304,9 +310,9 @@ int git_path_root(const char *path)
|
|
304
310
|
return -1; /* Not a real error - signals that path is not rooted */
|
305
311
|
}
|
306
312
|
|
307
|
-
static void path_trim_slashes(
|
313
|
+
static void path_trim_slashes(git_str *path)
|
308
314
|
{
|
309
|
-
int ceiling =
|
315
|
+
int ceiling = git_fs_path_root(path->ptr) + 1;
|
310
316
|
|
311
317
|
if (ceiling < 0)
|
312
318
|
return;
|
@@ -320,29 +326,29 @@ static void path_trim_slashes(git_buf *path)
|
|
320
326
|
}
|
321
327
|
}
|
322
328
|
|
323
|
-
int
|
324
|
-
|
329
|
+
int git_fs_path_join_unrooted(
|
330
|
+
git_str *path_out, const char *path, const char *base, ssize_t *root_at)
|
325
331
|
{
|
326
332
|
ssize_t root;
|
327
333
|
|
328
334
|
GIT_ASSERT_ARG(path_out);
|
329
335
|
GIT_ASSERT_ARG(path);
|
330
336
|
|
331
|
-
root = (ssize_t)
|
337
|
+
root = (ssize_t)git_fs_path_root(path);
|
332
338
|
|
333
339
|
if (base != NULL && root < 0) {
|
334
|
-
if (
|
340
|
+
if (git_str_joinpath(path_out, base, path) < 0)
|
335
341
|
return -1;
|
336
342
|
|
337
343
|
root = (ssize_t)strlen(base);
|
338
344
|
} else {
|
339
|
-
if (
|
345
|
+
if (git_str_sets(path_out, path) < 0)
|
340
346
|
return -1;
|
341
347
|
|
342
348
|
if (root < 0)
|
343
349
|
root = 0;
|
344
350
|
else if (base)
|
345
|
-
|
351
|
+
git_fs_path_equal_or_prefixed(base, path, &root);
|
346
352
|
}
|
347
353
|
|
348
354
|
if (root_at)
|
@@ -351,7 +357,7 @@ int git_path_join_unrooted(
|
|
351
357
|
return 0;
|
352
358
|
}
|
353
359
|
|
354
|
-
void
|
360
|
+
void git_fs_path_squash_slashes(git_str *path)
|
355
361
|
{
|
356
362
|
char *p, *q;
|
357
363
|
|
@@ -370,7 +376,7 @@ void git_path_squash_slashes(git_buf *path)
|
|
370
376
|
*p = '\0';
|
371
377
|
}
|
372
378
|
|
373
|
-
int
|
379
|
+
int git_fs_path_prettify(git_str *path_out, const char *path, const char *base)
|
374
380
|
{
|
375
381
|
char buf[GIT_PATH_MAX];
|
376
382
|
|
@@ -378,8 +384,8 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
|
|
378
384
|
GIT_ASSERT_ARG(path);
|
379
385
|
|
380
386
|
/* construct path if needed */
|
381
|
-
if (base != NULL &&
|
382
|
-
if (
|
387
|
+
if (base != NULL && git_fs_path_root(path) < 0) {
|
388
|
+
if (git_str_joinpath(path_out, base, path) < 0)
|
383
389
|
return -1;
|
384
390
|
path = path_out->ptr;
|
385
391
|
}
|
@@ -389,31 +395,41 @@ int git_path_prettify(git_buf *path_out, const char *path, const char *base)
|
|
389
395
|
int error = (errno == ENOENT || errno == ENOTDIR) ? GIT_ENOTFOUND : -1;
|
390
396
|
git_error_set(GIT_ERROR_OS, "failed to resolve path '%s'", path);
|
391
397
|
|
392
|
-
|
398
|
+
git_str_clear(path_out);
|
393
399
|
|
394
400
|
return error;
|
395
401
|
}
|
396
402
|
|
397
|
-
return
|
403
|
+
return git_str_sets(path_out, buf);
|
398
404
|
}
|
399
405
|
|
400
|
-
int
|
406
|
+
int git_fs_path_prettify_dir(git_str *path_out, const char *path, const char *base)
|
401
407
|
{
|
402
|
-
int error =
|
403
|
-
return (error < 0) ? error :
|
408
|
+
int error = git_fs_path_prettify(path_out, path, base);
|
409
|
+
return (error < 0) ? error : git_fs_path_to_dir(path_out);
|
404
410
|
}
|
405
411
|
|
406
|
-
int
|
412
|
+
int git_fs_path_to_dir(git_str *path)
|
407
413
|
{
|
408
414
|
if (path->asize > 0 &&
|
409
|
-
|
410
|
-
path->ptr[
|
411
|
-
|
415
|
+
git_str_len(path) > 0 &&
|
416
|
+
path->ptr[git_str_len(path) - 1] != '/')
|
417
|
+
git_str_putc(path, '/');
|
418
|
+
|
419
|
+
return git_str_oom(path) ? -1 : 0;
|
420
|
+
}
|
421
|
+
|
422
|
+
size_t git_fs_path_dirlen(const char *path)
|
423
|
+
{
|
424
|
+
size_t len = strlen(path);
|
425
|
+
|
426
|
+
while (len > 1 && path[len - 1] == '/')
|
427
|
+
len--;
|
412
428
|
|
413
|
-
return
|
429
|
+
return len;
|
414
430
|
}
|
415
431
|
|
416
|
-
void
|
432
|
+
void git_fs_path_string_to_dir(char *path, size_t size)
|
417
433
|
{
|
418
434
|
size_t end = strlen(path);
|
419
435
|
|
@@ -423,7 +439,7 @@ void git_path_string_to_dir(char *path, size_t size)
|
|
423
439
|
}
|
424
440
|
}
|
425
441
|
|
426
|
-
int git__percent_decode(
|
442
|
+
int git__percent_decode(git_str *decoded_out, const char *input)
|
427
443
|
{
|
428
444
|
int len, hi, lo, i;
|
429
445
|
|
@@ -431,7 +447,7 @@ int git__percent_decode(git_buf *decoded_out, const char *input)
|
|
431
447
|
GIT_ASSERT_ARG(input);
|
432
448
|
|
433
449
|
len = (int)strlen(input);
|
434
|
-
|
450
|
+
git_str_clear(decoded_out);
|
435
451
|
|
436
452
|
for(i = 0; i < len; i++)
|
437
453
|
{
|
@@ -453,7 +469,7 @@ int git__percent_decode(git_buf *decoded_out, const char *input)
|
|
453
469
|
i += 2;
|
454
470
|
|
455
471
|
append:
|
456
|
-
if (
|
472
|
+
if (git_str_putc(decoded_out, c) < 0)
|
457
473
|
return -1;
|
458
474
|
}
|
459
475
|
|
@@ -480,12 +496,12 @@ static int local_file_url_prefixlen(const char *file_url)
|
|
480
496
|
return len;
|
481
497
|
}
|
482
498
|
|
483
|
-
bool
|
499
|
+
bool git_fs_path_is_local_file_url(const char *file_url)
|
484
500
|
{
|
485
501
|
return (local_file_url_prefixlen(file_url) > 0);
|
486
502
|
}
|
487
503
|
|
488
|
-
int
|
504
|
+
int git_fs_path_fromurl(git_str *local_path_out, const char *file_url)
|
489
505
|
{
|
490
506
|
int offset;
|
491
507
|
|
@@ -500,18 +516,18 @@ int git_path_fromurl(git_buf *local_path_out, const char *file_url)
|
|
500
516
|
offset--; /* A *nix absolute path starts with a forward slash */
|
501
517
|
#endif
|
502
518
|
|
503
|
-
|
519
|
+
git_str_clear(local_path_out);
|
504
520
|
return git__percent_decode(local_path_out, file_url + offset);
|
505
521
|
}
|
506
522
|
|
507
|
-
int
|
508
|
-
|
523
|
+
int git_fs_path_walk_up(
|
524
|
+
git_str *path,
|
509
525
|
const char *ceiling,
|
510
526
|
int (*cb)(void *data, const char *),
|
511
527
|
void *data)
|
512
528
|
{
|
513
529
|
int error = 0;
|
514
|
-
|
530
|
+
git_str iter;
|
515
531
|
ssize_t stop = 0, scan;
|
516
532
|
char oldc = '\0';
|
517
533
|
|
@@ -522,20 +538,20 @@ int git_path_walk_up(
|
|
522
538
|
if (git__prefixcmp(path->ptr, ceiling) == 0)
|
523
539
|
stop = (ssize_t)strlen(ceiling);
|
524
540
|
else
|
525
|
-
stop =
|
541
|
+
stop = git_str_len(path);
|
526
542
|
}
|
527
|
-
scan =
|
543
|
+
scan = git_str_len(path);
|
528
544
|
|
529
545
|
/* empty path: yield only once */
|
530
546
|
if (!scan) {
|
531
547
|
error = cb(data, "");
|
532
548
|
if (error)
|
533
|
-
|
549
|
+
ensure_error_set(error);
|
534
550
|
return error;
|
535
551
|
}
|
536
552
|
|
537
553
|
iter.ptr = path->ptr;
|
538
|
-
iter.size =
|
554
|
+
iter.size = git_str_len(path);
|
539
555
|
iter.asize = path->asize;
|
540
556
|
|
541
557
|
while (scan >= stop) {
|
@@ -543,11 +559,11 @@ int git_path_walk_up(
|
|
543
559
|
iter.ptr[scan] = oldc;
|
544
560
|
|
545
561
|
if (error) {
|
546
|
-
|
562
|
+
ensure_error_set(error);
|
547
563
|
break;
|
548
564
|
}
|
549
565
|
|
550
|
-
scan =
|
566
|
+
scan = git_str_rfind_next(&iter, '/');
|
551
567
|
if (scan >= 0) {
|
552
568
|
scan++;
|
553
569
|
oldc = iter.ptr[scan];
|
@@ -563,19 +579,19 @@ int git_path_walk_up(
|
|
563
579
|
if (!error && stop == 0 && iter.ptr[0] != '/') {
|
564
580
|
error = cb(data, "");
|
565
581
|
if (error)
|
566
|
-
|
582
|
+
ensure_error_set(error);
|
567
583
|
}
|
568
584
|
|
569
585
|
return error;
|
570
586
|
}
|
571
587
|
|
572
|
-
bool
|
588
|
+
bool git_fs_path_exists(const char *path)
|
573
589
|
{
|
574
590
|
GIT_ASSERT_ARG_WITH_RETVAL(path, false);
|
575
591
|
return p_access(path, F_OK) == 0;
|
576
592
|
}
|
577
593
|
|
578
|
-
bool
|
594
|
+
bool git_fs_path_isdir(const char *path)
|
579
595
|
{
|
580
596
|
struct stat st;
|
581
597
|
if (p_stat(path, &st) < 0)
|
@@ -584,7 +600,7 @@ bool git_path_isdir(const char *path)
|
|
584
600
|
return S_ISDIR(st.st_mode) != 0;
|
585
601
|
}
|
586
602
|
|
587
|
-
bool
|
603
|
+
bool git_fs_path_isfile(const char *path)
|
588
604
|
{
|
589
605
|
struct stat st;
|
590
606
|
|
@@ -595,7 +611,7 @@ bool git_path_isfile(const char *path)
|
|
595
611
|
return S_ISREG(st.st_mode) != 0;
|
596
612
|
}
|
597
613
|
|
598
|
-
bool
|
614
|
+
bool git_fs_path_islink(const char *path)
|
599
615
|
{
|
600
616
|
struct stat st;
|
601
617
|
|
@@ -608,7 +624,7 @@ bool git_path_islink(const char *path)
|
|
608
624
|
|
609
625
|
#ifdef GIT_WIN32
|
610
626
|
|
611
|
-
bool
|
627
|
+
bool git_fs_path_is_empty_dir(const char *path)
|
612
628
|
{
|
613
629
|
git_win32_path filter_w;
|
614
630
|
bool empty = false;
|
@@ -627,7 +643,7 @@ bool git_path_is_empty_dir(const char *path)
|
|
627
643
|
* (a mount point).
|
628
644
|
*/
|
629
645
|
if (hFind == INVALID_HANDLE_VALUE)
|
630
|
-
return
|
646
|
+
return git_fs_path_isdir(path);
|
631
647
|
|
632
648
|
/* If the find handle was created successfully, then it's a directory */
|
633
649
|
empty = true;
|
@@ -637,7 +653,7 @@ bool git_path_is_empty_dir(const char *path)
|
|
637
653
|
* empty. In the special case of drive roots (i.e. C:\) where . and
|
638
654
|
* .. do not occur, we can still consider the path to be an empty
|
639
655
|
* directory if there's nothing there. */
|
640
|
-
if (!
|
656
|
+
if (!git_fs_path_is_dot_or_dotdotW(findData.cFileName)) {
|
641
657
|
empty = false;
|
642
658
|
break;
|
643
659
|
}
|
@@ -651,33 +667,33 @@ bool git_path_is_empty_dir(const char *path)
|
|
651
667
|
|
652
668
|
#else
|
653
669
|
|
654
|
-
static int path_found_entry(void *payload,
|
670
|
+
static int path_found_entry(void *payload, git_str *path)
|
655
671
|
{
|
656
672
|
GIT_UNUSED(payload);
|
657
|
-
return !
|
673
|
+
return !git_fs_path_is_dot_or_dotdot(path->ptr);
|
658
674
|
}
|
659
675
|
|
660
|
-
bool
|
676
|
+
bool git_fs_path_is_empty_dir(const char *path)
|
661
677
|
{
|
662
678
|
int error;
|
663
|
-
|
679
|
+
git_str dir = GIT_STR_INIT;
|
664
680
|
|
665
|
-
if (!
|
681
|
+
if (!git_fs_path_isdir(path))
|
666
682
|
return false;
|
667
683
|
|
668
|
-
if ((error =
|
684
|
+
if ((error = git_str_sets(&dir, path)) != 0)
|
669
685
|
git_error_clear();
|
670
686
|
else
|
671
|
-
error =
|
687
|
+
error = git_fs_path_direach(&dir, 0, path_found_entry, NULL);
|
672
688
|
|
673
|
-
|
689
|
+
git_str_dispose(&dir);
|
674
690
|
|
675
691
|
return !error;
|
676
692
|
}
|
677
693
|
|
678
694
|
#endif
|
679
695
|
|
680
|
-
int
|
696
|
+
int git_fs_path_set_error(int errno_value, const char *path, const char *action)
|
681
697
|
{
|
682
698
|
switch (errno_value) {
|
683
699
|
case ENOENT:
|
@@ -704,87 +720,87 @@ int git_path_set_error(int errno_value, const char *path, const char *action)
|
|
704
720
|
}
|
705
721
|
}
|
706
722
|
|
707
|
-
int
|
723
|
+
int git_fs_path_lstat(const char *path, struct stat *st)
|
708
724
|
{
|
709
725
|
if (p_lstat(path, st) == 0)
|
710
726
|
return 0;
|
711
727
|
|
712
|
-
return
|
728
|
+
return git_fs_path_set_error(errno, path, "stat");
|
713
729
|
}
|
714
730
|
|
715
731
|
static bool _check_dir_contents(
|
716
|
-
|
732
|
+
git_str *dir,
|
717
733
|
const char *sub,
|
718
734
|
bool (*predicate)(const char *))
|
719
735
|
{
|
720
736
|
bool result;
|
721
|
-
size_t dir_size =
|
737
|
+
size_t dir_size = git_str_len(dir);
|
722
738
|
size_t sub_size = strlen(sub);
|
723
739
|
size_t alloc_size;
|
724
740
|
|
725
741
|
/* leave base valid even if we could not make space for subdir */
|
726
742
|
if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, dir_size, sub_size) ||
|
727
743
|
GIT_ADD_SIZET_OVERFLOW(&alloc_size, alloc_size, 2) ||
|
728
|
-
|
744
|
+
git_str_try_grow(dir, alloc_size, false) < 0)
|
729
745
|
return false;
|
730
746
|
|
731
747
|
/* save excursion */
|
732
|
-
if (
|
748
|
+
if (git_str_joinpath(dir, dir->ptr, sub) < 0)
|
733
749
|
return false;
|
734
750
|
|
735
751
|
result = predicate(dir->ptr);
|
736
752
|
|
737
753
|
/* restore path */
|
738
|
-
|
754
|
+
git_str_truncate(dir, dir_size);
|
739
755
|
return result;
|
740
756
|
}
|
741
757
|
|
742
|
-
bool
|
758
|
+
bool git_fs_path_contains(git_str *dir, const char *item)
|
743
759
|
{
|
744
|
-
return _check_dir_contents(dir, item, &
|
760
|
+
return _check_dir_contents(dir, item, &git_fs_path_exists);
|
745
761
|
}
|
746
762
|
|
747
|
-
bool
|
763
|
+
bool git_fs_path_contains_dir(git_str *base, const char *subdir)
|
748
764
|
{
|
749
|
-
return _check_dir_contents(base, subdir, &
|
765
|
+
return _check_dir_contents(base, subdir, &git_fs_path_isdir);
|
750
766
|
}
|
751
767
|
|
752
|
-
bool
|
768
|
+
bool git_fs_path_contains_file(git_str *base, const char *file)
|
753
769
|
{
|
754
|
-
return _check_dir_contents(base, file, &
|
770
|
+
return _check_dir_contents(base, file, &git_fs_path_isfile);
|
755
771
|
}
|
756
772
|
|
757
|
-
int
|
773
|
+
int git_fs_path_find_dir(git_str *dir)
|
758
774
|
{
|
759
775
|
int error = 0;
|
760
776
|
char buf[GIT_PATH_MAX];
|
761
777
|
|
762
778
|
if (p_realpath(dir->ptr, buf) != NULL)
|
763
|
-
error =
|
779
|
+
error = git_str_sets(dir, buf);
|
764
780
|
|
765
781
|
/* call dirname if this is not a directory */
|
766
|
-
if (!error) /* &&
|
767
|
-
error = (
|
782
|
+
if (!error) /* && git_fs_path_isdir(dir->ptr) == false) */
|
783
|
+
error = (git_fs_path_dirname_r(dir, dir->ptr) < 0) ? -1 : 0;
|
768
784
|
|
769
785
|
if (!error)
|
770
|
-
error =
|
786
|
+
error = git_fs_path_to_dir(dir);
|
771
787
|
|
772
788
|
return error;
|
773
789
|
}
|
774
790
|
|
775
|
-
int
|
791
|
+
int git_fs_path_resolve_relative(git_str *path, size_t ceiling)
|
776
792
|
{
|
777
793
|
char *base, *to, *from, *next;
|
778
794
|
size_t len;
|
779
795
|
|
780
|
-
|
796
|
+
GIT_ERROR_CHECK_ALLOC_STR(path);
|
781
797
|
|
782
798
|
if (ceiling > path->size)
|
783
799
|
ceiling = path->size;
|
784
800
|
|
785
801
|
/* recognize drive prefixes, etc. that should not be backed over */
|
786
802
|
if (ceiling == 0)
|
787
|
-
ceiling =
|
803
|
+
ceiling = git_fs_path_root(path->ptr) + 1;
|
788
804
|
|
789
805
|
/* recognize URL prefixes that should not be backed over */
|
790
806
|
if (ceiling == 0) {
|
@@ -851,13 +867,13 @@ int git_path_resolve_relative(git_buf *path, size_t ceiling)
|
|
851
867
|
return 0;
|
852
868
|
}
|
853
869
|
|
854
|
-
int
|
870
|
+
int git_fs_path_apply_relative(git_str *target, const char *relpath)
|
855
871
|
{
|
856
|
-
return
|
857
|
-
|
872
|
+
return git_str_joinpath(target, git_str_cstr(target), relpath) ||
|
873
|
+
git_fs_path_resolve_relative(target, 0);
|
858
874
|
}
|
859
875
|
|
860
|
-
int
|
876
|
+
int git_fs_path_cmp(
|
861
877
|
const char *name1, size_t len1, int isdir1,
|
862
878
|
const char *name2, size_t len2, int isdir2,
|
863
879
|
int (*compare)(const char *, const char *, size_t))
|
@@ -882,7 +898,7 @@ int git_path_cmp(
|
|
882
898
|
return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
|
883
899
|
}
|
884
900
|
|
885
|
-
size_t
|
901
|
+
size_t git_fs_path_common_dirlen(const char *one, const char *two)
|
886
902
|
{
|
887
903
|
const char *p, *q, *dirsep = NULL;
|
888
904
|
|
@@ -896,7 +912,7 @@ size_t git_path_common_dirlen(const char *one, const char *two)
|
|
896
912
|
return dirsep ? (dirsep - one) + 1 : 0;
|
897
913
|
}
|
898
914
|
|
899
|
-
int
|
915
|
+
int git_fs_path_make_relative(git_str *path, const char *parent)
|
900
916
|
{
|
901
917
|
const char *p, *q, *p_dirsep, *q_dirsep;
|
902
918
|
size_t plen = path->size, newlen, alloclen, depth = 1, i, offset;
|
@@ -923,7 +939,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
|
|
923
939
|
else if (!*p && *q == '/')
|
924
940
|
q++;
|
925
941
|
else if (!*p && !*q)
|
926
|
-
return
|
942
|
+
return git_str_clear(path), 0;
|
927
943
|
else {
|
928
944
|
p = p_dirsep + 1;
|
929
945
|
q = q_dirsep + 1;
|
@@ -932,7 +948,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
|
|
932
948
|
plen -= (p - path->ptr);
|
933
949
|
|
934
950
|
if (!*q)
|
935
|
-
return
|
951
|
+
return git_str_set(path, p, plen);
|
936
952
|
|
937
953
|
for (; (q = strchr(q, '/')) && *(q + 1); q++)
|
938
954
|
depth++;
|
@@ -944,7 +960,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
|
|
944
960
|
|
945
961
|
/* save the offset as we might realllocate the pointer */
|
946
962
|
offset = p - path->ptr;
|
947
|
-
if (
|
963
|
+
if (git_str_try_grow(path, alloclen, 1) < 0)
|
948
964
|
return -1;
|
949
965
|
p = path->ptr + offset;
|
950
966
|
|
@@ -957,7 +973,7 @@ int git_path_make_relative(git_buf *path, const char *parent)
|
|
957
973
|
return 0;
|
958
974
|
}
|
959
975
|
|
960
|
-
bool
|
976
|
+
bool git_fs_path_has_non_ascii(const char *path, size_t pathlen)
|
961
977
|
{
|
962
978
|
const uint8_t *scan = (const uint8_t *)path, *end;
|
963
979
|
|
@@ -970,37 +986,37 @@ bool git_path_has_non_ascii(const char *path, size_t pathlen)
|
|
970
986
|
|
971
987
|
#ifdef GIT_USE_ICONV
|
972
988
|
|
973
|
-
int
|
989
|
+
int git_fs_path_iconv_init_precompose(git_fs_path_iconv_t *ic)
|
974
990
|
{
|
975
|
-
|
991
|
+
git_str_init(&ic->buf, 0);
|
976
992
|
ic->map = iconv_open(GIT_PATH_REPO_ENCODING, GIT_PATH_NATIVE_ENCODING);
|
977
993
|
return 0;
|
978
994
|
}
|
979
995
|
|
980
|
-
void
|
996
|
+
void git_fs_path_iconv_clear(git_fs_path_iconv_t *ic)
|
981
997
|
{
|
982
998
|
if (ic) {
|
983
999
|
if (ic->map != (iconv_t)-1)
|
984
1000
|
iconv_close(ic->map);
|
985
|
-
|
1001
|
+
git_str_dispose(&ic->buf);
|
986
1002
|
}
|
987
1003
|
}
|
988
1004
|
|
989
|
-
int
|
1005
|
+
int git_fs_path_iconv(git_fs_path_iconv_t *ic, const char **in, size_t *inlen)
|
990
1006
|
{
|
991
1007
|
char *nfd = (char*)*in, *nfc;
|
992
1008
|
size_t nfdlen = *inlen, nfclen, wantlen = nfdlen, alloclen, rv;
|
993
1009
|
int retry = 1;
|
994
1010
|
|
995
1011
|
if (!ic || ic->map == (iconv_t)-1 ||
|
996
|
-
!
|
1012
|
+
!git_fs_path_has_non_ascii(*in, *inlen))
|
997
1013
|
return 0;
|
998
1014
|
|
999
|
-
|
1015
|
+
git_str_clear(&ic->buf);
|
1000
1016
|
|
1001
1017
|
while (1) {
|
1002
1018
|
GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, wantlen, 1);
|
1003
|
-
if (
|
1019
|
+
if (git_str_grow(&ic->buf, alloclen) < 0)
|
1004
1020
|
return -1;
|
1005
1021
|
|
1006
1022
|
nfc = ic->buf.ptr + ic->buf.size;
|
@@ -1040,8 +1056,8 @@ fail:
|
|
1040
1056
|
return -1;
|
1041
1057
|
}
|
1042
1058
|
|
1043
|
-
static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D
|
1044
|
-
static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D
|
1059
|
+
static const char *nfc_file = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
|
1060
|
+
static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
|
1045
1061
|
|
1046
1062
|
/* Check if the platform is decomposing unicode data for us. We will
|
1047
1063
|
* emulate core Git and prefer to use precomposed unicode data internally
|
@@ -1052,47 +1068,50 @@ static const char *nfd_file = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D.XXXXXX";
|
|
1052
1068
|
* return decomposed unicode from readdir() even when the actual
|
1053
1069
|
* filesystem is storing precomposed unicode.
|
1054
1070
|
*/
|
1055
|
-
bool
|
1071
|
+
bool git_fs_path_does_decompose_unicode(const char *root)
|
1056
1072
|
{
|
1057
|
-
|
1073
|
+
git_str nfc_path = GIT_STR_INIT;
|
1074
|
+
git_str nfd_path = GIT_STR_INIT;
|
1058
1075
|
int fd;
|
1059
1076
|
bool found_decomposed = false;
|
1060
|
-
|
1077
|
+
size_t orig_len;
|
1078
|
+
const char *trailer;
|
1061
1079
|
|
1062
1080
|
/* Create a file using a precomposed path and then try to find it
|
1063
1081
|
* using the decomposed name. If the lookup fails, then we will mark
|
1064
1082
|
* that we should precompose unicode for this repository.
|
1065
1083
|
*/
|
1066
|
-
if (
|
1067
|
-
|
1084
|
+
if (git_str_joinpath(&nfc_path, root, nfc_file) < 0)
|
1085
|
+
goto done;
|
1086
|
+
|
1087
|
+
/* record original path length before trailer */
|
1088
|
+
orig_len = nfc_path.size;
|
1089
|
+
|
1090
|
+
if ((fd = git_futils_mktmp(&nfc_path, nfc_path.ptr, 0666)) < 0)
|
1068
1091
|
goto done;
|
1069
1092
|
p_close(fd);
|
1070
1093
|
|
1071
|
-
|
1072
|
-
memcpy(tmp, path.ptr + path.size - sizeof(tmp), sizeof(tmp));
|
1094
|
+
trailer = nfc_path.ptr + orig_len;
|
1073
1095
|
|
1074
1096
|
/* try to look up as NFD path */
|
1075
|
-
if (
|
1097
|
+
if (git_str_joinpath(&nfd_path, root, nfd_file) < 0 ||
|
1098
|
+
git_str_puts(&nfd_path, trailer) < 0)
|
1076
1099
|
goto done;
|
1077
|
-
memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp));
|
1078
1100
|
|
1079
|
-
found_decomposed =
|
1101
|
+
found_decomposed = git_fs_path_exists(nfd_path.ptr);
|
1080
1102
|
|
1081
1103
|
/* remove temporary file (using original precomposed path) */
|
1082
|
-
|
1083
|
-
goto done;
|
1084
|
-
memcpy(path.ptr + path.size - sizeof(tmp), tmp, sizeof(tmp));
|
1085
|
-
|
1086
|
-
(void)p_unlink(path.ptr);
|
1104
|
+
(void)p_unlink(nfc_path.ptr);
|
1087
1105
|
|
1088
1106
|
done:
|
1089
|
-
|
1107
|
+
git_str_dispose(&nfc_path);
|
1108
|
+
git_str_dispose(&nfd_path);
|
1090
1109
|
return found_decomposed;
|
1091
1110
|
}
|
1092
1111
|
|
1093
1112
|
#else
|
1094
1113
|
|
1095
|
-
bool
|
1114
|
+
bool git_fs_path_does_decompose_unicode(const char *root)
|
1096
1115
|
{
|
1097
1116
|
GIT_UNUSED(root);
|
1098
1117
|
return false;
|
@@ -1106,10 +1125,10 @@ typedef char path_dirent_data[sizeof(struct dirent) + FILENAME_MAX + 1];
|
|
1106
1125
|
typedef struct dirent path_dirent_data;
|
1107
1126
|
#endif
|
1108
1127
|
|
1109
|
-
int
|
1110
|
-
|
1128
|
+
int git_fs_path_direach(
|
1129
|
+
git_str *path,
|
1111
1130
|
uint32_t flags,
|
1112
|
-
int (*fn)(void *,
|
1131
|
+
int (*fn)(void *, git_str *),
|
1113
1132
|
void *arg)
|
1114
1133
|
{
|
1115
1134
|
int error = 0;
|
@@ -1118,15 +1137,15 @@ int git_path_direach(
|
|
1118
1137
|
struct dirent *de;
|
1119
1138
|
|
1120
1139
|
#ifdef GIT_USE_ICONV
|
1121
|
-
|
1140
|
+
git_fs_path_iconv_t ic = GIT_PATH_ICONV_INIT;
|
1122
1141
|
#endif
|
1123
1142
|
|
1124
1143
|
GIT_UNUSED(flags);
|
1125
1144
|
|
1126
|
-
if (
|
1145
|
+
if (git_fs_path_to_dir(path) < 0)
|
1127
1146
|
return -1;
|
1128
1147
|
|
1129
|
-
wd_len =
|
1148
|
+
wd_len = git_str_len(path);
|
1130
1149
|
|
1131
1150
|
if ((dir = opendir(path->ptr)) == NULL) {
|
1132
1151
|
git_error_set(GIT_ERROR_OS, "failed to open directory '%s'", path->ptr);
|
@@ -1137,34 +1156,34 @@ int git_path_direach(
|
|
1137
1156
|
}
|
1138
1157
|
|
1139
1158
|
#ifdef GIT_USE_ICONV
|
1140
|
-
if ((flags &
|
1141
|
-
(void)
|
1159
|
+
if ((flags & GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
|
1160
|
+
(void)git_fs_path_iconv_init_precompose(&ic);
|
1142
1161
|
#endif
|
1143
1162
|
|
1144
1163
|
while ((de = readdir(dir)) != NULL) {
|
1145
1164
|
const char *de_path = de->d_name;
|
1146
1165
|
size_t de_len = strlen(de_path);
|
1147
1166
|
|
1148
|
-
if (
|
1167
|
+
if (git_fs_path_is_dot_or_dotdot(de_path))
|
1149
1168
|
continue;
|
1150
1169
|
|
1151
1170
|
#ifdef GIT_USE_ICONV
|
1152
|
-
if ((error =
|
1171
|
+
if ((error = git_fs_path_iconv(&ic, &de_path, &de_len)) < 0)
|
1153
1172
|
break;
|
1154
1173
|
#endif
|
1155
1174
|
|
1156
|
-
if ((error =
|
1175
|
+
if ((error = git_str_put(path, de_path, de_len)) < 0)
|
1157
1176
|
break;
|
1158
1177
|
|
1159
1178
|
git_error_clear();
|
1160
1179
|
error = fn(arg, path);
|
1161
1180
|
|
1162
|
-
|
1181
|
+
git_str_truncate(path, wd_len); /* restore path */
|
1163
1182
|
|
1164
1183
|
/* Only set our own error if the callback did not set one already */
|
1165
1184
|
if (error != 0) {
|
1166
1185
|
if (!git_error_last())
|
1167
|
-
|
1186
|
+
ensure_error_set(error);
|
1168
1187
|
|
1169
1188
|
break;
|
1170
1189
|
}
|
@@ -1173,7 +1192,7 @@ int git_path_direach(
|
|
1173
1192
|
closedir(dir);
|
1174
1193
|
|
1175
1194
|
#ifdef GIT_USE_ICONV
|
1176
|
-
|
1195
|
+
git_fs_path_iconv_clear(&ic);
|
1177
1196
|
#endif
|
1178
1197
|
|
1179
1198
|
return error;
|
@@ -1188,8 +1207,8 @@ int git_path_direach(
|
|
1188
1207
|
# define FIND_FIRST_EX_LARGE_FETCH 2
|
1189
1208
|
#endif
|
1190
1209
|
|
1191
|
-
int
|
1192
|
-
|
1210
|
+
int git_fs_path_diriter_init(
|
1211
|
+
git_fs_path_diriter *diriter,
|
1193
1212
|
const char *path,
|
1194
1213
|
unsigned int flags)
|
1195
1214
|
{
|
@@ -1202,10 +1221,10 @@ int git_path_diriter_init(
|
|
1202
1221
|
GIT_ASSERT_ARG(diriter);
|
1203
1222
|
GIT_ASSERT_ARG(path);
|
1204
1223
|
|
1205
|
-
memset(diriter, 0, sizeof(
|
1224
|
+
memset(diriter, 0, sizeof(git_fs_path_diriter));
|
1206
1225
|
diriter->handle = INVALID_HANDLE_VALUE;
|
1207
1226
|
|
1208
|
-
if (
|
1227
|
+
if (git_str_puts(&diriter->path_utf8, path) < 0)
|
1209
1228
|
return -1;
|
1210
1229
|
|
1211
1230
|
path_trim_slashes(&diriter->path_utf8);
|
@@ -1239,7 +1258,7 @@ int git_path_diriter_init(
|
|
1239
1258
|
return 0;
|
1240
1259
|
}
|
1241
1260
|
|
1242
|
-
static int diriter_update_paths(
|
1261
|
+
static int diriter_update_paths(git_fs_path_diriter *diriter)
|
1243
1262
|
{
|
1244
1263
|
size_t filename_len, path_len;
|
1245
1264
|
|
@@ -1261,23 +1280,23 @@ static int diriter_update_paths(git_path_diriter *diriter)
|
|
1261
1280
|
diriter->current.cFileName, filename_len * sizeof(wchar_t));
|
1262
1281
|
diriter->path[path_len-1] = L'\0';
|
1263
1282
|
|
1264
|
-
|
1283
|
+
git_str_truncate(&diriter->path_utf8, diriter->parent_utf8_len);
|
1265
1284
|
|
1266
1285
|
if (diriter->parent_utf8_len > 0 &&
|
1267
1286
|
diriter->path_utf8.ptr[diriter->parent_utf8_len-1] != '/')
|
1268
|
-
|
1287
|
+
git_str_putc(&diriter->path_utf8, '/');
|
1269
1288
|
|
1270
|
-
|
1289
|
+
git_str_put_w(&diriter->path_utf8, diriter->current.cFileName, filename_len);
|
1271
1290
|
|
1272
|
-
if (
|
1291
|
+
if (git_str_oom(&diriter->path_utf8))
|
1273
1292
|
return -1;
|
1274
1293
|
|
1275
1294
|
return 0;
|
1276
1295
|
}
|
1277
1296
|
|
1278
|
-
int
|
1297
|
+
int git_fs_path_diriter_next(git_fs_path_diriter *diriter)
|
1279
1298
|
{
|
1280
|
-
bool skip_dot = !(diriter->flags &
|
1299
|
+
bool skip_dot = !(diriter->flags & GIT_FS_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
|
1281
1300
|
|
1282
1301
|
do {
|
1283
1302
|
/* Our first time through, we already have the data from
|
@@ -1287,7 +1306,7 @@ int git_path_diriter_next(git_path_diriter *diriter)
|
|
1287
1306
|
diriter->needs_next = 1;
|
1288
1307
|
else if (!FindNextFileW(diriter->handle, &diriter->current))
|
1289
1308
|
return GIT_ITEROVER;
|
1290
|
-
} while (skip_dot &&
|
1309
|
+
} while (skip_dot && git_fs_path_is_dot_or_dotdotW(diriter->current.cFileName));
|
1291
1310
|
|
1292
1311
|
if (diriter_update_paths(diriter) < 0)
|
1293
1312
|
return -1;
|
@@ -1295,10 +1314,10 @@ int git_path_diriter_next(git_path_diriter *diriter)
|
|
1295
1314
|
return 0;
|
1296
1315
|
}
|
1297
1316
|
|
1298
|
-
int
|
1317
|
+
int git_fs_path_diriter_filename(
|
1299
1318
|
const char **out,
|
1300
1319
|
size_t *out_len,
|
1301
|
-
|
1320
|
+
git_fs_path_diriter *diriter)
|
1302
1321
|
{
|
1303
1322
|
GIT_ASSERT_ARG(out);
|
1304
1323
|
GIT_ASSERT_ARG(out_len);
|
@@ -1310,10 +1329,10 @@ int git_path_diriter_filename(
|
|
1310
1329
|
return 0;
|
1311
1330
|
}
|
1312
1331
|
|
1313
|
-
int
|
1332
|
+
int git_fs_path_diriter_fullpath(
|
1314
1333
|
const char **out,
|
1315
1334
|
size_t *out_len,
|
1316
|
-
|
1335
|
+
git_fs_path_diriter *diriter)
|
1317
1336
|
{
|
1318
1337
|
GIT_ASSERT_ARG(out);
|
1319
1338
|
GIT_ASSERT_ARG(out_len);
|
@@ -1324,7 +1343,7 @@ int git_path_diriter_fullpath(
|
|
1324
1343
|
return 0;
|
1325
1344
|
}
|
1326
1345
|
|
1327
|
-
int
|
1346
|
+
int git_fs_path_diriter_stat(struct stat *out, git_fs_path_diriter *diriter)
|
1328
1347
|
{
|
1329
1348
|
GIT_ASSERT_ARG(out);
|
1330
1349
|
GIT_ASSERT_ARG(diriter);
|
@@ -1334,12 +1353,12 @@ int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter)
|
|
1334
1353
|
diriter->path);
|
1335
1354
|
}
|
1336
1355
|
|
1337
|
-
void
|
1356
|
+
void git_fs_path_diriter_free(git_fs_path_diriter *diriter)
|
1338
1357
|
{
|
1339
1358
|
if (diriter == NULL)
|
1340
1359
|
return;
|
1341
1360
|
|
1342
|
-
|
1361
|
+
git_str_dispose(&diriter->path_utf8);
|
1343
1362
|
|
1344
1363
|
if (diriter->handle != INVALID_HANDLE_VALUE) {
|
1345
1364
|
FindClose(diriter->handle);
|
@@ -1349,17 +1368,17 @@ void git_path_diriter_free(git_path_diriter *diriter)
|
|
1349
1368
|
|
1350
1369
|
#else
|
1351
1370
|
|
1352
|
-
int
|
1353
|
-
|
1371
|
+
int git_fs_path_diriter_init(
|
1372
|
+
git_fs_path_diriter *diriter,
|
1354
1373
|
const char *path,
|
1355
1374
|
unsigned int flags)
|
1356
1375
|
{
|
1357
1376
|
GIT_ASSERT_ARG(diriter);
|
1358
1377
|
GIT_ASSERT_ARG(path);
|
1359
1378
|
|
1360
|
-
memset(diriter, 0, sizeof(
|
1379
|
+
memset(diriter, 0, sizeof(git_fs_path_diriter));
|
1361
1380
|
|
1362
|
-
if (
|
1381
|
+
if (git_str_puts(&diriter->path, path) < 0)
|
1363
1382
|
return -1;
|
1364
1383
|
|
1365
1384
|
path_trim_slashes(&diriter->path);
|
@@ -1370,15 +1389,15 @@ int git_path_diriter_init(
|
|
1370
1389
|
}
|
1371
1390
|
|
1372
1391
|
if ((diriter->dir = opendir(diriter->path.ptr)) == NULL) {
|
1373
|
-
|
1392
|
+
git_str_dispose(&diriter->path);
|
1374
1393
|
|
1375
1394
|
git_error_set(GIT_ERROR_OS, "failed to open directory '%s'", path);
|
1376
1395
|
return -1;
|
1377
1396
|
}
|
1378
1397
|
|
1379
1398
|
#ifdef GIT_USE_ICONV
|
1380
|
-
if ((flags &
|
1381
|
-
(void)
|
1399
|
+
if ((flags & GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
|
1400
|
+
(void)git_fs_path_iconv_init_precompose(&diriter->ic);
|
1382
1401
|
#endif
|
1383
1402
|
|
1384
1403
|
diriter->parent_len = diriter->path.size;
|
@@ -1387,12 +1406,12 @@ int git_path_diriter_init(
|
|
1387
1406
|
return 0;
|
1388
1407
|
}
|
1389
1408
|
|
1390
|
-
int
|
1409
|
+
int git_fs_path_diriter_next(git_fs_path_diriter *diriter)
|
1391
1410
|
{
|
1392
1411
|
struct dirent *de;
|
1393
1412
|
const char *filename;
|
1394
1413
|
size_t filename_len;
|
1395
|
-
bool skip_dot = !(diriter->flags &
|
1414
|
+
bool skip_dot = !(diriter->flags & GIT_FS_PATH_DIR_INCLUDE_DOT_AND_DOTDOT);
|
1396
1415
|
int error = 0;
|
1397
1416
|
|
1398
1417
|
GIT_ASSERT_ARG(diriter);
|
@@ -1408,35 +1427,35 @@ int git_path_diriter_next(git_path_diriter *diriter)
|
|
1408
1427
|
"could not read directory '%s'", diriter->path.ptr);
|
1409
1428
|
return -1;
|
1410
1429
|
}
|
1411
|
-
} while (skip_dot &&
|
1430
|
+
} while (skip_dot && git_fs_path_is_dot_or_dotdot(de->d_name));
|
1412
1431
|
|
1413
1432
|
filename = de->d_name;
|
1414
1433
|
filename_len = strlen(filename);
|
1415
1434
|
|
1416
1435
|
#ifdef GIT_USE_ICONV
|
1417
|
-
if ((diriter->flags &
|
1418
|
-
(error =
|
1436
|
+
if ((diriter->flags & GIT_FS_PATH_DIR_PRECOMPOSE_UNICODE) != 0 &&
|
1437
|
+
(error = git_fs_path_iconv(&diriter->ic, &filename, &filename_len)) < 0)
|
1419
1438
|
return error;
|
1420
1439
|
#endif
|
1421
1440
|
|
1422
|
-
|
1441
|
+
git_str_truncate(&diriter->path, diriter->parent_len);
|
1423
1442
|
|
1424
1443
|
if (diriter->parent_len > 0 &&
|
1425
1444
|
diriter->path.ptr[diriter->parent_len-1] != '/')
|
1426
|
-
|
1445
|
+
git_str_putc(&diriter->path, '/');
|
1427
1446
|
|
1428
|
-
|
1447
|
+
git_str_put(&diriter->path, filename, filename_len);
|
1429
1448
|
|
1430
|
-
if (
|
1449
|
+
if (git_str_oom(&diriter->path))
|
1431
1450
|
return -1;
|
1432
1451
|
|
1433
1452
|
return error;
|
1434
1453
|
}
|
1435
1454
|
|
1436
|
-
int
|
1455
|
+
int git_fs_path_diriter_filename(
|
1437
1456
|
const char **out,
|
1438
1457
|
size_t *out_len,
|
1439
|
-
|
1458
|
+
git_fs_path_diriter *diriter)
|
1440
1459
|
{
|
1441
1460
|
GIT_ASSERT_ARG(out);
|
1442
1461
|
GIT_ASSERT_ARG(out_len);
|
@@ -1448,10 +1467,10 @@ int git_path_diriter_filename(
|
|
1448
1467
|
return 0;
|
1449
1468
|
}
|
1450
1469
|
|
1451
|
-
int
|
1470
|
+
int git_fs_path_diriter_fullpath(
|
1452
1471
|
const char **out,
|
1453
1472
|
size_t *out_len,
|
1454
|
-
|
1473
|
+
git_fs_path_diriter *diriter)
|
1455
1474
|
{
|
1456
1475
|
GIT_ASSERT_ARG(out);
|
1457
1476
|
GIT_ASSERT_ARG(out_len);
|
@@ -1462,15 +1481,15 @@ int git_path_diriter_fullpath(
|
|
1462
1481
|
return 0;
|
1463
1482
|
}
|
1464
1483
|
|
1465
|
-
int
|
1484
|
+
int git_fs_path_diriter_stat(struct stat *out, git_fs_path_diriter *diriter)
|
1466
1485
|
{
|
1467
1486
|
GIT_ASSERT_ARG(out);
|
1468
1487
|
GIT_ASSERT_ARG(diriter);
|
1469
1488
|
|
1470
|
-
return
|
1489
|
+
return git_fs_path_lstat(diriter->path.ptr, out);
|
1471
1490
|
}
|
1472
1491
|
|
1473
|
-
void
|
1492
|
+
void git_fs_path_diriter_free(git_fs_path_diriter *diriter)
|
1474
1493
|
{
|
1475
1494
|
if (diriter == NULL)
|
1476
1495
|
return;
|
@@ -1481,21 +1500,21 @@ void git_path_diriter_free(git_path_diriter *diriter)
|
|
1481
1500
|
}
|
1482
1501
|
|
1483
1502
|
#ifdef GIT_USE_ICONV
|
1484
|
-
|
1503
|
+
git_fs_path_iconv_clear(&diriter->ic);
|
1485
1504
|
#endif
|
1486
1505
|
|
1487
|
-
|
1506
|
+
git_str_dispose(&diriter->path);
|
1488
1507
|
}
|
1489
1508
|
|
1490
1509
|
#endif
|
1491
1510
|
|
1492
|
-
int
|
1511
|
+
int git_fs_path_dirload(
|
1493
1512
|
git_vector *contents,
|
1494
1513
|
const char *path,
|
1495
1514
|
size_t prefix_len,
|
1496
1515
|
uint32_t flags)
|
1497
1516
|
{
|
1498
|
-
|
1517
|
+
git_fs_path_diriter iter = GIT_FS_PATH_DIRITER_INIT;
|
1499
1518
|
const char *name;
|
1500
1519
|
size_t name_len;
|
1501
1520
|
char *dup;
|
@@ -1504,11 +1523,11 @@ int git_path_dirload(
|
|
1504
1523
|
GIT_ASSERT_ARG(contents);
|
1505
1524
|
GIT_ASSERT_ARG(path);
|
1506
1525
|
|
1507
|
-
if ((error =
|
1526
|
+
if ((error = git_fs_path_diriter_init(&iter, path, flags)) < 0)
|
1508
1527
|
return error;
|
1509
1528
|
|
1510
|
-
while ((error =
|
1511
|
-
if ((error =
|
1529
|
+
while ((error = git_fs_path_diriter_next(&iter)) == 0) {
|
1530
|
+
if ((error = git_fs_path_diriter_fullpath(&name, &name_len, &iter)) < 0)
|
1512
1531
|
break;
|
1513
1532
|
|
1514
1533
|
GIT_ASSERT(name_len > prefix_len);
|
@@ -1523,22 +1542,22 @@ int git_path_dirload(
|
|
1523
1542
|
if (error == GIT_ITEROVER)
|
1524
1543
|
error = 0;
|
1525
1544
|
|
1526
|
-
|
1545
|
+
git_fs_path_diriter_free(&iter);
|
1527
1546
|
return error;
|
1528
1547
|
}
|
1529
1548
|
|
1530
|
-
int
|
1549
|
+
int git_fs_path_from_url_or_path(git_str *local_path_out, const char *url_or_path)
|
1531
1550
|
{
|
1532
|
-
if (
|
1533
|
-
return
|
1551
|
+
if (git_fs_path_is_local_file_url(url_or_path))
|
1552
|
+
return git_fs_path_fromurl(local_path_out, url_or_path);
|
1534
1553
|
else
|
1535
|
-
return
|
1554
|
+
return git_str_sets(local_path_out, url_or_path);
|
1536
1555
|
}
|
1537
1556
|
|
1538
1557
|
/* Reject paths like AUX or COM1, or those versions that end in a dot or
|
1539
1558
|
* colon. ("AUX." or "AUX:")
|
1540
1559
|
*/
|
1541
|
-
GIT_INLINE(bool)
|
1560
|
+
GIT_INLINE(bool) validate_dospath(
|
1542
1561
|
const char *component,
|
1543
1562
|
size_t len,
|
1544
1563
|
const char dospath[3],
|
@@ -1557,180 +1576,15 @@ GIT_INLINE(bool) verify_dospath(
|
|
1557
1576
|
component[last] != ':');
|
1558
1577
|
}
|
1559
1578
|
|
1560
|
-
|
1561
|
-
{
|
1562
|
-
while (*len) {
|
1563
|
-
uint32_t codepoint;
|
1564
|
-
int cp_len = git_utf8_iterate(&codepoint, *in, *len);
|
1565
|
-
if (cp_len < 0)
|
1566
|
-
return -1;
|
1567
|
-
|
1568
|
-
(*in) += cp_len;
|
1569
|
-
(*len) -= cp_len;
|
1570
|
-
|
1571
|
-
/* these code points are ignored completely */
|
1572
|
-
switch (codepoint) {
|
1573
|
-
case 0x200c: /* ZERO WIDTH NON-JOINER */
|
1574
|
-
case 0x200d: /* ZERO WIDTH JOINER */
|
1575
|
-
case 0x200e: /* LEFT-TO-RIGHT MARK */
|
1576
|
-
case 0x200f: /* RIGHT-TO-LEFT MARK */
|
1577
|
-
case 0x202a: /* LEFT-TO-RIGHT EMBEDDING */
|
1578
|
-
case 0x202b: /* RIGHT-TO-LEFT EMBEDDING */
|
1579
|
-
case 0x202c: /* POP DIRECTIONAL FORMATTING */
|
1580
|
-
case 0x202d: /* LEFT-TO-RIGHT OVERRIDE */
|
1581
|
-
case 0x202e: /* RIGHT-TO-LEFT OVERRIDE */
|
1582
|
-
case 0x206a: /* INHIBIT SYMMETRIC SWAPPING */
|
1583
|
-
case 0x206b: /* ACTIVATE SYMMETRIC SWAPPING */
|
1584
|
-
case 0x206c: /* INHIBIT ARABIC FORM SHAPING */
|
1585
|
-
case 0x206d: /* ACTIVATE ARABIC FORM SHAPING */
|
1586
|
-
case 0x206e: /* NATIONAL DIGIT SHAPES */
|
1587
|
-
case 0x206f: /* NOMINAL DIGIT SHAPES */
|
1588
|
-
case 0xfeff: /* ZERO WIDTH NO-BREAK SPACE */
|
1589
|
-
continue;
|
1590
|
-
}
|
1591
|
-
|
1592
|
-
/* fold into lowercase -- this will only fold characters in
|
1593
|
-
* the ASCII range, which is perfectly fine, because the
|
1594
|
-
* git folder name can only be composed of ascii characters
|
1595
|
-
*/
|
1596
|
-
return git__tolower((int)codepoint);
|
1597
|
-
}
|
1598
|
-
return 0; /* NULL byte -- end of string */
|
1599
|
-
}
|
1600
|
-
|
1601
|
-
static bool verify_dotgit_hfs_generic(const char *path, size_t len, const char *needle, size_t needle_len)
|
1602
|
-
{
|
1603
|
-
size_t i;
|
1604
|
-
char c;
|
1605
|
-
|
1606
|
-
if (next_hfs_char(&path, &len) != '.')
|
1607
|
-
return true;
|
1608
|
-
|
1609
|
-
for (i = 0; i < needle_len; i++) {
|
1610
|
-
c = next_hfs_char(&path, &len);
|
1611
|
-
if (c != needle[i])
|
1612
|
-
return true;
|
1613
|
-
}
|
1614
|
-
|
1615
|
-
if (next_hfs_char(&path, &len) != '\0')
|
1616
|
-
return true;
|
1617
|
-
|
1618
|
-
return false;
|
1619
|
-
}
|
1620
|
-
|
1621
|
-
static bool verify_dotgit_hfs(const char *path, size_t len)
|
1622
|
-
{
|
1623
|
-
return verify_dotgit_hfs_generic(path, len, "git", CONST_STRLEN("git"));
|
1624
|
-
}
|
1625
|
-
|
1626
|
-
GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size_t len)
|
1627
|
-
{
|
1628
|
-
git_buf *reserved = git_repository__reserved_names_win32;
|
1629
|
-
size_t reserved_len = git_repository__reserved_names_win32_len;
|
1630
|
-
size_t start = 0, i;
|
1631
|
-
|
1632
|
-
if (repo)
|
1633
|
-
git_repository__reserved_names(&reserved, &reserved_len, repo, true);
|
1634
|
-
|
1635
|
-
for (i = 0; i < reserved_len; i++) {
|
1636
|
-
git_buf *r = &reserved[i];
|
1637
|
-
|
1638
|
-
if (len >= r->size &&
|
1639
|
-
strncasecmp(path, r->ptr, r->size) == 0) {
|
1640
|
-
start = r->size;
|
1641
|
-
break;
|
1642
|
-
}
|
1643
|
-
}
|
1644
|
-
|
1645
|
-
if (!start)
|
1646
|
-
return true;
|
1647
|
-
|
1648
|
-
/*
|
1649
|
-
* Reject paths that start with Windows-style directory separators
|
1650
|
-
* (".git\") or NTFS alternate streams (".git:") and could be used
|
1651
|
-
* to write to the ".git" directory on Windows platforms.
|
1652
|
-
*/
|
1653
|
-
if (path[start] == '\\' || path[start] == ':')
|
1654
|
-
return false;
|
1655
|
-
|
1656
|
-
/* Reject paths like '.git ' or '.git.' */
|
1657
|
-
for (i = start; i < len; i++) {
|
1658
|
-
if (path[i] != ' ' && path[i] != '.')
|
1659
|
-
return true;
|
1660
|
-
}
|
1661
|
-
|
1662
|
-
return false;
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
/*
|
1666
|
-
* Windows paths that end with spaces and/or dots are elided to the
|
1667
|
-
* path without them for backward compatibility. That is to say
|
1668
|
-
* that opening file "foo ", "foo." or even "foo . . ." will all
|
1669
|
-
* map to a filename of "foo". This function identifies spaces and
|
1670
|
-
* dots at the end of a filename, whether the proper end of the
|
1671
|
-
* filename (end of string) or a colon (which would indicate a
|
1672
|
-
* Windows alternate data stream.)
|
1673
|
-
*/
|
1674
|
-
GIT_INLINE(bool) ntfs_end_of_filename(const char *path)
|
1675
|
-
{
|
1676
|
-
const char *c = path;
|
1677
|
-
|
1678
|
-
for (;; c++) {
|
1679
|
-
if (*c == '\0' || *c == ':')
|
1680
|
-
return true;
|
1681
|
-
if (*c != ' ' && *c != '.')
|
1682
|
-
return false;
|
1683
|
-
}
|
1684
|
-
|
1685
|
-
return true;
|
1686
|
-
}
|
1687
|
-
|
1688
|
-
GIT_INLINE(bool) verify_dotgit_ntfs_generic(const char *name, size_t len, const char *dotgit_name, size_t dotgit_len, const char *shortname_pfix)
|
1689
|
-
{
|
1690
|
-
int i, saw_tilde;
|
1691
|
-
|
1692
|
-
if (name[0] == '.' && len >= dotgit_len &&
|
1693
|
-
!strncasecmp(name + 1, dotgit_name, dotgit_len)) {
|
1694
|
-
return !ntfs_end_of_filename(name + dotgit_len + 1);
|
1695
|
-
}
|
1696
|
-
|
1697
|
-
/* Detect the basic NTFS shortname with the first six chars */
|
1698
|
-
if (!strncasecmp(name, dotgit_name, 6) && name[6] == '~' &&
|
1699
|
-
name[7] >= '1' && name[7] <= '4')
|
1700
|
-
return !ntfs_end_of_filename(name + 8);
|
1701
|
-
|
1702
|
-
/* Catch fallback names */
|
1703
|
-
for (i = 0, saw_tilde = 0; i < 8; i++) {
|
1704
|
-
if (name[i] == '\0') {
|
1705
|
-
return true;
|
1706
|
-
} else if (saw_tilde) {
|
1707
|
-
if (name[i] < '0' || name[i] > '9')
|
1708
|
-
return true;
|
1709
|
-
} else if (name[i] == '~') {
|
1710
|
-
if (name[i+1] < '1' || name[i+1] > '9')
|
1711
|
-
return true;
|
1712
|
-
saw_tilde = 1;
|
1713
|
-
} else if (i >= 6) {
|
1714
|
-
return true;
|
1715
|
-
} else if ((unsigned char)name[i] > 127) {
|
1716
|
-
return true;
|
1717
|
-
} else if (git__tolower(name[i]) != shortname_pfix[i]) {
|
1718
|
-
return true;
|
1719
|
-
}
|
1720
|
-
}
|
1721
|
-
|
1722
|
-
return !ntfs_end_of_filename(name + i);
|
1723
|
-
}
|
1724
|
-
|
1725
|
-
GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags)
|
1579
|
+
GIT_INLINE(bool) validate_char(unsigned char c, unsigned int flags)
|
1726
1580
|
{
|
1727
|
-
if ((flags &
|
1581
|
+
if ((flags & GIT_FS_PATH_REJECT_BACKSLASH) && c == '\\')
|
1728
1582
|
return false;
|
1729
1583
|
|
1730
|
-
if ((flags &
|
1584
|
+
if ((flags & GIT_FS_PATH_REJECT_SLASH) && c == '/')
|
1731
1585
|
return false;
|
1732
1586
|
|
1733
|
-
if (flags &
|
1587
|
+
if (flags & GIT_FS_PATH_REJECT_NT_CHARS) {
|
1734
1588
|
if (c < 32)
|
1735
1589
|
return false;
|
1736
1590
|
|
@@ -1749,211 +1603,166 @@ GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags)
|
|
1749
1603
|
return true;
|
1750
1604
|
}
|
1751
1605
|
|
1752
|
-
/*
|
1753
|
-
* Return the length of the common prefix between str and prefix, comparing them
|
1754
|
-
* case-insensitively (must be ASCII to match).
|
1755
|
-
*/
|
1756
|
-
GIT_INLINE(size_t) common_prefix_icase(const char *str, size_t len, const char *prefix)
|
1757
|
-
{
|
1758
|
-
size_t count = 0;
|
1759
|
-
|
1760
|
-
while (len >0 && tolower(*str) == tolower(*prefix)) {
|
1761
|
-
count++;
|
1762
|
-
str++;
|
1763
|
-
prefix++;
|
1764
|
-
len--;
|
1765
|
-
}
|
1766
|
-
|
1767
|
-
return count;
|
1768
|
-
}
|
1769
|
-
|
1770
1606
|
/*
|
1771
1607
|
* We fundamentally don't like some paths when dealing with user-inputted
|
1772
|
-
* strings (
|
1608
|
+
* strings (to avoid escaping a sandbox): we don't want dot or dot-dot
|
1773
1609
|
* anywhere, we want to avoid writing weird paths on Windows that can't
|
1774
1610
|
* be handled by tools that use the non-\\?\ APIs, we don't want slashes
|
1775
1611
|
* or double slashes at the end of paths that can make them ambiguous.
|
1776
1612
|
*
|
1777
1613
|
* For checkout, we don't want to recurse into ".git" either.
|
1778
1614
|
*/
|
1779
|
-
static bool
|
1780
|
-
git_repository *repo,
|
1615
|
+
static bool validate_component(
|
1781
1616
|
const char *component,
|
1782
1617
|
size_t len,
|
1783
|
-
uint16_t mode,
|
1784
1618
|
unsigned int flags)
|
1785
1619
|
{
|
1786
1620
|
if (len == 0)
|
1787
|
-
return
|
1621
|
+
return !(flags & GIT_FS_PATH_REJECT_EMPTY_COMPONENT);
|
1788
1622
|
|
1789
|
-
if ((flags &
|
1790
|
-
|
1623
|
+
if ((flags & GIT_FS_PATH_REJECT_TRAVERSAL) &&
|
1624
|
+
len == 1 && component[0] == '.')
|
1791
1625
|
return false;
|
1792
1626
|
|
1793
|
-
if ((flags &
|
1794
|
-
|
1627
|
+
if ((flags & GIT_FS_PATH_REJECT_TRAVERSAL) &&
|
1628
|
+
len == 2 && component[0] == '.' && component[1] == '.')
|
1795
1629
|
return false;
|
1796
1630
|
|
1797
|
-
if ((flags &
|
1631
|
+
if ((flags & GIT_FS_PATH_REJECT_TRAILING_DOT) &&
|
1632
|
+
component[len - 1] == '.')
|
1798
1633
|
return false;
|
1799
1634
|
|
1800
|
-
if ((flags &
|
1635
|
+
if ((flags & GIT_FS_PATH_REJECT_TRAILING_SPACE) &&
|
1636
|
+
component[len - 1] == ' ')
|
1801
1637
|
return false;
|
1802
1638
|
|
1803
|
-
if ((flags &
|
1639
|
+
if ((flags & GIT_FS_PATH_REJECT_TRAILING_COLON) &&
|
1640
|
+
component[len - 1] == ':')
|
1804
1641
|
return false;
|
1805
1642
|
|
1806
|
-
if (flags &
|
1807
|
-
if (!
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1643
|
+
if (flags & GIT_FS_PATH_REJECT_DOS_PATHS) {
|
1644
|
+
if (!validate_dospath(component, len, "CON", false) ||
|
1645
|
+
!validate_dospath(component, len, "PRN", false) ||
|
1646
|
+
!validate_dospath(component, len, "AUX", false) ||
|
1647
|
+
!validate_dospath(component, len, "NUL", false) ||
|
1648
|
+
!validate_dospath(component, len, "COM", true) ||
|
1649
|
+
!validate_dospath(component, len, "LPT", true))
|
1813
1650
|
return false;
|
1814
1651
|
}
|
1815
1652
|
|
1816
|
-
if (flags & GIT_PATH_REJECT_DOT_GIT_HFS) {
|
1817
|
-
if (!verify_dotgit_hfs(component, len))
|
1818
|
-
return false;
|
1819
|
-
if (S_ISLNK(mode) && git_path_is_gitfile(component, len, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_HFS))
|
1820
|
-
return false;
|
1821
|
-
}
|
1822
|
-
|
1823
|
-
if (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) {
|
1824
|
-
if (!verify_dotgit_ntfs(repo, component, len))
|
1825
|
-
return false;
|
1826
|
-
if (S_ISLNK(mode) && git_path_is_gitfile(component, len, GIT_PATH_GITFILE_GITMODULES, GIT_PATH_FS_NTFS))
|
1827
|
-
return false;
|
1828
|
-
}
|
1829
|
-
|
1830
|
-
/* don't bother rerunning the `.git` test if we ran the HFS or NTFS
|
1831
|
-
* specific tests, they would have already rejected `.git`.
|
1832
|
-
*/
|
1833
|
-
if ((flags & GIT_PATH_REJECT_DOT_GIT_HFS) == 0 &&
|
1834
|
-
(flags & GIT_PATH_REJECT_DOT_GIT_NTFS) == 0 &&
|
1835
|
-
(flags & GIT_PATH_REJECT_DOT_GIT_LITERAL)) {
|
1836
|
-
if (len >= 4 &&
|
1837
|
-
component[0] == '.' &&
|
1838
|
-
(component[1] == 'g' || component[1] == 'G') &&
|
1839
|
-
(component[2] == 'i' || component[2] == 'I') &&
|
1840
|
-
(component[3] == 't' || component[3] == 'T')) {
|
1841
|
-
if (len == 4)
|
1842
|
-
return false;
|
1843
|
-
|
1844
|
-
if (S_ISLNK(mode) && common_prefix_icase(component, len, ".gitmodules") == len)
|
1845
|
-
return false;
|
1846
|
-
}
|
1847
|
-
}
|
1848
|
-
|
1849
1653
|
return true;
|
1850
1654
|
}
|
1851
1655
|
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1656
|
+
#ifdef GIT_WIN32
|
1657
|
+
GIT_INLINE(bool) validate_length(
|
1658
|
+
const char *path,
|
1659
|
+
size_t len,
|
1660
|
+
size_t utf8_char_len)
|
1855
1661
|
{
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
flags |= GIT_PATH_REJECT_DOT_GIT_LITERAL;
|
1662
|
+
GIT_UNUSED(path);
|
1663
|
+
GIT_UNUSED(len);
|
1860
1664
|
|
1861
|
-
|
1862
|
-
|
1665
|
+
return (utf8_char_len <= MAX_PATH);
|
1666
|
+
}
|
1863
1667
|
#endif
|
1864
1668
|
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1669
|
+
bool git_fs_path_str_is_valid_ext(
|
1670
|
+
const git_str *path,
|
1671
|
+
unsigned int flags,
|
1672
|
+
bool (*validate_char_cb)(char ch, void *payload),
|
1673
|
+
bool (*validate_component_cb)(const char *component, size_t len, void *payload),
|
1674
|
+
bool (*validate_length_cb)(const char *path, size_t len, size_t utf8_char_len),
|
1675
|
+
void *payload)
|
1676
|
+
{
|
1677
|
+
const char *start, *c;
|
1678
|
+
size_t len = 0;
|
1869
1679
|
|
1870
|
-
if (
|
1871
|
-
|
1872
|
-
if (!error && protectNTFS)
|
1873
|
-
flags |= GIT_PATH_REJECT_DOT_GIT_NTFS;
|
1680
|
+
if (!flags)
|
1681
|
+
return true;
|
1874
1682
|
|
1875
|
-
|
1876
|
-
|
1683
|
+
for (start = c = path->ptr; *c && len < path->size; c++, len++) {
|
1684
|
+
if (!validate_char(*c, flags))
|
1685
|
+
return false;
|
1877
1686
|
|
1878
|
-
|
1879
|
-
|
1880
|
-
const char *path,
|
1881
|
-
uint16_t mode,
|
1882
|
-
unsigned int flags)
|
1883
|
-
{
|
1884
|
-
const char *start, *c;
|
1687
|
+
if (validate_char_cb && !validate_char_cb(*c, payload))
|
1688
|
+
return false;
|
1885
1689
|
|
1886
|
-
|
1887
|
-
|
1888
|
-
flags = dotgit_flags(repo, flags);
|
1690
|
+
if (*c != '/')
|
1691
|
+
continue;
|
1889
1692
|
|
1890
|
-
|
1891
|
-
if (!verify_char(*c, flags))
|
1693
|
+
if (!validate_component(start, (c - start), flags))
|
1892
1694
|
return false;
|
1893
1695
|
|
1894
|
-
if (
|
1895
|
-
|
1896
|
-
|
1696
|
+
if (validate_component_cb &&
|
1697
|
+
!validate_component_cb(start, (c - start), payload))
|
1698
|
+
return false;
|
1897
1699
|
|
1898
|
-
|
1899
|
-
}
|
1700
|
+
start = c + 1;
|
1900
1701
|
}
|
1901
1702
|
|
1902
|
-
|
1903
|
-
|
1703
|
+
/*
|
1704
|
+
* We want to support paths specified as either `const char *`
|
1705
|
+
* or `git_str *`; we pass size as `SIZE_MAX` when we use a
|
1706
|
+
* `const char *` to avoid a `strlen`. Ensure that we didn't
|
1707
|
+
* have a NUL in the buffer if there was a non-SIZE_MAX length.
|
1708
|
+
*/
|
1709
|
+
if (path->size != SIZE_MAX && len != path->size)
|
1710
|
+
return false;
|
1904
1711
|
|
1905
|
-
|
1906
|
-
|
1907
|
-
{
|
1908
|
-
int longpaths = 0;
|
1712
|
+
if (!validate_component(start, (c - start), flags))
|
1713
|
+
return false;
|
1909
1714
|
|
1910
|
-
if (
|
1911
|
-
|
1912
|
-
|
1715
|
+
if (validate_component_cb &&
|
1716
|
+
!validate_component_cb(start, (c - start), payload))
|
1717
|
+
return false;
|
1913
1718
|
|
1914
|
-
|
1915
|
-
|
1719
|
+
#ifdef GIT_WIN32
|
1720
|
+
if ((flags & GIT_FS_PATH_REJECT_LONG_PATHS) != 0) {
|
1721
|
+
size_t utf8_len = git_utf8_char_length(path->ptr, len);
|
1916
1722
|
|
1917
|
-
|
1723
|
+
if (!validate_length(path->ptr, len, utf8_len))
|
1724
|
+
return false;
|
1918
1725
|
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1726
|
+
if (validate_length_cb &&
|
1727
|
+
!validate_length_cb(path->ptr, len, utf8_len))
|
1728
|
+
return false;
|
1729
|
+
}
|
1730
|
+
#else
|
1731
|
+
GIT_UNUSED(validate_length_cb);
|
1732
|
+
#endif
|
1922
1733
|
|
1923
|
-
return
|
1734
|
+
return true;
|
1924
1735
|
}
|
1925
|
-
#endif
|
1926
1736
|
|
1927
|
-
int
|
1737
|
+
int git_fs_path_validate_str_length_with_suffix(
|
1738
|
+
git_str *path,
|
1739
|
+
size_t suffix_len)
|
1928
1740
|
{
|
1929
|
-
|
1930
|
-
|
1741
|
+
#ifdef GIT_WIN32
|
1742
|
+
size_t utf8_len = git_utf8_char_length(path->ptr, path->size);
|
1743
|
+
size_t total_len;
|
1931
1744
|
|
1932
|
-
|
1933
|
-
|
1745
|
+
if (GIT_ADD_SIZET_OVERFLOW(&total_len, utf8_len, suffix_len) ||
|
1746
|
+
total_len > MAX_PATH) {
|
1934
1747
|
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1748
|
+
git_error_set(GIT_ERROR_FILESYSTEM, "path too long: '%.*s'",
|
1749
|
+
(int)path->size, path->ptr);
|
1750
|
+
return -1;
|
1751
|
+
}
|
1752
|
+
#else
|
1753
|
+
GIT_UNUSED(path);
|
1754
|
+
GIT_UNUSED(suffix_len);
|
1755
|
+
#endif
|
1942
1756
|
|
1943
1757
|
return 0;
|
1944
1758
|
}
|
1945
1759
|
|
1946
|
-
int
|
1947
|
-
{
|
1948
|
-
return git_path_validate_workdir_with_len(repo, path->ptr, path->size);
|
1949
|
-
}
|
1950
|
-
|
1951
|
-
int git_path_normalize_slashes(git_buf *out, const char *path)
|
1760
|
+
int git_fs_path_normalize_slashes(git_str *out, const char *path)
|
1952
1761
|
{
|
1953
1762
|
int error;
|
1954
1763
|
char *p;
|
1955
1764
|
|
1956
|
-
if ((error =
|
1765
|
+
if ((error = git_str_puts(out, path)) < 0)
|
1957
1766
|
return error;
|
1958
1767
|
|
1959
1768
|
for (p = out->ptr; *p; p++) {
|
@@ -1964,47 +1773,9 @@ int git_path_normalize_slashes(git_buf *out, const char *path)
|
|
1964
1773
|
return 0;
|
1965
1774
|
}
|
1966
1775
|
|
1967
|
-
|
1968
|
-
const char *file;
|
1969
|
-
const char *hash;
|
1970
|
-
size_t filelen;
|
1971
|
-
} gitfiles[] = {
|
1972
|
-
{ "gitignore", "gi250a", CONST_STRLEN("gitignore") },
|
1973
|
-
{ "gitmodules", "gi7eba", CONST_STRLEN("gitmodules") },
|
1974
|
-
{ "gitattributes", "gi7d29", CONST_STRLEN("gitattributes") }
|
1975
|
-
};
|
1976
|
-
|
1977
|
-
extern int git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfile gitfile, git_path_fs fs)
|
1978
|
-
{
|
1979
|
-
const char *file, *hash;
|
1980
|
-
size_t filelen;
|
1981
|
-
|
1982
|
-
if (!(gitfile >= GIT_PATH_GITFILE_GITIGNORE && gitfile < ARRAY_SIZE(gitfiles))) {
|
1983
|
-
git_error_set(GIT_ERROR_OS, "invalid gitfile for path validation");
|
1984
|
-
return -1;
|
1985
|
-
}
|
1986
|
-
|
1987
|
-
file = gitfiles[gitfile].file;
|
1988
|
-
filelen = gitfiles[gitfile].filelen;
|
1989
|
-
hash = gitfiles[gitfile].hash;
|
1990
|
-
|
1991
|
-
switch (fs) {
|
1992
|
-
case GIT_PATH_FS_GENERIC:
|
1993
|
-
return !verify_dotgit_ntfs_generic(path, pathlen, file, filelen, hash) ||
|
1994
|
-
!verify_dotgit_hfs_generic(path, pathlen, file, filelen);
|
1995
|
-
case GIT_PATH_FS_NTFS:
|
1996
|
-
return !verify_dotgit_ntfs_generic(path, pathlen, file, filelen, hash);
|
1997
|
-
case GIT_PATH_FS_HFS:
|
1998
|
-
return !verify_dotgit_hfs_generic(path, pathlen, file, filelen);
|
1999
|
-
default:
|
2000
|
-
git_error_set(GIT_ERROR_OS, "invalid filesystem for path validation");
|
2001
|
-
return -1;
|
2002
|
-
}
|
2003
|
-
}
|
2004
|
-
|
2005
|
-
bool git_path_supports_symlinks(const char *dir)
|
1776
|
+
bool git_fs_path_supports_symlinks(const char *dir)
|
2006
1777
|
{
|
2007
|
-
|
1778
|
+
git_str path = GIT_STR_INIT;
|
2008
1779
|
bool supported = false;
|
2009
1780
|
struct stat st;
|
2010
1781
|
int fd;
|
@@ -2020,82 +1791,287 @@ bool git_path_supports_symlinks(const char *dir)
|
|
2020
1791
|
done:
|
2021
1792
|
if (path.size)
|
2022
1793
|
(void)p_unlink(path.ptr);
|
2023
|
-
|
1794
|
+
git_str_dispose(&path);
|
2024
1795
|
return supported;
|
2025
1796
|
}
|
2026
1797
|
|
2027
|
-
|
1798
|
+
static git_fs_path_owner_t mock_owner = GIT_FS_PATH_OWNER_NONE;
|
1799
|
+
|
1800
|
+
void git_fs_path__set_owner(git_fs_path_owner_t owner)
|
1801
|
+
{
|
1802
|
+
mock_owner = owner;
|
1803
|
+
}
|
1804
|
+
|
1805
|
+
#ifdef GIT_WIN32
|
1806
|
+
static PSID *sid_dup(PSID sid)
|
1807
|
+
{
|
1808
|
+
DWORD len;
|
1809
|
+
PSID dup;
|
1810
|
+
|
1811
|
+
len = GetLengthSid(sid);
|
1812
|
+
|
1813
|
+
if ((dup = git__malloc(len)) == NULL)
|
1814
|
+
return NULL;
|
1815
|
+
|
1816
|
+
if (!CopySid(len, dup, sid)) {
|
1817
|
+
git_error_set(GIT_ERROR_OS, "could not duplicate sid");
|
1818
|
+
git__free(dup);
|
1819
|
+
return NULL;
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
return dup;
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
static int current_user_sid(PSID *out)
|
2028
1826
|
{
|
2029
|
-
#ifndef GIT_WIN32
|
2030
|
-
GIT_UNUSED(path);
|
2031
|
-
return GIT_OK;
|
2032
|
-
#else
|
2033
|
-
git_win32_path buf;
|
2034
|
-
PSID owner_sid;
|
2035
|
-
PSECURITY_DESCRIPTOR descriptor = NULL;
|
2036
|
-
HANDLE token;
|
2037
1827
|
TOKEN_USER *info = NULL;
|
2038
|
-
|
2039
|
-
|
1828
|
+
HANDLE token = NULL;
|
1829
|
+
DWORD len = 0;
|
1830
|
+
int error = -1;
|
2040
1831
|
|
2041
|
-
if (
|
2042
|
-
|
1832
|
+
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
|
1833
|
+
git_error_set(GIT_ERROR_OS, "could not lookup process information");
|
1834
|
+
goto done;
|
1835
|
+
}
|
2043
1836
|
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
1837
|
+
if (GetTokenInformation(token, TokenUser, NULL, 0, &len) ||
|
1838
|
+
GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
1839
|
+
git_error_set(GIT_ERROR_OS, "could not lookup token metadata");
|
1840
|
+
goto done;
|
1841
|
+
}
|
1842
|
+
|
1843
|
+
info = git__malloc(len);
|
1844
|
+
GIT_ERROR_CHECK_ALLOC(info);
|
2048
1845
|
|
2049
|
-
if (
|
2050
|
-
|
2051
|
-
goto
|
1846
|
+
if (!GetTokenInformation(token, TokenUser, info, len, &len)) {
|
1847
|
+
git_error_set(GIT_ERROR_OS, "could not lookup current user");
|
1848
|
+
goto done;
|
2052
1849
|
}
|
2053
1850
|
|
2054
|
-
if (
|
1851
|
+
if ((*out = sid_dup(info->User.Sid)))
|
1852
|
+
error = 0;
|
1853
|
+
|
1854
|
+
done:
|
1855
|
+
if (token)
|
1856
|
+
CloseHandle(token);
|
1857
|
+
|
1858
|
+
git__free(info);
|
1859
|
+
return error;
|
1860
|
+
}
|
1861
|
+
|
1862
|
+
static int file_owner_sid(PSID *out, const char *path)
|
1863
|
+
{
|
1864
|
+
git_win32_path path_w32;
|
1865
|
+
PSECURITY_DESCRIPTOR descriptor = NULL;
|
1866
|
+
PSID owner_sid;
|
1867
|
+
DWORD ret;
|
1868
|
+
int error = GIT_EINVALID;
|
1869
|
+
|
1870
|
+
if (git_win32_path_from_utf8(path_w32, path) < 0)
|
1871
|
+
return -1;
|
1872
|
+
|
1873
|
+
ret = GetNamedSecurityInfoW(path_w32, SE_FILE_OBJECT,
|
1874
|
+
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
1875
|
+
&owner_sid, NULL, NULL, NULL, &descriptor);
|
1876
|
+
|
1877
|
+
if (ret == ERROR_FILE_NOT_FOUND || ret == ERROR_PATH_NOT_FOUND)
|
1878
|
+
error = GIT_ENOTFOUND;
|
1879
|
+
else if (ret != ERROR_SUCCESS)
|
2055
1880
|
git_error_set(GIT_ERROR_OS, "failed to get security information");
|
2056
|
-
|
2057
|
-
|
1881
|
+
else if (!IsValidSid(owner_sid))
|
1882
|
+
git_error_set(GIT_ERROR_OS, "file owner is not valid");
|
1883
|
+
else if ((*out = sid_dup(owner_sid)))
|
1884
|
+
error = 0;
|
1885
|
+
|
1886
|
+
if (descriptor)
|
1887
|
+
LocalFree(descriptor);
|
1888
|
+
|
1889
|
+
return error;
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
int git_fs_path_owner_is(
|
1893
|
+
bool *out,
|
1894
|
+
const char *path,
|
1895
|
+
git_fs_path_owner_t owner_type)
|
1896
|
+
{
|
1897
|
+
PSID owner_sid = NULL, user_sid = NULL;
|
1898
|
+
BOOL is_admin, admin_owned;
|
1899
|
+
int error;
|
1900
|
+
|
1901
|
+
if (mock_owner) {
|
1902
|
+
*out = ((mock_owner & owner_type) != 0);
|
1903
|
+
return 0;
|
2058
1904
|
}
|
2059
1905
|
|
2060
|
-
if (
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
1906
|
+
if ((error = file_owner_sid(&owner_sid, path)) < 0)
|
1907
|
+
goto done;
|
1908
|
+
|
1909
|
+
if ((owner_type & GIT_FS_PATH_OWNER_CURRENT_USER) != 0) {
|
1910
|
+
if ((error = current_user_sid(&user_sid)) < 0)
|
1911
|
+
goto done;
|
1912
|
+
|
1913
|
+
if (EqualSid(owner_sid, user_sid)) {
|
1914
|
+
*out = true;
|
1915
|
+
goto done;
|
1916
|
+
}
|
2064
1917
|
}
|
2065
1918
|
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
1919
|
+
admin_owned =
|
1920
|
+
IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) ||
|
1921
|
+
IsWellKnownSid(owner_sid, WinLocalSystemSid);
|
1922
|
+
|
1923
|
+
if (admin_owned &&
|
1924
|
+
(owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR) != 0) {
|
1925
|
+
*out = true;
|
1926
|
+
goto done;
|
2070
1927
|
}
|
2071
1928
|
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
git__free(info);
|
2079
|
-
info = NULL;
|
2080
|
-
}
|
1929
|
+
if (admin_owned &&
|
1930
|
+
(owner_type & GIT_FS_PATH_USER_IS_ADMINISTRATOR) != 0 &&
|
1931
|
+
CheckTokenMembership(NULL, owner_sid, &is_admin) &&
|
1932
|
+
is_admin) {
|
1933
|
+
*out = true;
|
1934
|
+
goto done;
|
2081
1935
|
}
|
2082
1936
|
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
1937
|
+
*out = false;
|
1938
|
+
|
1939
|
+
done:
|
1940
|
+
git__free(owner_sid);
|
1941
|
+
git__free(user_sid);
|
1942
|
+
return error;
|
1943
|
+
}
|
1944
|
+
|
1945
|
+
#else
|
1946
|
+
|
1947
|
+
static int sudo_uid_lookup(uid_t *out)
|
1948
|
+
{
|
1949
|
+
git_str uid_str = GIT_STR_INIT;
|
1950
|
+
int64_t uid;
|
1951
|
+
int error = -1;
|
1952
|
+
|
1953
|
+
if (git__getenv(&uid_str, "SUDO_UID") == 0 &&
|
1954
|
+
git__strntol64(&uid, uid_str.ptr, uid_str.size, NULL, 10) == 0 &&
|
1955
|
+
uid == (int64_t)((uid_t)uid)) {
|
1956
|
+
*out = (uid_t)uid;
|
1957
|
+
error = 0;
|
2092
1958
|
}
|
2093
|
-
git__free(info);
|
2094
1959
|
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
1960
|
+
git_str_dispose(&uid_str);
|
1961
|
+
return error;
|
1962
|
+
}
|
1963
|
+
|
1964
|
+
int git_fs_path_owner_is(
|
1965
|
+
bool *out,
|
1966
|
+
const char *path,
|
1967
|
+
git_fs_path_owner_t owner_type)
|
1968
|
+
{
|
1969
|
+
struct stat st;
|
1970
|
+
uid_t euid, sudo_uid;
|
1971
|
+
|
1972
|
+
if (mock_owner) {
|
1973
|
+
*out = ((mock_owner & owner_type) != 0);
|
1974
|
+
return 0;
|
1975
|
+
}
|
1976
|
+
|
1977
|
+
euid = geteuid();
|
1978
|
+
|
1979
|
+
if (p_lstat(path, &st) != 0) {
|
1980
|
+
if (errno == ENOENT)
|
1981
|
+
return GIT_ENOTFOUND;
|
1982
|
+
|
1983
|
+
git_error_set(GIT_ERROR_OS, "could not stat '%s'", path);
|
1984
|
+
return -1;
|
1985
|
+
}
|
1986
|
+
|
1987
|
+
if ((owner_type & GIT_FS_PATH_OWNER_CURRENT_USER) != 0 &&
|
1988
|
+
st.st_uid == euid) {
|
1989
|
+
*out = true;
|
1990
|
+
return 0;
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
if ((owner_type & GIT_FS_PATH_OWNER_ADMINISTRATOR) != 0 &&
|
1994
|
+
st.st_uid == 0) {
|
1995
|
+
*out = true;
|
1996
|
+
return 0;
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
if ((owner_type & GIT_FS_PATH_OWNER_RUNNING_SUDO) != 0 &&
|
2000
|
+
euid == 0 &&
|
2001
|
+
sudo_uid_lookup(&sudo_uid) == 0 &&
|
2002
|
+
st.st_uid == sudo_uid) {
|
2003
|
+
*out = true;
|
2004
|
+
return 0;
|
2005
|
+
}
|
2006
|
+
|
2007
|
+
*out = false;
|
2008
|
+
return 0;
|
2009
|
+
}
|
2010
|
+
|
2011
|
+
#endif
|
2012
|
+
|
2013
|
+
int git_fs_path_owner_is_current_user(bool *out, const char *path)
|
2014
|
+
{
|
2015
|
+
return git_fs_path_owner_is(out, path, GIT_FS_PATH_OWNER_CURRENT_USER);
|
2016
|
+
}
|
2017
|
+
|
2018
|
+
int git_fs_path_owner_is_system(bool *out, const char *path)
|
2019
|
+
{
|
2020
|
+
return git_fs_path_owner_is(out, path, GIT_FS_PATH_OWNER_ADMINISTRATOR);
|
2021
|
+
}
|
2022
|
+
|
2023
|
+
int git_fs_path_find_executable(git_str *fullpath, const char *executable)
|
2024
|
+
{
|
2025
|
+
#ifdef GIT_WIN32
|
2026
|
+
git_win32_path fullpath_w, executable_w;
|
2027
|
+
int error;
|
2028
|
+
|
2029
|
+
if (git_utf8_to_16(executable_w, GIT_WIN_PATH_MAX, executable) < 0)
|
2030
|
+
return -1;
|
2031
|
+
|
2032
|
+
error = git_win32_path_find_executable(fullpath_w, executable_w);
|
2033
|
+
|
2034
|
+
if (error == 0)
|
2035
|
+
error = git_str_put_w(fullpath, fullpath_w, wcslen(fullpath_w));
|
2036
|
+
|
2037
|
+
return error;
|
2038
|
+
#else
|
2039
|
+
git_str path = GIT_STR_INIT;
|
2040
|
+
const char *current_dir, *term;
|
2041
|
+
bool found = false;
|
2042
|
+
|
2043
|
+
if (git__getenv(&path, "PATH") < 0)
|
2044
|
+
return -1;
|
2045
|
+
|
2046
|
+
current_dir = path.ptr;
|
2047
|
+
|
2048
|
+
while (*current_dir) {
|
2049
|
+
if (! (term = strchr(current_dir, GIT_PATH_LIST_SEPARATOR)))
|
2050
|
+
term = strchr(current_dir, '\0');
|
2051
|
+
|
2052
|
+
git_str_clear(fullpath);
|
2053
|
+
if (git_str_put(fullpath, current_dir, (term - current_dir)) < 0 ||
|
2054
|
+
git_str_putc(fullpath, '/') < 0 ||
|
2055
|
+
git_str_puts(fullpath, executable) < 0)
|
2056
|
+
return -1;
|
2057
|
+
|
2058
|
+
if (git_fs_path_isfile(fullpath->ptr)) {
|
2059
|
+
found = true;
|
2060
|
+
break;
|
2061
|
+
}
|
2062
|
+
|
2063
|
+
current_dir = term;
|
2064
|
+
|
2065
|
+
while (*current_dir == GIT_PATH_LIST_SEPARATOR)
|
2066
|
+
current_dir++;
|
2067
|
+
}
|
2068
|
+
|
2069
|
+
git_str_dispose(&path);
|
2070
|
+
|
2071
|
+
if (found)
|
2072
|
+
return 0;
|
2098
2073
|
|
2099
|
-
|
2074
|
+
git_str_clear(fullpath);
|
2075
|
+
return GIT_ENOTFOUND;
|
2100
2076
|
#endif
|
2101
2077
|
}
|