Skip to content

Commit 516680b

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d9c934 commit 516680b

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

builtin/rebase.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
559559
argc = parse_options(argc, argv, prefix, options,
560560
builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);
561561

562+
prepare_repo_settings(the_repository);
563+
the_repository->settings.command_requires_full_index = 0;
564+
562565
if (!is_null_oid(&squash_onto))
563566
opts.squash_onto = &squash_onto;
564567

@@ -1430,6 +1433,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14301433
usage_with_options(builtin_rebase_usage,
14311434
builtin_rebase_options);
14321435

1436+
prepare_repo_settings(the_repository);
1437+
the_repository->settings.command_requires_full_index = 0;
1438+
14331439
options.allow_empty_message = 1;
14341440
git_config(rebase_config, &options);
14351441
/* options.gpg_sign_opt will be either "-S" or NULL */

builtin/revert.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
136136
PARSE_OPT_KEEP_ARGV0 |
137137
PARSE_OPT_KEEP_UNKNOWN);
138138

139+
prepare_repo_settings(the_repository);
140+
the_repository->settings.command_requires_full_index = 0;
141+
139142
/* implies allow_empty */
140143
if (opts->keep_redundant_commits)
141144
opts->allow_empty = 1;

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,38 @@ test_expect_success 'merge with conflict outside cone' '
527527
test_all_match git rev-parse HEAD^{tree}
528528
'
529529

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+
530562
test_expect_success 'merge with outside renames' '
531563
init_repos &&
532564
@@ -665,8 +697,11 @@ test_expect_success 'sparse-index is not expanded' '
665697
test_config -C sparse-index pull.twohead ort &&
666698
(
667699
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
670705
)
671706
'
672707

0 commit comments

Comments
 (0)