rugged 0.27.10.1 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/extconf.rb +23 -2
- data/ext/rugged/rugged.c +48 -2
- data/ext/rugged/rugged.h +5 -0
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_blob.c +3 -3
- data/ext/rugged/rugged_branch.c +1 -1
- data/ext/rugged/rugged_commit.c +8 -8
- data/ext/rugged/rugged_config.c +1 -1
- data/ext/rugged/rugged_diff.c +24 -4
- data/ext/rugged/rugged_note.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -10
- data/ext/rugged/rugged_settings.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +69 -47
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/include/git2.h +3 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +19 -8
- data/vendor/libgit2/include/git2/blame.h +41 -24
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -2
- data/vendor/libgit2/include/git2/checkout.h +20 -19
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +11 -9
- data/vendor/libgit2/include/git2/commit.h +30 -2
- data/vendor/libgit2/include/git2/common.h +54 -4
- data/vendor/libgit2/include/git2/config.h +18 -7
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +193 -143
- data/vendor/libgit2/include/git2/errors.h +54 -46
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +72 -51
- data/vendor/libgit2/include/git2/indexer.h +30 -4
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +29 -8
- data/vendor/libgit2/include/git2/net.h +1 -1
- data/vendor/libgit2/include/git2/notes.h +1 -1
- data/vendor/libgit2/include/git2/object.h +16 -16
- data/vendor/libgit2/include/git2/odb.h +10 -10
- data/vendor/libgit2/include/git2/odb_backend.h +7 -7
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +2 -2
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refs.h +14 -15
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +92 -16
- data/vendor/libgit2/include/git2/repository.h +52 -37
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/revwalk.h +7 -7
- data/vendor/libgit2/include/git2/signature.h +2 -2
- data/vendor/libgit2/include/git2/stash.h +13 -10
- data/vendor/libgit2/include/git2/status.h +8 -4
- data/vendor/libgit2/include/git2/submodule.h +11 -10
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +1 -1
- data/vendor/libgit2/include/git2/sys/config.h +13 -13
- data/vendor/libgit2/include/git2/sys/filter.h +6 -6
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +9 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
- data/vendor/libgit2/include/git2/sys/stream.h +92 -12
- data/vendor/libgit2/include/git2/sys/transport.h +127 -81
- data/vendor/libgit2/include/git2/tag.h +2 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/transport.h +47 -18
- data/vendor/libgit2/include/git2/tree.h +3 -3
- data/vendor/libgit2/include/git2/types.h +35 -28
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +47 -12
- data/vendor/libgit2/src/CMakeLists.txt +87 -26
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +15 -8
- data/vendor/libgit2/src/apply.c +490 -14
- data/vendor/libgit2/src/apply.h +3 -1
- data/vendor/libgit2/src/array.h +2 -2
- data/vendor/libgit2/src/attr.c +11 -11
- data/vendor/libgit2/src/attr_file.c +20 -15
- data/vendor/libgit2/src/attrcache.c +11 -11
- data/vendor/libgit2/src/blame.c +30 -15
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +16 -13
- data/vendor/libgit2/src/blob.c +50 -28
- data/vendor/libgit2/src/blob.h +18 -1
- data/vendor/libgit2/src/branch.c +38 -38
- data/vendor/libgit2/src/buf_text.c +7 -6
- data/vendor/libgit2/src/buffer.c +55 -50
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/cache.c +16 -16
- data/vendor/libgit2/src/cache.h +2 -2
- data/vendor/libgit2/src/cc-compat.h +15 -3
- data/vendor/libgit2/src/checkout.c +83 -74
- data/vendor/libgit2/src/cherrypick.c +6 -6
- data/vendor/libgit2/src/clone.c +20 -20
- data/vendor/libgit2/src/commit.c +53 -33
- data/vendor/libgit2/src/commit.h +1 -0
- data/vendor/libgit2/src/commit_list.c +6 -10
- data/vendor/libgit2/src/common.h +32 -30
- data/vendor/libgit2/src/config.c +167 -147
- data/vendor/libgit2/src/config.h +1 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +7 -1
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +167 -439
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +69 -38
- data/vendor/libgit2/src/config_parse.h +4 -4
- data/vendor/libgit2/src/crlf.c +215 -186
- data/vendor/libgit2/src/delta.c +25 -18
- data/vendor/libgit2/src/describe.c +23 -23
- data/vendor/libgit2/src/diff.c +12 -12
- data/vendor/libgit2/src/diff_driver.c +14 -15
- data/vendor/libgit2/src/diff_file.c +10 -10
- data/vendor/libgit2/src/diff_generate.c +29 -23
- data/vendor/libgit2/src/diff_generate.h +1 -1
- data/vendor/libgit2/src/diff_parse.c +3 -3
- data/vendor/libgit2/src/diff_print.c +17 -17
- data/vendor/libgit2/src/diff_stats.c +22 -7
- data/vendor/libgit2/src/diff_tform.c +12 -12
- data/vendor/libgit2/src/diff_xdiff.c +15 -3
- data/vendor/libgit2/src/errors.c +42 -20
- data/vendor/libgit2/src/features.h.in +2 -1
- data/vendor/libgit2/src/fetch.c +3 -3
- data/vendor/libgit2/src/fetchhead.c +16 -16
- data/vendor/libgit2/src/filebuf.c +28 -28
- data/vendor/libgit2/src/fileops.c +54 -54
- data/vendor/libgit2/src/fileops.h +1 -1
- data/vendor/libgit2/src/filter.c +30 -30
- data/vendor/libgit2/src/filter.h +0 -10
- data/vendor/libgit2/src/global.c +36 -23
- data/vendor/libgit2/src/hash.h +4 -1
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
- data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
- data/vendor/libgit2/src/hash/hash_generic.h +5 -1
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
- data/vendor/libgit2/src/hash/hash_win32.c +13 -13
- data/vendor/libgit2/src/hashsig.c +4 -4
- data/vendor/libgit2/src/idxmap.c +25 -5
- data/vendor/libgit2/src/idxmap.h +4 -18
- data/vendor/libgit2/src/ignore.c +9 -9
- data/vendor/libgit2/src/index.c +280 -198
- data/vendor/libgit2/src/index.h +16 -0
- data/vendor/libgit2/src/indexer.c +311 -139
- data/vendor/libgit2/src/integer.h +32 -22
- data/vendor/libgit2/src/iterator.c +116 -49
- data/vendor/libgit2/src/iterator.h +15 -0
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/merge.c +89 -59
- data/vendor/libgit2/src/merge_driver.c +7 -7
- data/vendor/libgit2/src/merge_file.c +1 -1
- data/vendor/libgit2/src/mwindow.c +8 -8
- data/vendor/libgit2/src/netops.c +22 -13
- data/vendor/libgit2/src/netops.h +2 -0
- data/vendor/libgit2/src/notes.c +15 -10
- data/vendor/libgit2/src/object.c +118 -67
- data/vendor/libgit2/src/object.h +20 -9
- data/vendor/libgit2/src/object_api.c +8 -8
- data/vendor/libgit2/src/odb.c +72 -72
- data/vendor/libgit2/src/odb.h +7 -7
- data/vendor/libgit2/src/odb_loose.c +46 -46
- data/vendor/libgit2/src/odb_mempack.c +14 -14
- data/vendor/libgit2/src/odb_pack.c +14 -10
- data/vendor/libgit2/src/offmap.c +30 -0
- data/vendor/libgit2/src/offmap.h +20 -11
- data/vendor/libgit2/src/oid.c +6 -6
- data/vendor/libgit2/src/oidmap.c +20 -0
- data/vendor/libgit2/src/oidmap.h +9 -12
- data/vendor/libgit2/src/pack-objects.c +71 -63
- data/vendor/libgit2/src/pack-objects.h +1 -7
- data/vendor/libgit2/src/pack.c +58 -58
- data/vendor/libgit2/src/pack.h +6 -6
- data/vendor/libgit2/src/parse.h +1 -1
- data/vendor/libgit2/src/patch.c +3 -3
- data/vendor/libgit2/src/patch_generate.c +18 -18
- data/vendor/libgit2/src/patch_parse.c +13 -13
- data/vendor/libgit2/src/path.c +93 -225
- data/vendor/libgit2/src/path.h +2 -84
- data/vendor/libgit2/src/pathspec.c +6 -6
- data/vendor/libgit2/src/posix.c +3 -3
- data/vendor/libgit2/src/proxy.c +1 -1
- data/vendor/libgit2/src/push.c +27 -26
- data/vendor/libgit2/src/push.h +2 -1
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +49 -52
- data/vendor/libgit2/src/refdb.c +3 -3
- data/vendor/libgit2/src/refdb_fs.c +181 -103
- data/vendor/libgit2/src/reflog.c +3 -3
- data/vendor/libgit2/src/refs.c +98 -74
- data/vendor/libgit2/src/refs.h +5 -3
- data/vendor/libgit2/src/refspec.c +47 -21
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +219 -166
- data/vendor/libgit2/src/remote.h +9 -0
- data/vendor/libgit2/src/repository.c +173 -133
- data/vendor/libgit2/src/repository.h +6 -3
- data/vendor/libgit2/src/reset.c +8 -8
- data/vendor/libgit2/src/revert.c +6 -6
- data/vendor/libgit2/src/revparse.c +30 -30
- data/vendor/libgit2/src/revwalk.c +60 -30
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +42 -10
- data/vendor/libgit2/src/signature.c +11 -11
- data/vendor/libgit2/src/sortedcache.c +13 -13
- data/vendor/libgit2/src/stash.c +91 -45
- data/vendor/libgit2/src/status.c +13 -13
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
- data/vendor/libgit2/src/stream.h +17 -2
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +204 -114
- data/vendor/libgit2/src/streams/openssl.h +4 -108
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +54 -29
- data/vendor/libgit2/src/streams/stransport.c +57 -32
- data/vendor/libgit2/src/streams/stransport.h +5 -0
- data/vendor/libgit2/src/streams/tls.c +50 -19
- data/vendor/libgit2/src/streams/tls.h +12 -4
- data/vendor/libgit2/src/strmap.c +22 -2
- data/vendor/libgit2/src/strmap.h +18 -15
- data/vendor/libgit2/src/submodule.c +179 -155
- data/vendor/libgit2/src/sysdir.c +18 -18
- data/vendor/libgit2/src/tag.c +31 -26
- data/vendor/libgit2/src/tag.h +2 -1
- data/vendor/libgit2/src/trace.c +1 -1
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transaction.c +23 -23
- data/vendor/libgit2/src/transport.c +5 -5
- data/vendor/libgit2/src/transports/auth.c +7 -4
- data/vendor/libgit2/src/transports/auth.h +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
- data/vendor/libgit2/src/transports/cred.c +18 -18
- data/vendor/libgit2/src/transports/git.c +15 -15
- data/vendor/libgit2/src/transports/http.c +606 -216
- data/vendor/libgit2/src/transports/http.h +2 -0
- data/vendor/libgit2/src/transports/local.c +26 -26
- data/vendor/libgit2/src/transports/smart.c +54 -31
- data/vendor/libgit2/src/transports/smart.h +1 -2
- data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
- data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
- data/vendor/libgit2/src/transports/ssh.c +34 -33
- data/vendor/libgit2/src/transports/winhttp.c +99 -119
- data/vendor/libgit2/src/tree-cache.c +5 -5
- data/vendor/libgit2/src/tree.c +96 -121
- data/vendor/libgit2/src/tree.h +1 -12
- data/vendor/libgit2/src/unix/map.c +2 -2
- data/vendor/libgit2/src/util.c +22 -6
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/vector.c +4 -4
- data/vendor/libgit2/src/win32/dir.c +3 -3
- data/vendor/libgit2/src/win32/findfile.c +3 -3
- data/vendor/libgit2/src/win32/map.c +6 -6
- data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
- data/vendor/libgit2/src/win32/path_w32.c +101 -7
- data/vendor/libgit2/src/win32/path_w32.h +18 -0
- data/vendor/libgit2/src/win32/posix_w32.c +24 -43
- data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/win32/w32_stack.c +2 -2
- data/vendor/libgit2/src/win32/w32_util.c +1 -69
- data/vendor/libgit2/src/win32/w32_util.h +1 -19
- data/vendor/libgit2/src/worktree.c +75 -54
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
- data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
- data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
- data/vendor/libgit2/src/zstream.c +4 -4
- metadata +33 -7
- data/vendor/libgit2/src/config_file.h +0 -73
- data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -59,24 +59,6 @@ extern int git_win32__set_hidden(const char *path, bool hidden);
|
|
59
59
|
*/
|
60
60
|
extern int git_win32__hidden(bool *hidden, const char *path);
|
61
61
|
|
62
|
-
/**
|
63
|
-
* Removes any trailing backslashes from a path, except in the case of a drive
|
64
|
-
* letter path (C:\, D:\, etc.). This function cannot fail.
|
65
|
-
*
|
66
|
-
* @param path The path which should be trimmed.
|
67
|
-
* @return The length of the modified string (<= the input length)
|
68
|
-
*/
|
69
|
-
size_t git_win32__path_trim_end(wchar_t *str, size_t len);
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Removes any of the following namespace prefixes from a path,
|
73
|
-
* if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail.
|
74
|
-
*
|
75
|
-
* @param path The path which should be converted.
|
76
|
-
* @return The length of the modified string (<= the input length)
|
77
|
-
*/
|
78
|
-
size_t git_win32__canonicalize_path(wchar_t *str, size_t len);
|
79
|
-
|
80
62
|
/**
|
81
63
|
* Converts a FILETIME structure to a struct timespec.
|
82
64
|
*
|
@@ -176,7 +158,7 @@ GIT_INLINE(int) git_win32__file_attribute_to_stat(
|
|
176
158
|
/* st_size gets the UTF-8 length of the target name, in bytes,
|
177
159
|
* not counting the NULL terminator */
|
178
160
|
if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) {
|
179
|
-
|
161
|
+
git_error_set(GIT_ERROR_OS, "could not convert reparse point name for '%ls'", path);
|
180
162
|
return -1;
|
181
163
|
}
|
182
164
|
}
|
@@ -25,7 +25,7 @@ static bool is_worktree_dir(const char *dir)
|
|
25
25
|
&& git_path_contains_file(&buf, "gitdir")
|
26
26
|
&& git_path_contains_file(&buf, "HEAD");
|
27
27
|
|
28
|
-
|
28
|
+
git_buf_dispose(&buf);
|
29
29
|
return error;
|
30
30
|
}
|
31
31
|
|
@@ -64,7 +64,7 @@ int git_worktree_list(git_strarray *wts, git_repository *repo)
|
|
64
64
|
wts->strings = (char **)git_vector_detach(&wts->count, NULL, &worktrees);
|
65
65
|
|
66
66
|
exit:
|
67
|
-
|
67
|
+
git_buf_dispose(&path);
|
68
68
|
|
69
69
|
return error;
|
70
70
|
}
|
@@ -79,7 +79,7 @@ char *git_worktree__read_link(const char *base, const char *file)
|
|
79
79
|
goto err;
|
80
80
|
if (git_futils_readbuffer(&buf, path.ptr) < 0)
|
81
81
|
goto err;
|
82
|
-
|
82
|
+
git_buf_dispose(&path);
|
83
83
|
|
84
84
|
git_buf_rtrim(&buf);
|
85
85
|
|
@@ -90,13 +90,13 @@ char *git_worktree__read_link(const char *base, const char *file)
|
|
90
90
|
goto err;
|
91
91
|
if (git_path_apply_relative(&path, buf.ptr) < 0)
|
92
92
|
goto err;
|
93
|
-
|
93
|
+
git_buf_dispose(&buf);
|
94
94
|
|
95
95
|
return git_buf_detach(&path);
|
96
96
|
|
97
97
|
err:
|
98
|
-
|
99
|
-
|
98
|
+
git_buf_dispose(&buf);
|
99
|
+
git_buf_dispose(&path);
|
100
100
|
|
101
101
|
return NULL;
|
102
102
|
}
|
@@ -115,7 +115,7 @@ static int write_wtfile(const char *base, const char *file, const git_buf *buf)
|
|
115
115
|
goto out;
|
116
116
|
|
117
117
|
out:
|
118
|
-
|
118
|
+
git_buf_dispose(&path);
|
119
119
|
|
120
120
|
return err;
|
121
121
|
}
|
@@ -139,7 +139,8 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
139
139
|
if ((wt->name = git__strdup(name)) == NULL
|
140
140
|
|| (wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL
|
141
141
|
|| (wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL
|
142
|
-
|| (parent && (wt->parent_path = git__strdup(parent)) == NULL)
|
142
|
+
|| (parent && (wt->parent_path = git__strdup(parent)) == NULL)
|
143
|
+
|| (wt->worktree_path = git_path_dirname(wt->gitlink_path)) == NULL) {
|
143
144
|
error = -1;
|
144
145
|
goto out;
|
145
146
|
}
|
@@ -155,7 +156,7 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
|
|
155
156
|
out:
|
156
157
|
if (error)
|
157
158
|
git_worktree_free(wt);
|
158
|
-
|
159
|
+
git_buf_dispose(&gitdir);
|
159
160
|
|
160
161
|
return error;
|
161
162
|
}
|
@@ -177,7 +178,7 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na
|
|
177
178
|
goto out;
|
178
179
|
|
179
180
|
out:
|
180
|
-
|
181
|
+
git_buf_dispose(&path);
|
181
182
|
|
182
183
|
if (error)
|
183
184
|
git_worktree_free(wt);
|
@@ -193,7 +194,7 @@ int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
|
|
193
194
|
int error = 0;
|
194
195
|
|
195
196
|
if (!git_repository_is_worktree(repo)) {
|
196
|
-
|
197
|
+
git_error_set(GIT_ERROR_WORKTREE, "cannot open worktree of a non-worktree repo");
|
197
198
|
error = -1;
|
198
199
|
goto out;
|
199
200
|
}
|
@@ -212,7 +213,7 @@ int git_worktree_open_from_repository(git_worktree **out, git_repository *repo)
|
|
212
213
|
|
213
214
|
out:
|
214
215
|
git__free(name);
|
215
|
-
|
216
|
+
git_buf_dispose(&parent);
|
216
217
|
|
217
218
|
return error;
|
218
219
|
}
|
@@ -223,6 +224,7 @@ void git_worktree_free(git_worktree *wt)
|
|
223
224
|
return;
|
224
225
|
|
225
226
|
git__free(wt->commondir_path);
|
227
|
+
git__free(wt->worktree_path);
|
226
228
|
git__free(wt->gitlink_path);
|
227
229
|
git__free(wt->gitdir_path);
|
228
230
|
git__free(wt->parent_path);
|
@@ -232,40 +234,30 @@ void git_worktree_free(git_worktree *wt)
|
|
232
234
|
|
233
235
|
int git_worktree_validate(const git_worktree *wt)
|
234
236
|
{
|
235
|
-
git_buf buf = GIT_BUF_INIT;
|
236
|
-
int err = 0;
|
237
|
-
|
238
237
|
assert(wt);
|
239
238
|
|
240
|
-
|
241
|
-
|
242
|
-
giterr_set(GITERR_WORKTREE,
|
239
|
+
if (!is_worktree_dir(wt->gitdir_path)) {
|
240
|
+
git_error_set(GIT_ERROR_WORKTREE,
|
243
241
|
"Worktree gitdir ('%s') is not valid",
|
244
242
|
wt->gitlink_path);
|
245
|
-
|
246
|
-
goto out;
|
243
|
+
return GIT_ERROR;
|
247
244
|
}
|
248
245
|
|
249
|
-
if (!git_path_exists(wt->parent_path)) {
|
250
|
-
|
246
|
+
if (wt->parent_path && !git_path_exists(wt->parent_path)) {
|
247
|
+
git_error_set(GIT_ERROR_WORKTREE,
|
251
248
|
"Worktree parent directory ('%s') does not exist ",
|
252
249
|
wt->parent_path);
|
253
|
-
|
254
|
-
goto out;
|
250
|
+
return GIT_ERROR;
|
255
251
|
}
|
256
252
|
|
257
253
|
if (!git_path_exists(wt->commondir_path)) {
|
258
|
-
|
254
|
+
git_error_set(GIT_ERROR_WORKTREE,
|
259
255
|
"Worktree common directory ('%s') does not exist ",
|
260
256
|
wt->commondir_path);
|
261
|
-
|
262
|
-
goto out;
|
257
|
+
return GIT_ERROR;
|
263
258
|
}
|
264
259
|
|
265
|
-
|
266
|
-
git_buf_free(&buf);
|
267
|
-
|
268
|
-
return err;
|
260
|
+
return 0;
|
269
261
|
}
|
270
262
|
|
271
263
|
int git_worktree_add_init_options(git_worktree_add_options *opts,
|
@@ -288,7 +280,7 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
288
280
|
git_worktree_add_options wtopts = GIT_WORKTREE_ADD_OPTIONS_INIT;
|
289
281
|
int err;
|
290
282
|
|
291
|
-
|
283
|
+
GIT_ERROR_CHECK_VERSION(
|
292
284
|
opts, GIT_WORKTREE_ADD_OPTIONS_VERSION, "git_worktree_add_options");
|
293
285
|
|
294
286
|
if (opts)
|
@@ -348,13 +340,30 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
348
340
|
|| (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0)
|
349
341
|
goto out;
|
350
342
|
|
351
|
-
/*
|
352
|
-
if (
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
343
|
+
/* Set up worktree reference */
|
344
|
+
if (wtopts.ref) {
|
345
|
+
if (!git_reference_is_branch(wtopts.ref)) {
|
346
|
+
git_error_set(GIT_ERROR_WORKTREE, "reference is not a branch");
|
347
|
+
err = -1;
|
348
|
+
goto out;
|
349
|
+
}
|
350
|
+
|
351
|
+
if (git_branch_is_checked_out(wtopts.ref)) {
|
352
|
+
git_error_set(GIT_ERROR_WORKTREE, "reference is already checked out");
|
353
|
+
err = -1;
|
354
|
+
goto out;
|
355
|
+
}
|
356
|
+
|
357
|
+
if ((err = git_reference_dup(&ref, wtopts.ref)) < 0)
|
358
|
+
goto out;
|
359
|
+
} else {
|
360
|
+
if ((err = git_repository_head(&head, repo)) < 0)
|
361
|
+
goto out;
|
362
|
+
if ((err = git_commit_lookup(&commit, repo, &head->target.oid)) < 0)
|
363
|
+
goto out;
|
364
|
+
if ((err = git_branch_create(&ref, repo, name, commit, false)) < 0)
|
365
|
+
goto out;
|
366
|
+
}
|
358
367
|
|
359
368
|
/* Set worktree's HEAD */
|
360
369
|
if ((err = git_repository_create_head(gitdir.ptr, git_reference_name(ref))) < 0)
|
@@ -372,9 +381,9 @@ int git_worktree_add(git_worktree **out, git_repository *repo,
|
|
372
381
|
goto out;
|
373
382
|
|
374
383
|
out:
|
375
|
-
|
376
|
-
|
377
|
-
|
384
|
+
git_buf_dispose(&gitdir);
|
385
|
+
git_buf_dispose(&wddir);
|
386
|
+
git_buf_dispose(&buf);
|
378
387
|
git_reference_free(ref);
|
379
388
|
git_reference_free(head);
|
380
389
|
git_commit_free(commit);
|
@@ -405,7 +414,7 @@ int git_worktree_lock(git_worktree *wt, const char *reason)
|
|
405
414
|
wt->locked = 1;
|
406
415
|
|
407
416
|
out:
|
408
|
-
|
417
|
+
git_buf_dispose(&path);
|
409
418
|
|
410
419
|
return err;
|
411
420
|
}
|
@@ -423,13 +432,13 @@ int git_worktree_unlock(git_worktree *wt)
|
|
423
432
|
return -1;
|
424
433
|
|
425
434
|
if (p_unlink(path.ptr) != 0) {
|
426
|
-
|
435
|
+
git_buf_dispose(&path);
|
427
436
|
return -1;
|
428
437
|
}
|
429
438
|
|
430
439
|
wt->locked = 0;
|
431
440
|
|
432
|
-
|
441
|
+
git_buf_dispose(&path);
|
433
442
|
|
434
443
|
return 0;
|
435
444
|
}
|
@@ -450,11 +459,23 @@ int git_worktree_is_locked(git_buf *reason, const git_worktree *wt)
|
|
450
459
|
git_futils_readbuffer(reason, path.ptr);
|
451
460
|
|
452
461
|
out:
|
453
|
-
|
462
|
+
git_buf_dispose(&path);
|
454
463
|
|
455
464
|
return ret;
|
456
465
|
}
|
457
466
|
|
467
|
+
const char *git_worktree_name(const git_worktree *wt)
|
468
|
+
{
|
469
|
+
assert(wt);
|
470
|
+
return wt->name;
|
471
|
+
}
|
472
|
+
|
473
|
+
const char *git_worktree_path(const git_worktree *wt)
|
474
|
+
{
|
475
|
+
assert(wt);
|
476
|
+
return wt->worktree_path;
|
477
|
+
}
|
478
|
+
|
458
479
|
int git_worktree_prune_init_options(
|
459
480
|
git_worktree_prune_options *opts,
|
460
481
|
unsigned int version)
|
@@ -470,7 +491,7 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
470
491
|
git_buf reason = GIT_BUF_INIT;
|
471
492
|
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
|
472
493
|
|
473
|
-
|
494
|
+
GIT_ERROR_CHECK_VERSION(
|
474
495
|
opts, GIT_WORKTREE_PRUNE_OPTIONS_VERSION,
|
475
496
|
"git_worktree_prune_options");
|
476
497
|
|
@@ -482,8 +503,8 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
482
503
|
{
|
483
504
|
if (!reason.size)
|
484
505
|
git_buf_attach_notowned(&reason, "no reason given", 15);
|
485
|
-
|
486
|
-
|
506
|
+
git_error_set(GIT_ERROR_WORKTREE, "Not pruning locked working tree: '%s'", reason.ptr);
|
507
|
+
git_buf_dispose(&reason);
|
487
508
|
|
488
509
|
return 0;
|
489
510
|
}
|
@@ -491,7 +512,7 @@ int git_worktree_is_prunable(git_worktree *wt,
|
|
491
512
|
if ((popts.flags & GIT_WORKTREE_PRUNE_VALID) == 0 &&
|
492
513
|
git_worktree_validate(wt) == 0)
|
493
514
|
{
|
494
|
-
|
515
|
+
git_error_set(GIT_ERROR_WORKTREE, "Not pruning valid working tree");
|
495
516
|
return 0;
|
496
517
|
}
|
497
518
|
|
@@ -506,7 +527,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
506
527
|
char *wtpath;
|
507
528
|
int err;
|
508
529
|
|
509
|
-
|
530
|
+
GIT_ERROR_CHECK_VERSION(
|
510
531
|
opts, GIT_WORKTREE_PRUNE_OPTIONS_VERSION,
|
511
532
|
"git_worktree_prune_options");
|
512
533
|
|
@@ -523,7 +544,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
523
544
|
goto out;
|
524
545
|
if (!git_path_exists(path.ptr))
|
525
546
|
{
|
526
|
-
|
547
|
+
git_error_set(GIT_ERROR_WORKTREE, "Worktree gitdir '%s' does not exist", path.ptr);
|
527
548
|
err = -1;
|
528
549
|
goto out;
|
529
550
|
}
|
@@ -543,7 +564,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
543
564
|
git_buf_attach(&path, wtpath, 0);
|
544
565
|
if (!git_path_exists(path.ptr))
|
545
566
|
{
|
546
|
-
|
567
|
+
git_error_set(GIT_ERROR_WORKTREE, "Working tree '%s' does not exist", path.ptr);
|
547
568
|
err = -1;
|
548
569
|
goto out;
|
549
570
|
}
|
@@ -551,7 +572,7 @@ int git_worktree_prune(git_worktree *wt,
|
|
551
572
|
goto out;
|
552
573
|
|
553
574
|
out:
|
554
|
-
|
575
|
+
git_buf_dispose(&path);
|
555
576
|
|
556
577
|
return err;
|
557
578
|
}
|
@@ -18,6 +18,8 @@ struct git_worktree {
|
|
18
18
|
* directory. */
|
19
19
|
char *name;
|
20
20
|
|
21
|
+
/* Path to the where the worktree lives in the filesystem */
|
22
|
+
char *worktree_path;
|
21
23
|
/* Path to the .git file in the working tree's repository */
|
22
24
|
char *gitlink_path;
|
23
25
|
/* Path to the .git directory inside the parent's
|
@@ -33,8 +33,10 @@
|
|
33
33
|
/** Declare a function as always inlined. */
|
34
34
|
#if defined(_MSC_VER)
|
35
35
|
# define XDL_INLINE(type) static __inline type
|
36
|
+
#elif defined(__GNUC__)
|
37
|
+
# define XDL_INLINE(type) static __inline__ type
|
36
38
|
#else
|
37
|
-
#
|
39
|
+
#define XDG_INLINE(type) static type
|
38
40
|
#endif
|
39
41
|
|
40
42
|
typedef struct s_xdpsplit {
|
@@ -348,10 +350,10 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
|
348
350
|
* Allocate and setup K vectors to be used by the differential algorithm.
|
349
351
|
* One is to store the forward path and one to store the backward path.
|
350
352
|
*/
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
353
|
+
GIT_ERROR_CHECK_ALLOC_ADD3(&ndiags, xe->xdf1.nreff, xe->xdf2.nreff, 3);
|
354
|
+
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&allocsize, ndiags, 2);
|
355
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&allocsize, allocsize, 2);
|
356
|
+
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&allocsize, allocsize, sizeof(long));
|
355
357
|
|
356
358
|
if (!(kvd = (long *) xdl_malloc(allocsize))) {
|
357
359
|
xdl_free_env(xe);
|
@@ -302,7 +302,7 @@ static int histogram_diff(
|
|
302
302
|
|
303
303
|
index.table_bits = xdl_hashbits(count1);
|
304
304
|
sz = index.records_size = 1 << index.table_bits;
|
305
|
-
|
305
|
+
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&sz, sz, sizeof(struct record *));
|
306
306
|
|
307
307
|
if (!(index.records = (struct record **) xdl_malloc(sz)))
|
308
308
|
goto cleanup;
|
@@ -125,7 +125,7 @@ static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int c
|
|
125
125
|
if (dest)
|
126
126
|
memcpy(dest + size, recs[i]->ptr, recs[i]->size);
|
127
127
|
|
128
|
-
|
128
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, recs[i++]->size);
|
129
129
|
}
|
130
130
|
|
131
131
|
if (add_nl) {
|
@@ -134,13 +134,13 @@ static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int c
|
|
134
134
|
if (needs_cr) {
|
135
135
|
if (dest)
|
136
136
|
dest[size] = '\r';
|
137
|
-
|
137
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
|
138
138
|
}
|
139
139
|
|
140
140
|
if (dest)
|
141
141
|
dest[size] = '\n';
|
142
142
|
|
143
|
-
|
143
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, 1);
|
144
144
|
}
|
145
145
|
}
|
146
146
|
|
@@ -224,10 +224,10 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
|
|
224
224
|
dest ? dest + size : NULL) < 0)
|
225
225
|
return -1;
|
226
226
|
|
227
|
-
|
227
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
228
228
|
|
229
229
|
if (!dest) {
|
230
|
-
|
230
|
+
GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size);
|
231
231
|
} else {
|
232
232
|
memset(dest + size, '<', marker_size);
|
233
233
|
size += marker_size;
|
@@ -246,12 +246,12 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
|
|
246
246
|
dest ? dest + size : NULL) < 0)
|
247
247
|
return -1;
|
248
248
|
|
249
|
-
|
249
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
250
250
|
|
251
251
|
if (style == XDL_MERGE_DIFF3) {
|
252
252
|
/* Shared preimage */
|
253
253
|
if (!dest) {
|
254
|
-
|
254
|
+
GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size);
|
255
255
|
} else {
|
256
256
|
memset(dest + size, '|', marker_size);
|
257
257
|
size += marker_size;
|
@@ -268,11 +268,11 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
|
|
268
268
|
if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, needs_cr, 1,
|
269
269
|
dest ? dest + size : NULL) < 0)
|
270
270
|
return -1;
|
271
|
-
|
271
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
272
272
|
}
|
273
273
|
|
274
274
|
if (!dest) {
|
275
|
-
|
275
|
+
GIT_ERROR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, needs_cr);
|
276
276
|
} else {
|
277
277
|
memset(dest + size, '=', marker_size);
|
278
278
|
size += marker_size;
|
@@ -286,10 +286,10 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
|
|
286
286
|
if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, needs_cr, 1,
|
287
287
|
dest ? dest + size : NULL) < 0)
|
288
288
|
return -1;
|
289
|
-
|
289
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
290
290
|
|
291
291
|
if (!dest) {
|
292
|
-
|
292
|
+
GIT_ERROR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size);
|
293
293
|
} else {
|
294
294
|
memset(dest + size, '>', marker_size);
|
295
295
|
size += marker_size;
|
@@ -336,7 +336,7 @@ static int xdl_fill_merge_buffer(size_t *out,
|
|
336
336
|
if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
|
337
337
|
dest ? dest + size : NULL) < 0)
|
338
338
|
return -1;
|
339
|
-
|
339
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
340
340
|
|
341
341
|
/* Postimage from side #1 */
|
342
342
|
if (m->mode & 1) {
|
@@ -345,7 +345,7 @@ static int xdl_fill_merge_buffer(size_t *out,
|
|
345
345
|
if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, (m->mode & 2),
|
346
346
|
dest ? dest + size : NULL) < 0)
|
347
347
|
return -1;
|
348
|
-
|
348
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
349
349
|
}
|
350
350
|
|
351
351
|
/* Postimage from side #2 */
|
@@ -353,7 +353,7 @@ static int xdl_fill_merge_buffer(size_t *out,
|
|
353
353
|
if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, 0,
|
354
354
|
dest ? dest + size : NULL) < 0)
|
355
355
|
return -1;
|
356
|
-
|
356
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
357
357
|
}
|
358
358
|
} else
|
359
359
|
continue;
|
@@ -363,7 +363,7 @@ static int xdl_fill_merge_buffer(size_t *out,
|
|
363
363
|
if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, 0,
|
364
364
|
dest ? dest + size : NULL) < 0)
|
365
365
|
return -1;
|
366
|
-
|
366
|
+
GIT_ERROR_CHECK_ALLOC_ADD(&size, size, copied);
|
367
367
|
|
368
368
|
*out = size;
|
369
369
|
return 0;
|