rugged 0.27.5 → 0.27.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +2 -2
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/attr.h +18 -7
- data/vendor/libgit2/include/git2/blame.h +39 -22
- 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 +14 -2
- data/vendor/libgit2/include/git2/checkout.h +13 -12
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +8 -6
- data/vendor/libgit2/include/git2/commit.h +28 -0
- data/vendor/libgit2/include/git2/common.h +27 -0
- data/vendor/libgit2/include/git2/config.h +1 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +32 -22
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +10 -8
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +12 -10
- data/vendor/libgit2/include/git2/repository.h +7 -5
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/stash.h +11 -8
- data/vendor/libgit2/include/git2/status.h +7 -3
- data/vendor/libgit2/include/git2/submodule.h +8 -7
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- 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 +6 -1
- data/vendor/libgit2/include/git2/sys/path.h +55 -0
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/types.h +8 -5
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/include/git2/worktree.h +46 -11
- data/vendor/libgit2/src/CMakeLists.txt +87 -15
- data/vendor/libgit2/src/alloc.c +47 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/apply.c +4 -4
- data/vendor/libgit2/src/attr.c +4 -4
- data/vendor/libgit2/src/attr_file.c +8 -7
- data/vendor/libgit2/src/attrcache.c +2 -2
- data/vendor/libgit2/src/blame.c +11 -4
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +8 -5
- data/vendor/libgit2/src/blob.c +5 -5
- data/vendor/libgit2/src/branch.c +20 -20
- data/vendor/libgit2/src/buffer.c +9 -4
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/checkout.c +33 -24
- data/vendor/libgit2/src/cherrypick.c +3 -3
- data/vendor/libgit2/src/clone.c +13 -13
- data/vendor/libgit2/src/commit.c +16 -3
- data/vendor/libgit2/src/common.h +3 -1
- data/vendor/libgit2/src/config.c +3 -3
- data/vendor/libgit2/src/config_file.c +193 -241
- data/vendor/libgit2/src/config_parse.c +89 -66
- data/vendor/libgit2/src/config_parse.h +2 -2
- data/vendor/libgit2/src/crlf.c +9 -3
- data/vendor/libgit2/src/diff.c +2 -2
- data/vendor/libgit2/src/diff_driver.c +3 -3
- data/vendor/libgit2/src/diff_file.c +3 -3
- data/vendor/libgit2/src/diff_generate.c +4 -3
- data/vendor/libgit2/src/diff_print.c +8 -8
- data/vendor/libgit2/src/diff_tform.c +1 -1
- data/vendor/libgit2/src/diff_xdiff.c +12 -0
- data/vendor/libgit2/src/features.h.in +2 -0
- data/vendor/libgit2/src/fetch.c +2 -2
- data/vendor/libgit2/src/fetchhead.c +5 -5
- data/vendor/libgit2/src/filebuf.c +4 -4
- data/vendor/libgit2/src/fileops.c +10 -10
- data/vendor/libgit2/src/filter.c +3 -3
- data/vendor/libgit2/src/global.c +17 -12
- data/vendor/libgit2/src/hash.h +2 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +20 -0
- data/vendor/libgit2/src/ignore.c +15 -20
- data/vendor/libgit2/src/index.c +77 -36
- data/vendor/libgit2/src/index.h +10 -0
- data/vendor/libgit2/src/indexer.c +9 -9
- data/vendor/libgit2/src/iterator.c +8 -8
- 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 +7 -7
- data/vendor/libgit2/src/netops.c +5 -5
- data/vendor/libgit2/src/notes.c +2 -2
- data/vendor/libgit2/src/odb.c +7 -7
- data/vendor/libgit2/src/odb_loose.c +13 -13
- data/vendor/libgit2/src/odb_pack.c +3 -3
- data/vendor/libgit2/src/pack-objects.c +2 -2
- data/vendor/libgit2/src/pack.c +5 -5
- data/vendor/libgit2/src/pack.h +1 -1
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +11 -4
- data/vendor/libgit2/src/path.c +42 -66
- data/vendor/libgit2/src/path.h +2 -72
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/push.c +2 -2
- data/vendor/libgit2/src/rebase.c +19 -22
- data/vendor/libgit2/src/refdb_fs.c +65 -34
- data/vendor/libgit2/src/refs.c +6 -6
- data/vendor/libgit2/src/refspec.c +30 -5
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +40 -40
- data/vendor/libgit2/src/repository.c +63 -59
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revert.c +3 -3
- data/vendor/libgit2/src/revparse.c +4 -4
- data/vendor/libgit2/src/revwalk.c +44 -10
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +25 -1
- data/vendor/libgit2/src/signature.c +1 -1
- data/vendor/libgit2/src/stash.c +80 -34
- data/vendor/libgit2/src/status.c +1 -1
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/stdalloc.h +17 -0
- data/vendor/libgit2/src/streams/mbedtls.c +463 -0
- data/vendor/libgit2/src/streams/mbedtls.h +20 -0
- data/vendor/libgit2/src/streams/openssl.c +132 -34
- data/vendor/libgit2/src/streams/openssl.h +0 -107
- data/vendor/libgit2/src/streams/tls.c +3 -0
- data/vendor/libgit2/src/submodule.c +117 -82
- data/vendor/libgit2/src/sysdir.c +4 -4
- data/vendor/libgit2/src/tag.c +7 -7
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transport.c +2 -2
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +12 -12
- data/vendor/libgit2/src/transports/local.c +7 -7
- data/vendor/libgit2/src/transports/smart.c +17 -8
- data/vendor/libgit2/src/transports/smart.h +5 -5
- data/vendor/libgit2/src/transports/smart_pkt.c +122 -130
- data/vendor/libgit2/src/transports/smart_protocol.c +48 -38
- data/vendor/libgit2/src/transports/ssh.c +1 -1
- data/vendor/libgit2/src/transports/winhttp.c +6 -6
- data/vendor/libgit2/src/tree.c +12 -53
- data/vendor/libgit2/src/tree.h +0 -12
- data/vendor/libgit2/src/util.c +16 -0
- data/vendor/libgit2/src/util.h +12 -135
- data/vendor/libgit2/src/win32/findfile.c +2 -2
- data/vendor/libgit2/src/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +94 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/worktree.c +64 -43
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +3 -1
- metadata +16 -2
data/vendor/libgit2/src/reset.c
CHANGED
data/vendor/libgit2/src/revert.c
CHANGED
@@ -36,7 +36,7 @@ static int write_revert_head(
|
|
36
36
|
if (error < 0)
|
37
37
|
git_filebuf_cleanup(&file);
|
38
38
|
|
39
|
-
|
39
|
+
git_buf_dispose(&file_path);
|
40
40
|
|
41
41
|
return error;
|
42
42
|
}
|
@@ -62,7 +62,7 @@ cleanup:
|
|
62
62
|
if (error < 0)
|
63
63
|
git_filebuf_cleanup(&file);
|
64
64
|
|
65
|
-
|
65
|
+
git_buf_dispose(&file_path);
|
66
66
|
|
67
67
|
return error;
|
68
68
|
}
|
@@ -219,7 +219,7 @@ done:
|
|
219
219
|
git_index_free(index);
|
220
220
|
git_commit_free(our_commit);
|
221
221
|
git_reference_free(our_ref);
|
222
|
-
|
222
|
+
git_buf_dispose(&their_label);
|
223
223
|
|
224
224
|
return error;
|
225
225
|
}
|
@@ -197,7 +197,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
|
|
197
197
|
|
198
198
|
cleanup:
|
199
199
|
git_reference_free(ref);
|
200
|
-
|
200
|
+
git_buf_dispose(&buf);
|
201
201
|
regfree(&preg);
|
202
202
|
git_reflog_free(reflog);
|
203
203
|
return error;
|
@@ -350,7 +350,7 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s
|
|
350
350
|
error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (size_t)timestamp);
|
351
351
|
|
352
352
|
cleanup:
|
353
|
-
|
353
|
+
git_buf_dispose(&identifier);
|
354
354
|
return error;
|
355
355
|
}
|
356
356
|
|
@@ -624,7 +624,7 @@ static int ensure_base_rev_loaded(git_object **object, git_reference **reference
|
|
624
624
|
return -1;
|
625
625
|
|
626
626
|
error = revparse_lookup_object(object, reference, repo, git_buf_cstr(&identifier));
|
627
|
-
|
627
|
+
git_buf_dispose(&identifier);
|
628
628
|
|
629
629
|
return error;
|
630
630
|
}
|
@@ -820,7 +820,7 @@ cleanup:
|
|
820
820
|
git_reference_free(reference);
|
821
821
|
}
|
822
822
|
|
823
|
-
|
823
|
+
git_buf_dispose(&buf);
|
824
824
|
return error;
|
825
825
|
}
|
826
826
|
|
@@ -15,6 +15,8 @@
|
|
15
15
|
#include "merge.h"
|
16
16
|
#include "vector.h"
|
17
17
|
|
18
|
+
static int get_revision(git_commit_list_node **out, git_revwalk *walk, git_commit_list **list);
|
19
|
+
|
18
20
|
git_commit_list_node *git_revwalk__commit_lookup(
|
19
21
|
git_revwalk *walk, const git_oid *oid)
|
20
22
|
{
|
@@ -76,10 +78,12 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
|
|
76
78
|
if (commit->uninteresting)
|
77
79
|
return 0;
|
78
80
|
|
79
|
-
if (uninteresting)
|
81
|
+
if (uninteresting) {
|
82
|
+
walk->limited = 1;
|
80
83
|
walk->did_hide = 1;
|
81
|
-
else
|
84
|
+
} else {
|
82
85
|
walk->did_push = 1;
|
86
|
+
}
|
83
87
|
|
84
88
|
commit->uninteresting = uninteresting;
|
85
89
|
list = walk->user_input;
|
@@ -152,7 +156,7 @@ static int push_glob(git_revwalk *walk, const char *glob, int hide)
|
|
152
156
|
if (error == GIT_ITEROVER)
|
153
157
|
error = 0;
|
154
158
|
out:
|
155
|
-
|
159
|
+
git_buf_dispose(&buf);
|
156
160
|
return error;
|
157
161
|
}
|
158
162
|
|
@@ -245,9 +249,10 @@ static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk
|
|
245
249
|
|
246
250
|
static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk *walk)
|
247
251
|
{
|
252
|
+
int error;
|
248
253
|
git_commit_list_node *next;
|
249
254
|
|
250
|
-
while ((
|
255
|
+
while (!(error = get_revision(&next, walk, &walk->iterator_rand))) {
|
251
256
|
/* Some commits might become uninteresting after being added to the list */
|
252
257
|
if (!next->uninteresting) {
|
253
258
|
*object_out = next;
|
@@ -255,15 +260,15 @@ static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk
|
|
255
260
|
}
|
256
261
|
}
|
257
262
|
|
258
|
-
|
259
|
-
return GIT_ITEROVER;
|
263
|
+
return error;
|
260
264
|
}
|
261
265
|
|
262
266
|
static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk *walk)
|
263
267
|
{
|
268
|
+
int error;
|
264
269
|
git_commit_list_node *next;
|
265
270
|
|
266
|
-
while ((
|
271
|
+
while (!(error = get_revision(&next, walk, &walk->iterator_topo))) {
|
267
272
|
/* Some commits might become uninteresting after being added to the list */
|
268
273
|
if (!next->uninteresting) {
|
269
274
|
*object_out = next;
|
@@ -271,8 +276,7 @@ static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk
|
|
271
276
|
}
|
272
277
|
}
|
273
278
|
|
274
|
-
|
275
|
-
return GIT_ITEROVER;
|
279
|
+
return error;
|
276
280
|
}
|
277
281
|
|
278
282
|
static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *walk)
|
@@ -434,6 +438,30 @@ static int limit_list(git_commit_list **out, git_revwalk *walk, git_commit_list
|
|
434
438
|
return 0;
|
435
439
|
}
|
436
440
|
|
441
|
+
static int get_revision(git_commit_list_node **out, git_revwalk *walk, git_commit_list **list)
|
442
|
+
{
|
443
|
+
int error;
|
444
|
+
git_commit_list_node *commit;
|
445
|
+
|
446
|
+
commit = git_commit_list_pop(list);
|
447
|
+
if (!commit) {
|
448
|
+
giterr_clear();
|
449
|
+
return GIT_ITEROVER;
|
450
|
+
}
|
451
|
+
|
452
|
+
/*
|
453
|
+
* If we did not run limit_list and we must add parents to the
|
454
|
+
* list ourselves.
|
455
|
+
*/
|
456
|
+
if (!walk->limited) {
|
457
|
+
if ((error = add_parents_to_list(walk, commit, list)) < 0)
|
458
|
+
return error;
|
459
|
+
}
|
460
|
+
|
461
|
+
*out = commit;
|
462
|
+
return 0;
|
463
|
+
}
|
464
|
+
|
437
465
|
static int sort_in_topological_order(git_commit_list **out, git_revwalk *walk, git_commit_list *list)
|
438
466
|
{
|
439
467
|
git_commit_list *ll = NULL, *newlist, **pptr;
|
@@ -546,7 +574,7 @@ static int prepare_walk(git_revwalk *walk)
|
|
546
574
|
}
|
547
575
|
}
|
548
576
|
|
549
|
-
if ((error = limit_list(&commits, walk, commits)) < 0)
|
577
|
+
if (walk->limited && (error = limit_list(&commits, walk, commits)) < 0)
|
550
578
|
return error;
|
551
579
|
|
552
580
|
if (walk->sorting & GIT_SORT_TOPOLOGICAL) {
|
@@ -649,6 +677,9 @@ void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
|
|
649
677
|
walk->get_next = &revwalk_next_unsorted;
|
650
678
|
walk->enqueue = &revwalk_enqueue_unsorted;
|
651
679
|
}
|
680
|
+
|
681
|
+
if (walk->sorting != GIT_SORT_NONE)
|
682
|
+
walk->limited = 1;
|
652
683
|
}
|
653
684
|
|
654
685
|
void git_revwalk_simplify_first_parent(git_revwalk *walk)
|
@@ -704,7 +735,9 @@ void git_revwalk_reset(git_revwalk *walk)
|
|
704
735
|
git_commit_list_free(&walk->user_input);
|
705
736
|
walk->first_parent = 0;
|
706
737
|
walk->walking = 0;
|
738
|
+
walk->limited = 0;
|
707
739
|
walk->did_push = walk->did_hide = 0;
|
740
|
+
walk->sorting = GIT_SORT_NONE;
|
708
741
|
}
|
709
742
|
|
710
743
|
int git_revwalk_add_hide_cb(
|
@@ -725,6 +758,7 @@ int git_revwalk_add_hide_cb(
|
|
725
758
|
|
726
759
|
walk->hide_cb = hide_cb;
|
727
760
|
walk->hide_cb_payload = payload;
|
761
|
+
walk->limited = 1;
|
728
762
|
|
729
763
|
return 0;
|
730
764
|
}
|
@@ -11,15 +11,22 @@
|
|
11
11
|
# include <openssl/err.h>
|
12
12
|
#endif
|
13
13
|
|
14
|
+
#ifdef GIT_MBEDTLS
|
15
|
+
# include <mbedtls/error.h>
|
16
|
+
#endif
|
17
|
+
|
14
18
|
#include <git2.h>
|
19
|
+
#include "alloc.h"
|
15
20
|
#include "sysdir.h"
|
16
21
|
#include "cache.h"
|
17
22
|
#include "global.h"
|
18
23
|
#include "object.h"
|
19
24
|
#include "odb.h"
|
20
25
|
#include "refs.h"
|
26
|
+
#include "index.h"
|
21
27
|
#include "transports/smart.h"
|
22
28
|
#include "streams/openssl.h"
|
29
|
+
#include "streams/mbedtls.h"
|
23
30
|
|
24
31
|
void git_libgit2_version(int *major, int *minor, int *rev)
|
25
32
|
{
|
@@ -175,6 +182,15 @@ int git_libgit2_opts(int key, ...)
|
|
175
182
|
const char *path = va_arg(ap, const char *);
|
176
183
|
error = git_openssl__set_cert_location(file, path);
|
177
184
|
}
|
185
|
+
#elif defined(GIT_MBEDTLS)
|
186
|
+
{
|
187
|
+
const char *file = va_arg(ap, const char *);
|
188
|
+
const char *path = va_arg(ap, const char *);
|
189
|
+
if (file)
|
190
|
+
error = git_mbedtls__set_cert_location(file, 0);
|
191
|
+
if (error && path)
|
192
|
+
error = git_mbedtls__set_cert_location(path, 1);
|
193
|
+
}
|
178
194
|
#else
|
179
195
|
giterr_set(GITERR_SSL, "TLS backend doesn't support certificate locations");
|
180
196
|
error = -1;
|
@@ -199,7 +215,7 @@ int git_libgit2_opts(int key, ...)
|
|
199
215
|
break;
|
200
216
|
|
201
217
|
case GIT_OPT_SET_SSL_CIPHERS:
|
202
|
-
#
|
218
|
+
#if (GIT_OPENSSL || GIT_MBEDTLS)
|
203
219
|
{
|
204
220
|
git__free(git__ssl_ciphers);
|
205
221
|
git__ssl_ciphers = git__strdup(va_arg(ap, const char *));
|
@@ -246,6 +262,14 @@ int git_libgit2_opts(int key, ...)
|
|
246
262
|
git_odb__strict_hash_verification = (va_arg(ap, int) != 0);
|
247
263
|
break;
|
248
264
|
|
265
|
+
case GIT_OPT_SET_ALLOCATOR:
|
266
|
+
error = git_allocator_setup(va_arg(ap, git_allocator *));
|
267
|
+
break;
|
268
|
+
|
269
|
+
case GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY:
|
270
|
+
git_index__enforce_unsaved_safety = (va_arg(ap, int) != 0);
|
271
|
+
break;
|
272
|
+
|
249
273
|
default:
|
250
274
|
giterr_set(GITERR_INVALID, "invalid option key");
|
251
275
|
error = -1;
|
@@ -247,7 +247,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
|
|
247
247
|
|
248
248
|
if ((tz_start[0] != '-' && tz_start[0] != '+') ||
|
249
249
|
git__strtol32(&offset, tz_start + 1, &tz_end, 10) < 0) {
|
250
|
-
|
250
|
+
/* malformed timezone, just assume it's zero */
|
251
251
|
offset = 0;
|
252
252
|
}
|
253
253
|
|
data/vendor/libgit2/src/stash.c
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "message.h"
|
13
13
|
#include "tree.h"
|
14
14
|
#include "reflog.h"
|
15
|
+
#include "blob.h"
|
15
16
|
#include "git2/diff.h"
|
16
17
|
#include "git2/stash.h"
|
17
18
|
#include "git2/status.h"
|
@@ -103,19 +104,23 @@ cleanup:
|
|
103
104
|
return error;
|
104
105
|
}
|
105
106
|
|
106
|
-
static int build_tree_from_index(
|
107
|
+
static int build_tree_from_index(
|
108
|
+
git_tree **out,
|
109
|
+
git_repository *repo,
|
110
|
+
git_index *index)
|
107
111
|
{
|
108
112
|
int error;
|
109
113
|
git_oid i_tree_oid;
|
110
114
|
|
111
|
-
if ((error =
|
115
|
+
if ((error = git_index_write_tree_to(&i_tree_oid, index, repo)) < 0)
|
112
116
|
return error;
|
113
117
|
|
114
|
-
return git_tree_lookup(out,
|
118
|
+
return git_tree_lookup(out, repo, &i_tree_oid);
|
115
119
|
}
|
116
120
|
|
117
121
|
static int commit_index(
|
118
122
|
git_commit **i_commit,
|
123
|
+
git_repository *repo,
|
119
124
|
git_index *index,
|
120
125
|
const git_signature *stasher,
|
121
126
|
const char *message,
|
@@ -126,7 +131,7 @@ static int commit_index(
|
|
126
131
|
git_buf msg = GIT_BUF_INIT;
|
127
132
|
int error;
|
128
133
|
|
129
|
-
if ((error = build_tree_from_index(&i_tree, index)) < 0)
|
134
|
+
if ((error = build_tree_from_index(&i_tree, repo, index)) < 0)
|
130
135
|
goto cleanup;
|
131
136
|
|
132
137
|
if ((error = git_buf_printf(&msg, "index on %s\n", message)) < 0)
|
@@ -149,7 +154,7 @@ static int commit_index(
|
|
149
154
|
|
150
155
|
cleanup:
|
151
156
|
git_tree_free(i_tree);
|
152
|
-
|
157
|
+
git_buf_dispose(&msg);
|
153
158
|
return error;
|
154
159
|
}
|
155
160
|
|
@@ -159,7 +164,38 @@ struct stash_update_rules {
|
|
159
164
|
bool include_ignored;
|
160
165
|
};
|
161
166
|
|
167
|
+
/*
|
168
|
+
* Similar to git_index_add_bypath but able to operate on any
|
169
|
+
* index without making assumptions about the repository's index
|
170
|
+
*/
|
171
|
+
static int stash_to_index(
|
172
|
+
git_repository *repo,
|
173
|
+
git_index *index,
|
174
|
+
const char *path)
|
175
|
+
{
|
176
|
+
git_index *repo_index;
|
177
|
+
git_index_entry entry = {{0}};
|
178
|
+
struct stat st;
|
179
|
+
int error;
|
180
|
+
|
181
|
+
if (!git_repository_is_bare(repo) &&
|
182
|
+
(error = git_repository_index__weakptr(&repo_index, repo)) < 0)
|
183
|
+
return error;
|
184
|
+
|
185
|
+
if ((error = git_blob__create_from_paths(
|
186
|
+
&entry.id, &st, repo, NULL, path, 0, true)) < 0)
|
187
|
+
return error;
|
188
|
+
|
189
|
+
git_index_entry__init_from_stat(&entry, &st,
|
190
|
+
(repo_index != NULL || !repo_index->distrust_filemode));
|
191
|
+
|
192
|
+
entry.path = path;
|
193
|
+
|
194
|
+
return git_index_add(index, &entry);
|
195
|
+
}
|
196
|
+
|
162
197
|
static int stash_update_index_from_diff(
|
198
|
+
git_repository *repo,
|
163
199
|
git_index *index,
|
164
200
|
const git_diff *diff,
|
165
201
|
struct stash_update_rules *data)
|
@@ -205,7 +241,7 @@ static int stash_update_index_from_diff(
|
|
205
241
|
}
|
206
242
|
|
207
243
|
if (add_path != NULL)
|
208
|
-
error =
|
244
|
+
error = stash_to_index(repo, index, add_path);
|
209
245
|
}
|
210
246
|
|
211
247
|
return error;
|
@@ -213,17 +249,19 @@ static int stash_update_index_from_diff(
|
|
213
249
|
|
214
250
|
static int build_untracked_tree(
|
215
251
|
git_tree **tree_out,
|
216
|
-
|
252
|
+
git_repository *repo,
|
217
253
|
git_commit *i_commit,
|
218
254
|
uint32_t flags)
|
219
255
|
{
|
256
|
+
git_index *i_index = NULL;
|
220
257
|
git_tree *i_tree = NULL;
|
221
258
|
git_diff *diff = NULL;
|
222
259
|
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
223
260
|
struct stash_update_rules data = {0};
|
224
261
|
int error;
|
225
262
|
|
226
|
-
|
263
|
+
if ((error = git_index_new(&i_index)) < 0)
|
264
|
+
goto cleanup;
|
227
265
|
|
228
266
|
if (flags & GIT_STASH_INCLUDE_UNTRACKED) {
|
229
267
|
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED |
|
@@ -240,24 +278,24 @@ static int build_untracked_tree(
|
|
240
278
|
if ((error = git_commit_tree(&i_tree, i_commit)) < 0)
|
241
279
|
goto cleanup;
|
242
280
|
|
243
|
-
if ((error = git_diff_tree_to_workdir(
|
244
|
-
&diff, git_index_owner(index), i_tree, &opts)) < 0)
|
281
|
+
if ((error = git_diff_tree_to_workdir(&diff, repo, i_tree, &opts)) < 0)
|
245
282
|
goto cleanup;
|
246
283
|
|
247
|
-
if ((error = stash_update_index_from_diff(
|
284
|
+
if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
|
248
285
|
goto cleanup;
|
249
286
|
|
250
|
-
error = build_tree_from_index(tree_out,
|
287
|
+
error = build_tree_from_index(tree_out, repo, i_index);
|
251
288
|
|
252
289
|
cleanup:
|
253
290
|
git_diff_free(diff);
|
254
291
|
git_tree_free(i_tree);
|
292
|
+
git_index_free(i_index);
|
255
293
|
return error;
|
256
294
|
}
|
257
295
|
|
258
296
|
static int commit_untracked(
|
259
297
|
git_commit **u_commit,
|
260
|
-
|
298
|
+
git_repository *repo,
|
261
299
|
const git_signature *stasher,
|
262
300
|
const char *message,
|
263
301
|
git_commit *i_commit,
|
@@ -268,7 +306,7 @@ static int commit_untracked(
|
|
268
306
|
git_buf msg = GIT_BUF_INIT;
|
269
307
|
int error;
|
270
308
|
|
271
|
-
if ((error = build_untracked_tree(&u_tree,
|
309
|
+
if ((error = build_untracked_tree(&u_tree, repo, i_commit, flags)) < 0)
|
272
310
|
goto cleanup;
|
273
311
|
|
274
312
|
if ((error = git_buf_printf(&msg, "untracked files on %s\n", message)) < 0)
|
@@ -276,7 +314,7 @@ static int commit_untracked(
|
|
276
314
|
|
277
315
|
if ((error = git_commit_create(
|
278
316
|
&u_commit_oid,
|
279
|
-
|
317
|
+
repo,
|
280
318
|
NULL,
|
281
319
|
stasher,
|
282
320
|
stasher,
|
@@ -287,11 +325,11 @@ static int commit_untracked(
|
|
287
325
|
NULL)) < 0)
|
288
326
|
goto cleanup;
|
289
327
|
|
290
|
-
error = git_commit_lookup(u_commit,
|
328
|
+
error = git_commit_lookup(u_commit, repo, &u_commit_oid);
|
291
329
|
|
292
330
|
cleanup:
|
293
331
|
git_tree_free(u_tree);
|
294
|
-
|
332
|
+
git_buf_dispose(&msg);
|
295
333
|
return error;
|
296
334
|
}
|
297
335
|
|
@@ -316,10 +354,10 @@ static git_diff_delta *stash_delta_merge(
|
|
316
354
|
|
317
355
|
static int build_workdir_tree(
|
318
356
|
git_tree **tree_out,
|
319
|
-
|
357
|
+
git_repository *repo,
|
358
|
+
git_index *i_index,
|
320
359
|
git_commit *b_commit)
|
321
360
|
{
|
322
|
-
git_repository *repo = git_index_owner(index);
|
323
361
|
git_tree *b_tree = NULL;
|
324
362
|
git_diff *diff = NULL, *idx_to_wd = NULL;
|
325
363
|
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
@@ -331,17 +369,17 @@ static int build_workdir_tree(
|
|
331
369
|
if ((error = git_commit_tree(&b_tree, b_commit)) < 0)
|
332
370
|
goto cleanup;
|
333
371
|
|
334
|
-
if ((error = git_diff_tree_to_index(&diff, repo, b_tree,
|
335
|
-
(error = git_diff_index_to_workdir(&idx_to_wd, repo,
|
372
|
+
if ((error = git_diff_tree_to_index(&diff, repo, b_tree, i_index, &opts)) < 0 ||
|
373
|
+
(error = git_diff_index_to_workdir(&idx_to_wd, repo, i_index, &opts)) < 0 ||
|
336
374
|
(error = git_diff__merge(diff, idx_to_wd, stash_delta_merge)) < 0)
|
337
375
|
goto cleanup;
|
338
376
|
|
339
377
|
data.include_changed = true;
|
340
378
|
|
341
|
-
if ((error = stash_update_index_from_diff(
|
379
|
+
if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
|
342
380
|
goto cleanup;
|
343
381
|
|
344
|
-
error = build_tree_from_index(tree_out,
|
382
|
+
error = build_tree_from_index(tree_out, repo, i_index);
|
345
383
|
|
346
384
|
cleanup:
|
347
385
|
git_diff_free(idx_to_wd);
|
@@ -353,7 +391,7 @@ cleanup:
|
|
353
391
|
|
354
392
|
static int commit_worktree(
|
355
393
|
git_oid *w_commit_oid,
|
356
|
-
|
394
|
+
git_repository *repo,
|
357
395
|
const git_signature *stasher,
|
358
396
|
const char *message,
|
359
397
|
git_commit *i_commit,
|
@@ -362,7 +400,9 @@ static int commit_worktree(
|
|
362
400
|
{
|
363
401
|
int error = 0;
|
364
402
|
git_tree *w_tree = NULL, *i_tree = NULL;
|
403
|
+
git_index *i_index = NULL;
|
365
404
|
const git_commit *parents[] = { NULL, NULL, NULL };
|
405
|
+
int ignorecase;
|
366
406
|
|
367
407
|
parents[0] = b_commit;
|
368
408
|
parents[1] = i_commit;
|
@@ -371,15 +411,21 @@ static int commit_worktree(
|
|
371
411
|
if ((error = git_commit_tree(&i_tree, i_commit)) < 0)
|
372
412
|
goto cleanup;
|
373
413
|
|
374
|
-
if ((error =
|
414
|
+
if ((error = git_index_new(&i_index)) < 0 ||
|
415
|
+
(error = git_repository__cvar(&ignorecase, repo, GIT_CVAR_IGNORECASE)) < 0)
|
416
|
+
goto cleanup;
|
417
|
+
|
418
|
+
git_index__set_ignore_case(i_index, ignorecase);
|
419
|
+
|
420
|
+
if ((error = git_index_read_tree(i_index, i_tree)) < 0)
|
375
421
|
goto cleanup;
|
376
422
|
|
377
|
-
if ((error = build_workdir_tree(&w_tree,
|
423
|
+
if ((error = build_workdir_tree(&w_tree, repo, i_index, b_commit)) < 0)
|
378
424
|
goto cleanup;
|
379
425
|
|
380
426
|
error = git_commit_create(
|
381
427
|
w_commit_oid,
|
382
|
-
|
428
|
+
repo,
|
383
429
|
NULL,
|
384
430
|
stasher,
|
385
431
|
stasher,
|
@@ -392,6 +438,7 @@ static int commit_worktree(
|
|
392
438
|
cleanup:
|
393
439
|
git_tree_free(i_tree);
|
394
440
|
git_tree_free(w_tree);
|
441
|
+
git_index_free(i_index);
|
395
442
|
return error;
|
396
443
|
}
|
397
444
|
|
@@ -423,7 +470,7 @@ static int prepare_worktree_commit_message(
|
|
423
470
|
error = (git_buf_oom(msg) || git_buf_oom(&buf)) ? -1 : 0;
|
424
471
|
|
425
472
|
cleanup:
|
426
|
-
|
473
|
+
git_buf_dispose(&buf);
|
427
474
|
|
428
475
|
return error;
|
429
476
|
}
|
@@ -534,12 +581,12 @@ int git_stash_save(
|
|
534
581
|
goto cleanup;
|
535
582
|
|
536
583
|
if ((error = commit_index(
|
537
|
-
&i_commit, index, stasher, git_buf_cstr(&msg), b_commit)) < 0)
|
584
|
+
&i_commit, repo, index, stasher, git_buf_cstr(&msg), b_commit)) < 0)
|
538
585
|
goto cleanup;
|
539
586
|
|
540
587
|
if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
|
541
588
|
(error = commit_untracked(
|
542
|
-
&u_commit,
|
589
|
+
&u_commit, repo, stasher, git_buf_cstr(&msg),
|
543
590
|
i_commit, flags)) < 0)
|
544
591
|
goto cleanup;
|
545
592
|
|
@@ -547,7 +594,7 @@ int git_stash_save(
|
|
547
594
|
goto cleanup;
|
548
595
|
|
549
596
|
if ((error = commit_worktree(
|
550
|
-
out,
|
597
|
+
out, repo, stasher, git_buf_cstr(&msg),
|
551
598
|
i_commit, b_commit, u_commit)) < 0)
|
552
599
|
goto cleanup;
|
553
600
|
|
@@ -565,7 +612,7 @@ int git_stash_save(
|
|
565
612
|
|
566
613
|
cleanup:
|
567
614
|
|
568
|
-
|
615
|
+
git_buf_dispose(&msg);
|
569
616
|
git_commit_free(i_commit);
|
570
617
|
git_commit_free(b_commit);
|
571
618
|
git_commit_free(u_commit);
|
@@ -738,8 +785,7 @@ static void normalize_apply_options(
|
|
738
785
|
memcpy(opts, &default_apply_opts, sizeof(git_stash_apply_options));
|
739
786
|
}
|
740
787
|
|
741
|
-
|
742
|
-
opts->checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
|
788
|
+
opts->checkout_options.checkout_strategy |= GIT_CHECKOUT_NO_REFRESH;
|
743
789
|
|
744
790
|
if (!opts->checkout_options.our_label)
|
745
791
|
opts->checkout_options.our_label = "Updated upstream";
|