rugged 0.28.4.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/rugged/extconf.rb +3 -1
- data/ext/rugged/rugged.c +35 -31
- data/ext/rugged/rugged.h +13 -0
- data/ext/rugged/rugged_blob.c +11 -9
- data/ext/rugged/rugged_commit.c +17 -15
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +4 -26
- data/ext/rugged/rugged_index.c +4 -2
- data/ext/rugged/rugged_note.c +5 -3
- data/ext/rugged/rugged_object.c +57 -10
- data/ext/rugged/rugged_rebase.c +3 -1
- data/ext/rugged/rugged_remote.c +32 -8
- data/ext/rugged/rugged_repo.c +232 -17
- data/ext/rugged/rugged_tag.c +8 -6
- data/ext/rugged/rugged_tree.c +18 -16
- data/lib/rugged/commit.rb +1 -2
- data/lib/rugged/repository.rb +5 -6
- data/lib/rugged/submodule_collection.rb +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +39 -19
- data/vendor/libgit2/COPYING +28 -0
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -1
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
- data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +38 -0
- data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +37 -0
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +6 -0
- data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +77 -0
- data/vendor/libgit2/cmake/Modules/SanitizeBool.cmake +20 -0
- data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +56 -0
- data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +127 -0
- data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +69 -0
- data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +23 -0
- data/vendor/libgit2/deps/ntlmclient/compat.h +55 -0
- data/vendor/libgit2/deps/ntlmclient/crypt.h +64 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +120 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +145 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +18 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +130 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +21 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +1422 -0
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +174 -0
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +320 -0
- data/vendor/libgit2/deps/ntlmclient/unicode.h +36 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +445 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +201 -0
- data/vendor/libgit2/deps/ntlmclient/utf8.h +1257 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +21 -0
- data/vendor/libgit2/deps/ntlmclient/util.h +14 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
- data/vendor/libgit2/deps/pcre/COPYING +5 -0
- data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +22 -0
- data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +17 -0
- data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +58 -0
- data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +29 -0
- data/vendor/libgit2/deps/pcre/config.h.in +57 -0
- data/vendor/libgit2/deps/pcre/pcre.h +641 -0
- data/vendor/libgit2/deps/pcre/pcre_byte_order.c +319 -0
- data/vendor/libgit2/deps/pcre/pcre_chartables.c +198 -0
- data/vendor/libgit2/deps/pcre/pcre_compile.c +9800 -0
- data/vendor/libgit2/deps/pcre/pcre_config.c +190 -0
- data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +3676 -0
- data/vendor/libgit2/deps/pcre/pcre_exec.c +7173 -0
- data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +245 -0
- data/vendor/libgit2/deps/pcre/pcre_get.c +669 -0
- data/vendor/libgit2/deps/pcre/pcre_globals.c +86 -0
- data/vendor/libgit2/deps/pcre/pcre_internal.h +2787 -0
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +11913 -0
- data/vendor/libgit2/deps/pcre/pcre_maketables.c +156 -0
- data/vendor/libgit2/deps/pcre/pcre_newline.c +210 -0
- data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +94 -0
- data/vendor/libgit2/deps/pcre/pcre_printint.c +834 -0
- data/vendor/libgit2/deps/pcre/pcre_refcount.c +92 -0
- data/vendor/libgit2/deps/pcre/pcre_string_utils.c +211 -0
- data/vendor/libgit2/deps/pcre/pcre_study.c +1686 -0
- data/vendor/libgit2/deps/pcre/pcre_tables.c +727 -0
- data/vendor/libgit2/deps/pcre/pcre_ucd.c +3644 -0
- data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +301 -0
- data/vendor/libgit2/deps/pcre/pcre_version.c +98 -0
- data/vendor/libgit2/deps/pcre/pcre_xclass.c +268 -0
- data/vendor/libgit2/deps/pcre/pcreposix.c +421 -0
- data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
- data/vendor/libgit2/deps/pcre/ucp.h +224 -0
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +0 -7
- data/vendor/libgit2/include/git2.h +2 -0
- data/vendor/libgit2/include/git2/apply.h +22 -2
- data/vendor/libgit2/include/git2/attr.h +23 -13
- data/vendor/libgit2/include/git2/blame.h +2 -2
- data/vendor/libgit2/include/git2/blob.h +44 -12
- data/vendor/libgit2/include/git2/branch.h +74 -57
- data/vendor/libgit2/include/git2/buffer.h +20 -14
- data/vendor/libgit2/include/git2/cert.h +135 -0
- data/vendor/libgit2/include/git2/checkout.h +46 -14
- data/vendor/libgit2/include/git2/cherrypick.h +3 -3
- data/vendor/libgit2/include/git2/clone.h +2 -2
- data/vendor/libgit2/include/git2/commit.h +23 -1
- data/vendor/libgit2/include/git2/common.h +15 -6
- data/vendor/libgit2/include/git2/config.h +12 -12
- data/vendor/libgit2/include/git2/cred_helpers.h +4 -42
- data/vendor/libgit2/include/git2/credential.h +314 -0
- data/vendor/libgit2/include/git2/credential_helpers.h +52 -0
- data/vendor/libgit2/include/git2/deprecated.h +321 -3
- data/vendor/libgit2/include/git2/describe.h +4 -4
- data/vendor/libgit2/include/git2/diff.h +16 -14
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/filter.h +8 -0
- data/vendor/libgit2/include/git2/index.h +2 -1
- data/vendor/libgit2/include/git2/indexer.h +48 -4
- data/vendor/libgit2/include/git2/merge.h +6 -10
- data/vendor/libgit2/include/git2/net.h +0 -5
- data/vendor/libgit2/include/git2/object.h +2 -14
- data/vendor/libgit2/include/git2/odb.h +3 -2
- data/vendor/libgit2/include/git2/odb_backend.h +5 -4
- data/vendor/libgit2/include/git2/oid.h +11 -6
- data/vendor/libgit2/include/git2/pack.h +12 -1
- data/vendor/libgit2/include/git2/proxy.h +6 -4
- data/vendor/libgit2/include/git2/rebase.h +46 -2
- data/vendor/libgit2/include/git2/refs.h +19 -0
- data/vendor/libgit2/include/git2/remote.h +40 -15
- data/vendor/libgit2/include/git2/repository.h +29 -6
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +7 -3
- data/vendor/libgit2/include/git2/stash.h +4 -4
- data/vendor/libgit2/include/git2/status.h +25 -16
- data/vendor/libgit2/include/git2/submodule.h +20 -3
- data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
- data/vendor/libgit2/include/git2/sys/cred.h +15 -0
- data/vendor/libgit2/include/git2/sys/credential.h +90 -0
- data/vendor/libgit2/include/git2/sys/index.h +4 -2
- data/vendor/libgit2/include/git2/sys/mempack.h +2 -1
- data/vendor/libgit2/include/git2/sys/merge.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +48 -4
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +164 -21
- data/vendor/libgit2/include/git2/sys/repository.h +17 -6
- data/vendor/libgit2/include/git2/sys/transport.h +4 -4
- data/vendor/libgit2/include/git2/tag.h +11 -2
- data/vendor/libgit2/include/git2/trace.h +2 -2
- data/vendor/libgit2/include/git2/transport.h +11 -340
- data/vendor/libgit2/include/git2/tree.h +5 -3
- data/vendor/libgit2/include/git2/types.h +4 -89
- data/vendor/libgit2/include/git2/version.h +5 -5
- data/vendor/libgit2/include/git2/worktree.h +5 -5
- data/vendor/libgit2/src/CMakeLists.txt +99 -236
- data/vendor/libgit2/src/alloc.c +2 -14
- data/vendor/libgit2/src/{stdalloc.c → allocators/stdalloc.c} +3 -4
- data/vendor/libgit2/src/{stdalloc.h → allocators/stdalloc.h} +4 -4
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +118 -0
- data/vendor/libgit2/src/{transports/cred.h → allocators/win32_crtdbg.h} +5 -4
- data/vendor/libgit2/src/apply.c +60 -30
- data/vendor/libgit2/src/attr.c +70 -64
- data/vendor/libgit2/src/attr_file.c +189 -96
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +48 -48
- data/vendor/libgit2/src/attrcache.h +2 -1
- data/vendor/libgit2/src/blame.c +17 -5
- data/vendor/libgit2/src/blame.h +1 -1
- data/vendor/libgit2/src/blame_git.c +21 -7
- data/vendor/libgit2/src/blob.c +81 -17
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +60 -32
- data/vendor/libgit2/src/buffer.c +19 -7
- data/vendor/libgit2/src/buffer.h +1 -0
- data/vendor/libgit2/src/cache.c +33 -36
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +5 -0
- data/vendor/libgit2/src/checkout.c +26 -16
- data/vendor/libgit2/src/cherrypick.c +9 -3
- data/vendor/libgit2/src/clone.c +29 -7
- data/vendor/libgit2/src/clone.h +4 -0
- data/vendor/libgit2/src/commit.c +70 -22
- data/vendor/libgit2/src/commit.h +6 -0
- data/vendor/libgit2/src/commit_list.c +28 -76
- data/vendor/libgit2/src/commit_list.h +2 -2
- data/vendor/libgit2/src/common.h +3 -75
- data/vendor/libgit2/src/config.c +31 -40
- data/vendor/libgit2/src/config.h +7 -6
- data/vendor/libgit2/src/config_backend.h +12 -0
- data/vendor/libgit2/src/config_cache.c +39 -39
- data/vendor/libgit2/src/config_entries.c +69 -99
- data/vendor/libgit2/src/config_entries.h +1 -0
- data/vendor/libgit2/src/config_file.c +346 -380
- data/vendor/libgit2/src/config_mem.c +12 -16
- data/vendor/libgit2/src/config_parse.c +49 -29
- data/vendor/libgit2/src/config_parse.h +13 -12
- data/vendor/libgit2/src/config_snapshot.c +206 -0
- data/vendor/libgit2/src/crlf.c +14 -14
- data/vendor/libgit2/src/describe.c +21 -20
- data/vendor/libgit2/src/diff.c +43 -58
- data/vendor/libgit2/src/diff.h +4 -3
- data/vendor/libgit2/src/diff_driver.c +37 -38
- data/vendor/libgit2/src/diff_file.c +12 -10
- data/vendor/libgit2/src/diff_file.h +2 -2
- data/vendor/libgit2/src/diff_generate.c +148 -98
- data/vendor/libgit2/src/diff_generate.h +2 -2
- data/vendor/libgit2/src/diff_parse.c +1 -1
- data/vendor/libgit2/src/diff_print.c +25 -13
- data/vendor/libgit2/src/diff_stats.c +1 -1
- data/vendor/libgit2/src/diff_tform.c +11 -11
- data/vendor/libgit2/src/errors.c +21 -25
- data/vendor/libgit2/src/errors.h +81 -0
- data/vendor/libgit2/src/features.h.in +9 -2
- data/vendor/libgit2/src/fetch.c +7 -2
- data/vendor/libgit2/src/fetchhead.c +36 -4
- data/vendor/libgit2/src/filebuf.c +6 -10
- data/vendor/libgit2/src/filebuf.h +2 -2
- data/vendor/libgit2/src/filter.c +16 -8
- data/vendor/libgit2/src/{fileops.c → futils.c} +21 -17
- data/vendor/libgit2/src/{fileops.h → futils.h} +5 -5
- data/vendor/libgit2/src/global.c +12 -40
- data/vendor/libgit2/src/global.h +0 -2
- data/vendor/libgit2/src/hash.c +61 -0
- data/vendor/libgit2/src/hash.h +19 -21
- data/vendor/libgit2/src/hash/sha1.h +38 -0
- data/vendor/libgit2/src/hash/{hash_collisiondetect.h → sha1/collisiondetect.c} +14 -17
- data/vendor/libgit2/src/{sha1_lookup.h → hash/sha1/collisiondetect.h} +8 -8
- data/vendor/libgit2/src/hash/{hash_common_crypto.h → sha1/common_crypto.c} +15 -19
- data/vendor/libgit2/src/hash/sha1/common_crypto.h +19 -0
- data/vendor/libgit2/src/hash/{hash_generic.c → sha1/generic.c} +22 -10
- data/vendor/libgit2/src/hash/{hash_generic.h → sha1/generic.h} +4 -14
- data/vendor/libgit2/src/hash/{hash_mbedtls.c → sha1/mbedtls.c} +15 -7
- data/vendor/libgit2/src/hash/{hash_mbedtls.h → sha1/mbedtls.h} +6 -11
- data/vendor/libgit2/src/hash/{hash_openssl.h → sha1/openssl.c} +14 -18
- data/vendor/libgit2/src/hash/sha1/openssl.h +19 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.c +14 -3
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/sha1.h +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.c +0 -0
- data/vendor/libgit2/src/hash/{sha1dc → sha1/sha1dc}/ubc_check.h +0 -0
- data/vendor/libgit2/src/hash/{hash_win32.c → sha1/win32.c} +34 -24
- data/vendor/libgit2/src/hash/{hash_win32.h → sha1/win32.h} +6 -19
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/idxmap.c +91 -65
- data/vendor/libgit2/src/idxmap.h +151 -15
- data/vendor/libgit2/src/ignore.c +32 -38
- data/vendor/libgit2/src/index.c +105 -83
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +71 -72
- data/vendor/libgit2/src/integer.h +39 -4
- data/vendor/libgit2/src/iterator.c +40 -35
- data/vendor/libgit2/src/iterator.h +8 -8
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +78 -51
- data/vendor/libgit2/src/merge.h +2 -2
- data/vendor/libgit2/src/merge_driver.c +5 -5
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +18 -23
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/net.c +411 -0
- data/vendor/libgit2/src/net.h +57 -0
- data/vendor/libgit2/src/netops.c +6 -193
- data/vendor/libgit2/src/netops.h +1 -34
- data/vendor/libgit2/src/notes.c +8 -5
- data/vendor/libgit2/src/object.c +3 -3
- data/vendor/libgit2/src/object.h +2 -0
- data/vendor/libgit2/src/odb.c +41 -23
- data/vendor/libgit2/src/odb.h +3 -2
- data/vendor/libgit2/src/odb_loose.c +17 -10
- data/vendor/libgit2/src/odb_mempack.c +13 -24
- data/vendor/libgit2/src/odb_pack.c +4 -5
- data/vendor/libgit2/src/offmap.c +43 -55
- data/vendor/libgit2/src/offmap.h +102 -24
- data/vendor/libgit2/src/oid.c +19 -8
- data/vendor/libgit2/src/oidmap.c +39 -57
- data/vendor/libgit2/src/oidmap.h +99 -19
- data/vendor/libgit2/src/pack-objects.c +28 -33
- data/vendor/libgit2/src/pack-objects.h +1 -1
- data/vendor/libgit2/src/pack.c +117 -129
- data/vendor/libgit2/src/pack.h +15 -18
- data/vendor/libgit2/src/parse.c +10 -0
- data/vendor/libgit2/src/parse.h +3 -3
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +130 -33
- data/vendor/libgit2/src/path.c +43 -6
- data/vendor/libgit2/src/path.h +2 -0
- data/vendor/libgit2/src/pathspec.c +14 -14
- data/vendor/libgit2/src/pool.c +26 -22
- data/vendor/libgit2/src/pool.h +7 -7
- data/vendor/libgit2/src/posix.c +7 -7
- data/vendor/libgit2/src/posix.h +12 -1
- data/vendor/libgit2/src/proxy.c +7 -2
- data/vendor/libgit2/src/push.c +13 -7
- data/vendor/libgit2/src/reader.c +2 -2
- data/vendor/libgit2/src/rebase.c +87 -28
- data/vendor/libgit2/src/refdb.c +12 -0
- data/vendor/libgit2/src/refdb_fs.c +219 -167
- data/vendor/libgit2/src/reflog.c +11 -13
- data/vendor/libgit2/src/refs.c +39 -23
- data/vendor/libgit2/src/refs.h +8 -1
- data/vendor/libgit2/src/refspec.c +9 -16
- data/vendor/libgit2/src/regexp.c +221 -0
- data/vendor/libgit2/src/regexp.h +97 -0
- data/vendor/libgit2/src/remote.c +57 -55
- data/vendor/libgit2/src/remote.h +2 -2
- data/vendor/libgit2/src/repository.c +187 -154
- data/vendor/libgit2/src/repository.h +49 -40
- data/vendor/libgit2/src/revert.c +8 -3
- data/vendor/libgit2/src/revparse.c +18 -19
- data/vendor/libgit2/src/revwalk.c +72 -34
- data/vendor/libgit2/src/revwalk.h +20 -0
- data/vendor/libgit2/src/settings.c +13 -1
- data/vendor/libgit2/src/sortedcache.c +12 -26
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +47 -67
- data/vendor/libgit2/src/status.c +17 -11
- data/vendor/libgit2/src/streams/openssl.c +54 -2
- data/vendor/libgit2/src/streams/socket.c +2 -2
- data/vendor/libgit2/src/strmap.c +37 -84
- data/vendor/libgit2/src/strmap.h +105 -33
- data/vendor/libgit2/src/submodule.c +151 -126
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +11 -1
- data/vendor/libgit2/src/tag.c +10 -2
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/trailer.c +46 -32
- data/vendor/libgit2/src/transaction.c +10 -9
- data/vendor/libgit2/src/transports/auth.c +16 -15
- data/vendor/libgit2/src/transports/auth.h +18 -11
- data/vendor/libgit2/src/transports/auth_negotiate.c +64 -33
- data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
- data/vendor/libgit2/src/transports/auth_ntlm.c +223 -0
- data/vendor/libgit2/src/transports/auth_ntlm.h +38 -0
- data/vendor/libgit2/src/transports/credential.c +476 -0
- data/vendor/libgit2/src/transports/{cred_helpers.c → credential_helpers.c} +21 -8
- data/vendor/libgit2/src/transports/git.c +11 -16
- data/vendor/libgit2/src/transports/http.c +488 -1248
- data/vendor/libgit2/src/transports/http.h +4 -1
- data/vendor/libgit2/src/transports/httpclient.c +1549 -0
- data/vendor/libgit2/src/transports/httpclient.h +190 -0
- data/vendor/libgit2/src/transports/local.c +10 -10
- data/vendor/libgit2/src/transports/smart.c +19 -19
- data/vendor/libgit2/src/transports/smart.h +3 -3
- data/vendor/libgit2/src/transports/smart_pkt.c +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +40 -64
- data/vendor/libgit2/src/transports/ssh.c +77 -59
- data/vendor/libgit2/src/transports/winhttp.c +272 -242
- data/vendor/libgit2/src/tree-cache.c +14 -7
- data/vendor/libgit2/src/tree.c +16 -26
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +2 -12
- data/vendor/libgit2/src/userdiff.h +3 -1
- data/vendor/libgit2/src/util.c +51 -53
- data/vendor/libgit2/src/util.h +16 -21
- data/vendor/libgit2/src/wildmatch.c +320 -0
- data/vendor/libgit2/src/wildmatch.h +23 -0
- data/vendor/libgit2/src/win32/map.c +3 -5
- data/vendor/libgit2/src/win32/path_w32.c +40 -3
- data/vendor/libgit2/src/win32/path_w32.h +15 -29
- data/vendor/libgit2/src/win32/posix.h +1 -4
- data/vendor/libgit2/src/win32/posix_w32.c +47 -5
- data/vendor/libgit2/src/win32/precompiled.h +0 -2
- data/vendor/libgit2/src/win32/thread.c +5 -10
- data/vendor/libgit2/src/win32/w32_buffer.c +7 -3
- data/vendor/libgit2/src/win32/w32_common.h +39 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -93
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -2
- data/vendor/libgit2/src/win32/w32_stack.c +4 -9
- data/vendor/libgit2/src/win32/w32_stack.h +3 -3
- data/vendor/libgit2/src/win32/w32_util.c +31 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -32
- data/vendor/libgit2/src/worktree.c +79 -49
- data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +12 -0
- data/vendor/libgit2/src/xdiff/xpatience.c +3 -0
- data/vendor/libgit2/src/zstream.c +5 -0
- data/vendor/libgit2/src/zstream.h +1 -0
- metadata +108 -41
- data/vendor/libgit2/deps/regex/CMakeLists.txt +0 -2
- data/vendor/libgit2/deps/regex/COPYING +0 -502
- data/vendor/libgit2/deps/regex/config.h +0 -7
- data/vendor/libgit2/deps/regex/regcomp.c +0 -3857
- data/vendor/libgit2/deps/regex/regex.c +0 -92
- data/vendor/libgit2/deps/regex/regex.h +0 -582
- data/vendor/libgit2/deps/regex/regex_internal.c +0 -1744
- data/vendor/libgit2/deps/regex/regex_internal.h +0 -819
- data/vendor/libgit2/deps/regex/regexec.c +0 -4369
- data/vendor/libgit2/include/git2/inttypes.h +0 -309
- data/vendor/libgit2/include/git2/sys/time.h +0 -31
- data/vendor/libgit2/libgit2.pc.in +0 -13
- data/vendor/libgit2/src/fnmatch.c +0 -248
- data/vendor/libgit2/src/fnmatch.h +0 -48
- data/vendor/libgit2/src/sha1_lookup.c +0 -35
- data/vendor/libgit2/src/transports/cred.c +0 -390
@@ -0,0 +1,97 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef INCLUDE_regexp_h__
|
9
|
+
#define INCLUDE_regexp_h__
|
10
|
+
|
11
|
+
#include "common.h"
|
12
|
+
|
13
|
+
#if defined(GIT_REGEX_BUILTIN) || defined(GIT_REGEX_PCRE)
|
14
|
+
# include "pcre.h"
|
15
|
+
typedef pcre *git_regexp;
|
16
|
+
# define GIT_REGEX_INIT NULL
|
17
|
+
#elif defined(GIT_REGEX_PCRE2)
|
18
|
+
# define PCRE2_CODE_UNIT_WIDTH 8
|
19
|
+
# include <pcre2.h>
|
20
|
+
typedef pcre2_code *git_regexp;
|
21
|
+
# define GIT_REGEX_INIT NULL
|
22
|
+
#elif defined(GIT_REGEX_REGCOMP) || defined(GIT_REGEX_REGCOMP_L)
|
23
|
+
# include <regex.h>
|
24
|
+
typedef regex_t git_regexp;
|
25
|
+
# define GIT_REGEX_INIT { 0 }
|
26
|
+
#else
|
27
|
+
# error "No regex backend"
|
28
|
+
#endif
|
29
|
+
|
30
|
+
/** Options supported by @git_regexp_compile. */
|
31
|
+
typedef enum {
|
32
|
+
/** Enable case-insensitive matching */
|
33
|
+
GIT_REGEXP_ICASE = (1 << 0)
|
34
|
+
} git_regexp_flags_t;
|
35
|
+
|
36
|
+
/** Structure containing information about regular expression matching groups */
|
37
|
+
typedef struct {
|
38
|
+
/** Start of the given match. -1 if the group didn't match anything */
|
39
|
+
ssize_t start;
|
40
|
+
/** End of the given match. -1 if the group didn't match anything */
|
41
|
+
ssize_t end;
|
42
|
+
} git_regmatch;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Compile a regular expression. The compiled expression needs to
|
46
|
+
* be cleaned up afterwards with `git_regexp_dispose`.
|
47
|
+
*
|
48
|
+
* @param r Pointer to the storage where to initialize the regular expression.
|
49
|
+
* @param pattern The pattern that shall be compiled.
|
50
|
+
* @param flags Flags to alter how the pattern shall be handled.
|
51
|
+
* 0 for defaults, otherwise see @git_regexp_flags_t.
|
52
|
+
* @return 0 on success, otherwise a negative return value.
|
53
|
+
*/
|
54
|
+
int git_regexp_compile(git_regexp *r, const char *pattern, int flags);
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Free memory associated with the regular expression
|
58
|
+
*
|
59
|
+
* @param r The regular expression structure to dispose.
|
60
|
+
*/
|
61
|
+
void git_regexp_dispose(git_regexp *r);
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Test whether a given string matches a compiled regular
|
65
|
+
* expression.
|
66
|
+
*
|
67
|
+
* @param r Compiled regular expression.
|
68
|
+
* @param string String to match against the regular expression.
|
69
|
+
* @return 0 if the string matches, a negative error code
|
70
|
+
* otherwise. GIT_ENOTFOUND if no match was found,
|
71
|
+
* GIT_EINVALIDSPEC if the regular expression matching
|
72
|
+
* was invalid.
|
73
|
+
*/
|
74
|
+
int git_regexp_match(const git_regexp *r, const char *string);
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Search for matches inside of a given string.
|
78
|
+
*
|
79
|
+
* Given a regular expression with capturing groups, this
|
80
|
+
* function will populate provided @git_regmatch structures with
|
81
|
+
* offsets for each of the given matches. Non-matching groups
|
82
|
+
* will have start and end values of the respective @git_regmatch
|
83
|
+
* structure set to -1.
|
84
|
+
*
|
85
|
+
* @param r Compiled regular expression.
|
86
|
+
* @param string String to match against the regular expression.
|
87
|
+
* @param nmatches Number of @git_regmatch structures provided by
|
88
|
+
* the user.
|
89
|
+
* @param matches Pointer to an array of @git_regmatch structures.
|
90
|
+
* @return 0 if the string matches, a negative error code
|
91
|
+
* otherwise. GIT_ENOTFOUND if no match was found,
|
92
|
+
* GIT_EINVALIDSPEC if the regular expression matching
|
93
|
+
* was invalid.
|
94
|
+
*/
|
95
|
+
int git_regexp_search(const git_regexp *r, const char *string, size_t nmatches, git_regmatch *matches);
|
96
|
+
|
97
|
+
#endif
|
data/vendor/libgit2/src/remote.c
CHANGED
@@ -136,35 +136,6 @@ cleanup:
|
|
136
136
|
return 0;
|
137
137
|
}
|
138
138
|
|
139
|
-
#if 0
|
140
|
-
/* We could export this as a helper */
|
141
|
-
static int get_check_cert(int *out, git_repository *repo)
|
142
|
-
{
|
143
|
-
git_config *cfg;
|
144
|
-
const char *val;
|
145
|
-
int error = 0;
|
146
|
-
|
147
|
-
assert(out && repo);
|
148
|
-
|
149
|
-
/* By default, we *DO* want to verify the certificate. */
|
150
|
-
*out = 1;
|
151
|
-
|
152
|
-
/* Go through the possible sources for SSL verification settings, from
|
153
|
-
* most specific to least specific. */
|
154
|
-
|
155
|
-
/* GIT_SSL_NO_VERIFY environment variable */
|
156
|
-
if ((val = p_getenv("GIT_SSL_NO_VERIFY")) != NULL)
|
157
|
-
return git_config_parse_bool(out, val);
|
158
|
-
|
159
|
-
/* http.sslVerify config setting */
|
160
|
-
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
|
161
|
-
return error;
|
162
|
-
|
163
|
-
*out = git_config__get_bool_force(cfg, "http.sslverify", 1);
|
164
|
-
return 0;
|
165
|
-
}
|
166
|
-
#endif
|
167
|
-
|
168
139
|
static int canonicalize_url(git_buf *out, const char *in)
|
169
140
|
{
|
170
141
|
if (in == NULL || strlen(in) == 0) {
|
@@ -217,13 +188,18 @@ static int ensure_remote_doesnot_exist(git_repository *repo, const char *name)
|
|
217
188
|
return GIT_EEXISTS;
|
218
189
|
}
|
219
190
|
|
220
|
-
int
|
191
|
+
int git_remote_create_options_init(git_remote_create_options *opts, unsigned int version)
|
221
192
|
{
|
222
193
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
223
194
|
opts, version, git_remote_create_options, GIT_REMOTE_CREATE_OPTIONS_INIT);
|
224
195
|
return 0;
|
225
196
|
}
|
226
197
|
|
198
|
+
int git_remote_create_init_options(git_remote_create_options *opts, unsigned int version)
|
199
|
+
{
|
200
|
+
return git_remote_create_options_init(opts, version);
|
201
|
+
}
|
202
|
+
|
227
203
|
int git_remote_create_with_opts(git_remote **out, const char *url, const git_remote_create_options *opts)
|
228
204
|
{
|
229
205
|
git_remote *remote = NULL;
|
@@ -670,21 +646,44 @@ int git_remote_set_pushurl(git_repository *repo, const char *remote, const char*
|
|
670
646
|
return set_url(repo, remote, CONFIG_PUSHURL_FMT, url);
|
671
647
|
}
|
672
648
|
|
673
|
-
|
649
|
+
static int resolve_url(git_buf *resolved_url, const char *url, int direction, const git_remote_callbacks *callbacks)
|
674
650
|
{
|
675
|
-
|
651
|
+
int status;
|
652
|
+
|
653
|
+
if (callbacks && callbacks->resolve_url) {
|
654
|
+
git_buf_clear(resolved_url);
|
655
|
+
status = callbacks->resolve_url(resolved_url, url, direction, callbacks->payload);
|
656
|
+
if (status != GIT_PASSTHROUGH) {
|
657
|
+
git_error_set_after_callback_function(status, "git_resolve_url_cb");
|
658
|
+
git_buf_sanitize(resolved_url);
|
659
|
+
return status;
|
660
|
+
}
|
661
|
+
}
|
676
662
|
|
663
|
+
return git_buf_sets(resolved_url, url);
|
664
|
+
}
|
665
|
+
|
666
|
+
int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int direction, const git_remote_callbacks *callbacks)
|
667
|
+
{
|
668
|
+
const char *url = NULL;
|
669
|
+
|
670
|
+
assert(remote);
|
677
671
|
assert(direction == GIT_DIRECTION_FETCH || direction == GIT_DIRECTION_PUSH);
|
678
672
|
|
679
673
|
if (direction == GIT_DIRECTION_FETCH) {
|
680
|
-
|
674
|
+
url = remote->url;
|
675
|
+
} else if (direction == GIT_DIRECTION_PUSH) {
|
676
|
+
url = remote->pushurl ? remote->pushurl : remote->url;
|
681
677
|
}
|
682
678
|
|
683
|
-
if (
|
684
|
-
|
679
|
+
if (!url) {
|
680
|
+
git_error_set(GIT_ERROR_INVALID,
|
681
|
+
"malformed remote '%s' - missing %s URL",
|
682
|
+
remote->name ? remote->name : "(anonymous)",
|
683
|
+
direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
|
684
|
+
return GIT_EINVALID;
|
685
685
|
}
|
686
|
-
|
687
|
-
return NULL;
|
686
|
+
return resolve_url(url_out, url, direction, callbacks);
|
688
687
|
}
|
689
688
|
|
690
689
|
int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs)
|
@@ -707,11 +706,11 @@ static int set_transport_custom_headers(git_transport *t, const git_strarray *cu
|
|
707
706
|
int git_remote__connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_remote_connection_opts *conn)
|
708
707
|
{
|
709
708
|
git_transport *t;
|
710
|
-
|
709
|
+
git_buf url = GIT_BUF_INIT;
|
711
710
|
int flags = GIT_TRANSPORTFLAGS_NONE;
|
712
711
|
int error;
|
713
712
|
void *payload = NULL;
|
714
|
-
|
713
|
+
git_credential_acquire_cb credentials = NULL;
|
715
714
|
git_transport_cb transport = NULL;
|
716
715
|
|
717
716
|
assert(remote);
|
@@ -728,39 +727,38 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r
|
|
728
727
|
|
729
728
|
t = remote->transport;
|
730
729
|
|
731
|
-
|
732
|
-
|
733
|
-
git_error_set(GIT_ERROR_INVALID,
|
734
|
-
"Malformed remote '%s' - missing %s URL",
|
735
|
-
remote->name ? remote->name : "(anonymous)",
|
736
|
-
direction == GIT_DIRECTION_FETCH ? "fetch" : "push");
|
737
|
-
return -1;
|
738
|
-
}
|
730
|
+
if ((error = git_remote__urlfordirection(&url, remote, direction, callbacks)) < 0)
|
731
|
+
goto on_error;
|
739
732
|
|
740
733
|
/* If we don't have a transport object yet, and the caller specified a
|
741
734
|
* custom transport factory, use that */
|
742
735
|
if (!t && transport &&
|
743
736
|
(error = transport(&t, remote, payload)) < 0)
|
744
|
-
|
737
|
+
goto on_error;
|
745
738
|
|
746
739
|
/* If we still don't have a transport, then use the global
|
747
740
|
* transport registrations which map URI schemes to transport factories */
|
748
|
-
if (!t && (error = git_transport_new(&t, remote, url)) < 0)
|
749
|
-
|
741
|
+
if (!t && (error = git_transport_new(&t, remote, url.ptr)) < 0)
|
742
|
+
goto on_error;
|
750
743
|
|
751
744
|
if ((error = set_transport_custom_headers(t, conn->custom_headers)) != 0)
|
752
745
|
goto on_error;
|
753
746
|
|
754
747
|
if ((error = set_transport_callbacks(t, callbacks)) < 0 ||
|
755
|
-
(error = t->connect(t, url, credentials, payload, conn->proxy, direction, flags)) != 0)
|
748
|
+
(error = t->connect(t, url.ptr, credentials, payload, conn->proxy, direction, flags)) != 0)
|
756
749
|
goto on_error;
|
757
750
|
|
758
751
|
remote->transport = t;
|
759
752
|
|
753
|
+
git_buf_dispose(&url);
|
754
|
+
|
760
755
|
return 0;
|
761
756
|
|
762
757
|
on_error:
|
763
|
-
|
758
|
+
if (t)
|
759
|
+
t->free(t);
|
760
|
+
|
761
|
+
git_buf_dispose(&url);
|
764
762
|
|
765
763
|
if (t == remote->transport)
|
766
764
|
remote->transport = NULL;
|
@@ -1678,20 +1676,24 @@ int git_remote_connected(const git_remote *remote)
|
|
1678
1676
|
return remote->transport->is_connected(remote->transport);
|
1679
1677
|
}
|
1680
1678
|
|
1681
|
-
|
1679
|
+
int git_remote_stop(git_remote *remote)
|
1682
1680
|
{
|
1683
1681
|
assert(remote);
|
1684
1682
|
|
1685
1683
|
if (remote->transport && remote->transport->cancel)
|
1686
1684
|
remote->transport->cancel(remote->transport);
|
1685
|
+
|
1686
|
+
return 0;
|
1687
1687
|
}
|
1688
1688
|
|
1689
|
-
|
1689
|
+
int git_remote_disconnect(git_remote *remote)
|
1690
1690
|
{
|
1691
1691
|
assert(remote);
|
1692
1692
|
|
1693
1693
|
if (git_remote_connected(remote))
|
1694
1694
|
remote->transport->close(remote->transport);
|
1695
|
+
|
1696
|
+
return 0;
|
1695
1697
|
}
|
1696
1698
|
|
1697
1699
|
void git_remote_free(git_remote *remote)
|
@@ -1770,7 +1772,7 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
|
|
1770
1772
|
return 0;
|
1771
1773
|
}
|
1772
1774
|
|
1773
|
-
const
|
1775
|
+
const git_indexer_progress *git_remote_stats(git_remote *remote)
|
1774
1776
|
{
|
1775
1777
|
assert(remote);
|
1776
1778
|
return &remote->stats;
|
data/vendor/libgit2/src/remote.h
CHANGED
@@ -29,7 +29,7 @@ struct git_remote {
|
|
29
29
|
git_transport *transport;
|
30
30
|
git_repository *repo;
|
31
31
|
git_push *push;
|
32
|
-
|
32
|
+
git_indexer_progress stats;
|
33
33
|
unsigned int need_pack;
|
34
34
|
git_remote_autotag_option_t download_tags;
|
35
35
|
int prune_refs;
|
@@ -45,7 +45,7 @@ typedef struct git_remote_connection_opts {
|
|
45
45
|
|
46
46
|
int git_remote__connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_remote_connection_opts *conn);
|
47
47
|
|
48
|
-
|
48
|
+
int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int direction, const git_remote_callbacks *callbacks);
|
49
49
|
int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url);
|
50
50
|
|
51
51
|
git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname);
|
@@ -16,7 +16,7 @@
|
|
16
16
|
#include "commit.h"
|
17
17
|
#include "tag.h"
|
18
18
|
#include "blob.h"
|
19
|
-
#include "
|
19
|
+
#include "futils.h"
|
20
20
|
#include "sysdir.h"
|
21
21
|
#include "filebuf.h"
|
22
22
|
#include "index.h"
|
@@ -42,23 +42,24 @@ bool git_repository__fsync_gitdir = false;
|
|
42
42
|
|
43
43
|
static const struct {
|
44
44
|
git_repository_item_t parent;
|
45
|
+
git_repository_item_t fallback;
|
45
46
|
const char *name;
|
46
47
|
bool directory;
|
47
48
|
} items[] = {
|
48
|
-
{ GIT_REPOSITORY_ITEM_GITDIR, NULL, true },
|
49
|
-
{ GIT_REPOSITORY_ITEM_WORKDIR, NULL, true },
|
50
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, NULL, true },
|
51
|
-
{ GIT_REPOSITORY_ITEM_GITDIR, "index", false },
|
52
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "objects", true },
|
53
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "refs", true },
|
54
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "packed-refs", false },
|
55
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "remotes", true },
|
56
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "config", false },
|
57
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "info", true },
|
58
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "hooks", true },
|
59
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "logs", true },
|
60
|
-
{ GIT_REPOSITORY_ITEM_GITDIR, "modules", true },
|
61
|
-
{ GIT_REPOSITORY_ITEM_COMMONDIR, "worktrees", true }
|
49
|
+
{ GIT_REPOSITORY_ITEM_GITDIR, GIT_REPOSITORY_ITEM__LAST, NULL, true },
|
50
|
+
{ GIT_REPOSITORY_ITEM_WORKDIR, GIT_REPOSITORY_ITEM__LAST, NULL, true },
|
51
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM__LAST, NULL, true },
|
52
|
+
{ GIT_REPOSITORY_ITEM_GITDIR, GIT_REPOSITORY_ITEM__LAST, "index", false },
|
53
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "objects", true },
|
54
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "refs", true },
|
55
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "packed-refs", false },
|
56
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "remotes", true },
|
57
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "config", false },
|
58
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "info", true },
|
59
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "hooks", true },
|
60
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "logs", true },
|
61
|
+
{ GIT_REPOSITORY_ITEM_GITDIR, GIT_REPOSITORY_ITEM__LAST, "modules", true },
|
62
|
+
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "worktrees", true }
|
62
63
|
};
|
63
64
|
|
64
65
|
static int check_repositoryformatversion(git_config *config);
|
@@ -121,7 +122,7 @@ static void set_config(git_repository *repo, git_config *config)
|
|
121
122
|
git_config_free(config);
|
122
123
|
}
|
123
124
|
|
124
|
-
|
125
|
+
git_repository__configmap_lookup_cache_clear(repo);
|
125
126
|
}
|
126
127
|
|
127
128
|
static void set_index(git_repository *repo, git_index *index)
|
@@ -137,7 +138,7 @@ static void set_index(git_repository *repo, git_index *index)
|
|
137
138
|
}
|
138
139
|
}
|
139
140
|
|
140
|
-
|
141
|
+
int git_repository__cleanup(git_repository *repo)
|
141
142
|
{
|
142
143
|
assert(repo);
|
143
144
|
|
@@ -149,6 +150,8 @@ void git_repository__cleanup(git_repository *repo)
|
|
149
150
|
set_index(repo, NULL);
|
150
151
|
set_odb(repo, NULL);
|
151
152
|
set_refdb(repo, NULL);
|
153
|
+
|
154
|
+
return 0;
|
152
155
|
}
|
153
156
|
|
154
157
|
void git_repository_free(git_repository *repo)
|
@@ -160,7 +163,7 @@ void git_repository_free(git_repository *repo)
|
|
160
163
|
|
161
164
|
git_repository__cleanup(repo);
|
162
165
|
|
163
|
-
|
166
|
+
git_cache_dispose(&repo->objects);
|
164
167
|
|
165
168
|
git_diff_driver_registry_free(repo->diff_drivers);
|
166
169
|
repo->diff_drivers = NULL;
|
@@ -186,19 +189,25 @@ void git_repository_free(git_repository *repo)
|
|
186
189
|
*
|
187
190
|
* Open a repository object from its path
|
188
191
|
*/
|
189
|
-
static bool
|
192
|
+
static int is_valid_repository_path(bool *out, git_buf *repository_path, git_buf *common_path)
|
190
193
|
{
|
194
|
+
int error;
|
195
|
+
|
196
|
+
*out = false;
|
197
|
+
|
191
198
|
/* Check if we have a separate commondir (e.g. we have a
|
192
199
|
* worktree) */
|
193
200
|
if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
|
194
201
|
git_buf common_link = GIT_BUF_INIT;
|
195
|
-
git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE);
|
196
202
|
|
197
|
-
|
198
|
-
|
203
|
+
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
|
204
|
+
(error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
|
205
|
+
return error;
|
199
206
|
|
207
|
+
git_buf_rtrim(&common_link);
|
200
208
|
if (git_path_is_relative(common_link.ptr)) {
|
201
|
-
git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)
|
209
|
+
if ((error = git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)) < 0)
|
210
|
+
return error;
|
202
211
|
} else {
|
203
212
|
git_buf_swap(common_path, &common_link);
|
204
213
|
}
|
@@ -206,24 +215,26 @@ static bool valid_repository_path(git_buf *repository_path, git_buf *common_path
|
|
206
215
|
git_buf_dispose(&common_link);
|
207
216
|
}
|
208
217
|
else {
|
209
|
-
git_buf_set(common_path, repository_path->ptr, repository_path->size)
|
218
|
+
if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0)
|
219
|
+
return error;
|
210
220
|
}
|
211
221
|
|
212
222
|
/* Make sure the commondir path always has a trailing * slash */
|
213
223
|
if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1)
|
214
|
-
git_buf_putc(common_path, '/')
|
224
|
+
if ((error = git_buf_putc(common_path, '/')) < 0)
|
225
|
+
return error;
|
215
226
|
|
216
227
|
/* Ensure HEAD file exists */
|
217
228
|
if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false)
|
218
|
-
return
|
219
|
-
|
229
|
+
return 0;
|
220
230
|
/* Check files in common dir */
|
221
231
|
if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false)
|
222
|
-
return
|
232
|
+
return 0;
|
223
233
|
if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false)
|
224
|
-
return
|
234
|
+
return 0;
|
225
235
|
|
226
|
-
|
236
|
+
*out = true;
|
237
|
+
return 0;
|
227
238
|
}
|
228
239
|
|
229
240
|
static git_repository *repository_alloc(void)
|
@@ -238,14 +249,14 @@ static git_repository *repository_alloc(void)
|
|
238
249
|
if (!repo->reserved_names.ptr)
|
239
250
|
goto on_error;
|
240
251
|
|
241
|
-
/* set all the entries in the
|
242
|
-
|
252
|
+
/* set all the entries in the configmap cache to `unset` */
|
253
|
+
git_repository__configmap_lookup_cache_clear(repo);
|
243
254
|
|
244
255
|
return repo;
|
245
256
|
|
246
257
|
on_error:
|
247
258
|
if (repo)
|
248
|
-
|
259
|
+
git_cache_dispose(&repo->objects);
|
249
260
|
|
250
261
|
git__free(repo);
|
251
262
|
return NULL;
|
@@ -438,15 +449,15 @@ static int find_repo(
|
|
438
449
|
uint32_t flags,
|
439
450
|
const char *ceiling_dirs)
|
440
451
|
{
|
441
|
-
int error;
|
442
452
|
git_buf path = GIT_BUF_INIT;
|
443
453
|
git_buf repo_link = GIT_BUF_INIT;
|
444
454
|
git_buf common_link = GIT_BUF_INIT;
|
445
455
|
struct stat st;
|
446
456
|
dev_t initial_device = 0;
|
447
457
|
int min_iterations;
|
448
|
-
bool in_dot_git;
|
458
|
+
bool in_dot_git, is_valid;
|
449
459
|
size_t ceiling_offset = 0;
|
460
|
+
int error;
|
450
461
|
|
451
462
|
git_buf_clear(gitdir_path);
|
452
463
|
|
@@ -472,9 +483,8 @@ static int find_repo(
|
|
472
483
|
for (;;) {
|
473
484
|
if (!(flags & GIT_REPOSITORY_OPEN_NO_DOTGIT)) {
|
474
485
|
if (!in_dot_git) {
|
475
|
-
error = git_buf_joinpath(&path, path.ptr, DOT_GIT)
|
476
|
-
|
477
|
-
break;
|
486
|
+
if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
|
487
|
+
goto out;
|
478
488
|
}
|
479
489
|
in_dot_git = !in_dot_git;
|
480
490
|
}
|
@@ -488,28 +498,33 @@ static int find_repo(
|
|
488
498
|
break;
|
489
499
|
|
490
500
|
if (S_ISDIR(st.st_mode)) {
|
491
|
-
if (
|
492
|
-
|
493
|
-
|
501
|
+
if ((error = is_valid_repository_path(&is_valid, &path, &common_link)) < 0)
|
502
|
+
goto out;
|
503
|
+
|
504
|
+
if (is_valid) {
|
505
|
+
if ((error = git_path_to_dir(&path)) < 0 ||
|
506
|
+
(error = git_buf_set(gitdir_path, path.ptr, path.size)) < 0)
|
507
|
+
goto out;
|
494
508
|
|
495
509
|
if (gitlink_path)
|
496
|
-
git_buf_attach(gitlink_path,
|
497
|
-
|
510
|
+
if ((error = git_buf_attach(gitlink_path, git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0)) < 0)
|
511
|
+
goto out;
|
498
512
|
if (commondir_path)
|
499
513
|
git_buf_swap(&common_link, commondir_path);
|
500
514
|
|
501
515
|
break;
|
502
516
|
}
|
503
|
-
}
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
if (
|
517
|
+
} else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) {
|
518
|
+
if ((error = read_gitfile(&repo_link, path.ptr)) < 0 ||
|
519
|
+
(error = is_valid_repository_path(&is_valid, &repo_link, &common_link)) < 0)
|
520
|
+
goto out;
|
521
|
+
|
522
|
+
if (is_valid) {
|
509
523
|
git_buf_swap(gitdir_path, &repo_link);
|
510
524
|
|
511
525
|
if (gitlink_path)
|
512
|
-
error = git_buf_put(gitlink_path, path.ptr, path.size)
|
526
|
+
if ((error = git_buf_put(gitlink_path, path.ptr, path.size)) < 0)
|
527
|
+
goto out;
|
513
528
|
if (commondir_path)
|
514
529
|
git_buf_swap(&common_link, commondir_path);
|
515
530
|
}
|
@@ -520,10 +535,8 @@ static int find_repo(
|
|
520
535
|
/* Move up one directory. If we're in_dot_git, we'll search the
|
521
536
|
* parent itself next. If we're !in_dot_git, we'll search .git
|
522
537
|
* in the parent directory next (added at the top of the loop). */
|
523
|
-
if (git_path_dirname_r(&path, path.ptr) < 0)
|
524
|
-
|
525
|
-
break;
|
526
|
-
}
|
538
|
+
if ((error = git_path_dirname_r(&path, path.ptr)) < 0)
|
539
|
+
goto out;
|
527
540
|
|
528
541
|
/* Once we've checked the directory (and .git if applicable),
|
529
542
|
* find the ceiling for a search. */
|
@@ -531,31 +544,28 @@ static int find_repo(
|
|
531
544
|
ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
|
532
545
|
|
533
546
|
/* Check if we should stop searching here. */
|
534
|
-
if (min_iterations == 0
|
535
|
-
|
536
|
-
|| (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
|
547
|
+
if (min_iterations == 0 &&
|
548
|
+
(path.ptr[ceiling_offset] == 0 || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
|
537
549
|
break;
|
538
550
|
}
|
539
551
|
|
540
|
-
if (
|
552
|
+
if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
|
541
553
|
if (!git_buf_len(gitdir_path))
|
542
554
|
git_buf_clear(workdir_path);
|
543
|
-
else
|
544
|
-
|
545
|
-
|
546
|
-
}
|
547
|
-
if (git_buf_oom(workdir_path))
|
548
|
-
return -1;
|
555
|
+
else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 ||
|
556
|
+
(error = git_path_to_dir(workdir_path)) < 0)
|
557
|
+
goto out;
|
549
558
|
}
|
550
559
|
|
551
560
|
/* If we didn't find the repository, and we don't have any other error
|
552
561
|
* to report, report that. */
|
553
|
-
if (!git_buf_len(gitdir_path)
|
554
|
-
git_error_set(GIT_ERROR_REPOSITORY,
|
555
|
-
"could not find repository from '%s'", start_path);
|
562
|
+
if (!git_buf_len(gitdir_path)) {
|
563
|
+
git_error_set(GIT_ERROR_REPOSITORY, "could not find repository from '%s'", start_path);
|
556
564
|
error = GIT_ENOTFOUND;
|
565
|
+
goto out;
|
557
566
|
}
|
558
567
|
|
568
|
+
out:
|
559
569
|
git_buf_dispose(&path);
|
560
570
|
git_buf_dispose(&repo_link);
|
561
571
|
git_buf_dispose(&common_link);
|
@@ -566,14 +576,16 @@ int git_repository_open_bare(
|
|
566
576
|
git_repository **repo_ptr,
|
567
577
|
const char *bare_path)
|
568
578
|
{
|
569
|
-
int error;
|
570
579
|
git_buf path = GIT_BUF_INIT, common_path = GIT_BUF_INIT;
|
571
580
|
git_repository *repo = NULL;
|
581
|
+
bool is_valid;
|
582
|
+
int error;
|
572
583
|
|
573
|
-
if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0
|
584
|
+
if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0 ||
|
585
|
+
(error = is_valid_repository_path(&is_valid, &path, &common_path)) < 0)
|
574
586
|
return error;
|
575
587
|
|
576
|
-
if (!
|
588
|
+
if (!is_valid) {
|
577
589
|
git_buf_dispose(&path);
|
578
590
|
git_buf_dispose(&common_path);
|
579
591
|
git_error_set(GIT_ERROR_REPOSITORY, "path is not a repository: %s", bare_path);
|
@@ -799,7 +811,7 @@ int git_repository_open_ext(
|
|
799
811
|
unsigned is_worktree;
|
800
812
|
git_buf gitdir = GIT_BUF_INIT, workdir = GIT_BUF_INIT,
|
801
813
|
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
|
802
|
-
git_repository *repo;
|
814
|
+
git_repository *repo = NULL;
|
803
815
|
git_config *config = NULL;
|
804
816
|
|
805
817
|
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
|
@@ -812,7 +824,7 @@ int git_repository_open_ext(
|
|
812
824
|
&gitdir, &workdir, &gitlink, &commondir, start_path, flags, ceiling_dirs);
|
813
825
|
|
814
826
|
if (error < 0 || !repo_ptr)
|
815
|
-
|
827
|
+
goto cleanup;
|
816
828
|
|
817
829
|
repo = repository_alloc();
|
818
830
|
GIT_ERROR_CHECK_ALLOC(repo);
|
@@ -858,11 +870,13 @@ int git_repository_open_ext(
|
|
858
870
|
cleanup:
|
859
871
|
git_buf_dispose(&gitdir);
|
860
872
|
git_buf_dispose(&workdir);
|
873
|
+
git_buf_dispose(&gitlink);
|
874
|
+
git_buf_dispose(&commondir);
|
861
875
|
git_config_free(config);
|
862
876
|
|
863
877
|
if (error < 0)
|
864
878
|
git_repository_free(repo);
|
865
|
-
else
|
879
|
+
else if (repo_ptr)
|
866
880
|
*repo_ptr = repo;
|
867
881
|
|
868
882
|
return error;
|
@@ -878,7 +892,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
|
|
878
892
|
{
|
879
893
|
git_buf path = GIT_BUF_INIT;
|
880
894
|
git_repository *repo = NULL;
|
881
|
-
|
895
|
+
size_t len;
|
896
|
+
int err;
|
882
897
|
|
883
898
|
assert(repo_out && wt);
|
884
899
|
|
@@ -1066,10 +1081,11 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
|
|
1066
1081
|
return git_config_snapshot(out, weak);
|
1067
1082
|
}
|
1068
1083
|
|
1069
|
-
|
1084
|
+
int git_repository_set_config(git_repository *repo, git_config *config)
|
1070
1085
|
{
|
1071
1086
|
assert(repo && config);
|
1072
1087
|
set_config(repo, config);
|
1088
|
+
return 0;
|
1073
1089
|
}
|
1074
1090
|
|
1075
1091
|
int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
|
@@ -1117,10 +1133,11 @@ int git_repository_odb(git_odb **out, git_repository *repo)
|
|
1117
1133
|
return 0;
|
1118
1134
|
}
|
1119
1135
|
|
1120
|
-
|
1136
|
+
int git_repository_set_odb(git_repository *repo, git_odb *odb)
|
1121
1137
|
{
|
1122
1138
|
assert(repo && odb);
|
1123
1139
|
set_odb(repo, odb);
|
1140
|
+
return 0;
|
1124
1141
|
}
|
1125
1142
|
|
1126
1143
|
int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
|
@@ -1157,10 +1174,11 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
|
|
1157
1174
|
return 0;
|
1158
1175
|
}
|
1159
1176
|
|
1160
|
-
|
1177
|
+
int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
|
1161
1178
|
{
|
1162
1179
|
assert(repo && refdb);
|
1163
1180
|
set_refdb(repo, refdb);
|
1181
|
+
return 0;
|
1164
1182
|
}
|
1165
1183
|
|
1166
1184
|
int git_repository_index__weakptr(git_index **out, git_repository *repo)
|
@@ -1206,10 +1224,11 @@ int git_repository_index(git_index **out, git_repository *repo)
|
|
1206
1224
|
return 0;
|
1207
1225
|
}
|
1208
1226
|
|
1209
|
-
|
1227
|
+
int git_repository_set_index(git_repository *repo, git_index *index)
|
1210
1228
|
{
|
1211
1229
|
assert(repo);
|
1212
1230
|
set_index(repo, index);
|
1231
|
+
return 0;
|
1213
1232
|
}
|
1214
1233
|
|
1215
1234
|
int git_repository_set_namespace(git_repository *repo, const char *namespace)
|
@@ -1285,8 +1304,8 @@ bool git_repository__reserved_names(
|
|
1285
1304
|
int (*prefixcmp)(const char *, const char *);
|
1286
1305
|
int error, ignorecase;
|
1287
1306
|
|
1288
|
-
error =
|
1289
|
-
&ignorecase, repo,
|
1307
|
+
error = git_repository__configmap_lookup(
|
1308
|
+
&ignorecase, repo, GIT_CONFIGMAP_IGNORECASE);
|
1290
1309
|
prefixcmp = (error || ignorecase) ? git__prefixcmp_icase :
|
1291
1310
|
git__prefixcmp;
|
1292
1311
|
|
@@ -1358,10 +1377,11 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
|
|
1358
1377
|
git_buf ref_path = GIT_BUF_INIT;
|
1359
1378
|
git_filebuf ref = GIT_FILEBUF_INIT;
|
1360
1379
|
const char *fmt;
|
1380
|
+
int error;
|
1361
1381
|
|
1362
|
-
if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 ||
|
1363
|
-
|
1364
|
-
goto
|
1382
|
+
if ((error = git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE)) < 0 ||
|
1383
|
+
(error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
|
1384
|
+
goto out;
|
1365
1385
|
|
1366
1386
|
if (!ref_name)
|
1367
1387
|
ref_name = GIT_BRANCH_MASTER;
|
@@ -1371,17 +1391,14 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
|
|
1371
1391
|
else
|
1372
1392
|
fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n";
|
1373
1393
|
|
1374
|
-
if (git_filebuf_printf(&ref, fmt, ref_name) < 0 ||
|
1375
|
-
|
1376
|
-
goto
|
1377
|
-
|
1378
|
-
git_buf_dispose(&ref_path);
|
1379
|
-
return 0;
|
1394
|
+
if ((error = git_filebuf_printf(&ref, fmt, ref_name)) < 0 ||
|
1395
|
+
(error = git_filebuf_commit(&ref)) < 0)
|
1396
|
+
goto out;
|
1380
1397
|
|
1381
|
-
|
1398
|
+
out:
|
1382
1399
|
git_buf_dispose(&ref_path);
|
1383
1400
|
git_filebuf_cleanup(&ref);
|
1384
|
-
return
|
1401
|
+
return error;
|
1385
1402
|
}
|
1386
1403
|
|
1387
1404
|
static bool is_chmod_supported(const char *file_path)
|
@@ -1419,9 +1436,6 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1419
1436
|
git_buf xdg_buf = GIT_BUF_INIT;
|
1420
1437
|
git_buf system_buf = GIT_BUF_INIT;
|
1421
1438
|
git_buf programdata_buf = GIT_BUF_INIT;
|
1422
|
-
git_buf path = GIT_BUF_INIT;
|
1423
|
-
int fd;
|
1424
|
-
struct stat st;
|
1425
1439
|
int symlinks = 0;
|
1426
1440
|
|
1427
1441
|
/*
|
@@ -1448,23 +1462,14 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1448
1462
|
goto done;
|
1449
1463
|
#endif
|
1450
1464
|
|
1451
|
-
if ((
|
1452
|
-
p_close(fd) < 0 ||
|
1453
|
-
p_unlink(path.ptr) < 0 ||
|
1454
|
-
p_symlink("testing", path.ptr) < 0 ||
|
1455
|
-
p_lstat(path.ptr, &st) < 0)
|
1465
|
+
if (!(symlinks = git_path_supports_symlinks(wd_path)))
|
1456
1466
|
goto done;
|
1457
1467
|
|
1458
|
-
symlinks = (S_ISLNK(st.st_mode) != 0);
|
1459
|
-
|
1460
|
-
(void)p_unlink(path.ptr);
|
1461
|
-
|
1462
1468
|
done:
|
1463
1469
|
git_buf_dispose(&global_buf);
|
1464
1470
|
git_buf_dispose(&xdg_buf);
|
1465
1471
|
git_buf_dispose(&system_buf);
|
1466
1472
|
git_buf_dispose(&programdata_buf);
|
1467
|
-
git_buf_dispose(&path);
|
1468
1473
|
git_config_free(config);
|
1469
1474
|
return symlinks != 0;
|
1470
1475
|
}
|
@@ -1658,7 +1663,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse)
|
|
1658
1663
|
git_config_free(config);
|
1659
1664
|
git_buf_dispose(&path);
|
1660
1665
|
|
1661
|
-
|
1666
|
+
git_repository__configmap_lookup_cache_clear(repo);
|
1662
1667
|
|
1663
1668
|
if (!repo->is_bare && recurse)
|
1664
1669
|
(void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL);
|
@@ -2056,53 +2061,63 @@ int git_repository_init_ext(
|
|
2056
2061
|
const char *given_repo,
|
2057
2062
|
git_repository_init_options *opts)
|
2058
2063
|
{
|
2059
|
-
int error;
|
2060
2064
|
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
|
2061
|
-
common_path = GIT_BUF_INIT;
|
2065
|
+
common_path = GIT_BUF_INIT, head_path = GIT_BUF_INIT;
|
2062
2066
|
const char *wd;
|
2067
|
+
bool is_valid;
|
2068
|
+
int error;
|
2063
2069
|
|
2064
2070
|
assert(out && given_repo && opts);
|
2065
2071
|
|
2066
2072
|
GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
|
2067
2073
|
|
2068
|
-
error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)
|
2069
|
-
|
2070
|
-
goto cleanup;
|
2074
|
+
if ((error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)) < 0)
|
2075
|
+
goto out;
|
2071
2076
|
|
2072
2077
|
wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path);
|
2073
|
-
if (valid_repository_path(&repo_path, &common_path)) {
|
2074
2078
|
|
2079
|
+
if ((error = is_valid_repository_path(&is_valid, &repo_path, &common_path)) < 0)
|
2080
|
+
goto out;
|
2081
|
+
|
2082
|
+
if (is_valid) {
|
2075
2083
|
if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) {
|
2076
2084
|
git_error_set(GIT_ERROR_REPOSITORY,
|
2077
2085
|
"attempt to reinitialize '%s'", given_repo);
|
2078
2086
|
error = GIT_EEXISTS;
|
2079
|
-
goto
|
2087
|
+
goto out;
|
2080
2088
|
}
|
2081
2089
|
|
2082
2090
|
opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT;
|
2083
2091
|
|
2084
|
-
error = repo_init_config(
|
2085
|
-
|
2092
|
+
if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0)
|
2093
|
+
goto out;
|
2086
2094
|
|
2087
2095
|
/* TODO: reinitialize the templates */
|
2096
|
+
} else {
|
2097
|
+
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
|
2098
|
+
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
|
2099
|
+
(error = git_buf_joinpath(&head_path, repo_path.ptr, GIT_HEAD_FILE)) < 0)
|
2100
|
+
goto out;
|
2101
|
+
|
2102
|
+
/*
|
2103
|
+
* Only set the new HEAD if the file does not exist already via
|
2104
|
+
* a template or if the caller has explicitly supplied an
|
2105
|
+
* initial HEAD value.
|
2106
|
+
*/
|
2107
|
+
if ((!git_path_exists(head_path.ptr) || opts->initial_head) &&
|
2108
|
+
(error = git_repository_create_head(repo_path.ptr, opts->initial_head)) < 0)
|
2109
|
+
goto out;
|
2088
2110
|
}
|
2089
|
-
else {
|
2090
|
-
if (!(error = repo_init_structure(
|
2091
|
-
repo_path.ptr, wd, opts)) &&
|
2092
|
-
!(error = repo_init_config(
|
2093
|
-
repo_path.ptr, wd, opts->flags, opts->mode)))
|
2094
|
-
error = git_repository_create_head(
|
2095
|
-
repo_path.ptr, opts->initial_head);
|
2096
|
-
}
|
2097
|
-
if (error < 0)
|
2098
|
-
goto cleanup;
|
2099
2111
|
|
2100
|
-
error = git_repository_open(out, repo_path.ptr)
|
2112
|
+
if ((error = git_repository_open(out, repo_path.ptr)) < 0)
|
2113
|
+
goto out;
|
2101
2114
|
|
2102
|
-
if (
|
2103
|
-
|
2115
|
+
if (opts->origin_url &&
|
2116
|
+
(error = repo_init_create_origin(*out, opts->origin_url)) < 0)
|
2117
|
+
goto out;
|
2104
2118
|
|
2105
|
-
|
2119
|
+
out:
|
2120
|
+
git_buf_dispose(&head_path);
|
2106
2121
|
git_buf_dispose(&common_path);
|
2107
2122
|
git_buf_dispose(&repo_path);
|
2108
2123
|
git_buf_dispose(&wd_path);
|
@@ -2210,30 +2225,37 @@ out:
|
|
2210
2225
|
return error;
|
2211
2226
|
}
|
2212
2227
|
|
2213
|
-
int git_repository_foreach_head(git_repository *repo,
|
2228
|
+
int git_repository_foreach_head(git_repository *repo,
|
2229
|
+
git_repository_foreach_head_cb cb,
|
2230
|
+
int flags, void *payload)
|
2214
2231
|
{
|
2215
2232
|
git_strarray worktrees = GIT_VECTOR_INIT;
|
2216
2233
|
git_buf path = GIT_BUF_INIT;
|
2217
|
-
int error;
|
2234
|
+
int error = 0;
|
2218
2235
|
size_t i;
|
2219
2236
|
|
2220
|
-
/* Execute callback for HEAD of commondir */
|
2221
|
-
if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
|
2222
|
-
(error = cb(repo, path.ptr, payload) != 0))
|
2223
|
-
goto out;
|
2224
2237
|
|
2225
|
-
if ((
|
2226
|
-
|
2227
|
-
|
2238
|
+
if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO)) {
|
2239
|
+
/* Gather HEAD of main repository */
|
2240
|
+
if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 ||
|
2241
|
+
(error = cb(repo, path.ptr, payload) != 0))
|
2242
|
+
goto out;
|
2228
2243
|
}
|
2229
2244
|
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
continue;
|
2234
|
-
|
2235
|
-
if ((error = cb(repo, path.ptr, payload)) != 0)
|
2245
|
+
if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES)) {
|
2246
|
+
if ((error = git_worktree_list(&worktrees, repo)) < 0) {
|
2247
|
+
error = 0;
|
2236
2248
|
goto out;
|
2249
|
+
}
|
2250
|
+
|
2251
|
+
/* Gather HEADs of all worktrees */
|
2252
|
+
for (i = 0; i < worktrees.count; i++) {
|
2253
|
+
if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0)
|
2254
|
+
continue;
|
2255
|
+
|
2256
|
+
if ((error = cb(repo, path.ptr, payload)) != 0)
|
2257
|
+
goto out;
|
2258
|
+
}
|
2237
2259
|
}
|
2238
2260
|
|
2239
2261
|
out:
|
@@ -2300,11 +2322,11 @@ int git_repository_is_empty(git_repository *repo)
|
|
2300
2322
|
return is_empty;
|
2301
2323
|
}
|
2302
2324
|
|
2303
|
-
|
2325
|
+
static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
|
2304
2326
|
{
|
2305
2327
|
const char *parent;
|
2306
2328
|
|
2307
|
-
switch (
|
2329
|
+
switch (item) {
|
2308
2330
|
case GIT_REPOSITORY_ITEM_GITDIR:
|
2309
2331
|
parent = git_repository_path(repo);
|
2310
2332
|
break;
|
@@ -2316,9 +2338,17 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
|
|
2316
2338
|
break;
|
2317
2339
|
default:
|
2318
2340
|
git_error_set(GIT_ERROR_INVALID, "invalid item directory");
|
2319
|
-
return
|
2341
|
+
return NULL;
|
2320
2342
|
}
|
2343
|
+
if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST)
|
2344
|
+
return resolved_parent_path(repo, fallback, GIT_REPOSITORY_ITEM__LAST);
|
2321
2345
|
|
2346
|
+
return parent;
|
2347
|
+
}
|
2348
|
+
|
2349
|
+
int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
|
2350
|
+
{
|
2351
|
+
const char *parent = resolved_parent_path(repo, items[item].parent, items[item].fallback);
|
2322
2352
|
if (parent == NULL) {
|
2323
2353
|
git_error_set(GIT_ERROR_INVALID, "path cannot exist in repository");
|
2324
2354
|
return GIT_ENOTFOUND;
|
@@ -2473,7 +2503,7 @@ int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head
|
|
2473
2503
|
git_oid_fmt(orig_head_str, orig_head);
|
2474
2504
|
|
2475
2505
|
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_ORIG_HEAD_FILE)) == 0 &&
|
2476
|
-
(error = git_filebuf_open(&file, file_path.ptr,
|
2506
|
+
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) == 0 &&
|
2477
2507
|
(error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0)
|
2478
2508
|
error = git_filebuf_commit(&file);
|
2479
2509
|
|
@@ -2533,7 +2563,7 @@ int git_repository_hashfile(
|
|
2533
2563
|
int error;
|
2534
2564
|
git_filter_list *fl = NULL;
|
2535
2565
|
git_file fd = -1;
|
2536
|
-
|
2566
|
+
uint64_t len;
|
2537
2567
|
git_buf full_path = GIT_BUF_INIT;
|
2538
2568
|
|
2539
2569
|
assert(out && path && repo); /* as_path can be NULL */
|
@@ -2570,11 +2600,8 @@ int git_repository_hashfile(
|
|
2570
2600
|
goto cleanup;
|
2571
2601
|
}
|
2572
2602
|
|
2573
|
-
|
2574
|
-
if (len < 0) {
|
2575
|
-
error = (int)len;
|
2603
|
+
if ((error = git_futils_filesize(&len, fd)) < 0)
|
2576
2604
|
goto cleanup;
|
2577
|
-
}
|
2578
2605
|
|
2579
2606
|
if (!git__is_sizet(len)) {
|
2580
2607
|
git_error_set(GIT_ERROR_OS, "file size overflow for 32-bit systems");
|
@@ -2863,7 +2890,7 @@ int git_repository_is_shallow(git_repository *repo)
|
|
2863
2890
|
return st.st_size == 0 ? 0 : 1;
|
2864
2891
|
}
|
2865
2892
|
|
2866
|
-
int
|
2893
|
+
int git_repository_init_options_init(
|
2867
2894
|
git_repository_init_options *opts, unsigned int version)
|
2868
2895
|
{
|
2869
2896
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
@@ -2872,6 +2899,12 @@ int git_repository_init_init_options(
|
|
2872
2899
|
return 0;
|
2873
2900
|
}
|
2874
2901
|
|
2902
|
+
int git_repository_init_init_options(
|
2903
|
+
git_repository_init_options *opts, unsigned int version)
|
2904
|
+
{
|
2905
|
+
return git_repository_init_options_init(opts, version);
|
2906
|
+
}
|
2907
|
+
|
2875
2908
|
int git_repository_ident(const char **name, const char **email, const git_repository *repo)
|
2876
2909
|
{
|
2877
2910
|
*name = repo->ident_name;
|
@@ -2909,7 +2942,7 @@ int git_repository_submodule_cache_all(git_repository *repo)
|
|
2909
2942
|
|
2910
2943
|
assert(repo);
|
2911
2944
|
|
2912
|
-
if ((error =
|
2945
|
+
if ((error = git_strmap_new(&repo->submodule_cache)))
|
2913
2946
|
return error;
|
2914
2947
|
|
2915
2948
|
error = git_submodule__map(repo, repo->submodule_cache);
|