rugged 1.5.0.1 → 1.7.1
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 +2 -2
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +2 -0
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +1 -0
- data/ext/rugged/rugged_repo.c +5 -2
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +7 -8
- data/vendor/libgit2/COPYING +30 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +3 -3
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +21 -2
- data/vendor/libgit2/cmake/SelectHashes.cmake +4 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/git-xdiff.h +4 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.c +19 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.c +3 -3
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xhistogram.c +7 -18
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xmerge.c +24 -22
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xpatience.c +21 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.c +13 -30
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.c +18 -1
- data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/include/git2/common.h +38 -6
- data/vendor/libgit2/include/git2/deprecated.h +6 -0
- data/vendor/libgit2/include/git2/diff.h +42 -4
- data/vendor/libgit2/include/git2/errors.h +4 -2
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/index.h +9 -0
- data/vendor/libgit2/include/git2/indexer.h +29 -0
- data/vendor/libgit2/include/git2/object.h +28 -2
- data/vendor/libgit2/include/git2/odb.h +58 -7
- data/vendor/libgit2/include/git2/odb_backend.h +106 -18
- data/vendor/libgit2/include/git2/oid.h +116 -16
- data/vendor/libgit2/include/git2/remote.h +18 -0
- data/vendor/libgit2/include/git2/repository.h +32 -3
- data/vendor/libgit2/include/git2/stash.h +60 -6
- data/vendor/libgit2/include/git2/strarray.h +0 -13
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -34
- data/vendor/libgit2/include/git2/sys/commit_graph.h +12 -2
- data/vendor/libgit2/include/git2/sys/midx.h +5 -1
- data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
- data/vendor/libgit2/include/git2/sys/stream.h +16 -2
- data/vendor/libgit2/include/git2/sys/transport.h +32 -2
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +3 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +34 -17
- data/vendor/libgit2/src/cli/CMakeLists.txt +5 -2
- data/vendor/libgit2/src/cli/cmd_clone.c +22 -6
- data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
- data/vendor/libgit2/src/cli/opt.c +1 -1
- data/vendor/libgit2/src/cli/progress.c +9 -8
- data/vendor/libgit2/src/cli/progress.h +4 -4
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -34
- data/vendor/libgit2/src/libgit2/annotated_commit.c +2 -2
- data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
- data/vendor/libgit2/src/libgit2/apply.c +4 -3
- data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
- data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
- data/vendor/libgit2/src/libgit2/blame.c +23 -14
- data/vendor/libgit2/src/libgit2/blame_git.c +0 -1
- data/vendor/libgit2/src/libgit2/blob.c +4 -2
- data/vendor/libgit2/src/libgit2/blob.h +2 -2
- data/vendor/libgit2/src/libgit2/branch.c +2 -2
- data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
- data/vendor/libgit2/src/libgit2/clone.c +34 -3
- data/vendor/libgit2/src/libgit2/commit.c +78 -21
- data/vendor/libgit2/src/libgit2/commit.h +25 -7
- data/vendor/libgit2/src/libgit2/commit_graph.c +129 -47
- data/vendor/libgit2/src/libgit2/commit_graph.h +23 -4
- data/vendor/libgit2/src/libgit2/commit_list.c +16 -5
- data/vendor/libgit2/src/libgit2/commit_list.h +1 -0
- data/vendor/libgit2/src/libgit2/config.c +6 -3
- data/vendor/libgit2/src/libgit2/config_file.c +16 -10
- data/vendor/libgit2/src/libgit2/describe.c +11 -8
- data/vendor/libgit2/src/libgit2/diff.c +19 -6
- data/vendor/libgit2/src/libgit2/diff.h +6 -6
- data/vendor/libgit2/src/libgit2/diff_file.c +16 -7
- data/vendor/libgit2/src/libgit2/diff_generate.c +37 -11
- data/vendor/libgit2/src/libgit2/diff_parse.c +20 -4
- data/vendor/libgit2/src/libgit2/diff_print.c +26 -7
- data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
- data/vendor/libgit2/src/libgit2/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/libgit2/email.c +4 -3
- data/vendor/libgit2/src/libgit2/errors.c +73 -18
- data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
- data/vendor/libgit2/src/libgit2/fetch.c +38 -13
- data/vendor/libgit2/src/libgit2/fetch.h +0 -2
- data/vendor/libgit2/src/libgit2/fetchhead.c +11 -9
- data/vendor/libgit2/src/libgit2/grafts.c +272 -0
- data/vendor/libgit2/src/libgit2/grafts.h +36 -0
- data/vendor/libgit2/src/libgit2/ident.c +3 -3
- data/vendor/libgit2/src/libgit2/index.c +327 -123
- data/vendor/libgit2/src/libgit2/index.h +14 -1
- data/vendor/libgit2/src/libgit2/indexer.c +116 -46
- data/vendor/libgit2/src/libgit2/iterator.c +21 -4
- data/vendor/libgit2/src/libgit2/iterator.h +3 -0
- data/vendor/libgit2/src/libgit2/libgit2.c +58 -0
- data/vendor/libgit2/src/libgit2/merge.c +14 -9
- data/vendor/libgit2/src/libgit2/merge_file.c +0 -2
- data/vendor/libgit2/src/libgit2/midx.c +68 -38
- data/vendor/libgit2/src/libgit2/midx.h +13 -3
- data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
- data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
- data/vendor/libgit2/src/libgit2/notes.c +9 -8
- data/vendor/libgit2/src/libgit2/object.c +118 -29
- data/vendor/libgit2/src/libgit2/object.h +17 -2
- data/vendor/libgit2/src/libgit2/odb.c +224 -55
- data/vendor/libgit2/src/libgit2/odb.h +43 -4
- data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
- data/vendor/libgit2/src/libgit2/odb_pack.c +111 -46
- data/vendor/libgit2/src/libgit2/oid.c +141 -77
- data/vendor/libgit2/src/libgit2/oid.h +183 -9
- data/vendor/libgit2/src/libgit2/oidarray.c +49 -3
- data/vendor/libgit2/src/libgit2/oidarray.h +5 -1
- data/vendor/libgit2/src/libgit2/pack-objects.c +31 -13
- data/vendor/libgit2/src/libgit2/pack-objects.h +5 -2
- data/vendor/libgit2/src/libgit2/pack.c +93 -70
- data/vendor/libgit2/src/libgit2/pack.h +29 -15
- data/vendor/libgit2/src/libgit2/parse.c +8 -4
- data/vendor/libgit2/src/libgit2/parse.h +1 -1
- data/vendor/libgit2/src/libgit2/patch.h +7 -1
- data/vendor/libgit2/src/libgit2/patch_generate.c +24 -5
- data/vendor/libgit2/src/libgit2/patch_parse.c +16 -8
- data/vendor/libgit2/src/libgit2/push.c +13 -3
- data/vendor/libgit2/src/libgit2/reader.c +1 -1
- data/vendor/libgit2/src/libgit2/rebase.c +72 -83
- data/vendor/libgit2/src/libgit2/refdb_fs.c +92 -52
- data/vendor/libgit2/src/libgit2/reflog.c +7 -5
- data/vendor/libgit2/src/libgit2/reflog.h +1 -2
- data/vendor/libgit2/src/libgit2/refs.c +9 -0
- data/vendor/libgit2/src/libgit2/remote.c +47 -37
- data/vendor/libgit2/src/libgit2/remote.h +41 -0
- data/vendor/libgit2/src/libgit2/repository.c +784 -329
- data/vendor/libgit2/src/libgit2/repository.h +26 -2
- data/vendor/libgit2/src/libgit2/reset.c +2 -2
- data/vendor/libgit2/src/libgit2/revert.c +8 -11
- data/vendor/libgit2/src/libgit2/revparse.c +23 -7
- data/vendor/libgit2/src/libgit2/revwalk.c +31 -5
- data/vendor/libgit2/src/libgit2/stash.c +209 -33
- data/vendor/libgit2/src/libgit2/strarray.c +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/libgit2/streams/mbedtls.c +0 -1
- data/vendor/libgit2/src/libgit2/streams/openssl.c +9 -17
- data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +240 -51
- data/vendor/libgit2/src/libgit2/streams/socket.h +3 -1
- data/vendor/libgit2/src/libgit2/streams/stransport.c +40 -12
- data/vendor/libgit2/src/libgit2/streams/tls.c +5 -0
- data/vendor/libgit2/src/libgit2/submodule.c +6 -2
- data/vendor/libgit2/src/libgit2/submodule.h +3 -3
- data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
- data/vendor/libgit2/src/libgit2/sysdir.h +41 -9
- data/vendor/libgit2/src/libgit2/tag.c +29 -10
- data/vendor/libgit2/src/libgit2/tag.h +2 -2
- data/vendor/libgit2/src/libgit2/threadstate.c +15 -2
- data/vendor/libgit2/src/libgit2/threadstate.h +1 -3
- data/vendor/libgit2/src/libgit2/transports/auth.h +1 -2
- data/vendor/libgit2/src/libgit2/transports/{auth_negotiate.c → auth_gssapi.c} +32 -32
- data/vendor/libgit2/src/libgit2/transports/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/auth_ntlm.h +1 -1
- data/vendor/libgit2/src/libgit2/transports/{auth_ntlm.c → auth_ntlmclient.c} +12 -12
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/libgit2/transports/git.c +7 -8
- data/vendor/libgit2/src/libgit2/transports/http.c +15 -9
- data/vendor/libgit2/src/libgit2/transports/httpclient.c +14 -0
- data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/local.c +27 -4
- data/vendor/libgit2/src/libgit2/transports/smart.c +68 -27
- data/vendor/libgit2/src/libgit2/transports/smart.h +33 -9
- data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +281 -49
- data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +192 -55
- data/vendor/libgit2/src/libgit2/transports/ssh.c +334 -102
- data/vendor/libgit2/src/libgit2/transports/winhttp.c +22 -18
- data/vendor/libgit2/src/libgit2/tree-cache.c +26 -16
- data/vendor/libgit2/src/libgit2/tree-cache.h +5 -3
- data/vendor/libgit2/src/libgit2/tree.c +23 -17
- data/vendor/libgit2/src/libgit2/tree.h +2 -2
- data/vendor/libgit2/src/libgit2/worktree.c +30 -10
- data/vendor/libgit2/src/util/CMakeLists.txt +6 -1
- data/vendor/libgit2/src/util/alloc.c +65 -6
- data/vendor/libgit2/src/util/alloc.h +34 -9
- data/vendor/libgit2/src/util/allocators/failalloc.c +0 -60
- data/vendor/libgit2/src/util/allocators/failalloc.h +0 -6
- data/vendor/libgit2/src/util/allocators/stdalloc.c +2 -105
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +0 -68
- data/vendor/libgit2/src/util/array.h +6 -1
- data/vendor/libgit2/src/util/cc-compat.h +2 -0
- data/vendor/libgit2/src/util/filebuf.c +6 -1
- data/vendor/libgit2/src/util/filebuf.h +19 -6
- data/vendor/libgit2/src/util/fs_path.c +2 -2
- data/vendor/libgit2/src/util/futils.c +8 -8
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +9 -3
- data/vendor/libgit2/src/util/git2_util.h +2 -2
- data/vendor/libgit2/src/util/hash/openssl.c +4 -3
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
- data/vendor/libgit2/src/util/hash.h +13 -0
- data/vendor/libgit2/src/util/net.c +492 -87
- data/vendor/libgit2/src/util/net.h +32 -0
- data/vendor/libgit2/src/util/posix.c +54 -0
- data/vendor/libgit2/src/util/posix.h +24 -0
- data/vendor/libgit2/src/util/rand.c +10 -4
- data/vendor/libgit2/src/util/regexp.c +3 -3
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/util/thread.h +20 -19
- data/vendor/libgit2/src/util/util.c +15 -10
- data/vendor/libgit2/src/util/util.h +25 -16
- data/vendor/libgit2/src/util/win32/error.c +1 -1
- data/vendor/libgit2/src/util/win32/path_w32.c +8 -8
- data/vendor/libgit2/src/util/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +73 -75
- data/vendor/libgit2/src/util/win32/utf-conv.h +81 -14
- data/vendor/libgit2/src/util/win32/w32_util.c +1 -1
- metadata +34 -26
- data/vendor/libgit2/cmake/SelectWinHTTP.cmake +0 -17
- data/vendor/libgit2/src/libgit2/netops.c +0 -124
- data/vendor/libgit2/src/libgit2/netops.h +0 -68
- data/vendor/libgit2/src/util/win32/findfile.c +0 -286
- data/vendor/libgit2/src/util/win32/findfile.h +0 -22
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xdiff.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xinclude.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src/libgit2 → deps}/xdiff/xtypes.h +0 -0
@@ -24,6 +24,7 @@
|
|
24
24
|
#include "attrcache.h"
|
25
25
|
#include "submodule.h"
|
26
26
|
#include "diff_driver.h"
|
27
|
+
#include "grafts.h"
|
27
28
|
|
28
29
|
#define DOT_GIT ".git"
|
29
30
|
#define GIT_DIR DOT_GIT "/"
|
@@ -151,11 +152,16 @@ struct git_repository {
|
|
151
152
|
|
152
153
|
git_array_t(git_str) reserved_names;
|
153
154
|
|
154
|
-
unsigned
|
155
|
-
|
155
|
+
unsigned use_env:1,
|
156
|
+
is_bare:1,
|
157
|
+
is_worktree:1;
|
158
|
+
git_oid_t oid_type;
|
156
159
|
|
157
160
|
unsigned int lru_counter;
|
158
161
|
|
162
|
+
git_grafts *grafts;
|
163
|
+
git_grafts *shallow_grafts;
|
164
|
+
|
159
165
|
git_atomic32 attr_session_key;
|
160
166
|
|
161
167
|
intptr_t configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
|
@@ -187,6 +193,13 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo);
|
|
187
193
|
int git_repository_odb__weakptr(git_odb **out, git_repository *repo);
|
188
194
|
int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo);
|
189
195
|
int git_repository_index__weakptr(git_index **out, git_repository *repo);
|
196
|
+
int git_repository_grafts__weakptr(git_grafts **out, git_repository *repo);
|
197
|
+
int git_repository_shallow_grafts__weakptr(git_grafts **out, git_repository *repo);
|
198
|
+
|
199
|
+
int git_repository__wrap_odb(
|
200
|
+
git_repository **out,
|
201
|
+
git_odb *odb,
|
202
|
+
git_oid_t oid_type);
|
190
203
|
|
191
204
|
/*
|
192
205
|
* Configuration map cache
|
@@ -238,6 +251,9 @@ extern size_t git_repository__reserved_names_posix_len;
|
|
238
251
|
bool git_repository__reserved_names(
|
239
252
|
git_str **out, size_t *outlen, git_repository *repo, bool include_ntfs);
|
240
253
|
|
254
|
+
int git_repository__shallow_roots(git_oid **out, size_t *out_len, git_repository *repo);
|
255
|
+
int git_repository__shallow_roots_write(git_repository *repo, git_oidarray *roots);
|
256
|
+
|
241
257
|
/*
|
242
258
|
* The default branch for the repository; the `init.defaultBranch`
|
243
259
|
* configuration option, if set, or `master` if it is not.
|
@@ -256,4 +272,12 @@ int git_repository__extensions(char ***out, size_t *out_len);
|
|
256
272
|
int git_repository__set_extensions(const char **extensions, size_t len);
|
257
273
|
void git_repository__free_extensions(void);
|
258
274
|
|
275
|
+
/*
|
276
|
+
* Set the object format (OID type) for a repository; this will set
|
277
|
+
* both the configuration and the internal value for the oid type.
|
278
|
+
*/
|
279
|
+
int git_repository__set_objectformat(
|
280
|
+
git_repository *repo,
|
281
|
+
git_oid_t oid_type);
|
282
|
+
|
259
283
|
#endif
|
@@ -188,9 +188,9 @@ int git_reset(
|
|
188
188
|
git_reset_t reset_type,
|
189
189
|
const git_checkout_options *checkout_opts)
|
190
190
|
{
|
191
|
-
char to[
|
191
|
+
char to[GIT_OID_MAX_HEXSIZE + 1];
|
192
192
|
|
193
|
-
git_oid_tostr(to,
|
193
|
+
git_oid_tostr(to, GIT_OID_MAX_HEXSIZE + 1, git_object_id(target));
|
194
194
|
return reset(repo, target, to, reset_type, checkout_opts);
|
195
195
|
}
|
196
196
|
|
@@ -107,12 +107,10 @@ static int revert_state_cleanup(git_repository *repo)
|
|
107
107
|
|
108
108
|
static int revert_seterr(git_commit *commit, const char *fmt)
|
109
109
|
{
|
110
|
-
char
|
110
|
+
char commit_id[GIT_OID_MAX_HEXSIZE + 1];
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
git_error_set(GIT_ERROR_REVERT, fmt, commit_oidstr);
|
112
|
+
git_oid_tostr(commit_id, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit));
|
113
|
+
git_error_set(GIT_ERROR_REVERT, fmt, commit_id);
|
116
114
|
|
117
115
|
return -1;
|
118
116
|
}
|
@@ -176,7 +174,7 @@ int git_revert(
|
|
176
174
|
git_revert_options opts;
|
177
175
|
git_reference *our_ref = NULL;
|
178
176
|
git_commit *our_commit = NULL;
|
179
|
-
char
|
177
|
+
char commit_id[GIT_OID_MAX_HEXSIZE + 1];
|
180
178
|
const char *commit_msg;
|
181
179
|
git_str their_label = GIT_STR_INIT;
|
182
180
|
git_index *index = NULL;
|
@@ -191,19 +189,18 @@ int git_revert(
|
|
191
189
|
if ((error = git_repository__ensure_not_bare(repo, "revert")) < 0)
|
192
190
|
return error;
|
193
191
|
|
194
|
-
|
195
|
-
commit_oidstr[GIT_OID_HEXSZ] = '\0';
|
192
|
+
git_oid_tostr(commit_id, GIT_OID_MAX_HEXSIZE + 1, git_commit_id(commit));
|
196
193
|
|
197
194
|
if ((commit_msg = git_commit_summary(commit)) == NULL) {
|
198
195
|
error = -1;
|
199
196
|
goto on_error;
|
200
197
|
}
|
201
198
|
|
202
|
-
if ((error = git_str_printf(&their_label, "parent of %.7s... %s",
|
199
|
+
if ((error = git_str_printf(&their_label, "parent of %.7s... %s", commit_id, commit_msg)) < 0 ||
|
203
200
|
(error = revert_normalize_opts(repo, &opts, given_opts, git_str_cstr(&their_label))) < 0 ||
|
204
201
|
(error = git_indexwriter_init_for_operation(&indexwriter, repo, &opts.checkout_opts.checkout_strategy)) < 0 ||
|
205
|
-
(error = write_revert_head(repo,
|
206
|
-
(error = write_merge_msg(repo,
|
202
|
+
(error = write_revert_head(repo, commit_id)) < 0 ||
|
203
|
+
(error = write_merge_msg(repo, commit_id, commit_msg)) < 0 ||
|
207
204
|
(error = git_repository_head(&our_ref, repo)) < 0 ||
|
208
205
|
(error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJECT_COMMIT)) < 0 ||
|
209
206
|
(error = git_revert_commit(&index, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 ||
|
@@ -15,21 +15,28 @@
|
|
15
15
|
|
16
16
|
#include "git2.h"
|
17
17
|
|
18
|
-
static int maybe_sha_or_abbrev(
|
18
|
+
static int maybe_sha_or_abbrev(
|
19
|
+
git_object **out,
|
20
|
+
git_repository *repo,
|
21
|
+
const char *spec,
|
22
|
+
size_t speclen)
|
19
23
|
{
|
20
24
|
git_oid oid;
|
21
25
|
|
22
|
-
if (
|
26
|
+
if (git_oid__fromstrn(&oid, spec, speclen, repo->oid_type) < 0)
|
23
27
|
return GIT_ENOTFOUND;
|
24
28
|
|
25
29
|
return git_object_lookup_prefix(out, repo, &oid, speclen, GIT_OBJECT_ANY);
|
26
30
|
}
|
27
31
|
|
28
|
-
static int maybe_sha(
|
32
|
+
static int maybe_sha(
|
33
|
+
git_object **out,
|
34
|
+
git_repository *repo,
|
35
|
+
const char *spec)
|
29
36
|
{
|
30
37
|
size_t speclen = strlen(spec);
|
31
38
|
|
32
|
-
if (speclen !=
|
39
|
+
if (speclen != git_oid_hexsize(repo->oid_type))
|
33
40
|
return GIT_ENOTFOUND;
|
34
41
|
|
35
42
|
return maybe_sha_or_abbrev(out, repo, spec, speclen);
|
@@ -110,8 +117,8 @@ static int revparse_lookup_object(
|
|
110
117
|
if (error != GIT_ENOTFOUND)
|
111
118
|
return error;
|
112
119
|
|
113
|
-
if ((strlen(spec) <
|
114
|
-
|
120
|
+
if ((strlen(spec) < git_oid_hexsize(repo->oid_type)) &&
|
121
|
+
((error = maybe_abbrev(object_out, repo, spec)) != GIT_ENOTFOUND))
|
115
122
|
return error;
|
116
123
|
|
117
124
|
if ((error = maybe_describe(object_out, repo, spec)) != GIT_ENOTFOUND)
|
@@ -268,7 +275,16 @@ static int retrieve_revobject_from_reflog(git_object **out, git_reference **base
|
|
268
275
|
int error = -1;
|
269
276
|
|
270
277
|
if (*base_ref == NULL) {
|
271
|
-
|
278
|
+
/*
|
279
|
+
* When HEAD@{n} is specified, do not use dwim, which would resolve the
|
280
|
+
* reference (to the current branch that HEAD is pointing to).
|
281
|
+
*/
|
282
|
+
if (position > 0 && strcmp(identifier, GIT_HEAD_FILE) == 0)
|
283
|
+
error = git_reference_lookup(&ref, repo, GIT_HEAD_FILE);
|
284
|
+
else
|
285
|
+
error = git_reference_dwim(&ref, repo, identifier);
|
286
|
+
|
287
|
+
if (error < 0)
|
272
288
|
return error;
|
273
289
|
} else {
|
274
290
|
ref = *base_ref;
|
@@ -83,8 +83,13 @@ int git_revwalk__push_commit(git_revwalk *walk, const git_oid *oid, const git_re
|
|
83
83
|
|
84
84
|
commit->uninteresting = opts->uninteresting;
|
85
85
|
list = walk->user_input;
|
86
|
-
|
87
|
-
|
86
|
+
|
87
|
+
/* To insert by date, we need to parse so we know the date. */
|
88
|
+
if (opts->insert_by_date && ((error = git_commit_list_parse(walk, commit)) < 0))
|
89
|
+
return error;
|
90
|
+
|
91
|
+
if ((opts->insert_by_date == 0 ||
|
92
|
+
git_commit_list_insert_by_date(commit, &list) == NULL) &&
|
88
93
|
git_commit_list_insert(commit, &list) == NULL) {
|
89
94
|
git_error_set_oom();
|
90
95
|
return -1;
|
@@ -121,8 +126,12 @@ int git_revwalk__push_ref(git_revwalk *walk, const char *refname, const git_revw
|
|
121
126
|
{
|
122
127
|
git_oid oid;
|
123
128
|
|
124
|
-
|
129
|
+
int error = git_reference_name_to_id(&oid, walk->repo, refname);
|
130
|
+
if (opts->from_glob && (error == GIT_ENOTFOUND || error == GIT_EINVALIDSPEC || error == GIT_EPEEL)) {
|
131
|
+
return 0;
|
132
|
+
} else if (error < 0) {
|
125
133
|
return -1;
|
134
|
+
}
|
126
135
|
|
127
136
|
return git_revwalk__push_commit(walk, &oid, opts);
|
128
137
|
}
|
@@ -605,7 +614,7 @@ cleanup:
|
|
605
614
|
static int prepare_walk(git_revwalk *walk)
|
606
615
|
{
|
607
616
|
int error = 0;
|
608
|
-
git_commit_list *list, *commits = NULL;
|
617
|
+
git_commit_list *list, *commits = NULL, *commits_last = NULL;
|
609
618
|
git_commit_list_node *next;
|
610
619
|
|
611
620
|
/* If there were no pushes, we know that the walk is already over */
|
@@ -614,6 +623,12 @@ static int prepare_walk(git_revwalk *walk)
|
|
614
623
|
return GIT_ITEROVER;
|
615
624
|
}
|
616
625
|
|
626
|
+
/*
|
627
|
+
* This is a bit convoluted, but necessary to maintain the order of
|
628
|
+
* the commits. This is especially important in situations where
|
629
|
+
* git_revwalk__push_glob is called with a git_revwalk__push_options
|
630
|
+
* setting insert_by_date = 1, which is critical for fetch negotiation.
|
631
|
+
*/
|
617
632
|
for (list = walk->user_input; list; list = list->next) {
|
618
633
|
git_commit_list_node *commit = list->item;
|
619
634
|
if ((error = git_commit_list_parse(walk, commit)) < 0)
|
@@ -623,8 +638,19 @@ static int prepare_walk(git_revwalk *walk)
|
|
623
638
|
mark_parents_uninteresting(commit);
|
624
639
|
|
625
640
|
if (!commit->seen) {
|
641
|
+
git_commit_list *new_list = NULL;
|
642
|
+
if ((new_list = git_commit_list_create(commit, NULL)) == NULL) {
|
643
|
+
git_error_set_oom();
|
644
|
+
return -1;
|
645
|
+
}
|
646
|
+
|
626
647
|
commit->seen = 1;
|
627
|
-
|
648
|
+
if (commits_last == NULL)
|
649
|
+
commits = new_list;
|
650
|
+
else
|
651
|
+
commits_last->next = new_list;
|
652
|
+
|
653
|
+
commits_last = new_list;
|
628
654
|
}
|
629
655
|
}
|
630
656
|
|
@@ -25,6 +25,7 @@
|
|
25
25
|
#include "merge.h"
|
26
26
|
#include "diff.h"
|
27
27
|
#include "diff_generate.h"
|
28
|
+
#include "strarray.h"
|
28
29
|
|
29
30
|
static int create_error(int error, const char *msg)
|
30
31
|
{
|
@@ -193,6 +194,30 @@ static int stash_to_index(
|
|
193
194
|
return git_index_add(index, &entry);
|
194
195
|
}
|
195
196
|
|
197
|
+
static int stash_update_index_from_paths(
|
198
|
+
git_repository *repo,
|
199
|
+
git_index *index,
|
200
|
+
const git_strarray *paths)
|
201
|
+
{
|
202
|
+
unsigned int status_flags;
|
203
|
+
size_t i;
|
204
|
+
int error = 0;
|
205
|
+
|
206
|
+
for (i = 0; i < paths->count; i++) {
|
207
|
+
git_status_file(&status_flags, repo, paths->strings[i]);
|
208
|
+
|
209
|
+
if (status_flags & (GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_DELETED)) {
|
210
|
+
if ((error = git_index_remove(index, paths->strings[i], 0)) < 0)
|
211
|
+
return error;
|
212
|
+
} else {
|
213
|
+
if ((error = stash_to_index(repo, index, paths->strings[i])) < 0)
|
214
|
+
return error;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
return error;
|
219
|
+
}
|
220
|
+
|
196
221
|
static int stash_update_index_from_diff(
|
197
222
|
git_repository *repo,
|
198
223
|
git_index *index,
|
@@ -259,7 +284,7 @@ static int build_untracked_tree(
|
|
259
284
|
struct stash_update_rules data = {0};
|
260
285
|
int error;
|
261
286
|
|
262
|
-
if ((error =
|
287
|
+
if ((error = git_index__new(&i_index, repo->oid_type)) < 0)
|
263
288
|
goto cleanup;
|
264
289
|
|
265
290
|
if (flags & GIT_STASH_INCLUDE_UNTRACKED) {
|
@@ -388,26 +413,81 @@ cleanup:
|
|
388
413
|
return error;
|
389
414
|
}
|
390
415
|
|
391
|
-
static int
|
416
|
+
static int build_stash_commit_from_tree(
|
392
417
|
git_oid *w_commit_oid,
|
393
418
|
git_repository *repo,
|
394
419
|
const git_signature *stasher,
|
395
420
|
const char *message,
|
396
421
|
git_commit *i_commit,
|
397
422
|
git_commit *b_commit,
|
398
|
-
git_commit *u_commit
|
423
|
+
git_commit *u_commit,
|
424
|
+
const git_tree *tree)
|
399
425
|
{
|
400
426
|
const git_commit *parents[] = { NULL, NULL, NULL };
|
401
|
-
git_index *i_index = NULL, *r_index = NULL;
|
402
|
-
git_tree *w_tree = NULL;
|
403
|
-
int error = 0, ignorecase;
|
404
427
|
|
405
428
|
parents[0] = b_commit;
|
406
429
|
parents[1] = i_commit;
|
407
430
|
parents[2] = u_commit;
|
408
431
|
|
432
|
+
return git_commit_create(
|
433
|
+
w_commit_oid,
|
434
|
+
repo,
|
435
|
+
NULL,
|
436
|
+
stasher,
|
437
|
+
stasher,
|
438
|
+
NULL,
|
439
|
+
message,
|
440
|
+
tree,
|
441
|
+
u_commit ? 3 : 2,
|
442
|
+
parents);
|
443
|
+
}
|
444
|
+
|
445
|
+
static int build_stash_commit_from_index(
|
446
|
+
git_oid *w_commit_oid,
|
447
|
+
git_repository *repo,
|
448
|
+
const git_signature *stasher,
|
449
|
+
const char *message,
|
450
|
+
git_commit *i_commit,
|
451
|
+
git_commit *b_commit,
|
452
|
+
git_commit *u_commit,
|
453
|
+
git_index *index)
|
454
|
+
{
|
455
|
+
git_tree *tree;
|
456
|
+
int error;
|
457
|
+
|
458
|
+
if ((error = build_tree_from_index(&tree, repo, index)) < 0)
|
459
|
+
goto cleanup;
|
460
|
+
|
461
|
+
error = build_stash_commit_from_tree(
|
462
|
+
w_commit_oid,
|
463
|
+
repo,
|
464
|
+
stasher,
|
465
|
+
message,
|
466
|
+
i_commit,
|
467
|
+
b_commit,
|
468
|
+
u_commit,
|
469
|
+
tree);
|
470
|
+
|
471
|
+
cleanup:
|
472
|
+
git_tree_free(tree);
|
473
|
+
return error;
|
474
|
+
}
|
475
|
+
|
476
|
+
static int commit_worktree(
|
477
|
+
git_oid *w_commit_oid,
|
478
|
+
git_repository *repo,
|
479
|
+
const git_signature *stasher,
|
480
|
+
const char *message,
|
481
|
+
git_commit *i_commit,
|
482
|
+
git_commit *b_commit,
|
483
|
+
git_commit *u_commit)
|
484
|
+
{
|
485
|
+
git_index *i_index = NULL, *r_index = NULL;
|
486
|
+
git_tree *w_tree = NULL;
|
487
|
+
int error = 0, ignorecase;
|
488
|
+
|
409
489
|
if ((error = git_repository_index(&r_index, repo) < 0) ||
|
410
|
-
(error =
|
490
|
+
(error = git_index__new(&i_index, repo->oid_type)) < 0 ||
|
411
491
|
(error = git_index__fill(i_index, &r_index->entries) < 0) ||
|
412
492
|
(error = git_repository__configmap_lookup(&ignorecase, repo, GIT_CONFIGMAP_IGNORECASE)) < 0)
|
413
493
|
goto cleanup;
|
@@ -417,17 +497,16 @@ static int commit_worktree(
|
|
417
497
|
if ((error = build_workdir_tree(&w_tree, repo, i_index, b_commit)) < 0)
|
418
498
|
goto cleanup;
|
419
499
|
|
420
|
-
error =
|
500
|
+
error = build_stash_commit_from_tree(
|
421
501
|
w_commit_oid,
|
422
502
|
repo,
|
423
|
-
NULL,
|
424
|
-
stasher,
|
425
503
|
stasher,
|
426
|
-
NULL,
|
427
504
|
message,
|
428
|
-
|
429
|
-
|
430
|
-
|
505
|
+
i_commit,
|
506
|
+
b_commit,
|
507
|
+
u_commit,
|
508
|
+
w_tree
|
509
|
+
);
|
431
510
|
|
432
511
|
cleanup:
|
433
512
|
git_tree_free(w_tree);
|
@@ -520,6 +599,54 @@ static int ensure_there_are_changes_to_stash(git_repository *repo, uint32_t flag
|
|
520
599
|
return error;
|
521
600
|
}
|
522
601
|
|
602
|
+
static int has_changes_cb(
|
603
|
+
const char *path,
|
604
|
+
unsigned int status,
|
605
|
+
void *payload)
|
606
|
+
{
|
607
|
+
GIT_UNUSED(path);
|
608
|
+
GIT_UNUSED(status);
|
609
|
+
GIT_UNUSED(payload);
|
610
|
+
|
611
|
+
if (status == GIT_STATUS_CURRENT)
|
612
|
+
return GIT_ENOTFOUND;
|
613
|
+
|
614
|
+
return 0;
|
615
|
+
}
|
616
|
+
|
617
|
+
static int ensure_there_are_changes_to_stash_paths(
|
618
|
+
git_repository *repo,
|
619
|
+
uint32_t flags,
|
620
|
+
const git_strarray *paths)
|
621
|
+
{
|
622
|
+
int error;
|
623
|
+
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
|
624
|
+
|
625
|
+
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
626
|
+
opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES |
|
627
|
+
GIT_STATUS_OPT_INCLUDE_UNMODIFIED |
|
628
|
+
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH;
|
629
|
+
|
630
|
+
if (flags & GIT_STASH_INCLUDE_UNTRACKED)
|
631
|
+
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED |
|
632
|
+
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
|
633
|
+
|
634
|
+
if (flags & GIT_STASH_INCLUDE_IGNORED)
|
635
|
+
opts.flags |= GIT_STATUS_OPT_INCLUDE_IGNORED |
|
636
|
+
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS;
|
637
|
+
|
638
|
+
git_strarray_copy(&opts.pathspec, paths);
|
639
|
+
|
640
|
+
error = git_status_foreach_ext(repo, &opts, has_changes_cb, NULL);
|
641
|
+
|
642
|
+
git_strarray_dispose(&opts.pathspec);
|
643
|
+
|
644
|
+
if (error == GIT_ENOTFOUND)
|
645
|
+
return create_error(GIT_ENOTFOUND, "one of the files does not have any changes to stash.");
|
646
|
+
|
647
|
+
return error;
|
648
|
+
}
|
649
|
+
|
523
650
|
static int reset_index_and_workdir(git_repository *repo, git_commit *commit, uint32_t flags)
|
524
651
|
{
|
525
652
|
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
|
@@ -540,14 +667,36 @@ int git_stash_save(
|
|
540
667
|
const char *message,
|
541
668
|
uint32_t flags)
|
542
669
|
{
|
543
|
-
|
670
|
+
git_stash_save_options opts = GIT_STASH_SAVE_OPTIONS_INIT;
|
671
|
+
|
672
|
+
GIT_ASSERT_ARG(stasher);
|
673
|
+
|
674
|
+
opts.stasher = stasher;
|
675
|
+
opts.message = message;
|
676
|
+
opts.flags = flags;
|
677
|
+
|
678
|
+
return git_stash_save_with_opts(out, repo, &opts);
|
679
|
+
}
|
680
|
+
|
681
|
+
int git_stash_save_with_opts(
|
682
|
+
git_oid *out,
|
683
|
+
git_repository *repo,
|
684
|
+
const git_stash_save_options *opts)
|
685
|
+
{
|
686
|
+
git_index *index = NULL, *paths_index = NULL;
|
544
687
|
git_commit *b_commit = NULL, *i_commit = NULL, *u_commit = NULL;
|
545
688
|
git_str msg = GIT_STR_INIT;
|
689
|
+
git_tree *tree = NULL;
|
690
|
+
git_reference *head = NULL;
|
691
|
+
bool has_paths = false;
|
692
|
+
|
546
693
|
int error;
|
547
694
|
|
548
695
|
GIT_ASSERT_ARG(out);
|
549
696
|
GIT_ASSERT_ARG(repo);
|
550
|
-
GIT_ASSERT_ARG(stasher);
|
697
|
+
GIT_ASSERT_ARG(opts && opts->stasher);
|
698
|
+
|
699
|
+
has_paths = opts->paths.count > 0;
|
551
700
|
|
552
701
|
if ((error = git_repository__ensure_not_bare(repo, "stash save")) < 0)
|
553
702
|
return error;
|
@@ -555,44 +704,63 @@ int git_stash_save(
|
|
555
704
|
if ((error = retrieve_base_commit_and_message(&b_commit, &msg, repo)) < 0)
|
556
705
|
goto cleanup;
|
557
706
|
|
558
|
-
if (
|
707
|
+
if (!has_paths &&
|
708
|
+
(error = ensure_there_are_changes_to_stash(repo, opts->flags)) < 0)
|
709
|
+
goto cleanup;
|
710
|
+
else if (has_paths &&
|
711
|
+
(error = ensure_there_are_changes_to_stash_paths(
|
712
|
+
repo, opts->flags, &opts->paths)) < 0)
|
559
713
|
goto cleanup;
|
560
714
|
|
561
715
|
if ((error = git_repository_index(&index, repo)) < 0)
|
562
716
|
goto cleanup;
|
563
717
|
|
564
|
-
if ((error = commit_index(&i_commit, repo, index, stasher,
|
718
|
+
if ((error = commit_index(&i_commit, repo, index, opts->stasher,
|
565
719
|
git_str_cstr(&msg), b_commit)) < 0)
|
566
720
|
goto cleanup;
|
567
721
|
|
568
|
-
if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
|
569
|
-
(error = commit_untracked(&u_commit, repo, stasher,
|
570
|
-
|
722
|
+
if ((opts->flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
|
723
|
+
(error = commit_untracked(&u_commit, repo, opts->stasher,
|
724
|
+
git_str_cstr(&msg), i_commit, opts->flags)) < 0)
|
571
725
|
goto cleanup;
|
572
726
|
|
573
|
-
if ((error = prepare_worktree_commit_message(&msg, message)) < 0)
|
727
|
+
if ((error = prepare_worktree_commit_message(&msg, opts->message)) < 0)
|
574
728
|
goto cleanup;
|
575
729
|
|
576
|
-
if (
|
577
|
-
|
578
|
-
|
730
|
+
if (!has_paths) {
|
731
|
+
if ((error = commit_worktree(out, repo, opts->stasher, git_str_cstr(&msg),
|
732
|
+
i_commit, b_commit, u_commit)) < 0)
|
733
|
+
goto cleanup;
|
734
|
+
} else {
|
735
|
+
if ((error = git_index__new(&paths_index, repo->oid_type)) < 0 ||
|
736
|
+
(error = retrieve_head(&head, repo)) < 0 ||
|
737
|
+
(error = git_reference_peel((git_object**)&tree, head, GIT_OBJECT_TREE)) < 0 ||
|
738
|
+
(error = git_index_read_tree(paths_index, tree)) < 0 ||
|
739
|
+
(error = stash_update_index_from_paths(repo, paths_index, &opts->paths)) < 0 ||
|
740
|
+
(error = build_stash_commit_from_index(out, repo, opts->stasher, git_str_cstr(&msg),
|
741
|
+
i_commit, b_commit, u_commit, paths_index)) < 0)
|
742
|
+
goto cleanup;
|
743
|
+
}
|
579
744
|
|
580
745
|
git_str_rtrim(&msg);
|
581
746
|
|
582
747
|
if ((error = update_reflog(out, repo, git_str_cstr(&msg))) < 0)
|
583
748
|
goto cleanup;
|
584
749
|
|
585
|
-
if ((
|
586
|
-
|
750
|
+
if (!(opts->flags & GIT_STASH_KEEP_ALL) &&
|
751
|
+
(error = reset_index_and_workdir(repo,
|
752
|
+
(opts->flags & GIT_STASH_KEEP_INDEX) ? i_commit : b_commit,opts->flags)) < 0)
|
587
753
|
goto cleanup;
|
588
754
|
|
589
755
|
cleanup:
|
590
|
-
|
591
756
|
git_str_dispose(&msg);
|
592
757
|
git_commit_free(i_commit);
|
593
758
|
git_commit_free(b_commit);
|
594
759
|
git_commit_free(u_commit);
|
760
|
+
git_tree_free(tree);
|
761
|
+
git_reference_free(head);
|
595
762
|
git_index_free(index);
|
763
|
+
git_index_free(paths_index);
|
596
764
|
|
597
765
|
return error;
|
598
766
|
}
|
@@ -777,6 +945,13 @@ int git_stash_apply_options_init(git_stash_apply_options *opts, unsigned int ver
|
|
777
945
|
return 0;
|
778
946
|
}
|
779
947
|
|
948
|
+
int git_stash_save_options_init(git_stash_save_options *opts, unsigned int version)
|
949
|
+
{
|
950
|
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
|
951
|
+
opts, version, git_stash_save_options, GIT_STASH_SAVE_OPTIONS_INIT);
|
952
|
+
return 0;
|
953
|
+
}
|
954
|
+
|
780
955
|
#ifndef GIT_DEPRECATE_HARD
|
781
956
|
int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version)
|
782
957
|
{
|
@@ -828,6 +1003,7 @@ static int stage_new_file(const git_index_entry **entries, void *data)
|
|
828
1003
|
|
829
1004
|
static int stage_new_files(
|
830
1005
|
git_index **out,
|
1006
|
+
git_repository *repo,
|
831
1007
|
git_tree *parent_tree,
|
832
1008
|
git_tree *tree)
|
833
1009
|
{
|
@@ -836,7 +1012,7 @@ static int stage_new_files(
|
|
836
1012
|
git_index *index = NULL;
|
837
1013
|
int error;
|
838
1014
|
|
839
|
-
if ((error =
|
1015
|
+
if ((error = git_index__new(&index, repo->oid_type)) < 0 ||
|
840
1016
|
(error = git_iterator_for_tree(
|
841
1017
|
&iterators[0], parent_tree, &iterator_options)) < 0 ||
|
842
1018
|
(error = git_iterator_for_tree(
|
@@ -920,10 +1096,10 @@ int git_stash_apply(
|
|
920
1096
|
* previously unstaged contents are staged, not the previously staged.)
|
921
1097
|
*/
|
922
1098
|
} else if ((opts.flags & GIT_STASH_APPLY_REINSTATE_INDEX) == 0) {
|
923
|
-
if ((error = stage_new_files(
|
924
|
-
|
925
|
-
|
926
|
-
|
1099
|
+
if ((error = stage_new_files(&stash_adds, repo,
|
1100
|
+
stash_parent_tree, stash_tree)) < 0 ||
|
1101
|
+
(error = merge_indexes(&unstashed_index, repo,
|
1102
|
+
stash_parent_tree, repo_index, stash_adds)) < 0)
|
927
1103
|
goto cleanup;
|
928
1104
|
}
|
929
1105
|
|
@@ -0,0 +1,25 @@
|
|
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
|
+
#ifndef INCLUDE_strarray_h__
|
8
|
+
#define INCLUDE_strarray_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "git2/strarray.h"
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Copy a string array object from source to target.
|
15
|
+
*
|
16
|
+
* Note: target is overwritten and hence should be empty, otherwise its
|
17
|
+
* contents are leaked. Call git_strarray_free() if necessary.
|
18
|
+
*
|
19
|
+
* @param tgt target
|
20
|
+
* @param src source
|
21
|
+
* @return 0 on success, < 0 on allocation failure
|
22
|
+
*/
|
23
|
+
extern int git_strarray_copy(git_strarray *tgt, const git_strarray *src);
|
24
|
+
|
25
|
+
#endif
|