rugged 1.3.2.3 → 1.4.2
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/ext/rugged/extconf.rb +1 -1
- data/ext/rugged/rugged_config.c +7 -2
- data/ext/rugged/rugged_remote.c +17 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +103 -276
- data/vendor/libgit2/COPYING +36 -19
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
- data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
- data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -100
- data/vendor/libgit2/cmake/SelectHashes.cmake +39 -49
- data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +31 -31
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +1 -1
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/zlib/adler32.c +0 -7
- data/vendor/libgit2/deps/zlib/crc32.c +288 -975
- data/vendor/libgit2/deps/zlib/crc32.h +436 -9441
- data/vendor/libgit2/deps/zlib/deflate.c +31 -83
- data/vendor/libgit2/deps/zlib/deflate.h +15 -12
- data/vendor/libgit2/deps/zlib/gzguts.h +2 -3
- data/vendor/libgit2/deps/zlib/infback.c +1 -2
- data/vendor/libgit2/deps/zlib/inffast.c +14 -14
- data/vendor/libgit2/deps/zlib/inflate.c +8 -39
- data/vendor/libgit2/deps/zlib/inflate.h +2 -3
- data/vendor/libgit2/deps/zlib/inftrees.c +3 -3
- data/vendor/libgit2/deps/zlib/trees.c +48 -27
- data/vendor/libgit2/deps/zlib/zlib.h +100 -126
- data/vendor/libgit2/deps/zlib/zutil.c +2 -2
- data/vendor/libgit2/deps/zlib/zutil.h +9 -12
- data/vendor/libgit2/include/git2/apply.h +16 -2
- data/vendor/libgit2/include/git2/attr.h +11 -2
- data/vendor/libgit2/include/git2/blame.h +4 -1
- data/vendor/libgit2/include/git2/blob.h +14 -1
- data/vendor/libgit2/include/git2/branch.h +2 -0
- data/vendor/libgit2/include/git2/buffer.h +18 -78
- data/vendor/libgit2/include/git2/cert.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +5 -2
- data/vendor/libgit2/include/git2/clone.h +3 -3
- data/vendor/libgit2/include/git2/commit.h +2 -0
- data/vendor/libgit2/include/git2/common.h +5 -12
- data/vendor/libgit2/include/git2/config.h +19 -3
- data/vendor/libgit2/include/git2/credential.h +2 -1
- data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
- data/vendor/libgit2/include/git2/deprecated.h +1 -1
- data/vendor/libgit2/include/git2/describe.h +7 -2
- data/vendor/libgit2/include/git2/diff.h +17 -9
- data/vendor/libgit2/include/git2/email.h +1 -1
- data/vendor/libgit2/include/git2/errors.h +1 -2
- data/vendor/libgit2/include/git2/filter.h +7 -2
- data/vendor/libgit2/include/git2/graph.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +1 -1
- data/vendor/libgit2/include/git2/index.h +11 -5
- data/vendor/libgit2/include/git2/indexer.h +19 -0
- data/vendor/libgit2/include/git2/merge.h +23 -3
- data/vendor/libgit2/include/git2/message.h +2 -0
- data/vendor/libgit2/include/git2/object.h +23 -0
- data/vendor/libgit2/include/git2/odb.h +37 -7
- data/vendor/libgit2/include/git2/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +24 -8
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/pathspec.h +1 -1
- data/vendor/libgit2/include/git2/proxy.h +1 -1
- data/vendor/libgit2/include/git2/rebase.h +9 -1
- data/vendor/libgit2/include/git2/refdb.h +3 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/refs.h +2 -2
- data/vendor/libgit2/include/git2/remote.h +184 -37
- data/vendor/libgit2/include/git2/repository.h +14 -9
- data/vendor/libgit2/include/git2/reset.h +2 -2
- data/vendor/libgit2/include/git2/revparse.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +4 -1
- data/vendor/libgit2/include/git2/signature.h +1 -1
- data/vendor/libgit2/include/git2/stash.h +3 -3
- data/vendor/libgit2/include/git2/status.h +9 -3
- data/vendor/libgit2/include/git2/submodule.h +7 -2
- data/vendor/libgit2/include/git2/sys/commit_graph.h +1 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -5
- data/vendor/libgit2/include/git2/sys/remote.h +31 -0
- data/vendor/libgit2/include/git2/sys/stream.h +1 -1
- data/vendor/libgit2/include/git2/sys/transport.h +25 -34
- data/vendor/libgit2/include/git2/tag.h +1 -0
- data/vendor/libgit2/include/git2/tree.h +4 -3
- data/vendor/libgit2/include/git2/types.h +7 -7
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/include/git2/worktree.h +12 -2
- data/vendor/libgit2/src/CMakeLists.txt +189 -315
- data/vendor/libgit2/src/annotated_commit.h +1 -1
- data/vendor/libgit2/src/apply.c +18 -18
- data/vendor/libgit2/src/apply.h +2 -2
- data/vendor/libgit2/src/attr.c +18 -18
- data/vendor/libgit2/src/attr_file.c +17 -17
- data/vendor/libgit2/src/attr_file.h +4 -4
- data/vendor/libgit2/src/attrcache.c +17 -12
- data/vendor/libgit2/src/blame_git.c +1 -1
- data/vendor/libgit2/src/blob.c +33 -26
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +150 -109
- data/vendor/libgit2/src/branch.h +15 -3
- data/vendor/libgit2/src/buf.c +126 -0
- data/vendor/libgit2/src/buf.h +50 -0
- data/vendor/libgit2/src/cc-compat.h +1 -1
- data/vendor/libgit2/src/checkout.c +74 -68
- data/vendor/libgit2/src/cherrypick.c +10 -10
- data/vendor/libgit2/src/clone.c +66 -66
- data/vendor/libgit2/src/commit.c +128 -58
- data/vendor/libgit2/src/commit.h +24 -1
- data/vendor/libgit2/src/commit_graph.c +68 -53
- data/vendor/libgit2/src/commit_graph.h +10 -3
- data/vendor/libgit2/src/commit_list.c +2 -3
- data/vendor/libgit2/src/common.h +10 -3
- data/vendor/libgit2/src/config.c +99 -77
- data/vendor/libgit2/src/config.h +15 -2
- data/vendor/libgit2/src/config_file.c +103 -91
- data/vendor/libgit2/src/config_mem.c +9 -9
- data/vendor/libgit2/src/config_parse.c +27 -23
- data/vendor/libgit2/src/crlf.c +24 -21
- data/vendor/libgit2/src/date.c +10 -17
- data/vendor/libgit2/src/date.h +33 -0
- data/vendor/libgit2/src/describe.c +27 -19
- data/vendor/libgit2/src/diff.c +25 -8
- data/vendor/libgit2/src/diff.h +2 -4
- data/vendor/libgit2/src/diff_driver.c +34 -36
- data/vendor/libgit2/src/diff_driver.h +3 -3
- data/vendor/libgit2/src/diff_file.c +29 -20
- data/vendor/libgit2/src/diff_generate.c +30 -6
- data/vendor/libgit2/src/diff_generate.h +5 -3
- data/vendor/libgit2/src/diff_print.c +102 -95
- data/vendor/libgit2/src/diff_stats.c +40 -29
- data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +3 -8
- data/vendor/libgit2/src/email.c +54 -38
- data/vendor/libgit2/src/email.h +1 -1
- data/vendor/libgit2/src/errors.c +18 -18
- data/vendor/libgit2/src/features.h.in +6 -1
- data/vendor/libgit2/src/fetch.c +69 -24
- data/vendor/libgit2/src/fetch.h +1 -1
- data/vendor/libgit2/src/fetchhead.c +19 -19
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/filebuf.h +1 -1
- data/vendor/libgit2/src/filter.c +96 -52
- data/vendor/libgit2/src/filter.h +26 -5
- data/vendor/libgit2/src/fs_path.c +1912 -0
- data/vendor/libgit2/src/fs_path.h +752 -0
- data/vendor/libgit2/src/futils.c +91 -85
- data/vendor/libgit2/src/futils.h +26 -14
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +2 -2
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +2 -2
- data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +2 -2
- data/vendor/libgit2/src/hash/sha1/openssl.c +2 -2
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +1 -1
- data/vendor/libgit2/src/hash/sha1/win32.c +6 -6
- data/vendor/libgit2/src/hash/sha1.h +3 -1
- data/vendor/libgit2/src/hash.c +67 -35
- data/vendor/libgit2/src/hash.h +12 -12
- data/vendor/libgit2/src/ident.c +18 -18
- data/vendor/libgit2/src/ignore.c +35 -34
- data/vendor/libgit2/src/ignore.h +2 -2
- data/vendor/libgit2/src/index.c +79 -80
- data/vendor/libgit2/src/index.h +6 -3
- data/vendor/libgit2/src/indexer.c +75 -57
- data/vendor/libgit2/src/iterator.c +64 -56
- data/vendor/libgit2/src/iterator.h +5 -5
- data/vendor/libgit2/src/khash.h +1 -1
- data/vendor/libgit2/src/libgit2.c +22 -19
- data/vendor/libgit2/src/mailmap.c +38 -36
- data/vendor/libgit2/src/merge.c +27 -27
- data/vendor/libgit2/src/merge.h +1 -14
- data/vendor/libgit2/src/merge_driver.c +2 -2
- data/vendor/libgit2/src/merge_file.c +13 -3
- data/vendor/libgit2/src/message.c +21 -10
- data/vendor/libgit2/src/midx.c +83 -66
- data/vendor/libgit2/src/midx.h +3 -3
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/net.c +278 -68
- data/vendor/libgit2/src/net.h +10 -3
- data/vendor/libgit2/src/netops.c +1 -1
- data/vendor/libgit2/src/netops.h +1 -1
- data/vendor/libgit2/src/notes.c +20 -29
- data/vendor/libgit2/src/object.c +49 -9
- data/vendor/libgit2/src/object.h +1 -1
- data/vendor/libgit2/src/odb.c +35 -32
- data/vendor/libgit2/src/odb.h +1 -1
- data/vendor/libgit2/src/odb_loose.c +68 -68
- data/vendor/libgit2/src/odb_mempack.c +18 -5
- data/vendor/libgit2/src/odb_pack.c +43 -43
- data/vendor/libgit2/src/oid.c +11 -4
- data/vendor/libgit2/src/oid.h +15 -0
- data/vendor/libgit2/src/pack-objects.c +41 -26
- data/vendor/libgit2/src/pack-objects.h +11 -6
- data/vendor/libgit2/src/pack.c +10 -10
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch.h +1 -0
- data/vendor/libgit2/src/patch_generate.c +27 -11
- data/vendor/libgit2/src/patch_generate.h +5 -5
- data/vendor/libgit2/src/patch_parse.c +24 -24
- data/vendor/libgit2/src/path.c +76 -1951
- data/vendor/libgit2/src/path.h +34 -741
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/pathspec.h +2 -2
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/posix.h +1 -0
- data/vendor/libgit2/src/pqueue.h +1 -1
- data/vendor/libgit2/src/proxy.c +4 -1
- data/vendor/libgit2/src/proxy.h +1 -1
- data/vendor/libgit2/src/push.c +30 -35
- data/vendor/libgit2/src/push.h +4 -16
- data/vendor/libgit2/src/rand.c +226 -0
- data/vendor/libgit2/src/rand.h +37 -0
- data/vendor/libgit2/src/reader.c +8 -8
- data/vendor/libgit2/src/reader.h +2 -2
- data/vendor/libgit2/src/rebase.c +89 -88
- data/vendor/libgit2/src/refdb_fs.c +447 -173
- data/vendor/libgit2/src/refs.c +32 -32
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +32 -37
- data/vendor/libgit2/src/refspec.h +5 -2
- data/vendor/libgit2/src/regexp.c +1 -1
- data/vendor/libgit2/src/remote.c +713 -419
- data/vendor/libgit2/src/remote.h +15 -10
- data/vendor/libgit2/src/repository.c +350 -467
- data/vendor/libgit2/src/repository.h +11 -10
- data/vendor/libgit2/src/reset.c +8 -5
- data/vendor/libgit2/src/revert.c +10 -10
- data/vendor/libgit2/src/revparse.c +48 -35
- data/vendor/libgit2/src/revwalk.c +7 -7
- data/vendor/libgit2/src/signature.c +12 -6
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +1 -1
- data/vendor/libgit2/src/sortedcache.h +1 -1
- data/vendor/libgit2/src/stash.c +36 -37
- data/vendor/libgit2/src/status.c +4 -1
- data/vendor/libgit2/src/{buffer.c → str.c} +157 -151
- data/vendor/libgit2/src/str.h +357 -0
- data/vendor/libgit2/src/streams/mbedtls.c +8 -6
- data/vendor/libgit2/src/streams/openssl_dynamic.h +3 -3
- data/vendor/libgit2/src/submodule.c +171 -159
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/sysdir.c +68 -52
- data/vendor/libgit2/src/sysdir.h +15 -10
- data/vendor/libgit2/src/tag.c +29 -27
- data/vendor/libgit2/src/thread.h +3 -3
- data/vendor/libgit2/src/threadstate.c +3 -3
- data/vendor/libgit2/src/threadstate.h +1 -1
- data/vendor/libgit2/src/trace.c +1 -14
- data/vendor/libgit2/src/trace.h +5 -22
- data/vendor/libgit2/src/trailer.c +1 -1
- data/vendor/libgit2/src/transaction.c +1 -1
- data/vendor/libgit2/src/transport.c +10 -10
- data/vendor/libgit2/src/transports/auth.c +7 -9
- data/vendor/libgit2/src/transports/auth.h +2 -3
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -13
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -10
- data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
- data/vendor/libgit2/src/transports/git.c +9 -11
- data/vendor/libgit2/src/transports/http.c +37 -17
- data/vendor/libgit2/src/transports/http.h +2 -3
- data/vendor/libgit2/src/transports/httpclient.c +65 -65
- data/vendor/libgit2/src/transports/local.c +124 -116
- data/vendor/libgit2/src/transports/smart.c +51 -139
- data/vendor/libgit2/src/transports/smart.h +25 -31
- data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
- data/vendor/libgit2/src/transports/smart_protocol.c +57 -39
- data/vendor/libgit2/src/transports/ssh.c +47 -112
- data/vendor/libgit2/src/transports/winhttp.c +50 -56
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree-cache.h +2 -2
- data/vendor/libgit2/src/tree.c +59 -48
- data/vendor/libgit2/src/tree.h +1 -1
- data/vendor/libgit2/src/unix/map.c +0 -2
- data/vendor/libgit2/src/unix/posix.h +1 -4
- data/vendor/libgit2/src/unix/realpath.c +0 -2
- data/vendor/libgit2/src/util.c +14 -14
- data/vendor/libgit2/src/util.h +2 -28
- data/vendor/libgit2/src/vector.h +1 -1
- data/vendor/libgit2/src/win32/findfile.c +172 -116
- data/vendor/libgit2/src/win32/findfile.h +7 -4
- data/vendor/libgit2/src/win32/path_w32.c +140 -9
- data/vendor/libgit2/src/win32/path_w32.h +2 -0
- data/vendor/libgit2/src/win32/posix.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +11 -27
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -3
- data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
- data/vendor/libgit2/src/win32/w32_leakcheck.c +1 -1
- data/vendor/libgit2/src/worktree.c +116 -94
- data/vendor/libgit2/src/worktree.h +1 -1
- data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
- data/vendor/libgit2/src/xdiff/xemit.c +23 -7
- data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
- data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
- data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
- data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
- data/vendor/libgit2/src/xdiff/xutils.c +18 -7
- data/vendor/libgit2/src/zstream.c +5 -5
- data/vendor/libgit2/src/zstream.h +4 -4
- metadata +25 -10
- data/vendor/libgit2/src/buffer.h +0 -374
|
@@ -7,32 +7,34 @@
|
|
|
7
7
|
|
|
8
8
|
#include "worktree.h"
|
|
9
9
|
|
|
10
|
+
#include "buf.h"
|
|
11
|
+
#include "repository.h"
|
|
12
|
+
#include "path.h"
|
|
13
|
+
|
|
10
14
|
#include "git2/branch.h"
|
|
11
15
|
#include "git2/commit.h"
|
|
12
16
|
#include "git2/worktree.h"
|
|
13
17
|
|
|
14
|
-
#include "repository.h"
|
|
15
|
-
|
|
16
18
|
static bool is_worktree_dir(const char *dir)
|
|
17
19
|
{
|
|
18
|
-
|
|
20
|
+
git_str buf = GIT_STR_INIT;
|
|
19
21
|
int error;
|
|
20
22
|
|
|
21
|
-
if (
|
|
23
|
+
if (git_str_sets(&buf, dir) < 0)
|
|
22
24
|
return -1;
|
|
23
25
|
|
|
24
|
-
error =
|
|
25
|
-
&&
|
|
26
|
-
&&
|
|
26
|
+
error = git_fs_path_contains_file(&buf, "commondir")
|
|
27
|
+
&& git_fs_path_contains_file(&buf, "gitdir")
|
|
28
|
+
&& git_fs_path_contains_file(&buf, "HEAD");
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
git_str_dispose(&buf);
|
|
29
31
|
return error;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
int git_worktree_list(git_strarray *wts, git_repository *repo)
|
|
33
35
|
{
|
|
34
36
|
git_vector worktrees = GIT_VECTOR_INIT;
|
|
35
|
-
|
|
37
|
+
git_str path = GIT_STR_INIT;
|
|
36
38
|
char *worktree;
|
|
37
39
|
size_t i, len;
|
|
38
40
|
int error;
|
|
@@ -43,18 +45,18 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
|
|
|
43
45
|
wts->count = 0;
|
|
44
46
|
wts->strings = NULL;
|
|
45
47
|
|
|
46
|
-
if ((error =
|
|
48
|
+
if ((error = git_str_joinpath(&path, repo->commondir, "worktrees/")) < 0)
|
|
47
49
|
goto exit;
|
|
48
|
-
if (!
|
|
50
|
+
if (!git_fs_path_exists(path.ptr) || git_fs_path_is_empty_dir(path.ptr))
|
|
49
51
|
goto exit;
|
|
50
|
-
if ((error =
|
|
52
|
+
if ((error = git_fs_path_dirload(&worktrees, path.ptr, path.size, 0x0)) < 0)
|
|
51
53
|
goto exit;
|
|
52
54
|
|
|
53
55
|
len = path.size;
|
|
54
56
|
|
|
55
57
|
git_vector_foreach(&worktrees, i, worktree) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
git_str_truncate(&path, len);
|
|
59
|
+
git_str_puts(&path, worktree);
|
|
58
60
|
|
|
59
61
|
if (!is_worktree_dir(path.ptr)) {
|
|
60
62
|
git_vector_remove(&worktrees, i);
|
|
@@ -65,68 +67,68 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
|
|
|
65
67
|
wts->strings = (char **)git_vector_detach(&wts->count, NULL, &worktrees);
|
|
66
68
|
|
|
67
69
|
exit:
|
|
68
|
-
|
|
70
|
+
git_str_dispose(&path);
|
|
69
71
|
|
|
70
72
|
return error;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
char *git_worktree__read_link(const char *base, const char *file)
|
|
74
76
|
{
|
|
75
|
-
|
|
77
|
+
git_str path = GIT_STR_INIT, buf = GIT_STR_INIT;
|
|
76
78
|
|
|
77
79
|
GIT_ASSERT_ARG_WITH_RETVAL(base, NULL);
|
|
78
80
|
GIT_ASSERT_ARG_WITH_RETVAL(file, NULL);
|
|
79
81
|
|
|
80
|
-
if (
|
|
82
|
+
if (git_str_joinpath(&path, base, file) < 0)
|
|
81
83
|
goto err;
|
|
82
84
|
if (git_futils_readbuffer(&buf, path.ptr) < 0)
|
|
83
85
|
goto err;
|
|
84
|
-
|
|
86
|
+
git_str_dispose(&path);
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
git_str_rtrim(&buf);
|
|
87
89
|
|
|
88
|
-
if (!
|
|
89
|
-
return
|
|
90
|
+
if (!git_fs_path_is_relative(buf.ptr))
|
|
91
|
+
return git_str_detach(&buf);
|
|
90
92
|
|
|
91
|
-
if (
|
|
93
|
+
if (git_str_sets(&path, base) < 0)
|
|
92
94
|
goto err;
|
|
93
|
-
if (
|
|
95
|
+
if (git_fs_path_apply_relative(&path, buf.ptr) < 0)
|
|
94
96
|
goto err;
|
|
95
|
-
|
|
97
|
+
git_str_dispose(&buf);
|
|
96
98
|
|
|
97
|
-
return
|
|
99
|
+
return git_str_detach(&path);
|
|
98
100
|
|
|
99
101
|
err:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
git_str_dispose(&buf);
|
|
103
|
+
git_str_dispose(&path);
|
|
102
104
|
|
|
103
105
|
return NULL;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
static int write_wtfile(const char *base, const char *file, const
|
|
108
|
+
static int write_wtfile(const char *base, const char *file, const git_str *buf)
|
|
107
109
|
{
|
|
108
|
-
|
|
110
|
+
git_str path = GIT_STR_INIT;
|
|
109
111
|
int err;
|
|
110
112
|
|
|
111
113
|
GIT_ASSERT_ARG(base);
|
|
112
114
|
GIT_ASSERT_ARG(file);
|
|
113
115
|
GIT_ASSERT_ARG(buf);
|
|
114
116
|
|
|
115
|
-
if ((err =
|
|
117
|
+
if ((err = git_str_joinpath(&path, base, file)) < 0)
|
|
116
118
|
goto out;
|
|
117
119
|
|
|
118
120
|
if ((err = git_futils_writebuffer(buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
|
|
119
121
|
goto out;
|
|
120
122
|
|
|
121
123
|
out:
|
|
122
|
-
|
|
124
|
+
git_str_dispose(&path);
|
|
123
125
|
|
|
124
126
|
return err;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
static int open_worktree_dir(git_worktree **out, const char *parent, const char *dir, const char *name)
|
|
128
130
|
{
|
|
129
|
-
|
|
131
|
+
git_str gitdir = GIT_STR_INIT;
|
|
130
132
|
git_worktree *wt = NULL;
|
|
131
133
|
int error = 0;
|
|
132
134
|
|
|
@@ -135,7 +137,7 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
|
135
137
|
goto out;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
if ((error =
|
|
140
|
+
if ((error = git_path_validate_length(NULL, dir)) < 0)
|
|
139
141
|
goto out;
|
|
140
142
|
|
|
141
143
|
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
|
|
@@ -147,14 +149,14 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
|
147
149
|
(wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL ||
|
|
148
150
|
(wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL ||
|
|
149
151
|
(parent && (wt->parent_path = git__strdup(parent)) == NULL) ||
|
|
150
|
-
(wt->worktree_path =
|
|
152
|
+
(wt->worktree_path = git_fs_path_dirname(wt->gitlink_path)) == NULL) {
|
|
151
153
|
error = -1;
|
|
152
154
|
goto out;
|
|
153
155
|
}
|
|
154
156
|
|
|
155
|
-
if ((error =
|
|
157
|
+
if ((error = git_fs_path_prettify_dir(&gitdir, dir, NULL)) < 0)
|
|
156
158
|
goto out;
|
|
157
|
-
wt->gitdir_path =
|
|
159
|
+
wt->gitdir_path = git_str_detach(&gitdir);
|
|
158
160
|
|
|
159
161
|
if ((error = git_worktree_is_locked(NULL, wt)) < 0)
|
|
160
162
|
goto out;
|
|
@@ -166,14 +168,14 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
|
166
168
|
out:
|
|
167
169
|
if (error)
|
|
168
170
|
git_worktree_free(wt);
|
|
169
|
-
|
|
171
|
+
git_str_dispose(&gitdir);
|
|
170
172
|
|
|
171
173
|
return error;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *name)
|
|
175
177
|
{
|
|
176
|
-
|
|
178
|
+
git_str path = GIT_STR_INIT;
|
|
177
179
|
git_worktree *wt = NULL;
|
|
178
180
|
int error;
|
|
179
181
|
|
|
@@ -182,14 +184,14 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na
|
|
|
182
184
|
|
|
183
185
|
*out = NULL;
|
|
184
186
|
|
|
185
|
-
if ((error =
|
|
187
|
+
if ((error = git_str_join3(&path, '/', repo->commondir, "worktrees", name)) < 0)
|
|
186
188
|
goto out;
|
|
187
189
|
|
|
188
190
|
if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0)
|
|
189
191
|
goto out;
|
|
190
192
|
|
|
191
193
|
out:
|
|
192
|
-
|
|
194
|
+
git_str_dispose(&path);
|
|
193
195
|
|
|
194
196
|
if (error)
|
|
195
197
|
git_worktree_free(wt);
|
|
@@ -199,7 +201,7 @@ out:
|
|
|
199
201
|
|
|
200
202
|
int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
|
|
201
203
|
{
|
|
202
|
-
|
|
204
|
+
git_str parent = GIT_STR_INIT;
|
|
203
205
|
const char *gitdir, *commondir;
|
|
204
206
|
char *name = NULL;
|
|
205
207
|
int error = 0;
|
|
@@ -213,18 +215,18 @@ int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
|
|
|
213
215
|
gitdir = git_repository_path(repo);
|
|
214
216
|
commondir = git_repository_commondir(repo);
|
|
215
217
|
|
|
216
|
-
if ((error =
|
|
218
|
+
if ((error = git_fs_path_prettify_dir(&parent, "..", commondir)) < 0)
|
|
217
219
|
goto out;
|
|
218
220
|
|
|
219
221
|
/* The name is defined by the last component in '.git/worktree/%s' */
|
|
220
|
-
name =
|
|
222
|
+
name = git_fs_path_basename(gitdir);
|
|
221
223
|
|
|
222
224
|
if ((error = open_worktree_dir(out, parent.ptr, gitdir, name)) < 0)
|
|
223
225
|
goto out;
|
|
224
226
|
|
|
225
227
|
out:
|
|
226
228
|
git__free(name);
|
|
227
|
-
|
|
229
|
+
git_str_dispose(&parent);
|
|
228
230
|
|
|
229
231
|
return error;
|
|
230
232
|
}
|
|
@@ -254,21 +256,21 @@ int git_worktree_validate(const git_worktree *wt)
|
|
|
254
256
|
return GIT_ERROR;
|
|
255
257
|
}
|
|
256
258
|
|
|
257
|
-
if (wt->parent_path && !
|
|
259
|
+
if (wt->parent_path && !git_fs_path_exists(wt->parent_path)) {
|
|
258
260
|
git_error_set(GIT_ERROR_WORKTREE,
|
|
259
261
|
"worktree parent directory ('%s') does not exist ",
|
|
260
262
|
wt->parent_path);
|
|
261
263
|
return GIT_ERROR;
|
|
262
264
|
}
|
|
263
265
|
|
|
264
|
-
if (!
|
|
266
|
+
if (!git_fs_path_exists(wt->commondir_path)) {
|
|
265
267
|
git_error_set(GIT_ERROR_WORKTREE,
|
|
266
268
|
"worktree common directory ('%s') does not exist ",
|
|
267
269
|
wt->commondir_path);
|
|
268
270
|
return GIT_ERROR;
|
|
269
271
|
}
|
|
270
272
|
|
|
271
|
-
if (!
|
|
273
|
+
if (!git_fs_path_exists(wt->worktree_path)) {
|
|
272
274
|
git_error_set(GIT_ERROR_WORKTREE,
|
|
273
275
|
"worktree directory '%s' does not exist",
|
|
274
276
|
wt->worktree_path);
|
|
@@ -298,20 +300,17 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
|
298
300
|
const char *name, const char *worktree,
|
|
299
301
|
const git_worktree_add_options *opts)
|
|
300
302
|
{
|
|
301
|
-
|
|
303
|
+
git_str gitdir = GIT_STR_INIT, wddir = GIT_STR_INIT, buf = GIT_STR_INIT;
|
|
302
304
|
git_reference *ref = NULL, *head = NULL;
|
|
303
305
|
git_commit *commit = NULL;
|
|
304
306
|
git_repository *wt = NULL;
|
|
305
|
-
git_checkout_options coopts
|
|
307
|
+
git_checkout_options coopts;
|
|
306
308
|
git_worktree_add_options wtopts = GIT_WORKTREE_ADD_OPTIONS_INIT;
|
|
307
309
|
int err;
|
|
308
310
|
|
|
309
311
|
GIT_ERROR_CHECK_VERSION(
|
|
310
312
|
opts, GIT_WORKTREE_ADD_OPTIONS_VERSION, "git_worktree_add_options");
|
|
311
313
|
|
|
312
|
-
if (opts)
|
|
313
|
-
memcpy(&wtopts, opts, sizeof(wtopts));
|
|
314
|
-
|
|
315
314
|
GIT_ASSERT_ARG(out);
|
|
316
315
|
GIT_ASSERT_ARG(repo);
|
|
317
316
|
GIT_ASSERT_ARG(name);
|
|
@@ -319,6 +318,11 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
|
319
318
|
|
|
320
319
|
*out = NULL;
|
|
321
320
|
|
|
321
|
+
if (opts)
|
|
322
|
+
memcpy(&wtopts, opts, sizeof(wtopts));
|
|
323
|
+
|
|
324
|
+
memcpy(&coopts, &wtopts.checkout_options, sizeof(coopts));
|
|
325
|
+
|
|
322
326
|
if (wtopts.ref) {
|
|
323
327
|
if (!git_reference_is_branch(wtopts.ref)) {
|
|
324
328
|
git_error_set(GIT_ERROR_WORKTREE, "reference is not a branch");
|
|
@@ -334,28 +338,28 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
/* Create gitdir directory ".git/worktrees/<name>" */
|
|
337
|
-
if ((err =
|
|
341
|
+
if ((err = git_str_joinpath(&gitdir, repo->commondir, "worktrees")) < 0)
|
|
338
342
|
goto out;
|
|
339
|
-
if (!
|
|
343
|
+
if (!git_fs_path_exists(gitdir.ptr))
|
|
340
344
|
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
|
|
341
345
|
goto out;
|
|
342
|
-
if ((err =
|
|
346
|
+
if ((err = git_str_joinpath(&gitdir, gitdir.ptr, name)) < 0)
|
|
343
347
|
goto out;
|
|
344
348
|
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0)
|
|
345
349
|
goto out;
|
|
346
|
-
if ((err =
|
|
350
|
+
if ((err = git_fs_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0)
|
|
347
351
|
goto out;
|
|
348
352
|
|
|
349
353
|
/* Create worktree work dir */
|
|
350
354
|
if ((err = git_futils_mkdir(worktree, 0755, GIT_MKDIR_EXCL)) < 0)
|
|
351
355
|
goto out;
|
|
352
|
-
if ((err =
|
|
356
|
+
if ((err = git_fs_path_prettify_dir(&wddir, worktree, NULL)) < 0)
|
|
353
357
|
goto out;
|
|
354
358
|
|
|
355
359
|
if (wtopts.lock) {
|
|
356
360
|
int fd;
|
|
357
361
|
|
|
358
|
-
if ((err =
|
|
362
|
+
if ((err = git_str_joinpath(&buf, gitdir.ptr, "locked")) < 0)
|
|
359
363
|
goto out;
|
|
360
364
|
|
|
361
365
|
if ((fd = p_creat(buf.ptr, 0644)) < 0) {
|
|
@@ -364,22 +368,22 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
|
364
368
|
}
|
|
365
369
|
|
|
366
370
|
p_close(fd);
|
|
367
|
-
|
|
371
|
+
git_str_clear(&buf);
|
|
368
372
|
}
|
|
369
373
|
|
|
370
374
|
/* Create worktree .git file */
|
|
371
|
-
if ((err =
|
|
375
|
+
if ((err = git_str_printf(&buf, "gitdir: %s\n", gitdir.ptr)) < 0)
|
|
372
376
|
goto out;
|
|
373
377
|
if ((err = write_wtfile(wddir.ptr, ".git", &buf)) < 0)
|
|
374
378
|
goto out;
|
|
375
379
|
|
|
376
380
|
/* Create gitdir files */
|
|
377
|
-
if ((err =
|
|
378
|
-
|| (err =
|
|
381
|
+
if ((err = git_fs_path_prettify_dir(&buf, repo->commondir, NULL) < 0)
|
|
382
|
+
|| (err = git_str_putc(&buf, '\n')) < 0
|
|
379
383
|
|| (err = write_wtfile(gitdir.ptr, "commondir", &buf)) < 0)
|
|
380
384
|
goto out;
|
|
381
|
-
if ((err =
|
|
382
|
-
|| (err =
|
|
385
|
+
if ((err = git_str_joinpath(&buf, wddir.ptr, ".git")) < 0
|
|
386
|
+
|| (err = git_str_putc(&buf, '\n')) < 0
|
|
383
387
|
|| (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0)
|
|
384
388
|
goto out;
|
|
385
389
|
|
|
@@ -403,7 +407,6 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
|
403
407
|
goto out;
|
|
404
408
|
|
|
405
409
|
/* Checkout worktree's HEAD */
|
|
406
|
-
coopts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
|
407
410
|
if ((err = git_checkout_head(wt, &coopts)) < 0)
|
|
408
411
|
goto out;
|
|
409
412
|
|
|
@@ -412,9 +415,9 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
|
412
415
|
goto out;
|
|
413
416
|
|
|
414
417
|
out:
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
+
git_str_dispose(&gitdir);
|
|
419
|
+
git_str_dispose(&wddir);
|
|
420
|
+
git_str_dispose(&buf);
|
|
418
421
|
git_reference_free(ref);
|
|
419
422
|
git_reference_free(head);
|
|
420
423
|
git_commit_free(commit);
|
|
@@ -425,7 +428,7 @@ out:
|
|
|
425
428
|
|
|
426
429
|
int git_worktree_lock(git_worktree *wt, const char *reason)
|
|
427
430
|
{
|
|
428
|
-
|
|
431
|
+
git_str buf = GIT_STR_INIT, path = GIT_STR_INIT;
|
|
429
432
|
int error;
|
|
430
433
|
|
|
431
434
|
GIT_ASSERT_ARG(wt);
|
|
@@ -437,11 +440,11 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
|
|
|
437
440
|
goto out;
|
|
438
441
|
}
|
|
439
442
|
|
|
440
|
-
if ((error =
|
|
443
|
+
if ((error = git_str_joinpath(&path, wt->gitdir_path, "locked")) < 0)
|
|
441
444
|
goto out;
|
|
442
445
|
|
|
443
446
|
if (reason)
|
|
444
|
-
|
|
447
|
+
git_str_attach_notowned(&buf, reason, strlen(reason));
|
|
445
448
|
|
|
446
449
|
if ((error = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
|
|
447
450
|
goto out;
|
|
@@ -449,14 +452,14 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
|
|
|
449
452
|
wt->locked = 1;
|
|
450
453
|
|
|
451
454
|
out:
|
|
452
|
-
|
|
455
|
+
git_str_dispose(&path);
|
|
453
456
|
|
|
454
457
|
return error;
|
|
455
458
|
}
|
|
456
459
|
|
|
457
460
|
int git_worktree_unlock(git_worktree *wt)
|
|
458
461
|
{
|
|
459
|
-
|
|
462
|
+
git_str path = GIT_STR_INIT;
|
|
460
463
|
int error;
|
|
461
464
|
|
|
462
465
|
GIT_ASSERT_ARG(wt);
|
|
@@ -466,42 +469,61 @@ int git_worktree_unlock(git_worktree *wt)
|
|
|
466
469
|
if (!error)
|
|
467
470
|
return 1;
|
|
468
471
|
|
|
469
|
-
if (
|
|
472
|
+
if (git_str_joinpath(&path, wt->gitdir_path, "locked") < 0)
|
|
470
473
|
return -1;
|
|
471
474
|
|
|
472
475
|
if (p_unlink(path.ptr) != 0) {
|
|
473
|
-
|
|
476
|
+
git_str_dispose(&path);
|
|
474
477
|
return -1;
|
|
475
478
|
}
|
|
476
479
|
|
|
477
480
|
wt->locked = 0;
|
|
478
481
|
|
|
479
|
-
|
|
482
|
+
git_str_dispose(&path);
|
|
480
483
|
|
|
481
484
|
return 0;
|
|
482
485
|
}
|
|
483
486
|
|
|
484
|
-
int
|
|
487
|
+
static int git_worktree__is_locked(git_str *reason, const git_worktree *wt)
|
|
485
488
|
{
|
|
486
|
-
|
|
489
|
+
git_str path = GIT_STR_INIT;
|
|
487
490
|
int error, locked;
|
|
488
491
|
|
|
489
492
|
GIT_ASSERT_ARG(wt);
|
|
490
493
|
|
|
491
494
|
if (reason)
|
|
492
|
-
|
|
495
|
+
git_str_clear(reason);
|
|
493
496
|
|
|
494
|
-
if ((error =
|
|
497
|
+
if ((error = git_str_joinpath(&path, wt->gitdir_path, "locked")) < 0)
|
|
495
498
|
goto out;
|
|
496
|
-
locked =
|
|
499
|
+
locked = git_fs_path_exists(path.ptr);
|
|
497
500
|
if (locked && reason &&
|
|
498
501
|
(error = git_futils_readbuffer(reason, path.ptr)) < 0)
|
|
499
502
|
goto out;
|
|
500
503
|
|
|
501
504
|
error = locked;
|
|
502
505
|
out:
|
|
503
|
-
|
|
506
|
+
git_str_dispose(&path);
|
|
507
|
+
|
|
508
|
+
return error;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
|
|
512
|
+
{
|
|
513
|
+
git_str str = GIT_STR_INIT;
|
|
514
|
+
int error = 0;
|
|
515
|
+
|
|
516
|
+
if (reason && (error = git_buf_tostr(&str, reason)) < 0)
|
|
517
|
+
return error;
|
|
518
|
+
|
|
519
|
+
error = git_worktree__is_locked(reason ? &str : NULL, wt);
|
|
520
|
+
|
|
521
|
+
if (error >= 0 && reason) {
|
|
522
|
+
if (git_buf_fromstr(reason, &str) < 0)
|
|
523
|
+
error = -1;
|
|
524
|
+
}
|
|
504
525
|
|
|
526
|
+
git_str_dispose(&str);
|
|
505
527
|
return error;
|
|
506
528
|
}
|
|
507
529
|
|
|
@@ -547,17 +569,17 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
|
547
569
|
memcpy(&popts, opts, sizeof(popts));
|
|
548
570
|
|
|
549
571
|
if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) {
|
|
550
|
-
|
|
572
|
+
git_str reason = GIT_STR_INIT;
|
|
551
573
|
int error;
|
|
552
574
|
|
|
553
|
-
if ((error =
|
|
575
|
+
if ((error = git_worktree__is_locked(&reason, wt)) < 0)
|
|
554
576
|
return error;
|
|
555
577
|
|
|
556
578
|
if (error) {
|
|
557
579
|
if (!reason.size)
|
|
558
|
-
|
|
580
|
+
git_str_attach_notowned(&reason, "no reason given", 15);
|
|
559
581
|
git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
|
|
560
|
-
|
|
582
|
+
git_str_dispose(&reason);
|
|
561
583
|
return 0;
|
|
562
584
|
}
|
|
563
585
|
}
|
|
@@ -575,7 +597,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
|
575
597
|
git_worktree_prune_options *opts)
|
|
576
598
|
{
|
|
577
599
|
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
|
|
578
|
-
|
|
600
|
+
git_str path = GIT_STR_INIT;
|
|
579
601
|
char *wtpath;
|
|
580
602
|
int err;
|
|
581
603
|
|
|
@@ -592,9 +614,9 @@ int git_worktree_prune(git_worktree *wt,
|
|
|
592
614
|
}
|
|
593
615
|
|
|
594
616
|
/* Delete gitdir in parent repository */
|
|
595
|
-
if ((err =
|
|
617
|
+
if ((err = git_str_join3(&path, '/', wt->commondir_path, "worktrees", wt->name)) < 0)
|
|
596
618
|
goto out;
|
|
597
|
-
if (!
|
|
619
|
+
if (!git_fs_path_exists(path.ptr))
|
|
598
620
|
{
|
|
599
621
|
git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir '%s' does not exist", path.ptr);
|
|
600
622
|
err = -1;
|
|
@@ -606,15 +628,15 @@ int git_worktree_prune(git_worktree *wt,
|
|
|
606
628
|
/* Skip deletion of the actual working tree if it does
|
|
607
629
|
* not exist or deletion was not requested */
|
|
608
630
|
if ((popts.flags & GIT_WORKTREE_PRUNE_WORKING_TREE) == 0 ||
|
|
609
|
-
!
|
|
631
|
+
!git_fs_path_exists(wt->gitlink_path))
|
|
610
632
|
{
|
|
611
633
|
goto out;
|
|
612
634
|
}
|
|
613
635
|
|
|
614
|
-
if ((wtpath =
|
|
636
|
+
if ((wtpath = git_fs_path_dirname(wt->gitlink_path)) == NULL)
|
|
615
637
|
goto out;
|
|
616
|
-
|
|
617
|
-
if (!
|
|
638
|
+
git_str_attach(&path, wtpath, 0);
|
|
639
|
+
if (!git_fs_path_exists(path.ptr))
|
|
618
640
|
{
|
|
619
641
|
git_error_set(GIT_ERROR_WORKTREE, "working tree '%s' does not exist", path.ptr);
|
|
620
642
|
err = -1;
|
|
@@ -624,7 +646,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
|
624
646
|
goto out;
|
|
625
647
|
|
|
626
648
|
out:
|
|
627
|
-
|
|
649
|
+
git_str_dispose(&path);
|
|
628
650
|
|
|
629
651
|
return err;
|
|
630
652
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* This file provides the necessary indirection between xdiff and
|
|
10
|
+
* libgit2. libgit2-specific functionality should live here, so
|
|
11
|
+
* that git and libgit2 can share a common xdiff implementation.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef INCLUDE_git_xdiff_h__
|
|
15
|
+
#define INCLUDE_git_xdiff_h__
|
|
16
|
+
|
|
17
|
+
#include "regexp.h"
|
|
18
|
+
|
|
19
|
+
/* Work around C90-conformance issues */
|
|
20
|
+
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
|
|
21
|
+
# if defined(_MSC_VER)
|
|
22
|
+
# define inline __inline
|
|
23
|
+
# elif defined(__GNUC__)
|
|
24
|
+
# define inline __inline__
|
|
25
|
+
# else
|
|
26
|
+
# define inline
|
|
27
|
+
# endif
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#define xdl_malloc(x) git__malloc(x)
|
|
31
|
+
#define xdl_free(ptr) git__free(ptr)
|
|
32
|
+
#define xdl_realloc(ptr, x) git__realloc(ptr, x)
|
|
33
|
+
|
|
34
|
+
#define XDL_BUG(msg) GIT_ASSERT(msg)
|
|
35
|
+
|
|
36
|
+
#define xdl_regex_t git_regexp
|
|
37
|
+
#define xdl_regmatch_t git_regmatch
|
|
38
|
+
|
|
39
|
+
GIT_INLINE(int) xdl_regexec_buf(
|
|
40
|
+
const xdl_regex_t *preg, const char *buf, size_t size,
|
|
41
|
+
size_t nmatch, xdl_regmatch_t pmatch[], int eflags)
|
|
42
|
+
{
|
|
43
|
+
GIT_UNUSED(preg);
|
|
44
|
+
GIT_UNUSED(buf);
|
|
45
|
+
GIT_UNUSED(size);
|
|
46
|
+
GIT_UNUSED(nmatch);
|
|
47
|
+
GIT_UNUSED(pmatch);
|
|
48
|
+
GIT_UNUSED(eflags);
|
|
49
|
+
GIT_ASSERT("not implemented");
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#endif
|