]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sparse-index: integrate with cherry-pick and rebase
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 8 Sep 2021 11:24:01 +0000 (11:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 9 Sep 2021 22:49:05 +0000 (15:49 -0700)
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>
builtin/rebase.c
builtin/revert.c
t/t1092-sparse-checkout-compatibility.sh

index 33e09619005b2aa706ffb33c0f31f2378eba1fe7..27433d7c5a2b6e25e8e984b0ad159285c9e9276e 100644 (file)
@@ -559,6 +559,9 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, options,
                        builtin_rebase_interactive_usage, PARSE_OPT_KEEP_ARGV0);
 
+       prepare_repo_settings(the_repository);
+       the_repository->settings.command_requires_full_index = 0;
+
        if (!is_null_oid(&squash_onto))
                opts.squash_onto = &squash_onto;
 
@@ -1430,6 +1433,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                usage_with_options(builtin_rebase_usage,
                                   builtin_rebase_options);
 
+       prepare_repo_settings(the_repository);
+       the_repository->settings.command_requires_full_index = 0;
+
        options.allow_empty_message = 1;
        git_config(rebase_config, &options);
        /* options.gpg_sign_opt will be either "-S" or NULL */
index 237f2f18d4c0355a661a6dc7e64879870a32ac5d..6c4c22691bdaf014191f13b848dececb3461757d 100644 (file)
@@ -136,6 +136,9 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
                        PARSE_OPT_KEEP_ARGV0 |
                        PARSE_OPT_KEEP_UNKNOWN);
 
+       prepare_repo_settings(the_repository);
+       the_repository->settings.command_requires_full_index = 0;
+
        /* implies allow_empty */
        if (opts->keep_redundant_commits)
                opts->allow_empty = 1;
index d9424ed6427cb3b8d7a932c094397491aa93f844..886e78715feccf99e9db12844029a676812ebb0f 100755 (executable)
@@ -527,6 +527,38 @@ test_expect_success 'merge with conflict outside cone' '
        test_all_match git rev-parse HEAD^{tree}
 '
 
+test_expect_success 'cherry-pick/rebase with conflict outside cone' '
+       init_repos &&
+
+       for OPERATION in cherry-pick rebase
+       do
+               test_all_match git checkout -B tip &&
+               test_all_match git reset --hard merge-left &&
+               test_all_match git status --porcelain=v2 &&
+               test_all_match test_must_fail git $OPERATION merge-right &&
+               test_all_match git status --porcelain=v2 &&
+
+               # Resolve the conflict in different ways:
+               # 1. Revert to the base
+               test_all_match git checkout base -- deep/deeper2/a &&
+               test_all_match git status --porcelain=v2 &&
+
+               # 2. Add the file with conflict markers
+               test_all_match git add folder1/a &&
+               test_all_match git status --porcelain=v2 &&
+
+               # 3. Rename the file to another sparse filename and
+               #    accept conflict markers as resolved content.
+               run_on_all mv folder2/a folder2/z &&
+               test_all_match git add folder2 &&
+               test_all_match git status --porcelain=v2 &&
+
+               test_all_match git $OPERATION --continue &&
+               test_all_match git status --porcelain=v2 &&
+               test_all_match git rev-parse HEAD^{tree} || return 1
+       done
+'
+
 test_expect_success 'merge with outside renames' '
        init_repos &&
 
@@ -665,8 +697,11 @@ test_expect_success 'sparse-index is not expanded' '
        test_config -C sparse-index pull.twohead ort &&
        (
                sane_unset GIT_TEST_MERGE_ALGORITHM &&
-               ensure_not_expanded merge -m merge update-folder1 &&
-               ensure_not_expanded merge -m merge update-folder2
+               for OPERATION in "merge -m merge" cherry-pick rebase
+               do
+                       ensure_not_expanded merge -m merge update-folder1 &&
+                       ensure_not_expanded merge -m merge update-folder2 || return 1
+               done
        )
 '