| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test if rebase detects and aborts on incompatible options' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup' ' |
| 8 | test_seq 2 9 >foo && |
| 9 | git add foo && |
| 10 | git commit -m orig && |
| 11 | |
| 12 | git branch A && |
| 13 | git branch B && |
| 14 | |
| 15 | git checkout A && |
| 16 | test_seq 1 9 >foo && |
| 17 | git add foo && |
| 18 | git commit -m A && |
| 19 | |
| 20 | git checkout B && |
| 21 | echo "q qfoo();" | q_to_tab >>foo && |
| 22 | git add foo && |
| 23 | git commit -m B |
| 24 | ' |
| 25 | |
| 26 | # |
| 27 | # Rebase has a couple options which are specific to the apply backend, |
| 28 | # and several options which are specific to the merge backend. Flags |
| 29 | # from the different sets cannot work together, and we do not want to |
| 30 | # just ignore one of the sets of flags. Make sure rebase warns the |
| 31 | # user and aborts instead. |
| 32 | # |
| 33 | |
| 34 | test_rebase_am_only () { |
| 35 | opt=$1 |
| 36 | shift |
| 37 | test_expect_success "$opt incompatible with --merge" " |
| 38 | git checkout B^0 && |
| 39 | test_must_fail git rebase $opt --merge A |
| 40 | " |
| 41 | |
| 42 | test_expect_success "$opt incompatible with --strategy=ours" " |
| 43 | git checkout B^0 && |
| 44 | test_must_fail git rebase $opt --strategy=ours A |
| 45 | " |
| 46 | |
| 47 | test_expect_success "$opt incompatible with --strategy-option=ours" " |
| 48 | git checkout B^0 && |
| 49 | test_must_fail git rebase $opt --strategy-option=ours A |
| 50 | " |
| 51 | |
| 52 | test_expect_success "$opt incompatible with --autosquash" " |
| 53 | git checkout B^0 && |
| 54 | test_must_fail git rebase $opt --autosquash A |
| 55 | " |
| 56 | |
| 57 | test_expect_success "$opt incompatible with --interactive" " |
| 58 | git checkout B^0 && |
| 59 | test_must_fail git rebase $opt --interactive A |
| 60 | " |
| 61 | |
| 62 | test_expect_success "$opt incompatible with --exec" " |
| 63 | git checkout B^0 && |
| 64 | test_must_fail git rebase $opt --exec 'true' A |
| 65 | " |
| 66 | |
| 67 | test_expect_success "$opt incompatible with --keep-empty" " |
| 68 | git checkout B^0 && |
| 69 | test_must_fail git rebase $opt --keep-empty A |
| 70 | " |
| 71 | |
| 72 | test_expect_success "$opt incompatible with --empty=..." " |
| 73 | git checkout B^0 && |
| 74 | test_must_fail git rebase $opt --empty=ask A |
| 75 | " |
| 76 | |
| 77 | test_expect_success "$opt incompatible with --no-reapply-cherry-picks" " |
| 78 | git checkout B^0 && |
| 79 | test_must_fail git rebase $opt --no-reapply-cherry-picks A |
| 80 | " |
| 81 | |
| 82 | test_expect_success "$opt incompatible with --reapply-cherry-picks" " |
| 83 | git checkout B^0 && |
| 84 | test_must_fail git rebase $opt --reapply-cherry-picks A |
| 85 | " |
| 86 | |
| 87 | test_expect_success "$opt incompatible with --rebase-merges" " |
| 88 | git checkout B^0 && |
| 89 | test_must_fail git rebase $opt --rebase-merges A |
| 90 | " |
| 91 | |
| 92 | test_expect_success "$opt incompatible with --update-refs" " |
| 93 | git checkout B^0 && |
| 94 | test_must_fail git rebase $opt --update-refs A |
| 95 | " |
| 96 | |
| 97 | test_expect_success "$opt incompatible with --root without --onto" " |
| 98 | git checkout B^0 && |
| 99 | test_must_fail git rebase $opt --root A |
| 100 | " |
| 101 | |
| 102 | test_expect_success "$opt incompatible with rebase.rebaseMerges" " |
| 103 | git checkout B^0 && |
| 104 | test_must_fail git -c rebase.rebaseMerges=true rebase $opt A 2>err && |
| 105 | test_grep -e --no-rebase-merges err |
| 106 | " |
| 107 | |
| 108 | test_expect_success "$opt incompatible with rebase.updateRefs" " |
| 109 | git checkout B^0 && |
| 110 | test_must_fail git -c rebase.updateRefs=true rebase $opt A 2>err && |
| 111 | test_grep -e --no-update-refs err |
| 112 | " |
| 113 | |
| 114 | test_expect_success "$opt okay with overridden rebase.rebaseMerges" " |
| 115 | test_when_finished \"git reset --hard B^0\" && |
| 116 | git checkout B^0 && |
| 117 | git -c rebase.rebaseMerges=true rebase --no-rebase-merges $opt A |
| 118 | " |
| 119 | |
| 120 | test_expect_success "$opt okay with overridden rebase.updateRefs" " |
| 121 | test_when_finished \"git reset --hard B^0\" && |
| 122 | git checkout B^0 && |
| 123 | git -c rebase.updateRefs=true rebase --no-update-refs $opt A |
| 124 | " |
| 125 | } |
| 126 | |
| 127 | # Check options which imply --apply |
| 128 | test_rebase_am_only --whitespace=fix |
| 129 | test_rebase_am_only -C4 |
| 130 | # Also check an explicit --apply |
| 131 | test_rebase_am_only --apply |
| 132 | |
| 133 | test_done |