rugged 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +3 -3
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_commit.c +1 -1
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_remote.c +32 -2
- data/ext/rugged/rugged_repo.c +13 -3
- data/lib/rugged/commit.rb +17 -4
- data/lib/rugged/repository.rb +7 -8
- data/lib/rugged/submodule_collection.rb +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +41 -74
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -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/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -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/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
- data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
- data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +29 -32
- data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +21 -28
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +24 -10
- data/vendor/libgit2/deps/ntlmclient/compat.h +0 -27
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +164 -135
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
- data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
- data/vendor/libgit2/deps/pcre/LICENCE +93 -0
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
- data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
- data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
- data/vendor/libgit2/deps/zlib/deflate.c +1 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
- data/vendor/libgit2/include/git2/apply.h +2 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +95 -42
- data/vendor/libgit2/include/git2/blob.h +31 -3
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +33 -6
- data/vendor/libgit2/include/git2/config.h +1 -1
- data/vendor/libgit2/include/git2/deprecated.h +248 -8
- data/vendor/libgit2/include/git2/diff.h +35 -20
- data/vendor/libgit2/include/git2/errors.h +8 -7
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +4 -5
- data/vendor/libgit2/include/git2/indexer.h +2 -1
- data/vendor/libgit2/include/git2/odb.h +44 -20
- data/vendor/libgit2/include/git2/pack.h +1 -1
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +9 -5
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/repository.h +95 -52
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/strarray.h +6 -10
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/tree.h +2 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +77 -44
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +21 -8
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/assert_safe.h +58 -0
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +92 -42
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +44 -40
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +28 -15
- data/vendor/libgit2/src/blame_git.c +6 -3
- data/vendor/libgit2/src/blob.c +46 -24
- data/vendor/libgit2/src/branch.c +87 -37
- data/vendor/libgit2/src/buffer.c +339 -27
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +3 -24
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +97 -98
- data/vendor/libgit2/src/cherrypick.c +8 -2
- data/vendor/libgit2/src/clone.c +104 -29
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +26 -2
- data/vendor/libgit2/src/config.c +40 -22
- data/vendor/libgit2/src/config_cache.c +9 -4
- data/vendor/libgit2/src/config_entries.c +35 -27
- data/vendor/libgit2/src/config_file.c +25 -8
- data/vendor/libgit2/src/config_parse.c +5 -7
- data/vendor/libgit2/src/config_snapshot.c +2 -1
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +11 -4
- data/vendor/libgit2/src/diff.c +23 -19
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +5 -7
- data/vendor/libgit2/src/diff_generate.c +56 -28
- data/vendor/libgit2/src/diff_parse.c +2 -3
- data/vendor/libgit2/src/diff_print.c +81 -65
- data/vendor/libgit2/src/diff_stats.c +19 -16
- data/vendor/libgit2/src/diff_tform.c +13 -13
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +26 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +7 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +209 -113
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +8 -8
- data/vendor/libgit2/src/futils.h +4 -4
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/idxmap.c +0 -22
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +126 -84
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +60 -36
- data/vendor/libgit2/src/integer.h +79 -2
- data/vendor/libgit2/src/iterator.c +40 -28
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +125 -49
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +108 -46
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +15 -9
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +879 -0
- data/vendor/libgit2/src/midx.h +110 -0
- data/vendor/libgit2/src/mwindow.c +214 -95
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +133 -4
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +24 -15
- data/vendor/libgit2/src/odb.c +298 -57
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +31 -21
- data/vendor/libgit2/src/odb_mempack.c +3 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +7 -4
- data/vendor/libgit2/src/pack-objects.c +83 -69
- data/vendor/libgit2/src/pack.c +383 -150
- data/vendor/libgit2/src/pack.h +44 -9
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +3 -5
- data/vendor/libgit2/src/patch_parse.c +6 -3
- data/vendor/libgit2/src/path.c +102 -57
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +12 -11
- data/vendor/libgit2/src/pool.c +34 -22
- data/vendor/libgit2/src/pool.h +9 -1
- data/vendor/libgit2/src/posix.c +43 -12
- data/vendor/libgit2/src/posix.h +9 -0
- data/vendor/libgit2/src/proxy.c +2 -0
- data/vendor/libgit2/src/push.c +2 -0
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +95 -49
- data/vendor/libgit2/src/refdb.c +165 -13
- data/vendor/libgit2/src/refdb.h +69 -0
- data/vendor/libgit2/src/refdb_fs.c +144 -152
- data/vendor/libgit2/src/reflog.c +21 -20
- data/vendor/libgit2/src/refs.c +151 -231
- data/vendor/libgit2/src/refs.h +2 -20
- data/vendor/libgit2/src/refspec.c +80 -44
- data/vendor/libgit2/src/regexp.c +2 -2
- data/vendor/libgit2/src/remote.c +312 -121
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +351 -189
- data/vendor/libgit2/src/repository.h +23 -29
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +8 -2
- data/vendor/libgit2/src/revparse.c +19 -13
- data/vendor/libgit2/src/revwalk.c +35 -20
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/{refdb_fs.h → settings.h} +3 -11
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.c +2 -3
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +7 -3
- data/vendor/libgit2/src/status.c +9 -4
- data/vendor/libgit2/src/strarray.c +64 -0
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +113 -207
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +10 -9
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +134 -66
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +8 -26
- data/vendor/libgit2/src/sysdir.h +0 -11
- data/vendor/libgit2/src/tag.c +49 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +21 -9
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +17 -7
- data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +84 -42
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +5 -5
- data/vendor/libgit2/src/transports/smart.c +14 -9
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +156 -88
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/posix.h +16 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +74 -183
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/git2.rc +18 -3
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +23 -25
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +77 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +37 -15
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +56 -38
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -361
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -246
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
data/vendor/libgit2/src/remote.h
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
#include "refspec.h"
|
|
17
17
|
#include "vector.h"
|
|
18
|
+
#include "net.h"
|
|
18
19
|
|
|
19
20
|
#define GIT_REMOTE_ORIGIN "origin"
|
|
20
21
|
|
|
@@ -46,7 +47,7 @@ typedef struct git_remote_connection_opts {
|
|
|
46
47
|
int git_remote__connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_remote_connection_opts *conn);
|
|
47
48
|
|
|
48
49
|
int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int direction, const git_remote_callbacks *callbacks);
|
|
49
|
-
int
|
|
50
|
+
int git_remote__http_proxy(char **out, git_remote *remote, git_net_url *url);
|
|
50
51
|
|
|
51
52
|
git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname);
|
|
52
53
|
git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname);
|
|
@@ -62,16 +62,18 @@ static const struct {
|
|
|
62
62
|
{ GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "worktrees", true }
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
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);
|
|
66
67
|
|
|
67
68
|
#define GIT_COMMONDIR_FILE "commondir"
|
|
68
69
|
#define GIT_GITDIR_FILE "gitdir"
|
|
69
70
|
|
|
70
71
|
#define GIT_FILE_CONTENT_PREFIX "gitdir:"
|
|
71
72
|
|
|
72
|
-
#define
|
|
73
|
+
#define GIT_BRANCH_DEFAULT "master"
|
|
73
74
|
|
|
74
75
|
#define GIT_REPO_VERSION 0
|
|
76
|
+
#define GIT_REPO_MAX_VERSION 1
|
|
75
77
|
|
|
76
78
|
git_buf git_repository__reserved_names_win32[] = {
|
|
77
79
|
{ DOT_GIT, 0, CONST_STRLEN(DOT_GIT) },
|
|
@@ -91,7 +93,7 @@ static void set_odb(git_repository *repo, git_odb *odb)
|
|
|
91
93
|
GIT_REFCOUNT_INC(odb);
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
if ((odb =
|
|
96
|
+
if ((odb = git_atomic_swap(repo->_odb, odb)) != NULL) {
|
|
95
97
|
GIT_REFCOUNT_OWN(odb, NULL);
|
|
96
98
|
git_odb_free(odb);
|
|
97
99
|
}
|
|
@@ -104,7 +106,7 @@ static void set_refdb(git_repository *repo, git_refdb *refdb)
|
|
|
104
106
|
GIT_REFCOUNT_INC(refdb);
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
if ((refdb =
|
|
109
|
+
if ((refdb = git_atomic_swap(repo->_refdb, refdb)) != NULL) {
|
|
108
110
|
GIT_REFCOUNT_OWN(refdb, NULL);
|
|
109
111
|
git_refdb_free(refdb);
|
|
110
112
|
}
|
|
@@ -117,7 +119,7 @@ static void set_config(git_repository *repo, git_config *config)
|
|
|
117
119
|
GIT_REFCOUNT_INC(config);
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
if ((config =
|
|
122
|
+
if ((config = git_atomic_swap(repo->_config, config)) != NULL) {
|
|
121
123
|
GIT_REFCOUNT_OWN(config, NULL);
|
|
122
124
|
git_config_free(config);
|
|
123
125
|
}
|
|
@@ -132,7 +134,7 @@ static void set_index(git_repository *repo, git_index *index)
|
|
|
132
134
|
GIT_REFCOUNT_INC(index);
|
|
133
135
|
}
|
|
134
136
|
|
|
135
|
-
if ((index =
|
|
137
|
+
if ((index = git_atomic_swap(repo->_index, index)) != NULL) {
|
|
136
138
|
GIT_REFCOUNT_OWN(index, NULL);
|
|
137
139
|
git_index_free(index);
|
|
138
140
|
}
|
|
@@ -140,7 +142,7 @@ static void set_index(git_repository *repo, git_index *index)
|
|
|
140
142
|
|
|
141
143
|
int git_repository__cleanup(git_repository *repo)
|
|
142
144
|
{
|
|
143
|
-
|
|
145
|
+
GIT_ASSERT_ARG(repo);
|
|
144
146
|
|
|
145
147
|
git_repository_submodule_cache_clear(repo);
|
|
146
148
|
git_cache_clear(&repo->objects);
|
|
@@ -184,6 +186,63 @@ void git_repository_free(git_repository *repo)
|
|
|
184
186
|
git__free(repo);
|
|
185
187
|
}
|
|
186
188
|
|
|
189
|
+
/* Check if we have a separate commondir (e.g. we have a worktree) */
|
|
190
|
+
static int lookup_commondir(bool *separate, git_buf *commondir, git_buf *repository_path)
|
|
191
|
+
{
|
|
192
|
+
git_buf common_link = GIT_BUF_INIT;
|
|
193
|
+
int error;
|
|
194
|
+
|
|
195
|
+
/*
|
|
196
|
+
* If there's no commondir file, the repository path is the
|
|
197
|
+
* common path, but it needs a trailing slash.
|
|
198
|
+
*/
|
|
199
|
+
if (!git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
|
|
200
|
+
if ((error = git_buf_set(commondir, repository_path->ptr, repository_path->size)) == 0)
|
|
201
|
+
error = git_path_to_dir(commondir);
|
|
202
|
+
|
|
203
|
+
*separate = false;
|
|
204
|
+
goto done;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
*separate = true;
|
|
208
|
+
|
|
209
|
+
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
|
|
210
|
+
(error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
|
|
211
|
+
goto done;
|
|
212
|
+
|
|
213
|
+
git_buf_rtrim(&common_link);
|
|
214
|
+
if (git_path_is_relative(common_link.ptr)) {
|
|
215
|
+
if ((error = git_buf_joinpath(commondir, repository_path->ptr, common_link.ptr)) < 0)
|
|
216
|
+
goto done;
|
|
217
|
+
} else {
|
|
218
|
+
git_buf_swap(commondir, &common_link);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
git_buf_dispose(&common_link);
|
|
222
|
+
|
|
223
|
+
/* Make sure the commondir path always has a trailing slash */
|
|
224
|
+
error = git_path_prettify_dir(commondir, commondir->ptr, NULL);
|
|
225
|
+
|
|
226
|
+
done:
|
|
227
|
+
return error;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
GIT_INLINE(int) validate_repo_path(git_buf *path)
|
|
231
|
+
{
|
|
232
|
+
/*
|
|
233
|
+
* The longest static path in a repository (or commondir) is the
|
|
234
|
+
* packed refs file. (Loose refs may be longer since they
|
|
235
|
+
* include the reference name, but will be validated when the
|
|
236
|
+
* path is constructed.)
|
|
237
|
+
*/
|
|
238
|
+
static size_t suffix_len =
|
|
239
|
+
CONST_STRLEN("objects/pack/pack-.pack.lock") +
|
|
240
|
+
GIT_OID_HEXSZ;
|
|
241
|
+
|
|
242
|
+
return git_path_validate_filesystem_with_suffix(
|
|
243
|
+
path->ptr, path->size, suffix_len);
|
|
244
|
+
}
|
|
245
|
+
|
|
187
246
|
/*
|
|
188
247
|
* Git repository open methods
|
|
189
248
|
*
|
|
@@ -191,48 +250,30 @@ void git_repository_free(git_repository *repo)
|
|
|
191
250
|
*/
|
|
192
251
|
static int is_valid_repository_path(bool *out, git_buf *repository_path, git_buf *common_path)
|
|
193
252
|
{
|
|
253
|
+
bool separate_commondir = false;
|
|
194
254
|
int error;
|
|
195
255
|
|
|
196
256
|
*out = false;
|
|
197
257
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
|
|
201
|
-
git_buf common_link = GIT_BUF_INIT;
|
|
202
|
-
|
|
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;
|
|
206
|
-
|
|
207
|
-
git_buf_rtrim(&common_link);
|
|
208
|
-
if (git_path_is_relative(common_link.ptr)) {
|
|
209
|
-
if ((error = git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)) < 0)
|
|
210
|
-
return error;
|
|
211
|
-
} else {
|
|
212
|
-
git_buf_swap(common_path, &common_link);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
git_buf_dispose(&common_link);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0)
|
|
219
|
-
return error;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/* Make sure the commondir path always has a trailing * slash */
|
|
223
|
-
if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1)
|
|
224
|
-
if ((error = git_buf_putc(common_path, '/')) < 0)
|
|
225
|
-
return error;
|
|
258
|
+
if ((error = lookup_commondir(&separate_commondir, common_path, repository_path)) < 0)
|
|
259
|
+
return error;
|
|
226
260
|
|
|
227
261
|
/* Ensure HEAD file exists */
|
|
228
262
|
if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false)
|
|
229
263
|
return 0;
|
|
264
|
+
|
|
230
265
|
/* Check files in common dir */
|
|
231
266
|
if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false)
|
|
232
267
|
return 0;
|
|
233
268
|
if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false)
|
|
234
269
|
return 0;
|
|
235
270
|
|
|
271
|
+
/* Ensure the repo (and commondir) are valid paths */
|
|
272
|
+
if ((error = validate_repo_path(common_path)) < 0 ||
|
|
273
|
+
(separate_commondir &&
|
|
274
|
+
(error = validate_repo_path(repository_path)) < 0))
|
|
275
|
+
return error;
|
|
276
|
+
|
|
236
277
|
*out = true;
|
|
237
278
|
return 0;
|
|
238
279
|
}
|
|
@@ -366,7 +407,7 @@ static size_t find_ceiling_dir_offset(
|
|
|
366
407
|
const char *ceil, *sep;
|
|
367
408
|
size_t len, max_len = 0, min_len;
|
|
368
409
|
|
|
369
|
-
|
|
410
|
+
GIT_ASSERT_ARG(path);
|
|
370
411
|
|
|
371
412
|
min_len = (size_t)(git_path_root(path) + 1);
|
|
372
413
|
|
|
@@ -412,7 +453,8 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
|
|
|
412
453
|
git_buf file = GIT_BUF_INIT;
|
|
413
454
|
size_t prefix_len = strlen(GIT_FILE_CONTENT_PREFIX);
|
|
414
455
|
|
|
415
|
-
|
|
456
|
+
GIT_ASSERT_ARG(path_out);
|
|
457
|
+
GIT_ASSERT_ARG(file_path);
|
|
416
458
|
|
|
417
459
|
if (git_futils_readbuffer(&file, file_path) < 0)
|
|
418
460
|
return -1;
|
|
@@ -813,6 +855,7 @@ int git_repository_open_ext(
|
|
|
813
855
|
gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT;
|
|
814
856
|
git_repository *repo = NULL;
|
|
815
857
|
git_config *config = NULL;
|
|
858
|
+
int version = 0;
|
|
816
859
|
|
|
817
860
|
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV)
|
|
818
861
|
return _git_repository_open_ext_from_env(repo_ptr, start_path);
|
|
@@ -854,7 +897,10 @@ int git_repository_open_ext(
|
|
|
854
897
|
if (error < 0 && error != GIT_ENOTFOUND)
|
|
855
898
|
goto cleanup;
|
|
856
899
|
|
|
857
|
-
if (config && (error = check_repositoryformatversion(config)) < 0)
|
|
900
|
+
if (config && (error = check_repositoryformatversion(&version, config)) < 0)
|
|
901
|
+
goto cleanup;
|
|
902
|
+
|
|
903
|
+
if ((error = check_extensions(config, version)) < 0)
|
|
858
904
|
goto cleanup;
|
|
859
905
|
|
|
860
906
|
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
|
|
@@ -895,7 +941,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
|
|
|
895
941
|
size_t len;
|
|
896
942
|
int err;
|
|
897
943
|
|
|
898
|
-
|
|
944
|
+
GIT_ASSERT_ARG(repo_out);
|
|
945
|
+
GIT_ASSERT_ARG(wt);
|
|
899
946
|
|
|
900
947
|
*repo_out = NULL;
|
|
901
948
|
len = strlen(wt->gitlink_path);
|
|
@@ -939,10 +986,12 @@ int git_repository_discover(
|
|
|
939
986
|
const char *ceiling_dirs)
|
|
940
987
|
{
|
|
941
988
|
uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0;
|
|
989
|
+
int error;
|
|
942
990
|
|
|
943
|
-
|
|
991
|
+
GIT_ASSERT_ARG(start_path);
|
|
944
992
|
|
|
945
|
-
git_buf_sanitize(out)
|
|
993
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
|
994
|
+
return error;
|
|
946
995
|
|
|
947
996
|
return find_repo(out, NULL, NULL, NULL, start_path, flags, ceiling_dirs);
|
|
948
997
|
}
|
|
@@ -959,7 +1008,7 @@ static int load_config(
|
|
|
959
1008
|
git_buf config_path = GIT_BUF_INIT;
|
|
960
1009
|
git_config *cfg = NULL;
|
|
961
1010
|
|
|
962
|
-
|
|
1011
|
+
GIT_ASSERT_ARG(out);
|
|
963
1012
|
|
|
964
1013
|
if ((error = git_config_new(&cfg)) < 0)
|
|
965
1014
|
return error;
|
|
@@ -1044,8 +1093,7 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo)
|
|
|
1044
1093
|
if (!error) {
|
|
1045
1094
|
GIT_REFCOUNT_OWN(config, repo);
|
|
1046
1095
|
|
|
1047
|
-
|
|
1048
|
-
if (config != NULL) {
|
|
1096
|
+
if (git_atomic_compare_and_swap(&repo->_config, NULL, config) != NULL) {
|
|
1049
1097
|
GIT_REFCOUNT_OWN(config, NULL);
|
|
1050
1098
|
git_config_free(config);
|
|
1051
1099
|
}
|
|
@@ -1083,7 +1131,9 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
|
|
|
1083
1131
|
|
|
1084
1132
|
int git_repository_set_config(git_repository *repo, git_config *config)
|
|
1085
1133
|
{
|
|
1086
|
-
|
|
1134
|
+
GIT_ASSERT_ARG(repo);
|
|
1135
|
+
GIT_ASSERT_ARG(config);
|
|
1136
|
+
|
|
1087
1137
|
set_config(repo, config);
|
|
1088
1138
|
return 0;
|
|
1089
1139
|
}
|
|
@@ -1092,9 +1142,11 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
|
|
|
1092
1142
|
{
|
|
1093
1143
|
int error = 0;
|
|
1094
1144
|
|
|
1095
|
-
|
|
1145
|
+
GIT_ASSERT_ARG(repo);
|
|
1146
|
+
GIT_ASSERT_ARG(out);
|
|
1096
1147
|
|
|
1097
|
-
|
|
1148
|
+
*out = git_atomic_load(repo->_odb);
|
|
1149
|
+
if (*out == NULL) {
|
|
1098
1150
|
git_buf odb_path = GIT_BUF_INIT;
|
|
1099
1151
|
git_odb *odb;
|
|
1100
1152
|
|
|
@@ -1111,16 +1163,15 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
|
|
|
1111
1163
|
return error;
|
|
1112
1164
|
}
|
|
1113
1165
|
|
|
1114
|
-
|
|
1115
|
-
if (odb != NULL) {
|
|
1166
|
+
if (git_atomic_compare_and_swap(&repo->_odb, NULL, odb) != NULL) {
|
|
1116
1167
|
GIT_REFCOUNT_OWN(odb, NULL);
|
|
1117
1168
|
git_odb_free(odb);
|
|
1118
1169
|
}
|
|
1119
1170
|
|
|
1120
1171
|
git_buf_dispose(&odb_path);
|
|
1172
|
+
*out = git_atomic_load(repo->_odb);
|
|
1121
1173
|
}
|
|
1122
1174
|
|
|
1123
|
-
*out = repo->_odb;
|
|
1124
1175
|
return error;
|
|
1125
1176
|
}
|
|
1126
1177
|
|
|
@@ -1135,7 +1186,9 @@ int git_repository_odb(git_odb **out, git_repository *repo)
|
|
|
1135
1186
|
|
|
1136
1187
|
int git_repository_set_odb(git_repository *repo, git_odb *odb)
|
|
1137
1188
|
{
|
|
1138
|
-
|
|
1189
|
+
GIT_ASSERT_ARG(repo);
|
|
1190
|
+
GIT_ASSERT_ARG(odb);
|
|
1191
|
+
|
|
1139
1192
|
set_odb(repo, odb);
|
|
1140
1193
|
return 0;
|
|
1141
1194
|
}
|
|
@@ -1144,7 +1197,8 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
|
|
|
1144
1197
|
{
|
|
1145
1198
|
int error = 0;
|
|
1146
1199
|
|
|
1147
|
-
|
|
1200
|
+
GIT_ASSERT_ARG(out);
|
|
1201
|
+
GIT_ASSERT_ARG(repo);
|
|
1148
1202
|
|
|
1149
1203
|
if (repo->_refdb == NULL) {
|
|
1150
1204
|
git_refdb *refdb;
|
|
@@ -1153,8 +1207,7 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
|
|
|
1153
1207
|
if (!error) {
|
|
1154
1208
|
GIT_REFCOUNT_OWN(refdb, repo);
|
|
1155
1209
|
|
|
1156
|
-
|
|
1157
|
-
if (refdb != NULL) {
|
|
1210
|
+
if (git_atomic_compare_and_swap(&repo->_refdb, NULL, refdb) != NULL) {
|
|
1158
1211
|
GIT_REFCOUNT_OWN(refdb, NULL);
|
|
1159
1212
|
git_refdb_free(refdb);
|
|
1160
1213
|
}
|
|
@@ -1176,7 +1229,9 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
|
|
|
1176
1229
|
|
|
1177
1230
|
int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
|
|
1178
1231
|
{
|
|
1179
|
-
|
|
1232
|
+
GIT_ASSERT_ARG(repo);
|
|
1233
|
+
GIT_ASSERT_ARG(refdb);
|
|
1234
|
+
|
|
1180
1235
|
set_refdb(repo, refdb);
|
|
1181
1236
|
return 0;
|
|
1182
1237
|
}
|
|
@@ -1185,7 +1240,8 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
|
|
|
1185
1240
|
{
|
|
1186
1241
|
int error = 0;
|
|
1187
1242
|
|
|
1188
|
-
|
|
1243
|
+
GIT_ASSERT_ARG(out);
|
|
1244
|
+
GIT_ASSERT_ARG(repo);
|
|
1189
1245
|
|
|
1190
1246
|
if (repo->_index == NULL) {
|
|
1191
1247
|
git_buf index_path = GIT_BUF_INIT;
|
|
@@ -1198,8 +1254,7 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
|
|
|
1198
1254
|
if (!error) {
|
|
1199
1255
|
GIT_REFCOUNT_OWN(index, repo);
|
|
1200
1256
|
|
|
1201
|
-
|
|
1202
|
-
if (index != NULL) {
|
|
1257
|
+
if (git_atomic_compare_and_swap(&repo->_index, NULL, index) != NULL) {
|
|
1203
1258
|
GIT_REFCOUNT_OWN(index, NULL);
|
|
1204
1259
|
git_index_free(index);
|
|
1205
1260
|
}
|
|
@@ -1226,7 +1281,7 @@ int git_repository_index(git_index **out, git_repository *repo)
|
|
|
1226
1281
|
|
|
1227
1282
|
int git_repository_set_index(git_repository *repo, git_index *index)
|
|
1228
1283
|
{
|
|
1229
|
-
|
|
1284
|
+
GIT_ASSERT_ARG(repo);
|
|
1230
1285
|
set_index(repo, index);
|
|
1231
1286
|
return 0;
|
|
1232
1287
|
}
|
|
@@ -1350,11 +1405,11 @@ bool git_repository__reserved_names(
|
|
|
1350
1405
|
}
|
|
1351
1406
|
#endif
|
|
1352
1407
|
|
|
1353
|
-
static int check_repositoryformatversion(git_config *config)
|
|
1408
|
+
static int check_repositoryformatversion(int *version, git_config *config)
|
|
1354
1409
|
{
|
|
1355
|
-
int
|
|
1410
|
+
int error;
|
|
1356
1411
|
|
|
1357
|
-
error = git_config_get_int32(
|
|
1412
|
+
error = git_config_get_int32(version, config, "core.repositoryformatversion");
|
|
1358
1413
|
/* git ignores this if the config variable isn't there */
|
|
1359
1414
|
if (error == GIT_ENOTFOUND)
|
|
1360
1415
|
return 0;
|
|
@@ -1362,16 +1417,35 @@ static int check_repositoryformatversion(git_config *config)
|
|
|
1362
1417
|
if (error < 0)
|
|
1363
1418
|
return -1;
|
|
1364
1419
|
|
|
1365
|
-
if (
|
|
1420
|
+
if (GIT_REPO_MAX_VERSION < *version) {
|
|
1366
1421
|
git_error_set(GIT_ERROR_REPOSITORY,
|
|
1367
|
-
"unsupported repository version %d
|
|
1368
|
-
version,
|
|
1422
|
+
"unsupported repository version %d; only versions up to %d are supported",
|
|
1423
|
+
*version, GIT_REPO_MAX_VERSION);
|
|
1369
1424
|
return -1;
|
|
1370
1425
|
}
|
|
1371
1426
|
|
|
1372
1427
|
return 0;
|
|
1373
1428
|
}
|
|
1374
1429
|
|
|
1430
|
+
static int check_valid_extension(const git_config_entry *entry, void *payload)
|
|
1431
|
+
{
|
|
1432
|
+
GIT_UNUSED(payload);
|
|
1433
|
+
|
|
1434
|
+
if (!strcmp(entry->name, "extensions.noop"))
|
|
1435
|
+
return 0;
|
|
1436
|
+
|
|
1437
|
+
git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name);
|
|
1438
|
+
return -1;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
static int check_extensions(git_config *config, int version)
|
|
1442
|
+
{
|
|
1443
|
+
if (version < 1)
|
|
1444
|
+
return 0;
|
|
1445
|
+
|
|
1446
|
+
return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1375
1449
|
int git_repository_create_head(const char *git_dir, const char *ref_name)
|
|
1376
1450
|
{
|
|
1377
1451
|
git_buf ref_path = GIT_BUF_INIT;
|
|
@@ -1383,9 +1457,6 @@ int git_repository_create_head(const char *git_dir, const char *ref_name)
|
|
|
1383
1457
|
(error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0)
|
|
1384
1458
|
goto out;
|
|
1385
1459
|
|
|
1386
|
-
if (!ref_name)
|
|
1387
|
-
ref_name = GIT_BRANCH_MASTER;
|
|
1388
|
-
|
|
1389
1460
|
if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0)
|
|
1390
1461
|
fmt = "ref: %s\n";
|
|
1391
1462
|
else
|
|
@@ -1583,11 +1654,15 @@ static int repo_init_config(
|
|
|
1583
1654
|
git_config *config = NULL;
|
|
1584
1655
|
bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0);
|
|
1585
1656
|
bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0);
|
|
1657
|
+
int version = 0;
|
|
1586
1658
|
|
|
1587
1659
|
if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0)
|
|
1588
1660
|
goto cleanup;
|
|
1589
1661
|
|
|
1590
|
-
if (is_reinit && (error = check_repositoryformatversion(config)) < 0)
|
|
1662
|
+
if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0)
|
|
1663
|
+
goto cleanup;
|
|
1664
|
+
|
|
1665
|
+
if ((error = check_extensions(config, version)) < 0)
|
|
1591
1666
|
goto cleanup;
|
|
1592
1667
|
|
|
1593
1668
|
#define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \
|
|
@@ -2032,6 +2107,44 @@ static int repo_init_directories(
|
|
|
2032
2107
|
return error;
|
|
2033
2108
|
}
|
|
2034
2109
|
|
|
2110
|
+
static int repo_init_head(const char *repo_dir, const char *given)
|
|
2111
|
+
{
|
|
2112
|
+
git_config *cfg = NULL;
|
|
2113
|
+
git_buf head_path = GIT_BUF_INIT, cfg_branch = GIT_BUF_INIT;
|
|
2114
|
+
const char *initial_head = NULL;
|
|
2115
|
+
int error;
|
|
2116
|
+
|
|
2117
|
+
if ((error = git_buf_joinpath(&head_path, repo_dir, GIT_HEAD_FILE)) < 0)
|
|
2118
|
+
goto out;
|
|
2119
|
+
|
|
2120
|
+
/*
|
|
2121
|
+
* A template may have set a HEAD; use that unless it's been
|
|
2122
|
+
* overridden by the caller's given initial head setting.
|
|
2123
|
+
*/
|
|
2124
|
+
if (git_path_exists(head_path.ptr) && !given)
|
|
2125
|
+
goto out;
|
|
2126
|
+
|
|
2127
|
+
if (given) {
|
|
2128
|
+
initial_head = given;
|
|
2129
|
+
} else if ((error = git_config_open_default(&cfg)) >= 0 &&
|
|
2130
|
+
(error = git_config_get_string_buf(&cfg_branch, cfg, "init.defaultbranch")) >= 0 &&
|
|
2131
|
+
*cfg_branch.ptr) {
|
|
2132
|
+
initial_head = cfg_branch.ptr;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
if (!initial_head)
|
|
2136
|
+
initial_head = GIT_BRANCH_DEFAULT;
|
|
2137
|
+
|
|
2138
|
+
error = git_repository_create_head(repo_dir, initial_head);
|
|
2139
|
+
|
|
2140
|
+
out:
|
|
2141
|
+
git_config_free(cfg);
|
|
2142
|
+
git_buf_dispose(&head_path);
|
|
2143
|
+
git_buf_dispose(&cfg_branch);
|
|
2144
|
+
|
|
2145
|
+
return error;
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2035
2148
|
static int repo_init_create_origin(git_repository *repo, const char *url)
|
|
2036
2149
|
{
|
|
2037
2150
|
int error;
|
|
@@ -2062,12 +2175,14 @@ int git_repository_init_ext(
|
|
|
2062
2175
|
git_repository_init_options *opts)
|
|
2063
2176
|
{
|
|
2064
2177
|
git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT,
|
|
2065
|
-
common_path = GIT_BUF_INIT
|
|
2178
|
+
common_path = GIT_BUF_INIT;
|
|
2066
2179
|
const char *wd;
|
|
2067
2180
|
bool is_valid;
|
|
2068
2181
|
int error;
|
|
2069
2182
|
|
|
2070
|
-
|
|
2183
|
+
GIT_ASSERT_ARG(out);
|
|
2184
|
+
GIT_ASSERT_ARG(given_repo);
|
|
2185
|
+
GIT_ASSERT_ARG(opts);
|
|
2071
2186
|
|
|
2072
2187
|
GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
|
|
2073
2188
|
|
|
@@ -2096,16 +2211,7 @@ int git_repository_init_ext(
|
|
|
2096
2211
|
} else {
|
|
2097
2212
|
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 ||
|
|
2098
2213
|
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 ||
|
|
2099
|
-
(error =
|
|
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)
|
|
2214
|
+
(error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0)
|
|
2109
2215
|
goto out;
|
|
2110
2216
|
}
|
|
2111
2217
|
|
|
@@ -2117,7 +2223,6 @@ int git_repository_init_ext(
|
|
|
2117
2223
|
goto out;
|
|
2118
2224
|
|
|
2119
2225
|
out:
|
|
2120
|
-
git_buf_dispose(&head_path);
|
|
2121
2226
|
git_buf_dispose(&common_path);
|
|
2122
2227
|
git_buf_dispose(&repo_path);
|
|
2123
2228
|
git_buf_dispose(&wd_path);
|
|
@@ -2148,18 +2253,13 @@ int git_repository_head_detached(git_repository *repo)
|
|
|
2148
2253
|
return exists;
|
|
2149
2254
|
}
|
|
2150
2255
|
|
|
2151
|
-
static int get_worktree_file_path(git_buf *out, git_repository *repo, const char *worktree, const char *file)
|
|
2152
|
-
{
|
|
2153
|
-
git_buf_clear(out);
|
|
2154
|
-
return git_buf_printf(out, "%s/worktrees/%s/%s", repo->commondir, worktree, file);
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
2256
|
int git_repository_head_detached_for_worktree(git_repository *repo, const char *name)
|
|
2158
2257
|
{
|
|
2159
2258
|
git_reference *ref = NULL;
|
|
2160
2259
|
int error;
|
|
2161
2260
|
|
|
2162
|
-
|
|
2261
|
+
GIT_ASSERT_ARG(repo);
|
|
2262
|
+
GIT_ASSERT_ARG(name);
|
|
2163
2263
|
|
|
2164
2264
|
if ((error = git_repository_head_for_worktree(&ref, repo, name)) < 0)
|
|
2165
2265
|
goto out;
|
|
@@ -2176,7 +2276,7 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
|
|
|
2176
2276
|
git_reference *head;
|
|
2177
2277
|
int error;
|
|
2178
2278
|
|
|
2179
|
-
|
|
2279
|
+
GIT_ASSERT_ARG(head_out);
|
|
2180
2280
|
|
|
2181
2281
|
if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
|
|
2182
2282
|
return error;
|
|
@@ -2194,73 +2294,85 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
|
|
|
2194
2294
|
|
|
2195
2295
|
int git_repository_head_for_worktree(git_reference **out, git_repository *repo, const char *name)
|
|
2196
2296
|
{
|
|
2197
|
-
|
|
2297
|
+
git_repository *worktree_repo = NULL;
|
|
2298
|
+
git_worktree *worktree = NULL;
|
|
2198
2299
|
git_reference *head = NULL;
|
|
2199
2300
|
int error;
|
|
2200
2301
|
|
|
2201
|
-
|
|
2302
|
+
GIT_ASSERT_ARG(out);
|
|
2303
|
+
GIT_ASSERT_ARG(repo);
|
|
2304
|
+
GIT_ASSERT_ARG(name);
|
|
2202
2305
|
|
|
2203
2306
|
*out = NULL;
|
|
2204
2307
|
|
|
2205
|
-
if ((error =
|
|
2206
|
-
(error =
|
|
2308
|
+
if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 ||
|
|
2309
|
+
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 ||
|
|
2310
|
+
(error = git_reference_lookup(&head, worktree_repo, GIT_HEAD_FILE)) < 0)
|
|
2207
2311
|
goto out;
|
|
2208
2312
|
|
|
2209
2313
|
if (git_reference_type(head) != GIT_REFERENCE_DIRECT) {
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
head =
|
|
2314
|
+
if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0)
|
|
2315
|
+
goto out;
|
|
2316
|
+
} else {
|
|
2317
|
+
*out = head;
|
|
2318
|
+
head = NULL;
|
|
2215
2319
|
}
|
|
2216
2320
|
|
|
2217
|
-
*out = head;
|
|
2218
|
-
|
|
2219
2321
|
out:
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
git_buf_dispose(&path);
|
|
2224
|
-
|
|
2322
|
+
git_reference_free(head);
|
|
2323
|
+
git_worktree_free(worktree);
|
|
2324
|
+
git_repository_free(worktree_repo);
|
|
2225
2325
|
return error;
|
|
2226
2326
|
}
|
|
2227
2327
|
|
|
2228
|
-
int
|
|
2229
|
-
|
|
2230
|
-
|
|
2328
|
+
int git_repository_foreach_worktree(git_repository *repo,
|
|
2329
|
+
git_repository_foreach_worktree_cb cb,
|
|
2330
|
+
void *payload)
|
|
2231
2331
|
{
|
|
2232
|
-
git_strarray worktrees =
|
|
2233
|
-
|
|
2234
|
-
|
|
2332
|
+
git_strarray worktrees = {0};
|
|
2333
|
+
git_repository *worktree_repo = NULL;
|
|
2334
|
+
git_worktree *worktree = NULL;
|
|
2335
|
+
int error;
|
|
2235
2336
|
size_t i;
|
|
2236
2337
|
|
|
2338
|
+
/* apply operation to repository supplied when commondir is empty, implying there's
|
|
2339
|
+
* no linked worktrees to iterate, which can occur when using custom odb/refdb
|
|
2340
|
+
*/
|
|
2341
|
+
if (!repo->commondir)
|
|
2342
|
+
return cb(repo, payload);
|
|
2237
2343
|
|
|
2238
|
-
if (
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
(error = cb(repo, path.ptr, payload) != 0))
|
|
2242
|
-
goto out;
|
|
2243
|
-
}
|
|
2344
|
+
if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
|
|
2345
|
+
(error = cb(worktree_repo, payload) != 0))
|
|
2346
|
+
goto out;
|
|
2244
2347
|
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
error = 0;
|
|
2248
|
-
goto out;
|
|
2249
|
-
}
|
|
2348
|
+
git_repository_free(worktree_repo);
|
|
2349
|
+
worktree_repo = NULL;
|
|
2250
2350
|
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0)
|
|
2254
|
-
continue;
|
|
2351
|
+
if ((error = git_worktree_list(&worktrees, repo)) < 0)
|
|
2352
|
+
goto out;
|
|
2255
2353
|
|
|
2256
|
-
|
|
2354
|
+
for (i = 0; i < worktrees.count; i++) {
|
|
2355
|
+
git_repository_free(worktree_repo);
|
|
2356
|
+
worktree_repo = NULL;
|
|
2357
|
+
git_worktree_free(worktree);
|
|
2358
|
+
worktree = NULL;
|
|
2359
|
+
|
|
2360
|
+
if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) ||
|
|
2361
|
+
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0) {
|
|
2362
|
+
if (error != GIT_ENOTFOUND)
|
|
2257
2363
|
goto out;
|
|
2364
|
+
error = 0;
|
|
2365
|
+
continue;
|
|
2258
2366
|
}
|
|
2367
|
+
|
|
2368
|
+
if ((error = cb(worktree_repo, payload)) != 0)
|
|
2369
|
+
goto out;
|
|
2259
2370
|
}
|
|
2260
2371
|
|
|
2261
2372
|
out:
|
|
2262
|
-
|
|
2263
|
-
|
|
2373
|
+
git_strarray_dispose(&worktrees);
|
|
2374
|
+
git_repository_free(worktree_repo);
|
|
2375
|
+
git_worktree_free(worktree);
|
|
2264
2376
|
return error;
|
|
2265
2377
|
}
|
|
2266
2378
|
|
|
@@ -2283,43 +2395,79 @@ int git_repository_head_unborn(git_repository *repo)
|
|
|
2283
2395
|
return 0;
|
|
2284
2396
|
}
|
|
2285
2397
|
|
|
2286
|
-
static int
|
|
2398
|
+
static int repo_contains_no_reference(git_repository *repo)
|
|
2287
2399
|
{
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2400
|
+
git_reference_iterator *iter;
|
|
2401
|
+
const char *refname;
|
|
2402
|
+
int error;
|
|
2403
|
+
|
|
2404
|
+
if ((error = git_reference_iterator_new(&iter, repo)) < 0)
|
|
2405
|
+
return error;
|
|
2406
|
+
|
|
2407
|
+
error = git_reference_next_name(&refname, iter);
|
|
2408
|
+
git_reference_iterator_free(iter);
|
|
2409
|
+
|
|
2410
|
+
if (error == GIT_ITEROVER)
|
|
2411
|
+
return 1;
|
|
2412
|
+
|
|
2413
|
+
return error;
|
|
2291
2414
|
}
|
|
2292
2415
|
|
|
2293
|
-
|
|
2416
|
+
int git_repository_initialbranch(git_buf *out, git_repository *repo)
|
|
2294
2417
|
{
|
|
2295
|
-
|
|
2418
|
+
git_config *config;
|
|
2419
|
+
git_config_entry *entry = NULL;
|
|
2420
|
+
const char *branch;
|
|
2421
|
+
int valid, error;
|
|
2296
2422
|
|
|
2297
|
-
if (error
|
|
2298
|
-
return
|
|
2423
|
+
if ((error = git_repository_config__weakptr(&config, repo)) < 0)
|
|
2424
|
+
return error;
|
|
2299
2425
|
|
|
2300
|
-
if (
|
|
2301
|
-
|
|
2426
|
+
if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0 &&
|
|
2427
|
+
*entry->value) {
|
|
2428
|
+
branch = entry->value;
|
|
2429
|
+
}
|
|
2430
|
+
else if (!error || error == GIT_ENOTFOUND) {
|
|
2431
|
+
branch = GIT_BRANCH_DEFAULT;
|
|
2432
|
+
}
|
|
2433
|
+
else {
|
|
2434
|
+
goto done;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
|
|
2438
|
+
(error = git_buf_puts(out, branch)) < 0 ||
|
|
2439
|
+
(error = git_reference_name_is_valid(&valid, out->ptr)) < 0)
|
|
2440
|
+
goto done;
|
|
2441
|
+
|
|
2442
|
+
if (!valid) {
|
|
2443
|
+
git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid branch name");
|
|
2444
|
+
error = -1;
|
|
2445
|
+
}
|
|
2302
2446
|
|
|
2447
|
+
done:
|
|
2448
|
+
git_config_entry_free(entry);
|
|
2303
2449
|
return error;
|
|
2304
2450
|
}
|
|
2305
2451
|
|
|
2306
2452
|
int git_repository_is_empty(git_repository *repo)
|
|
2307
2453
|
{
|
|
2308
2454
|
git_reference *head = NULL;
|
|
2309
|
-
|
|
2455
|
+
git_buf initialbranch = GIT_BUF_INIT;
|
|
2456
|
+
int result = 0;
|
|
2310
2457
|
|
|
2311
|
-
if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0
|
|
2312
|
-
|
|
2458
|
+
if ((result = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0 ||
|
|
2459
|
+
(result = git_repository_initialbranch(&initialbranch, repo)) < 0)
|
|
2460
|
+
goto done;
|
|
2313
2461
|
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
GIT_REFS_HEADS_DIR "master") == 0) &&
|
|
2318
|
-
repo_contains_no_reference(repo);
|
|
2462
|
+
result = (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC &&
|
|
2463
|
+
strcmp(git_reference_symbolic_target(head), initialbranch.ptr) == 0 &&
|
|
2464
|
+
repo_contains_no_reference(repo));
|
|
2319
2465
|
|
|
2466
|
+
done:
|
|
2320
2467
|
git_reference_free(head);
|
|
2468
|
+
git_buf_dispose(&initialbranch);
|
|
2321
2469
|
|
|
2322
|
-
return
|
|
2470
|
+
return result;
|
|
2323
2471
|
}
|
|
2324
2472
|
|
|
2325
2473
|
static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback)
|
|
@@ -2372,13 +2520,13 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
|
|
|
2372
2520
|
|
|
2373
2521
|
const char *git_repository_path(const git_repository *repo)
|
|
2374
2522
|
{
|
|
2375
|
-
|
|
2523
|
+
GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
|
|
2376
2524
|
return repo->gitdir;
|
|
2377
2525
|
}
|
|
2378
2526
|
|
|
2379
2527
|
const char *git_repository_workdir(const git_repository *repo)
|
|
2380
2528
|
{
|
|
2381
|
-
|
|
2529
|
+
GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
|
|
2382
2530
|
|
|
2383
2531
|
if (repo->is_bare)
|
|
2384
2532
|
return NULL;
|
|
@@ -2386,9 +2534,25 @@ const char *git_repository_workdir(const git_repository *repo)
|
|
|
2386
2534
|
return repo->workdir;
|
|
2387
2535
|
}
|
|
2388
2536
|
|
|
2537
|
+
int git_repository_workdir_path(
|
|
2538
|
+
git_buf *out, git_repository *repo, const char *path)
|
|
2539
|
+
{
|
|
2540
|
+
int error;
|
|
2541
|
+
|
|
2542
|
+
if (!repo->workdir) {
|
|
2543
|
+
git_error_set(GIT_ERROR_REPOSITORY, "repository has no working directory");
|
|
2544
|
+
return GIT_EBAREREPO;
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
if (!(error = git_buf_joinpath(out, repo->workdir, path)))
|
|
2548
|
+
error = git_path_validate_workdir_buf(repo, out);
|
|
2549
|
+
|
|
2550
|
+
return error;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2389
2553
|
const char *git_repository_commondir(const git_repository *repo)
|
|
2390
2554
|
{
|
|
2391
|
-
|
|
2555
|
+
GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
|
|
2392
2556
|
return repo->commondir;
|
|
2393
2557
|
}
|
|
2394
2558
|
|
|
@@ -2398,7 +2562,8 @@ int git_repository_set_workdir(
|
|
|
2398
2562
|
int error = 0;
|
|
2399
2563
|
git_buf path = GIT_BUF_INIT;
|
|
2400
2564
|
|
|
2401
|
-
|
|
2565
|
+
GIT_ASSERT_ARG(repo);
|
|
2566
|
+
GIT_ASSERT_ARG(workdir);
|
|
2402
2567
|
|
|
2403
2568
|
if (git_path_prettify_dir(&path, workdir, NULL) < 0)
|
|
2404
2569
|
return -1;
|
|
@@ -2438,13 +2603,13 @@ int git_repository_set_workdir(
|
|
|
2438
2603
|
|
|
2439
2604
|
int git_repository_is_bare(const git_repository *repo)
|
|
2440
2605
|
{
|
|
2441
|
-
|
|
2606
|
+
GIT_ASSERT_ARG(repo);
|
|
2442
2607
|
return repo->is_bare;
|
|
2443
2608
|
}
|
|
2444
2609
|
|
|
2445
2610
|
int git_repository_is_worktree(const git_repository *repo)
|
|
2446
2611
|
{
|
|
2447
|
-
|
|
2612
|
+
GIT_ASSERT_ARG(repo);
|
|
2448
2613
|
return repo->is_worktree;
|
|
2449
2614
|
}
|
|
2450
2615
|
|
|
@@ -2453,7 +2618,7 @@ int git_repository_set_bare(git_repository *repo)
|
|
|
2453
2618
|
int error;
|
|
2454
2619
|
git_config *config;
|
|
2455
2620
|
|
|
2456
|
-
|
|
2621
|
+
GIT_ASSERT_ARG(repo);
|
|
2457
2622
|
|
|
2458
2623
|
if (repo->is_bare)
|
|
2459
2624
|
return 0;
|
|
@@ -2521,7 +2686,8 @@ int git_repository_message(git_buf *out, git_repository *repo)
|
|
|
2521
2686
|
struct stat st;
|
|
2522
2687
|
int error;
|
|
2523
2688
|
|
|
2524
|
-
git_buf_sanitize(out)
|
|
2689
|
+
if ((error = git_buf_sanitize(out)) < 0)
|
|
2690
|
+
return error;
|
|
2525
2691
|
|
|
2526
2692
|
if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0)
|
|
2527
2693
|
return -1;
|
|
@@ -2566,16 +2732,19 @@ int git_repository_hashfile(
|
|
|
2566
2732
|
uint64_t len;
|
|
2567
2733
|
git_buf full_path = GIT_BUF_INIT;
|
|
2568
2734
|
|
|
2569
|
-
|
|
2735
|
+
/* as_path can be NULL */
|
|
2736
|
+
GIT_ASSERT_ARG(out);
|
|
2737
|
+
GIT_ASSERT_ARG(path);
|
|
2738
|
+
GIT_ASSERT_ARG(repo);
|
|
2570
2739
|
|
|
2571
2740
|
/* At some point, it would be nice if repo could be NULL to just
|
|
2572
2741
|
* apply filter rules defined in system and global files, but for
|
|
2573
2742
|
* now that is not possible because git_filters_load() needs it.
|
|
2574
2743
|
*/
|
|
2575
2744
|
|
|
2576
|
-
error = git_path_join_unrooted(
|
|
2577
|
-
&full_path, path, git_repository_workdir(repo), NULL)
|
|
2578
|
-
|
|
2745
|
+
if ((error = git_path_join_unrooted(
|
|
2746
|
+
&full_path, path, git_repository_workdir(repo), NULL)) < 0 ||
|
|
2747
|
+
(error = git_path_validate_workdir_buf(repo, &full_path)) < 0)
|
|
2579
2748
|
return error;
|
|
2580
2749
|
|
|
2581
2750
|
if (!as_path)
|
|
@@ -2651,7 +2820,8 @@ static int detach(git_repository *repo, const git_oid *id, const char *new)
|
|
|
2651
2820
|
git_object *object = NULL, *peeled = NULL;
|
|
2652
2821
|
git_reference *new_head = NULL, *current = NULL;
|
|
2653
2822
|
|
|
2654
|
-
|
|
2823
|
+
GIT_ASSERT_ARG(repo);
|
|
2824
|
+
GIT_ASSERT_ARG(id);
|
|
2655
2825
|
|
|
2656
2826
|
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0)
|
|
2657
2827
|
return error;
|
|
@@ -2687,7 +2857,8 @@ int git_repository_set_head(
|
|
|
2687
2857
|
git_buf log_message = GIT_BUF_INIT;
|
|
2688
2858
|
int error;
|
|
2689
2859
|
|
|
2690
|
-
|
|
2860
|
+
GIT_ASSERT_ARG(repo);
|
|
2861
|
+
GIT_ASSERT_ARG(refname);
|
|
2691
2862
|
|
|
2692
2863
|
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0)
|
|
2693
2864
|
return error;
|
|
@@ -2739,7 +2910,8 @@ int git_repository_set_head_detached_from_annotated(
|
|
|
2739
2910
|
git_repository *repo,
|
|
2740
2911
|
const git_annotated_commit *commitish)
|
|
2741
2912
|
{
|
|
2742
|
-
|
|
2913
|
+
GIT_ASSERT_ARG(repo);
|
|
2914
|
+
GIT_ASSERT_ARG(commitish);
|
|
2743
2915
|
|
|
2744
2916
|
return detach(repo, git_annotated_commit_id(commitish), commitish->description);
|
|
2745
2917
|
}
|
|
@@ -2751,7 +2923,7 @@ int git_repository_detach_head(git_repository* repo)
|
|
|
2751
2923
|
git_buf log_message = GIT_BUF_INIT;
|
|
2752
2924
|
int error;
|
|
2753
2925
|
|
|
2754
|
-
|
|
2926
|
+
GIT_ASSERT_ARG(repo);
|
|
2755
2927
|
|
|
2756
2928
|
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0)
|
|
2757
2929
|
return error;
|
|
@@ -2786,7 +2958,7 @@ int git_repository_state(git_repository *repo)
|
|
|
2786
2958
|
git_buf repo_path = GIT_BUF_INIT;
|
|
2787
2959
|
int state = GIT_REPOSITORY_STATE_NONE;
|
|
2788
2960
|
|
|
2789
|
-
|
|
2961
|
+
GIT_ASSERT_ARG(repo);
|
|
2790
2962
|
|
|
2791
2963
|
if (git_buf_puts(&repo_path, repo->gitdir) < 0)
|
|
2792
2964
|
return -1;
|
|
@@ -2863,7 +3035,7 @@ static const char *state_files[] = {
|
|
|
2863
3035
|
|
|
2864
3036
|
int git_repository_state_cleanup(git_repository *repo)
|
|
2865
3037
|
{
|
|
2866
|
-
|
|
3038
|
+
GIT_ASSERT_ARG(repo);
|
|
2867
3039
|
|
|
2868
3040
|
return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files));
|
|
2869
3041
|
}
|
|
@@ -2899,11 +3071,13 @@ int git_repository_init_options_init(
|
|
|
2899
3071
|
return 0;
|
|
2900
3072
|
}
|
|
2901
3073
|
|
|
3074
|
+
#ifndef GIT_DEPRECATE_HARD
|
|
2902
3075
|
int git_repository_init_init_options(
|
|
2903
3076
|
git_repository_init_options *opts, unsigned int version)
|
|
2904
3077
|
{
|
|
2905
3078
|
return git_repository_init_options_init(opts, version);
|
|
2906
3079
|
}
|
|
3080
|
+
#endif
|
|
2907
3081
|
|
|
2908
3082
|
int git_repository_ident(const char **name, const char **email, const git_repository *repo)
|
|
2909
3083
|
{
|
|
@@ -2927,8 +3101,8 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
|
|
|
2927
3101
|
GIT_ERROR_CHECK_ALLOC(tmp_email);
|
|
2928
3102
|
}
|
|
2929
3103
|
|
|
2930
|
-
tmp_name =
|
|
2931
|
-
tmp_email =
|
|
3104
|
+
tmp_name = git_atomic_swap(repo->ident_name, tmp_name);
|
|
3105
|
+
tmp_email = git_atomic_swap(repo->ident_email, tmp_email);
|
|
2932
3106
|
|
|
2933
3107
|
git__free(tmp_name);
|
|
2934
3108
|
git__free(tmp_email);
|
|
@@ -2938,28 +3112,16 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
|
|
|
2938
3112
|
|
|
2939
3113
|
int git_repository_submodule_cache_all(git_repository *repo)
|
|
2940
3114
|
{
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
assert(repo);
|
|
2944
|
-
|
|
2945
|
-
if ((error = git_strmap_new(&repo->submodule_cache)))
|
|
2946
|
-
return error;
|
|
2947
|
-
|
|
2948
|
-
error = git_submodule__map(repo, repo->submodule_cache);
|
|
2949
|
-
return error;
|
|
3115
|
+
GIT_ASSERT_ARG(repo);
|
|
3116
|
+
return git_submodule_cache_init(&repo->submodule_cache, repo);
|
|
2950
3117
|
}
|
|
2951
3118
|
|
|
2952
3119
|
int git_repository_submodule_cache_clear(git_repository *repo)
|
|
2953
3120
|
{
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
git_submodule_free(sm);
|
|
2961
|
-
});
|
|
2962
|
-
git_strmap_free(repo->submodule_cache);
|
|
2963
|
-
repo->submodule_cache = 0;
|
|
2964
|
-
return 0;
|
|
3121
|
+
int error = 0;
|
|
3122
|
+
GIT_ASSERT_ARG(repo);
|
|
3123
|
+
|
|
3124
|
+
error = git_submodule_cache_free(repo->submodule_cache);
|
|
3125
|
+
repo->submodule_cache = NULL;
|
|
3126
|
+
return error;
|
|
2965
3127
|
}
|