Skip to content

Commit 350ed86

Browse files
committed
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]>
1 parent ca23bf3 commit 350ed86

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
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: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,38 @@ test_expect_success 'merge with conflict outside cone' '
532532
test_all_match git rev-parse HEAD^{tree}
533533
'
534534

535+
test_expect_success 'cherry-pick/rebase with conflict outside cone' '
536+
init_repos &&
537+
538+
for OPERATION in cherry-pick rebase
539+
do
540+
test_all_match git checkout -B tip &&
541+
test_all_match git reset --hard merge-left &&
542+
test_all_match git status --porcelain=v2 &&
543+
test_all_match test_must_fail git $OPERATION merge-right &&
544+
test_all_match git status --porcelain=v2 &&
545+
546+
# Resolve the conflict in different ways:
547+
# 1. Revert to the base
548+
test_all_match git checkout base -- deep/deeper2/a &&
549+
test_all_match git status --porcelain=v2 &&
550+
551+
# 2. Add the file with conflict markers
552+
test_all_match git add folder1/a &&
553+
test_all_match git status --porcelain=v2 &&
554+
555+
# 3. Rename the file to another sparse filename and
556+
# accept conflict markers as resolved content.
557+
run_on_all mv folder2/a folder2/z &&
558+
test_all_match git add folder2 &&
559+
test_all_match git status --porcelain=v2 &&
560+
561+
test_all_match git $OPERATION --continue &&
562+
test_all_match git status --porcelain=v2 &&
563+
test_all_match git rev-parse HEAD^{tree} || return 1
564+
done
565+
'
566+
535567
test_expect_success 'merge with outside renames' '
536568
init_repos &&
537569
@@ -670,9 +702,12 @@ test_expect_success 'sparse-index is not expanded' '
670702
echo >>sparse-index/untracked.txt &&
671703
ensure_not_expanded add . &&
672704
673-
ensure_not_expanded checkout -f update-deep &&
674-
ensure_not_expanded merge -s ort -m merge update-folder1 &&
675-
ensure_not_expanded merge -s ort -m merge update-folder2
705+
for OPERATION in "merge -s ort -m merge" cherry-pick rebase
706+
do
707+
ensure_not_expanded checkout -f -B temp update-deep &&
708+
ensure_not_expanded $OPERATION update-folder1 &&
709+
ensure_not_expanded $OPERATION update-folder2 || return 1
710+
done
676711
'
677712

678713
test_expect_success 'sparse-index is not expanded: merge conflict in cone' '

0 commit comments

Comments
 (0)