]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: add coverage of other incompatible options
authorElijah Newren <newren@gmail.com>
Wed, 25 Jan 2023 04:03:50 +0000 (04:03 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Jan 2023 17:20:53 +0000 (09:20 -0800)
The git-rebase manual noted several sets of incompatible options, but
we were missing tests for a few of these.  Further, we were missing
code checks for one of these, which could result in command line
options being silently ignored.

Also, note that adding a check for autosquash means that using
--whitespace=fix together with the config setting rebase.autosquash=true
will trigger an error.  A subsequent commit will improve the error
message.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c
t/t3422-rebase-incompatible-options.sh

index 05b130bfae5a28b1d36982679f73a29767d0bf00..d6b20a6a536238b6bd7293d2f2d0260baf9ef6c7 100644 (file)
@@ -1511,6 +1511,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
        if (options.update_refs)
                imply_merge(&options, "--update-refs");
 
+       if (options.autosquash)
+               imply_merge(&options, "--autosquash");
+
        if (options.type == REBASE_UNSPECIFIED) {
                if (!strcmp(options.default_backend, "merge"))
                        imply_merge(&options, "--merge");
index 826f3b94ae63d0780712db4623fe428a617442b7..6a17b571ec7ac75986194b7daf372557c08e5957 100755 (executable)
@@ -50,6 +50,11 @@ test_rebase_am_only () {
                test_must_fail git rebase $opt --strategy-option=ours A
        "
 
+       test_expect_success "$opt incompatible with --autosquash" "
+               git checkout B^0 &&
+               test_must_fail git rebase $opt --autosquash A
+       "
+
        test_expect_success "$opt incompatible with --interactive" "
                git checkout B^0 &&
                test_must_fail git rebase $opt --interactive A
@@ -60,6 +65,16 @@ test_rebase_am_only () {
                test_must_fail git rebase $opt --exec 'true' A
        "
 
+       test_expect_success "$opt incompatible with --keep-empty" "
+               git checkout B^0 &&
+               test_must_fail git rebase $opt --keep-empty A
+       "
+
+       test_expect_success "$opt incompatible with --empty=..." "
+               git checkout B^0 &&
+               test_must_fail git rebase $opt --empty=ask A
+       "
+
        test_expect_success "$opt incompatible with --no-reapply-cherry-picks" "
                git checkout B^0 &&
                test_must_fail git rebase $opt --no-reapply-cherry-picks A