sparse-index: integrate with cherry-pick and rebase
The hard work was already done with 'git merge' and the ORT strategy. Just add extra tests to see that we get the expected results in the non-conflict cases. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Sep 8, 2021 at 11:24 UTC
516680ba7704c473bb21628aa19cabbd787df4db
3 files changed
+46
-2
builtin/rebase.c
+6
@@ -559,6 +559,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
559
argc = parse_options(argc, argv, prefix, options,
560
builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);
561
562
+ prepare_repo_settings(the_repository);
563
+ the_repository->settings.command_requires_full_index = 0;
564
+
565
if (!is_null_oid(&squash_onto))
566
opts.squash_onto = &squash_onto;
567
@@ -1430,6 +1433,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1433
usage_with_options(builtin_rebase_usage,
1434
builtin_rebase_options);
1435
1436
+ prepare_repo_settings(the_repository);
1437
+ the_repository->settings.command_requires_full_index = 0;
1438
+
1439
options.allow_empty_message = 1;
1440
git_config(rebase_config, &options);
1441
/* options.gpg_sign_opt will be either "-S" or NULL */
builtin/revert.c
+3
@@ -136,6 +136,9 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
136
PARSE_OPT_KEEP_ARGV0 |
137
PARSE_OPT_KEEP_UNKNOWN);
138
139
+ prepare_repo_settings(the_repository);
140
+ the_repository->settings.command_requires_full_index = 0;
141
+
142
/* implies allow_empty */
143
if (opts->keep_redundant_commits)
144
opts->allow_empty = 1;
t/t1092-sparse-checkout-compatibility.sh
+37
-2
@@ -527,6 +527,38 @@ test_expect_success 'merge with conflict outside cone' '
527
test_all_match git rev-parse HEAD^{tree}
528
'
529
530
+test_expect_success 'cherry-pick/rebase with conflict outside cone' '
531
+ init_repos &&
532
+
533
+ for OPERATION in cherry-pick rebase
534
+ do
535
+ test_all_match git checkout -B tip &&
536
+ test_all_match git reset --hard merge-left &&
537
+ test_all_match git status --porcelain=v2 &&
538
+ test_all_match test_must_fail git $OPERATION merge-right &&
539
+ test_all_match git status --porcelain=v2 &&
540
+
541
+ # Resolve the conflict in different ways:
542
+ # 1. Revert to the base
543
+ test_all_match git checkout base -- deep/deeper2/a &&
544
+ test_all_match git status --porcelain=v2 &&
545
+
546
+ # 2. Add the file with conflict markers
547
+ test_all_match git add folder1/a &&
548
+ test_all_match git status --porcelain=v2 &&
549
+
550
+ # 3. Rename the file to another sparse filename and
551
+ # accept conflict markers as resolved content.
552
+ run_on_all mv folder2/a folder2/z &&
553
+ test_all_match git add folder2 &&
554
+ test_all_match git status --porcelain=v2 &&
555
+
556
+ test_all_match git $OPERATION --continue &&
557
+ test_all_match git status --porcelain=v2 &&
558
+ test_all_match git rev-parse HEAD^{tree} || return 1
559
+ done
560
+'
561
+
562
test_expect_success 'merge with outside renames' '
563
init_repos &&
564
@@ -665,8 +697,11 @@ test_expect_success 'sparse-index is not expanded' '
697
test_config -C sparse-index pull.twohead ort &&
698
(
699
sane_unset GIT_TEST_MERGE_ALGORITHM &&
668
- ensure_not_expanded merge -m merge update-folder1 &&
669
- ensure_not_expanded merge -m merge update-folder2
700
+ for OPERATION in "merge -m merge" cherry-pick rebase
701
+ do
702
+ ensure_not_expanded merge -m merge update-folder1 &&
703
+ ensure_not_expanded merge -m merge update-folder2 || return 1
704
+ done
705
)
706
'
707