rebase: add coverage of other incompatible options
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>
Elijah Newren committed
Jan 25, 2023 at 04:03 UTC
796abac7e11ffb0ac140e93f4649bb0264f35025
2 files changed
+18
builtin/rebase.c
+3
@@ -1511,6 +1511,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1511
if (options.update_refs)
1512
imply_merge(&options, "--update-refs");
1513
1514
+ if (options.autosquash)
1515
+ imply_merge(&options, "--autosquash");
1516
+
1517
if (options.type == REBASE_UNSPECIFIED) {
1518
if (!strcmp(options.default_backend, "merge"))
1519
imply_merge(&options, "--merge");
t/t3422-rebase-incompatible-options.sh
+15
@@ -50,6 +50,11 @@ test_rebase_am_only () {
50
test_must_fail git rebase $opt --strategy-option=ours A
51
"
52
53
+ test_expect_success "$opt incompatible with --autosquash" "
54
+ git checkout B^0 &&
55
+ test_must_fail git rebase $opt --autosquash A
56
+ "
57
+
58
test_expect_success "$opt incompatible with --interactive" "
59
git checkout B^0 &&
60
test_must_fail git rebase $opt --interactive A
@@ -60,6 +65,16 @@ test_rebase_am_only () {
65
test_must_fail git rebase $opt --exec 'true' A
66
"
67
68
+ test_expect_success "$opt incompatible with --keep-empty" "
69
+ git checkout B^0 &&
70
+ test_must_fail git rebase $opt --keep-empty A
71
+ "
72
+
73
+ test_expect_success "$opt incompatible with --empty=..." "
74
+ git checkout B^0 &&
75
+ test_must_fail git rebase $opt --empty=ask A
76
+ "
77
+
78
test_expect_success "$opt incompatible with --no-reapply-cherry-picks" "
79
git checkout B^0 &&
80
test_must_fail git rebase $opt --no-reapply-cherry-picks A