rugged 0.28.5 → 1.1.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 +18 -16
- 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 +17 -4
- 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/CMakeLists.txt +57 -75
- data/vendor/libgit2/COPYING +28 -0
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +5 -1
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +2 -2
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +1 -1
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +28 -0
- data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
- data/vendor/libgit2/cmake/FindPCRE.cmake +38 -0
- data/vendor/libgit2/cmake/FindPCRE2.cmake +37 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +2 -2
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +6 -0
- data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +77 -0
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +48 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +120 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +61 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/http-parser/http_parser.c +11 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +25 -0
- data/vendor/libgit2/deps/ntlmclient/compat.h +28 -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 +1419 -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 +35 -0
- data/vendor/libgit2/deps/ntlmclient/util.h +15 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +140 -0
- data/vendor/libgit2/deps/pcre/COPYING +5 -0
- data/vendor/libgit2/deps/pcre/LICENCE +93 -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 +9812 -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 +420 -0
- data/vendor/libgit2/deps/pcre/pcreposix.h +117 -0
- data/vendor/libgit2/deps/pcre/ucp.h +224 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +0 -7
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2.h +2 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/apply.h +24 -2
- data/vendor/libgit2/include/git2/attr.h +23 -13
- data/vendor/libgit2/include/git2/blame.h +4 -2
- data/vendor/libgit2/include/git2/blob.h +61 -13
- 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 +34 -8
- data/vendor/libgit2/include/git2/config.h +13 -13
- 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 +362 -4
- data/vendor/libgit2/include/git2/describe.h +4 -4
- data/vendor/libgit2/include/git2/diff.h +17 -15
- data/vendor/libgit2/include/git2/errors.h +5 -2
- data/vendor/libgit2/include/git2/filter.h +8 -0
- data/vendor/libgit2/include/git2/index.h +5 -5
- data/vendor/libgit2/include/git2/indexer.h +49 -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 +18 -22
- 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 +13 -2
- 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 +22 -3
- data/vendor/libgit2/include/git2/remote.h +40 -15
- data/vendor/libgit2/include/git2/repository.h +124 -58
- 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/strarray.h +6 -10
- 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 +7 -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 +147 -272
- 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 +36 -16
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr.c +70 -64
- data/vendor/libgit2/src/attr_file.c +197 -99
- data/vendor/libgit2/src/attr_file.h +9 -9
- data/vendor/libgit2/src/attrcache.c +48 -49
- data/vendor/libgit2/src/attrcache.h +2 -1
- data/vendor/libgit2/src/blame.c +34 -15
- data/vendor/libgit2/src/blame.h +1 -1
- data/vendor/libgit2/src/blame_git.c +27 -10
- data/vendor/libgit2/src/blob.c +92 -17
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +68 -42
- data/vendor/libgit2/src/buffer.c +11 -3
- data/vendor/libgit2/src/buffer.h +1 -0
- data/vendor/libgit2/src/cache.c +34 -58
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +5 -0
- data/vendor/libgit2/src/checkout.c +73 -86
- data/vendor/libgit2/src/cherrypick.c +9 -1
- data/vendor/libgit2/src/clone.c +130 -27
- 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 +4 -75
- data/vendor/libgit2/src/config.c +34 -47
- data/vendor/libgit2/src/config.h +7 -6
- data/vendor/libgit2/src/config_backend.h +12 -0
- data/vendor/libgit2/src/config_cache.c +42 -39
- data/vendor/libgit2/src/config_entries.c +76 -98
- 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 +50 -30
- data/vendor/libgit2/src/config_parse.h +13 -12
- data/vendor/libgit2/src/config_snapshot.c +207 -0
- data/vendor/libgit2/src/crlf.c +14 -14
- data/vendor/libgit2/src/describe.c +26 -21
- data/vendor/libgit2/src/diff.c +53 -75
- data/vendor/libgit2/src/diff.h +4 -3
- data/vendor/libgit2/src/diff_driver.c +37 -38
- data/vendor/libgit2/src/diff_file.c +15 -11
- data/vendor/libgit2/src/diff_file.h +2 -2
- data/vendor/libgit2/src/diff_generate.c +36 -37
- data/vendor/libgit2/src/diff_generate.h +2 -2
- data/vendor/libgit2/src/diff_parse.c +3 -4
- data/vendor/libgit2/src/diff_print.c +86 -71
- data/vendor/libgit2/src/diff_stats.c +13 -12
- data/vendor/libgit2/src/diff_tform.c +15 -16
- data/vendor/libgit2/src/errors.c +23 -25
- data/vendor/libgit2/src/errors.h +81 -0
- data/vendor/libgit2/src/features.h.in +9 -2
- data/vendor/libgit2/src/fetch.c +9 -2
- data/vendor/libgit2/src/fetchhead.c +9 -9
- data/vendor/libgit2/src/filebuf.c +1 -1
- data/vendor/libgit2/src/filebuf.h +1 -1
- data/vendor/libgit2/src/filter.c +19 -11
- data/vendor/libgit2/src/{fileops.c → futils.c} +23 -20
- data/vendor/libgit2/src/{fileops.h → futils.h} +8 -8
- data/vendor/libgit2/src/global.c +3 -1
- 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/{refdb_fs.h → hash/sha1/openssl.h} +8 -8
- 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 +73 -69
- data/vendor/libgit2/src/idxmap.h +151 -15
- data/vendor/libgit2/src/ignore.c +26 -35
- data/vendor/libgit2/src/index.c +123 -95
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +99 -78
- data/vendor/libgit2/src/integer.h +26 -4
- data/vendor/libgit2/src/iterator.c +36 -32
- data/vendor/libgit2/src/iterator.h +8 -8
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +93 -57
- data/vendor/libgit2/src/merge.h +2 -2
- data/vendor/libgit2/src/merge_driver.c +5 -5
- data/vendor/libgit2/src/merge_file.c +5 -7
- data/vendor/libgit2/src/midx.c +418 -0
- data/vendor/libgit2/src/midx.h +83 -0
- data/vendor/libgit2/src/mwindow.c +144 -74
- data/vendor/libgit2/src/mwindow.h +4 -4
- data/vendor/libgit2/src/net.c +416 -0
- data/vendor/libgit2/src/net.h +57 -0
- data/vendor/libgit2/src/netops.c +6 -222
- data/vendor/libgit2/src/netops.h +1 -37
- data/vendor/libgit2/src/notes.c +8 -5
- data/vendor/libgit2/src/object.c +5 -4
- data/vendor/libgit2/src/object.h +2 -0
- data/vendor/libgit2/src/odb.c +54 -32
- data/vendor/libgit2/src/odb.h +3 -2
- data/vendor/libgit2/src/odb_loose.c +20 -13
- data/vendor/libgit2/src/odb_mempack.c +15 -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 +21 -8
- data/vendor/libgit2/src/oidmap.c +39 -57
- data/vendor/libgit2/src/oidmap.h +99 -19
- data/vendor/libgit2/src/pack-objects.c +55 -52
- data/vendor/libgit2/src/pack-objects.h +1 -1
- data/vendor/libgit2/src/pack.c +160 -149
- data/vendor/libgit2/src/pack.h +32 -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 -4
- data/vendor/libgit2/src/patch_parse.c +34 -11
- data/vendor/libgit2/src/path.c +47 -10
- data/vendor/libgit2/src/path.h +2 -0
- data/vendor/libgit2/src/pathspec.c +18 -17
- data/vendor/libgit2/src/pool.c +42 -32
- data/vendor/libgit2/src/pool.h +15 -7
- data/vendor/libgit2/src/posix.c +39 -16
- data/vendor/libgit2/src/posix.h +21 -1
- data/vendor/libgit2/src/proxy.c +9 -2
- data/vendor/libgit2/src/push.c +15 -7
- data/vendor/libgit2/src/reader.c +2 -2
- data/vendor/libgit2/src/rebase.c +89 -28
- data/vendor/libgit2/src/refdb.c +147 -0
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +230 -241
- data/vendor/libgit2/src/reflog.c +13 -19
- data/vendor/libgit2/src/refs.c +113 -217
- data/vendor/libgit2/src/refs.h +10 -21
- data/vendor/libgit2/src/refspec.c +57 -48
- data/vendor/libgit2/src/regexp.c +221 -0
- data/vendor/libgit2/src/regexp.h +97 -0
- data/vendor/libgit2/src/remote.c +102 -79
- data/vendor/libgit2/src/remote.h +2 -2
- data/vendor/libgit2/src/repository.c +322 -203
- data/vendor/libgit2/src/repository.h +49 -57
- data/vendor/libgit2/src/revert.c +8 -1
- data/vendor/libgit2/src/revparse.c +23 -23
- data/vendor/libgit2/src/revwalk.c +73 -37
- data/vendor/libgit2/src/revwalk.h +20 -0
- data/vendor/libgit2/src/settings.c +22 -1
- data/vendor/libgit2/src/sortedcache.c +14 -29
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +49 -67
- data/vendor/libgit2/src/status.c +19 -11
- data/vendor/libgit2/src/strarray.c +63 -0
- data/vendor/libgit2/src/streams/openssl.c +66 -8
- data/vendor/libgit2/src/streams/registry.c +5 -3
- 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 +157 -130
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +4 -20
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +12 -2
- data/vendor/libgit2/src/thread-utils.h +163 -40
- 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 +5 -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 +478 -0
- data/vendor/libgit2/src/transports/{cred_helpers.c → credential_helpers.c} +23 -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 +1552 -0
- data/vendor/libgit2/src/transports/httpclient.h +190 -0
- data/vendor/libgit2/src/transports/local.c +12 -12
- data/vendor/libgit2/src/transports/smart.c +21 -21
- data/vendor/libgit2/src/transports/smart.h +3 -3
- 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 +368 -285
- 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 +16 -11
- data/vendor/libgit2/src/userdiff.h +3 -1
- data/vendor/libgit2/src/util.c +75 -110
- data/vendor/libgit2/src/util.h +18 -23
- data/vendor/libgit2/src/wildmatch.c +320 -0
- data/vendor/libgit2/src/wildmatch.h +23 -0
- data/vendor/libgit2/src/win32/git2.rc +18 -3
- data/vendor/libgit2/src/win32/map.c +3 -5
- data/vendor/libgit2/src/win32/path_w32.c +42 -5
- 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 +117 -5
- data/vendor/libgit2/src/win32/precompiled.h +0 -2
- data/vendor/libgit2/src/win32/thread.c +5 -5
- 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 +91 -50
- 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 +123 -53
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- 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
@@ -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,35 +42,38 @@ 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
|
-
static int check_repositoryformatversion(git_config *config);
|
65
|
+
static int check_repositoryformatversion(int *version, git_config *config);
|
66
|
+
static int check_extensions(git_config *config, int version);
|
65
67
|
|
66
68
|
#define GIT_COMMONDIR_FILE "commondir"
|
67
69
|
#define GIT_GITDIR_FILE "gitdir"
|
68
70
|
|
69
71
|
#define GIT_FILE_CONTENT_PREFIX "gitdir:"
|
70
72
|
|
71
|
-
#define
|
73
|
+
#define GIT_BRANCH_DEFAULT "master"
|
72
74
|
|
73
75
|
#define GIT_REPO_VERSION 0
|
76
|
+
#define GIT_REPO_MAX_VERSION 1
|
74
77
|
|
75
78
|
git_buf git_repository__reserved_names_win32[] = {
|
76
79
|
{ DOT_GIT, 0, CONST_STRLEN(DOT_GIT) },
|
@@ -121,7 +124,7 @@ static void set_config(git_repository *repo, git_config *config)
|
|
121
124
|
git_config_free(config);
|
122
125
|
}
|
123
126
|
|
124
|
-
|
127
|
+
git_repository__configmap_lookup_cache_clear(repo);
|
125
128
|
}
|
126
129
|
|
127
130
|
static void set_index(git_repository *repo, git_index *index)
|
@@ -137,7 +140,7 @@ static void set_index(git_repository *repo, git_index *index)
|
|
137
140
|
}
|
138
141
|
}
|
139
142
|
|
140
|
-
|
143
|
+
int git_repository__cleanup(git_repository *repo)
|
141
144
|
{
|
142
145
|
assert(repo);
|
143
146
|
|
@@ -149,6 +152,8 @@ void git_repository__cleanup(git_repository *repo)
|
|
149
152
|
set_index(repo, NULL);
|
150
153
|
set_odb(repo, NULL);
|
151
154
|
set_refdb(repo, NULL);
|
155
|
+
|
156
|
+
return 0;
|
152
157
|
}
|
153
158
|
|
154
159
|
void git_repository_free(git_repository *repo)
|
@@ -160,7 +165,7 @@ void git_repository_free(git_repository *repo)
|
|
160
165
|
|
161
166
|
git_repository__cleanup(repo);
|
162
167
|
|
163
|
-
|
168
|
+
git_cache_dispose(&repo->objects);
|
164
169
|
|
165
170
|
git_diff_driver_registry_free(repo->diff_drivers);
|
166
171
|
repo->diff_drivers = NULL;
|
@@ -186,19 +191,25 @@ void git_repository_free(git_repository *repo)
|
|
186
191
|
*
|
187
192
|
* Open a repository object from its path
|
188
193
|
*/
|
189
|
-
static bool
|
194
|
+
static int is_valid_repository_path(bool *out, git_buf *repository_path, git_buf *common_path)
|
190
195
|
{
|
196
|
+
int error;
|
197
|
+
|
198
|
+
*out = false;
|
199
|
+
|
191
200
|
/* Check if we have a separate commondir (e.g. we have a
|
192
201
|
* worktree) */
|
193
202
|
if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
|
194
203
|
git_buf common_link = GIT_BUF_INIT;
|
195
|
-
git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE);
|
196
204
|
|
197
|
-
|
198
|
-
|
205
|
+
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
|
206
|
+
(error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
|
207
|
+
return error;
|
199
208
|
|
209
|
+
git_buf_rtrim(&common_link);
|
200
210
|
if (git_path_is_relative(common_link.ptr)) {
|
201
|
-
git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)
|
211
|
+
if ((error = git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)) < 0)
|
212
|
+
return error;
|
202
213
|
} else {
|
203
214
|
git_buf_swap(common_path, &common_link);
|
204
215
|
}
|
@@ -206,24 +217,26 @@ static bool valid_repository_path(git_buf *repository_path, git_buf *common_path
|
|
206
217
|
git_buf_dispose(&common_link);
|
207
218
|
}
|
208
219
|
else {
|
209
|
-
git_buf_set(common_path, repository_path->ptr, repository_path->size)
|
220
|
+
if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0)
|
221
|
+
return error;
|
210
222
|
}
|
211
223
|
|
212
224
|
/* Make sure the commondir path always has a trailing * slash */
|
213
225
|
if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1)
|
214
|
-
git_buf_putc(common_path, '/')
|
226
|
+
if ((error = git_buf_putc(common_path, '/')) < 0)
|
227
|
+
return error;
|
215
228
|
|
216
229
|
/* Ensure HEAD file exists */
|
217
230
|
if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false)
|
218
|
-
return
|
219
|
-
|
231
|
+
return 0;
|
220
232
|
/* Check files in common dir */
|
221
233
|
if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false)
|
222
|
-
return
|
234
|
+
return 0;
|
223
235
|
if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false)
|
224
|
-
return
|
236
|
+
return 0;
|
225
237
|
|
226
|
-
|
238
|
+
*out = true;
|
239
|
+
return 0;
|
227
240
|
}
|
228
241
|
|
229
242
|
static git_repository *repository_alloc(void)
|
@@ -238,14 +251,14 @@ static git_repository *repository_alloc(void)
|
|
238
251
|
if (!repo->reserved_names.ptr)
|
239
252
|
goto on_error;
|
240
253
|
|
241
|
-
/* set all the entries in the
|
242
|
-
|
254
|
+
/* set all the entries in the configmap cache to `unset` */
|
255
|
+
git_repository__configmap_lookup_cache_clear(repo);
|
243
256
|
|
244
257
|
return repo;
|
245
258
|
|
246
259
|
on_error:
|
247
260
|
if (repo)
|
248
|
-
|
261
|
+
git_cache_dispose(&repo->objects);
|
249
262
|
|
250
263
|
git__free(repo);
|
251
264
|
return NULL;
|
@@ -438,15 +451,15 @@ static int find_repo(
|
|
438
451
|
uint32_t flags,
|
439
452
|
const char *ceiling_dirs)
|
440
453
|
{
|
441
|
-
int error;
|
442
454
|
git_buf path = GIT_BUF_INIT;
|
443
455
|
git_buf repo_link = GIT_BUF_INIT;
|
444
456
|
git_buf common_link = GIT_BUF_INIT;
|
445
457
|
struct stat st;
|
446
458
|
dev_t initial_device = 0;
|
447
459
|
int min_iterations;
|
448
|
-
bool in_dot_git;
|
460
|
+
bool in_dot_git, is_valid;
|
449
461
|
size_t ceiling_offset = 0;
|
462
|
+
int error;
|
450
463
|
|
451
464
|
git_buf_clear(gitdir_path);
|
452
465
|
|
@@ -472,9 +485,8 @@ static int find_repo(
|
|
472
485
|
for (;;) {
|
473
486
|
if (!(flags & GIT_REPOSITORY_OPEN_NO_DOTGIT)) {
|
474
487
|
if (!in_dot_git) {
|
475
|
-
error = git_buf_joinpath(&path, path.ptr, DOT_GIT)
|
476
|
-
|
477
|
-
break;
|
488
|
+
if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
|
489
|
+
goto out;
|
478
490
|
}
|
479
491
|
in_dot_git = !in_dot_git;
|
480
492
|
}
|
@@ -488,28 +500,33 @@ static int find_repo(
|
|
488
500
|
break;
|
489
501
|
|
490
502
|
if (S_ISDIR(st.st_mode)) {
|
491
|
-
if (
|
492
|
-
|
493
|
-
|
503
|
+
if ((error = is_valid_repository_path(&is_valid, &path, &common_link)) < 0)
|
504
|
+
goto out;
|
505
|
+
|
506
|
+
if (is_valid) {
|
507
|
+
if ((error = git_path_to_dir(&path)) < 0 ||
|
508
|
+
(error = git_buf_set(gitdir_path, path.ptr, path.size)) < 0)
|
509
|
+
goto out;
|
494
510
|
|
495
511
|
if (gitlink_path)
|
496
|
-
git_buf_attach(gitlink_path,
|
497
|
-
|
512
|
+
if ((error = git_buf_attach(gitlink_path, git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0)) < 0)
|
513
|
+
goto out;
|
498
514
|
if (commondir_path)
|
499
515
|
git_buf_swap(&common_link, commondir_path);
|
500
516
|
|
501
517
|
break;
|
502
518
|
}
|
503
|
-
}
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
if (
|
519
|
+
} else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) {
|
520
|
+
if ((error = read_gitfile(&repo_link, path.ptr)) < 0 ||
|
521
|
+
(error = is_valid_repository_path(&is_valid, &repo_link, &common_link)) < 0)
|
522
|
+
goto out;
|
523
|
+
|
524
|
+
if (is_valid) {
|
509
525
|
git_buf_swap(gitdir_path, &repo_link);
|
510
526
|
|
511
527
|
if (gitlink_path)
|
512
|
-
error = git_buf_put(gitlink_path, path.ptr, path.size)
|
528
|
+
if ((error = git_buf_put(gitlink_path, path.ptr, path.size)) < 0)
|
529
|
+
goto out;
|
513
530
|
if (commondir_path)
|
514
531
|
git_buf_swap(&common_link, commondir_path);
|
515
532
|
}
|
@@ -520,10 +537,8 @@ static int find_repo(
|
|
520
537
|
/* Move up one directory. If we're in_dot_git, we'll search the
|
521
538
|
* parent itself next. If we're !in_dot_git, we'll search .git
|
522
539
|
* 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
|
-
}
|
540
|
+
if ((error = git_path_dirname_r(&path, path.ptr)) < 0)
|
541
|
+
goto out;
|
527
542
|
|
528
543
|
/* Once we've checked the directory (and .git if applicable),
|
529
544
|
* find the ceiling for a search. */
|
@@ -531,31 +546,28 @@ static int find_repo(
|
|
531
546
|
ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
|
532
547
|
|
533
548
|
/* Check if we should stop searching here. */
|
534
|
-
if (min_iterations == 0
|
535
|
-
|
536
|
-
|| (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
|
549
|
+
if (min_iterations == 0 &&
|
550
|
+
(path.ptr[ceiling_offset] == 0 || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))
|
537
551
|
break;
|
538
552
|
}
|
539
553
|
|
540
|
-
if (
|
554
|
+
if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
|
541
555
|
if (!git_buf_len(gitdir_path))
|
542
556
|
git_buf_clear(workdir_path);
|
543
|
-
else
|
544
|
-
|
545
|
-
|
546
|
-
}
|
547
|
-
if (git_buf_oom(workdir_path))
|
548
|
-
return -1;
|
557
|
+
else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 ||
|
558
|
+
(error = git_path_to_dir(workdir_path)) < 0)
|
559
|
+
goto out;
|
549
560
|
}
|
550
561
|
|
551
562
|
/* If we didn't find the repository, and we don't have any other error
|
552
563
|
* 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);
|
564
|
+
if (!git_buf_len(gitdir_path)) {
|
565
|
+
git_error_set(GIT_ERROR_REPOSITORY, "could not find repository from '%s'", start_path);
|
556
566
|
error = GIT_ENOTFOUND;
|
567
|
+
goto out;
|
557
568
|
}
|
558
569
|
|
570
|
+
out:
|
559
571
|
git_buf_dispose(&path);
|
560
572
|
git_buf_dispose(&repo_link);
|
561
573
|
git_buf_dispose(&common_link);
|
@@ -566,14 +578,16 @@ int git_repository_open_bare(
|
|
566
578
|
git_repository **repo_ptr,
|
567
579
|
const char *bare_path)
|
568
580
|
{
|
569
|
-
int error;
|
570
581
|
git_buf path = GIT_BUF_INIT, common_path = GIT_BUF_INIT;
|
571
582
|
git_repository *repo = NULL;
|
583
|
+
bool is_valid;
|
584
|
+
int error;
|
572
585
|
|
573
|
-
if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0
|
586
|
+
if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0 ||
|
587
|
+
(error = is_valid_repository_path(&is_valid, &path, &common_path)) < 0)
|
574
588
|
return error;
|
575
589
|
|
576
|
-
if (!
|
590
|
+
if (!is_valid) {
|
577
591
|
git_buf_dispose(&path);
|
578
592
|
git_buf_dispose(&common_path);
|
579
593
|
git_error_set(GIT_ERROR_REPOSITORY, "path is not a repository: %s", bare_path);
|
@@ -801,6 +815,7 @@ int git_repository_open_ext(
|
|
801
815
|
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
|
802
816
|
git_repository *repo = NULL;
|
803
817
|
git_config *config = NULL;
|
818
|
+
int version = 0;
|
804
819
|
|
805
820
|
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
|
806
821
|
return _git_repository_open_ext_from_env(repo_ptr, start_path);
|
@@ -842,7 +857,10 @@ int git_repository_open_ext(
|
|
842
857
|
if (error < 0 && error != GIT_ENOTFOUND)
|
843
858
|
goto cleanup;
|
844
859
|
|
845
|
-
if (config && (error = check_repositoryformatversion(config)) < 0)
|
860
|
+
if (config && (error = check_repositoryformatversion(&version, config)) < 0)
|
861
|
+
goto cleanup;
|
862
|
+
|
863
|
+
if ((error = check_extensions(config, version)) < 0)
|
846
864
|
goto cleanup;
|
847
865
|
|
848
866
|
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
|
@@ -864,8 +882,7 @@ cleanup:
|
|
864
882
|
|
865
883
|
if (error < 0)
|
866
884
|
git_repository_free(repo);
|
867
|
-
|
868
|
-
if (repo_ptr)
|
885
|
+
else if (repo_ptr)
|
869
886
|
*repo_ptr = repo;
|
870
887
|
|
871
888
|
return error;
|
@@ -881,7 +898,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
|
|
881
898
|
{
|
882
899
|
git_buf path = GIT_BUF_INIT;
|
883
900
|
git_repository *repo = NULL;
|
884
|
-
|
901
|
+
size_t len;
|
902
|
+
int err;
|
885
903
|
|
886
904
|
assert(repo_out && wt);
|
887
905
|
|
@@ -1069,10 +1087,11 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
|
|
1069
1087
|
return git_config_snapshot(out, weak);
|
1070
1088
|
}
|
1071
1089
|
|
1072
|
-
|
1090
|
+
int git_repository_set_config(git_repository *repo, git_config *config)
|
1073
1091
|
{
|
1074
1092
|
assert(repo && config);
|
1075
1093
|
set_config(repo, config);
|
1094
|
+
return 0;
|
1076
1095
|
}
|
1077
1096
|
|
1078
1097
|
int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
|
@@ -1120,10 +1139,11 @@ int git_repository_odb(git_odb **out, git_repository *repo)
|
|
1120
1139
|
return 0;
|
1121
1140
|
}
|
1122
1141
|
|
1123
|
-
|
1142
|
+
int git_repository_set_odb(git_repository *repo, git_odb *odb)
|
1124
1143
|
{
|
1125
1144
|
assert(repo && odb);
|
1126
1145
|
set_odb(repo, odb);
|
1146
|
+
return 0;
|
1127
1147
|
}
|
1128
1148
|
|
1129
1149
|
int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
|
@@ -1160,10 +1180,11 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
|
|
1160
1180
|
return 0;
|
1161
1181
|
}
|
1162
1182
|
|
1163
|
-
|
1183
|
+
int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
|
1164
1184
|
{
|
1165
1185
|
assert(repo && refdb);
|
1166
1186
|
set_refdb(repo, refdb);
|
1187
|
+
return 0;
|
1167
1188
|
}
|
1168
1189
|
|
1169
1190
|
int git_repository_index__weakptr(git_index **out, git_repository *repo)
|
@@ -1209,10 +1230,11 @@ int git_repository_index(git_index **out, git_repository *repo)
|
|
1209
1230
|
return 0;
|
1210
1231
|
}
|
1211
1232
|
|
1212
|
-
|
1233
|
+
int git_repository_set_index(git_repository *repo, git_index *index)
|
1213
1234
|
{
|
1214
1235
|
assert(repo);
|
1215
1236
|
set_index(repo, index);
|
1237
|
+
return 0;
|
1216
1238
|
}
|
1217
1239
|
|
1218
1240
|
int git_repository_set_namespace(git_repository *repo, const char *namespace)
|
@@ -1288,8 +1310,8 @@ bool git_repository__reserved_names(
|
|
1288
1310
|
int (*prefixcmp)(const char *, const char *);
|
1289
1311
|
int error, ignorecase;
|
1290
1312
|
|
1291
|
-
error =
|
1292
|
-
&ignorecase, repo,
|
1313
|
+
error = git_repository__configmap_lookup(
|
1314
|
+
&ignorecase, repo, GIT_CONFIGMAP_IGNORECASE);
|
1293
1315
|
prefixcmp = (error || ignorecase) ? git__prefixcmp_icase :
|
1294
1316
|
git__prefixcmp;
|
1295
1317
|
|
@@ -1334,11 +1356,11 @@ bool git_repository__reserved_names(
|
|
1334
1356
|
}
|
1335
1357
|
#endif
|
1336
1358
|
|
1337
|
-
static int check_repositoryformatversion(git_config *config)
|
1359
|
+
static int check_repositoryformatversion(int *version, git_config *config)
|
1338
1360
|
{
|
1339
|
-
int
|
1361
|
+
int error;
|
1340
1362
|
|
1341
|
-
error = git_config_get_int32(
|
1363
|
+
error = git_config_get_int32(version, config, "core.repositoryformatversion");
|
1342
1364
|
/* git ignores this if the config variable isn't there */
|
1343
1365
|
if (error == GIT_ENOTFOUND)
|
1344
1366
|
return 0;
|
@@ -1346,45 +1368,59 @@ static int check_repositoryformatversion(git_config *config)
|
|
1346
1368
|
if (error < 0)
|
1347
1369
|
return -1;
|
1348
1370
|
|
1349
|
-
if (
|
1371
|
+
if (GIT_REPO_MAX_VERSION < *version) {
|
1350
1372
|
git_error_set(GIT_ERROR_REPOSITORY,
|
1351
|
-
"unsupported repository version %d
|
1352
|
-
version,
|
1373
|
+
"unsupported repository version %d; only versions up to %d are supported",
|
1374
|
+
*version, GIT_REPO_MAX_VERSION);
|
1353
1375
|
return -1;
|
1354
1376
|
}
|
1355
1377
|
|
1356
1378
|
return 0;
|
1357
1379
|
}
|
1358
1380
|
|
1381
|
+
static int check_valid_extension(const git_config_entry *entry, void *payload)
|
1382
|
+
{
|
1383
|
+
GIT_UNUSED(payload);
|
1384
|
+
|
1385
|
+
if (!strcmp(entry->name, "extensions.noop"))
|
1386
|
+
return 0;
|
1387
|
+
|
1388
|
+
git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name);
|
1389
|
+
return -1;
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
static int check_extensions(git_config *config, int version)
|
1393
|
+
{
|
1394
|
+
if (version < 1)
|
1395
|
+
return 0;
|
1396
|
+
|
1397
|
+
return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL);
|
1398
|
+
}
|
1399
|
+
|
1359
1400
|
int git_repository_create_head(const char *git_dir, const char *ref_name)
|
1360
1401
|
{
|
1361
1402
|
git_buf ref_path = GIT_BUF_INIT;
|
1362
1403
|
git_filebuf ref = GIT_FILEBUF_INIT;
|
1363
1404
|
const char *fmt;
|
1405
|
+
int error;
|
1364
1406
|
|
1365
|
-
if (git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE) < 0 ||
|
1366
|
-
|
1367
|
-
goto
|
1368
|
-
|
1369
|
-
if (!ref_name)
|
1370
|
-
ref_name = GIT_BRANCH_MASTER;
|
1407
|
+
if ((error = git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE)) < 0 ||
|
1408
|
+
(error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
|
1409
|
+
goto out;
|
1371
1410
|
|
1372
1411
|
if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0)
|
1373
1412
|
fmt = "ref: %s\n";
|
1374
1413
|
else
|
1375
1414
|
fmt = "ref: " GIT_REFS_HEADS_DIR "%s\n";
|
1376
1415
|
|
1377
|
-
if (git_filebuf_printf(&ref, fmt, ref_name) < 0 ||
|
1378
|
-
|
1379
|
-
goto
|
1380
|
-
|
1381
|
-
git_buf_dispose(&ref_path);
|
1382
|
-
return 0;
|
1416
|
+
if ((error = git_filebuf_printf(&ref, fmt, ref_name)) < 0 ||
|
1417
|
+
(error = git_filebuf_commit(&ref)) < 0)
|
1418
|
+
goto out;
|
1383
1419
|
|
1384
|
-
|
1420
|
+
out:
|
1385
1421
|
git_buf_dispose(&ref_path);
|
1386
1422
|
git_filebuf_cleanup(&ref);
|
1387
|
-
return
|
1423
|
+
return error;
|
1388
1424
|
}
|
1389
1425
|
|
1390
1426
|
static bool is_chmod_supported(const char *file_path)
|
@@ -1422,9 +1458,6 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1422
1458
|
git_buf xdg_buf = GIT_BUF_INIT;
|
1423
1459
|
git_buf system_buf = GIT_BUF_INIT;
|
1424
1460
|
git_buf programdata_buf = GIT_BUF_INIT;
|
1425
|
-
git_buf path = GIT_BUF_INIT;
|
1426
|
-
int fd;
|
1427
|
-
struct stat st;
|
1428
1461
|
int symlinks = 0;
|
1429
1462
|
|
1430
1463
|
/*
|
@@ -1451,23 +1484,14 @@ static bool are_symlinks_supported(const char *wd_path)
|
|
1451
1484
|
goto done;
|
1452
1485
|
#endif
|
1453
1486
|
|
1454
|
-
if ((
|
1455
|
-
p_close(fd) < 0 ||
|
1456
|
-
p_unlink(path.ptr) < 0 ||
|
1457
|
-
p_symlink("testing", path.ptr) < 0 ||
|
1458
|
-
p_lstat(path.ptr, &st) < 0)
|
1487
|
+
if (!(symlinks = git_path_supports_symlinks(wd_path)))
|
1459
1488
|
goto done;
|
1460
1489
|
|
1461
|
-
symlinks = (S_ISLNK(st.st_mode) != 0);
|
1462
|
-
|
1463
|
-
(void)p_unlink(path.ptr);
|
1464
|
-
|
1465
1490
|
done:
|
1466
1491
|
git_buf_dispose(&global_buf);
|
1467
1492
|
git_buf_dispose(&xdg_buf);
|
1468
1493
|
git_buf_dispose(&system_buf);
|
1469
1494
|
git_buf_dispose(&programdata_buf);
|
1470
|
-
git_buf_dispose(&path);
|
1471
1495
|
git_config_free(config);
|
1472
1496
|
return symlinks != 0;
|
1473
1497
|
}
|
@@ -1581,11 +1605,15 @@ static int repo_init_config(
|
|
1581
1605
|
git_config *config = NULL;
|
1582
1606
|
bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0);
|
1583
1607
|
bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0);
|
1608
|
+
int version = 0;
|
1584
1609
|
|
1585
1610
|
if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0)
|
1586
1611
|
goto cleanup;
|
1587
1612
|
|
1588
|
-
if (is_reinit && (error = check_repositoryformatversion(config)) < 0)
|
1613
|
+
if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0)
|
1614
|
+
goto cleanup;
|
1615
|
+
|
1616
|
+
if ((error = check_extensions(config, version)) < 0)
|
1589
1617
|
goto cleanup;
|
1590
1618
|
|
1591
1619
|
#define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \
|
@@ -1661,7 +1689,7 @@ int git_repository_reinit_filesystem(git_repository *repo, int recurse)
|
|
1661
1689
|
git_config_free(config);
|
1662
1690
|
git_buf_dispose(&path);
|
1663
1691
|
|
1664
|
-
|
1692
|
+
git_repository__configmap_lookup_cache_clear(repo);
|
1665
1693
|
|
1666
1694
|
if (!repo->is_bare && recurse)
|
1667
1695
|
(void)git_submodule_foreach(repo, repo_reinit_submodule_fs, NULL);
|
@@ -2030,6 +2058,44 @@ static int repo_init_directories(
|
|
2030
2058
|
return error;
|
2031
2059
|
}
|
2032
2060
|
|
2061
|
+
static int repo_init_head(const char *repo_dir, const char *given)
|
2062
|
+
{
|
2063
|
+
git_config *cfg = NULL;
|
2064
|
+
git_buf head_path = GIT_BUF_INIT, cfg_branch = GIT_BUF_INIT;
|
2065
|
+
const char *initial_head = NULL;
|
2066
|
+
int error;
|
2067
|
+
|
2068
|
+
if ((error = git_buf_joinpath(&head_path, repo_dir, GIT_HEAD_FILE)) < 0)
|
2069
|
+
goto out;
|
2070
|
+
|
2071
|
+
/*
|
2072
|
+
* A template may have set a HEAD; use that unless it's been
|
2073
|
+
* overridden by the caller's given initial head setting.
|
2074
|
+
*/
|
2075
|
+
if (git_path_exists(head_path.ptr) && !given)
|
2076
|
+
goto out;
|
2077
|
+
|
2078
|
+
if (given) {
|
2079
|
+
initial_head = given;
|
2080
|
+
} else if ((error = git_config_open_default(&cfg)) >= 0 &&
|
2081
|
+
(error = git_config_get_string_buf(&cfg_branch, cfg, "init.defaultbranch")) >= 0 &&
|
2082
|
+
*cfg_branch.ptr) {
|
2083
|
+
initial_head = cfg_branch.ptr;
|
2084
|
+
}
|
2085
|
+
|
2086
|
+
if (!initial_head)
|
2087
|
+
initial_head = GIT_BRANCH_DEFAULT;
|
2088
|
+
|
2089
|
+
error = git_repository_create_head(repo_dir, initial_head);
|
2090
|
+
|
2091
|
+
out:
|
2092
|
+
git_config_free(cfg);
|
2093
|
+
git_buf_dispose(&head_path);
|
2094
|
+
git_buf_dispose(&cfg_branch);
|
2095
|
+
|
2096
|
+
return error;
|
2097
|
+
}
|
2098
|
+
|
2033
2099
|
static int repo_init_create_origin(git_repository *repo, const char *url)
|
2034
2100
|
{
|
2035
2101
|
int error;
|
@@ -2059,53 +2125,53 @@ int git_repository_init_ext(
|
|
2059
2125
|
const char *given_repo,
|
2060
2126
|
git_repository_init_options *opts)
|
2061
2127
|
{
|
2062
|
-
int error;
|
2063
2128
|
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
|
2064
2129
|
common_path = GIT_BUF_INIT;
|
2065
2130
|
const char *wd;
|
2131
|
+
bool is_valid;
|
2132
|
+
int error;
|
2066
2133
|
|
2067
2134
|
assert(out && given_repo && opts);
|
2068
2135
|
|
2069
2136
|
GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
|
2070
2137
|
|
2071
|
-
error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)
|
2072
|
-
|
2073
|
-
goto cleanup;
|
2138
|
+
if ((error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)) < 0)
|
2139
|
+
goto out;
|
2074
2140
|
|
2075
2141
|
wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path);
|
2076
|
-
if (valid_repository_path(&repo_path, &common_path)) {
|
2077
2142
|
|
2143
|
+
if ((error = is_valid_repository_path(&is_valid, &repo_path, &common_path)) < 0)
|
2144
|
+
goto out;
|
2145
|
+
|
2146
|
+
if (is_valid) {
|
2078
2147
|
if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) {
|
2079
2148
|
git_error_set(GIT_ERROR_REPOSITORY,
|
2080
2149
|
"attempt to reinitialize '%s'", given_repo);
|
2081
2150
|
error = GIT_EEXISTS;
|
2082
|
-
goto
|
2151
|
+
goto out;
|
2083
2152
|
}
|
2084
2153
|
|
2085
2154
|
opts->flags |= GIT_REPOSITORY_INIT__IS_REINIT;
|
2086
2155
|
|
2087
|
-
error = repo_init_config(
|
2088
|
-
|
2156
|
+
if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0)
|
2157
|
+
goto out;
|
2089
2158
|
|
2090
2159
|
/* TODO: reinitialize the templates */
|
2160
|
+
} else {
|
2161
|
+
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
|
2162
|
+
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
|
2163
|
+
(error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0)
|
2164
|
+
goto out;
|
2091
2165
|
}
|
2092
|
-
else {
|
2093
|
-
if (!(error = repo_init_structure(
|
2094
|
-
repo_path.ptr, wd, opts)) &&
|
2095
|
-
!(error = repo_init_config(
|
2096
|
-
repo_path.ptr, wd, opts->flags, opts->mode)))
|
2097
|
-
error = git_repository_create_head(
|
2098
|
-
repo_path.ptr, opts->initial_head);
|
2099
|
-
}
|
2100
|
-
if (error < 0)
|
2101
|
-
goto cleanup;
|
2102
2166
|
|
2103
|
-
error = git_repository_open(out, repo_path.ptr)
|
2167
|
+
if ((error = git_repository_open(out, repo_path.ptr)) < 0)
|
2168
|
+
goto out;
|
2104
2169
|
|
2105
|
-
if (
|
2106
|
-
|
2170
|
+
if (opts->origin_url &&
|
2171
|
+
(error = repo_init_create_origin(*out, opts->origin_url)) < 0)
|
2172
|
+
goto out;
|
2107
2173
|
|
2108
|
-
|
2174
|
+
out:
|
2109
2175
|
git_buf_dispose(&common_path);
|
2110
2176
|
git_buf_dispose(&repo_path);
|
2111
2177
|
git_buf_dispose(&wd_path);
|
@@ -2136,12 +2202,6 @@ int git_repository_head_detached(git_repository *repo)
|
|
2136
2202
|
return exists;
|
2137
2203
|
}
|
2138
2204
|
|
2139
|
-
static int get_worktree_file_path(git_buf *out, git_repository *repo, const char *worktree, const char *file)
|
2140
|
-
{
|
2141
|
-
git_buf_clear(out);
|
2142
|
-
return git_buf_printf(out, "%s/worktrees/%s/%s", repo->commondir, worktree, file);
|
2143
|
-
}
|
2144
|
-
|
2145
2205
|
int git_repository_head_detached_for_worktree(git_repository *repo, const char *name)
|
2146
2206
|
{
|
2147
2207
|
git_reference *ref = NULL;
|
@@ -2182,7 +2242,8 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
|
|
2182
2242
|
|
2183
2243
|
int git_repository_head_for_worktree(git_reference **out, git_repository *repo, const char *name)
|
2184
2244
|
{
|
2185
|
-
|
2245
|
+
git_repository *worktree_repo = NULL;
|
2246
|
+
git_worktree *worktree = NULL;
|
2186
2247
|
git_reference *head = NULL;
|
2187
2248
|
int error;
|
2188
2249
|
|
@@ -2190,58 +2251,68 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
|
|
2190
2251
|
|
2191
2252
|
*out = NULL;
|
2192
2253
|
|
2193
|
-
if ((error =
|
2194
|
-
(error =
|
2254
|
+
if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 ||
|
2255
|
+
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 ||
|
2256
|
+
(error = git_reference_lookup(&head, worktree_repo, GIT_HEAD_FILE)) < 0)
|
2195
2257
|
goto out;
|
2196
2258
|
|
2197
2259
|
if (git_reference_type(head) != GIT_REFERENCE_DIRECT) {
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
head =
|
2260
|
+
if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0)
|
2261
|
+
goto out;
|
2262
|
+
} else {
|
2263
|
+
*out = head;
|
2264
|
+
head = NULL;
|
2203
2265
|
}
|
2204
2266
|
|
2205
|
-
*out = head;
|
2206
|
-
|
2207
2267
|
out:
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
git_buf_dispose(&path);
|
2212
|
-
|
2268
|
+
git_reference_free(head);
|
2269
|
+
git_worktree_free(worktree);
|
2270
|
+
git_repository_free(worktree_repo);
|
2213
2271
|
return error;
|
2214
2272
|
}
|
2215
2273
|
|
2216
|
-
int
|
2274
|
+
int git_repository_foreach_worktree(git_repository *repo,
|
2275
|
+
git_repository_foreach_worktree_cb cb,
|
2276
|
+
void *payload)
|
2217
2277
|
{
|
2218
|
-
git_strarray worktrees =
|
2219
|
-
|
2278
|
+
git_strarray worktrees = {0};
|
2279
|
+
git_repository *worktree_repo = NULL;
|
2280
|
+
git_worktree *worktree = NULL;
|
2220
2281
|
int error;
|
2221
2282
|
size_t i;
|
2222
2283
|
|
2223
|
-
|
2224
|
-
|
2225
|
-
(error = cb(repo, path.ptr, payload) != 0))
|
2284
|
+
if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
|
2285
|
+
(error = cb(worktree_repo, payload) != 0))
|
2226
2286
|
goto out;
|
2227
2287
|
|
2228
|
-
|
2229
|
-
|
2288
|
+
git_repository_free(worktree_repo);
|
2289
|
+
worktree_repo = NULL;
|
2290
|
+
|
2291
|
+
if ((error = git_worktree_list(&worktrees, repo)) < 0)
|
2230
2292
|
goto out;
|
2231
|
-
}
|
2232
2293
|
|
2233
|
-
/* Execute callback for all worktree HEADs */
|
2234
2294
|
for (i = 0; i < worktrees.count; i++) {
|
2235
|
-
|
2295
|
+
git_repository_free(worktree_repo);
|
2296
|
+
worktree_repo = NULL;
|
2297
|
+
git_worktree_free(worktree);
|
2298
|
+
worktree = NULL;
|
2299
|
+
|
2300
|
+
if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) ||
|
2301
|
+
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0) {
|
2302
|
+
if (error != GIT_ENOTFOUND)
|
2303
|
+
goto out;
|
2304
|
+
error = 0;
|
2236
2305
|
continue;
|
2306
|
+
}
|
2237
2307
|
|
2238
|
-
if ((error = cb(
|
2308
|
+
if ((error = cb(worktree_repo, payload)) != 0)
|
2239
2309
|
goto out;
|
2240
2310
|
}
|
2241
2311
|
|
2242
2312
|
out:
|
2243
|
-
|
2244
|
-
|
2313
|
+
git_strarray_dispose(&worktrees);
|
2314
|
+
git_repository_free(worktree_repo);
|
2315
|
+
git_worktree_free(worktree);
|
2245
2316
|
return error;
|
2246
2317
|
}
|
2247
2318
|
|
@@ -2264,50 +2335,85 @@ int git_repository_head_unborn(git_repository *repo)
|
|
2264
2335
|
return 0;
|
2265
2336
|
}
|
2266
2337
|
|
2267
|
-
static int
|
2338
|
+
static int repo_contains_no_reference(git_repository *repo)
|
2268
2339
|
{
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2340
|
+
git_reference_iterator *iter;
|
2341
|
+
const char *refname;
|
2342
|
+
int error;
|
2343
|
+
|
2344
|
+
if ((error = git_reference_iterator_new(&iter, repo)) < 0)
|
2345
|
+
return error;
|
2346
|
+
|
2347
|
+
error = git_reference_next_name(&refname, iter);
|
2348
|
+
git_reference_iterator_free(iter);
|
2349
|
+
|
2350
|
+
if (error == GIT_ITEROVER)
|
2351
|
+
return 1;
|
2352
|
+
|
2353
|
+
return error;
|
2272
2354
|
}
|
2273
2355
|
|
2274
|
-
|
2356
|
+
int git_repository_initialbranch(git_buf *out, git_repository *repo)
|
2275
2357
|
{
|
2276
|
-
|
2358
|
+
git_config *config;
|
2359
|
+
git_config_entry *entry = NULL;
|
2360
|
+
const char *branch;
|
2361
|
+
int error;
|
2277
2362
|
|
2278
|
-
if (error
|
2279
|
-
return
|
2363
|
+
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
|
2364
|
+
return error;
|
2280
2365
|
|
2281
|
-
if (
|
2282
|
-
|
2366
|
+
if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0 &&
|
2367
|
+
*entry->value) {
|
2368
|
+
branch = entry->value;
|
2369
|
+
}
|
2370
|
+
else if (!error || error == GIT_ENOTFOUND) {
|
2371
|
+
branch = GIT_BRANCH_DEFAULT;
|
2372
|
+
}
|
2373
|
+
else {
|
2374
|
+
goto done;
|
2375
|
+
}
|
2376
|
+
|
2377
|
+
if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
|
2378
|
+
(error = git_buf_puts(out, branch)) < 0)
|
2379
|
+
goto done;
|
2380
|
+
|
2381
|
+
if (!git_reference_is_valid_name(out->ptr)) {
|
2382
|
+
git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid branch name");
|
2383
|
+
error = -1;
|
2384
|
+
}
|
2283
2385
|
|
2386
|
+
done:
|
2387
|
+
git_config_entry_free(entry);
|
2284
2388
|
return error;
|
2285
2389
|
}
|
2286
2390
|
|
2287
2391
|
int git_repository_is_empty(git_repository *repo)
|
2288
2392
|
{
|
2289
2393
|
git_reference *head = NULL;
|
2290
|
-
|
2394
|
+
git_buf initialbranch = GIT_BUF_INIT;
|
2395
|
+
int result = 0;
|
2291
2396
|
|
2292
|
-
if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0
|
2293
|
-
|
2397
|
+
if ((result = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0 ||
|
2398
|
+
(result = git_repository_initialbranch(&initialbranch, repo)) < 0)
|
2399
|
+
goto done;
|
2294
2400
|
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
GIT_REFS_HEADS_DIR "master") == 0) &&
|
2299
|
-
repo_contains_no_reference(repo);
|
2401
|
+
result = (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC &&
|
2402
|
+
strcmp(git_reference_symbolic_target(head), initialbranch.ptr) == 0 &&
|
2403
|
+
repo_contains_no_reference(repo));
|
2300
2404
|
|
2405
|
+
done:
|
2301
2406
|
git_reference_free(head);
|
2407
|
+
git_buf_dispose(&initialbranch);
|
2302
2408
|
|
2303
|
-
return
|
2409
|
+
return result;
|
2304
2410
|
}
|
2305
2411
|
|
2306
|
-
|
2412
|
+
static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
|
2307
2413
|
{
|
2308
2414
|
const char *parent;
|
2309
2415
|
|
2310
|
-
switch (
|
2416
|
+
switch (item) {
|
2311
2417
|
case GIT_REPOSITORY_ITEM_GITDIR:
|
2312
2418
|
parent = git_repository_path(repo);
|
2313
2419
|
break;
|
@@ -2319,9 +2425,17 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
|
|
2319
2425
|
break;
|
2320
2426
|
default:
|
2321
2427
|
git_error_set(GIT_ERROR_INVALID, "invalid item directory");
|
2322
|
-
return
|
2428
|
+
return NULL;
|
2323
2429
|
}
|
2430
|
+
if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST)
|
2431
|
+
return resolved_parent_path(repo, fallback, GIT_REPOSITORY_ITEM__LAST);
|
2324
2432
|
|
2433
|
+
return parent;
|
2434
|
+
}
|
2435
|
+
|
2436
|
+
int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item)
|
2437
|
+
{
|
2438
|
+
const char *parent = resolved_parent_path(repo, items[item].parent, items[item].fallback);
|
2325
2439
|
if (parent == NULL) {
|
2326
2440
|
git_error_set(GIT_ERROR_INVALID, "path cannot exist in repository");
|
2327
2441
|
return GIT_ENOTFOUND;
|
@@ -2536,7 +2650,7 @@ int git_repository_hashfile(
|
|
2536
2650
|
int error;
|
2537
2651
|
git_filter_list *fl = NULL;
|
2538
2652
|
git_file fd = -1;
|
2539
|
-
|
2653
|
+
uint64_t len;
|
2540
2654
|
git_buf full_path = GIT_BUF_INIT;
|
2541
2655
|
|
2542
2656
|
assert(out && path && repo); /* as_path can be NULL */
|
@@ -2573,11 +2687,8 @@ int git_repository_hashfile(
|
|
2573
2687
|
goto cleanup;
|
2574
2688
|
}
|
2575
2689
|
|
2576
|
-
|
2577
|
-
if (len < 0) {
|
2578
|
-
error = (int)len;
|
2690
|
+
if ((error = git_futils_filesize(&len, fd)) < 0)
|
2579
2691
|
goto cleanup;
|
2580
|
-
}
|
2581
2692
|
|
2582
2693
|
if (!git__is_sizet(len)) {
|
2583
2694
|
git_error_set(GIT_ERROR_OS, "file size overflow for 32-bit systems");
|
@@ -2866,7 +2977,7 @@ int git_repository_is_shallow(git_repository *repo)
|
|
2866
2977
|
return st.st_size == 0 ? 0 : 1;
|
2867
2978
|
}
|
2868
2979
|
|
2869
|
-
int
|
2980
|
+
int git_repository_init_options_init(
|
2870
2981
|
git_repository_init_options *opts, unsigned int version)
|
2871
2982
|
{
|
2872
2983
|
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
@@ -2875,6 +2986,14 @@ int git_repository_init_init_options(
|
|
2875
2986
|
return 0;
|
2876
2987
|
}
|
2877
2988
|
|
2989
|
+
#ifndef GIT_DEPRECATE_HARD
|
2990
|
+
int git_repository_init_init_options(
|
2991
|
+
git_repository_init_options *opts, unsigned int version)
|
2992
|
+
{
|
2993
|
+
return git_repository_init_options_init(opts, version);
|
2994
|
+
}
|
2995
|
+
#endif
|
2996
|
+
|
2878
2997
|
int git_repository_ident(const char **name, const char **email, const git_repository *repo)
|
2879
2998
|
{
|
2880
2999
|
*name = repo->ident_name;
|
@@ -2912,7 +3031,7 @@ int git_repository_submodule_cache_all(git_repository *repo)
|
|
2912
3031
|
|
2913
3032
|
assert(repo);
|
2914
3033
|
|
2915
|
-
if ((error =
|
3034
|
+
if ((error = git_strmap_new(&repo->submodule_cache)))
|
2916
3035
|
return error;
|
2917
3036
|
|
2918
3037
|
error = git_submodule__map(repo, repo->submodule_cache);
|