Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t3403-rebase-skip.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t3403-rebase-skip.sh` 206 lines ยท 5904 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2006 Eric Wong 4 # 5 6 test_description='git rebase --merge --skip tests' 7 8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 10 11 . ./test-lib.sh 12 13 . "$TEST_DIRECTORY"/lib-rebase.sh 14 15 # we assume the default git am -3 --skip strategy is tested independently 16 # and always works :) 17 18 test_expect_success setup ' 19 echo hello > hello && 20 git add hello && 21 git commit -m "hello" && 22 git branch skip-reference && 23 git tag hello && 24 25 echo world >> hello && 26 git commit -a -m "hello world" && 27 echo goodbye >> hello && 28 git commit -a -m "goodbye" && 29 git tag goodbye && 30 31 git checkout --detach && 32 git checkout HEAD^ . && 33 test_tick && 34 git commit -m reverted-goodbye && 35 git tag reverted-goodbye && 36 git checkout goodbye && 37 test_tick && 38 GIT_AUTHOR_NAME="Another Author" \ 39 GIT_AUTHOR_EMAIL="another.author@example.com" \ 40 git commit --amend --no-edit -m amended-goodbye \ 41 --reset-author && 42 test_tick && 43 git tag amended-goodbye && 44 45 git checkout -f skip-reference && 46 echo moo > hello && 47 git commit -a -m "we should skip this" && 48 echo moo > cow && 49 git add cow && 50 git commit -m "this should not be skipped" && 51 git branch pre-rebase skip-reference && 52 git branch skip-merge skip-reference 53 ' 54 55 test_expect_success 'rebase with git am -3 (default)' ' 56 test_must_fail git rebase --apply main 57 ' 58 59 test_expect_success 'rebase --skip can not be used with other options' ' 60 test_must_fail git rebase -v --skip && 61 test_must_fail git rebase --skip -v 62 ' 63 64 test_expect_success 'rebase --skip with am -3' ' 65 git rebase --skip 66 ' 67 68 test_expect_success 'rebase moves back to skip-reference' ' 69 test refs/heads/skip-reference = $(git symbolic-ref HEAD) && 70 git branch post-rebase && 71 git reset --hard pre-rebase && 72 test_must_fail git rebase main && 73 echo "hello" > hello && 74 git add hello && 75 git rebase --continue && 76 test refs/heads/skip-reference = $(git symbolic-ref HEAD) && 77 git reset --hard post-rebase 78 ' 79 80 test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge' 81 82 test_expect_success 'rebase with --merge' ' 83 test_must_fail git rebase --merge main 84 ' 85 86 test_expect_success 'rebase --skip with --merge' ' 87 git rebase --skip 88 ' 89 90 test_expect_success 'merge and reference trees equal' ' 91 test -z "$(git diff-tree skip-merge skip-reference)" 92 ' 93 94 test_expect_success 'moved back to branch correctly' ' 95 test refs/heads/skip-merge = $(git symbolic-ref HEAD) 96 ' 97 98 test_debug 'gitk --all & sleep 1' 99 100 test_expect_success 'skipping final pick removes REBASE_HEAD & .git/MERGE_MSG' ' 101 test_must_fail git rebase --onto hello reverted-goodbye^ \ 102 reverted-goodbye && 103 git show-ref --verify AUTO_MERGE && 104 test_cmp_rev reverted-goodbye REBASE_HEAD && 105 git rebase --skip && 106 test_ref_missing AUTO_MERGE && 107 test_ref_missing REBASE_HEAD && 108 test_path_is_missing .git/MERGE_MSG 109 ' 110 111 test_expect_success 'correct advice upon picking empty commit' ' 112 test_when_finished "git rebase --abort" && 113 test_must_fail git rebase -i --onto goodbye \ 114 amended-goodbye^ amended-goodbye 2>err && 115 test_grep "previous cherry-pick is now empty" err && 116 test_grep "git rebase --skip" err && 117 test_must_fail git commit && 118 test_grep "git rebase --skip" err 119 ' 120 121 test_expect_success 'correct authorship when committing empty pick' ' 122 test_when_finished "git rebase --abort" && 123 test_must_fail git rebase -i --onto goodbye \ 124 amended-goodbye^ amended-goodbye && 125 git commit --allow-empty && 126 git log --pretty=format:"%an <%ae>%n%ad%B" -1 amended-goodbye >expect && 127 git log --pretty=format:"%an <%ae>%n%ad%B" -1 HEAD >actual && 128 test_cmp expect actual 129 ' 130 131 test_expect_success 'correct advice upon rewording empty commit' ' 132 test_when_finished "git rebase --abort" && 133 ( 134 set_fake_editor && 135 test_must_fail env FAKE_LINES="reword 1" git rebase -i \ 136 --onto goodbye amended-goodbye^ amended-goodbye 2>err 137 ) && 138 test_grep "previous cherry-pick is now empty" err && 139 test_grep "git rebase --skip" err && 140 test_must_fail git commit && 141 test_grep "git rebase --skip" err 142 ' 143 144 test_expect_success 'correct advice upon editing empty commit' ' 145 test_when_finished "git rebase --abort" && 146 ( 147 set_fake_editor && 148 test_must_fail env FAKE_LINES="edit 1" git rebase -i \ 149 --onto goodbye amended-goodbye^ amended-goodbye 2>err 150 ) && 151 test_grep "previous cherry-pick is now empty" err && 152 test_grep "git rebase --skip" err && 153 test_must_fail git commit && 154 test_grep "git rebase --skip" err 155 ' 156 157 test_expect_success 'correct advice upon cherry-picking an empty commit during a rebase' ' 158 test_when_finished "git rebase --abort" && 159 ( 160 set_fake_editor && 161 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_amended-goodbye" \ 162 git rebase -i goodbye^ goodbye 2>err 163 ) && 164 test_grep "previous cherry-pick is now empty" err && 165 test_grep "git cherry-pick --skip" err && 166 test_must_fail git commit 2>err && 167 test_grep "git cherry-pick --skip" err 168 ' 169 170 test_expect_success 'correct advice upon multi cherry-pick picking an empty commit during a rebase' ' 171 test_when_finished "git rebase --abort" && 172 ( 173 set_fake_editor && 174 test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_goodbye_amended-goodbye" \ 175 git rebase -i goodbye^^ goodbye 2>err 176 ) && 177 test_grep "previous cherry-pick is now empty" err && 178 test_grep "git cherry-pick --skip" err && 179 test_must_fail git commit 2>err && 180 test_grep "git cherry-pick --skip" err 181 ' 182 183 test_expect_success 'fixup that empties commit fails' ' 184 test_when_finished "git rebase --abort" && 185 ( 186 set_fake_editor && 187 test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \ 188 goodbye^ reverted-goodbye 189 ) 190 ' 191 192 test_expect_success 'squash that empties commit fails' ' 193 test_when_finished "git rebase --abort" && 194 ( 195 set_fake_editor && 196 test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \ 197 goodbye^ reverted-goodbye 198 ) 199 ' 200 201 # Must be the last test in this file 202 test_expect_success '$EDITOR and friends are unchanged' ' 203 test_editor_unchanged 204 ' 205 206 test_done