| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas, |
| 4 | # Thomas Nguy, Khoi Nguyen |
| 5 | # Grenoble INP Ensimag |
| 6 | # |
| 7 | |
| 8 | test_description='git status advice' |
| 9 | |
| 10 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 11 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 12 | |
| 13 | . ./test-lib.sh |
| 14 | |
| 15 | . "$TEST_DIRECTORY"/lib-rebase.sh |
| 16 | |
| 17 | set_fake_editor |
| 18 | |
| 19 | test_expect_success 'prepare for conflicts' ' |
| 20 | git config --global advice.statusuoption false && |
| 21 | test_commit init main.txt init && |
| 22 | git branch conflicts && |
| 23 | test_commit on_main main.txt on_main && |
| 24 | git checkout conflicts && |
| 25 | test_commit on_conflicts main.txt on_conflicts |
| 26 | ' |
| 27 | |
| 28 | |
| 29 | test_expect_success 'status when conflicts unresolved' ' |
| 30 | test_must_fail git merge main && |
| 31 | cat >expected <<\EOF && |
| 32 | On branch conflicts |
| 33 | You have unmerged paths. |
| 34 | (fix conflicts and run "git commit") |
| 35 | (use "git merge --abort" to abort the merge) |
| 36 | |
| 37 | Unmerged paths: |
| 38 | (use "git add <file>..." to mark resolution) |
| 39 | both modified: main.txt |
| 40 | |
| 41 | no changes added to commit (use "git add" and/or "git commit -a") |
| 42 | EOF |
| 43 | git status --untracked-files=no >actual && |
| 44 | test_cmp expected actual |
| 45 | ' |
| 46 | |
| 47 | |
| 48 | test_expect_success 'status when conflicts resolved before commit' ' |
| 49 | git reset --hard conflicts && |
| 50 | test_must_fail git merge main && |
| 51 | echo one >main.txt && |
| 52 | git add main.txt && |
| 53 | cat >expected <<\EOF && |
| 54 | On branch conflicts |
| 55 | All conflicts fixed but you are still merging. |
| 56 | (use "git commit" to conclude merge) |
| 57 | |
| 58 | Changes to be committed: |
| 59 | modified: main.txt |
| 60 | |
| 61 | Untracked files not listed (use -u option to show untracked files) |
| 62 | EOF |
| 63 | git status --untracked-files=no >actual && |
| 64 | test_cmp expected actual |
| 65 | ' |
| 66 | |
| 67 | |
| 68 | test_expect_success 'prepare for rebase conflicts' ' |
| 69 | git reset --hard main && |
| 70 | git checkout -b rebase_conflicts && |
| 71 | test_commit one_rebase main.txt one && |
| 72 | test_commit two_rebase main.txt two && |
| 73 | test_commit three_rebase main.txt three |
| 74 | ' |
| 75 | |
| 76 | |
| 77 | test_expect_success 'status when rebase --apply in progress before resolving conflicts' ' |
| 78 | test_when_finished "git rebase --abort" && |
| 79 | ONTO=$(git rev-parse --short HEAD^^) && |
| 80 | test_must_fail git rebase --apply HEAD^ --onto HEAD^^ && |
| 81 | cat >expected <<EOF && |
| 82 | rebase in progress; onto $ONTO |
| 83 | You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. |
| 84 | (fix conflicts and then run "git rebase --continue") |
| 85 | (use "git rebase --skip" to skip this patch) |
| 86 | (use "git rebase --abort" to check out the original branch) |
| 87 | |
| 88 | Unmerged paths: |
| 89 | (use "git restore --staged <file>..." to unstage) |
| 90 | (use "git add <file>..." to mark resolution) |
| 91 | both modified: main.txt |
| 92 | |
| 93 | no changes added to commit (use "git add" and/or "git commit -a") |
| 94 | EOF |
| 95 | git status --untracked-files=no >actual && |
| 96 | test_cmp expected actual |
| 97 | ' |
| 98 | |
| 99 | |
| 100 | test_expect_success 'status when rebase --apply in progress before rebase --continue' ' |
| 101 | git reset --hard rebase_conflicts && |
| 102 | test_when_finished "git rebase --abort" && |
| 103 | ONTO=$(git rev-parse --short HEAD^^) && |
| 104 | test_must_fail git rebase --apply HEAD^ --onto HEAD^^ && |
| 105 | echo three >main.txt && |
| 106 | git add main.txt && |
| 107 | cat >expected <<EOF && |
| 108 | rebase in progress; onto $ONTO |
| 109 | You are currently rebasing branch '\''rebase_conflicts'\'' on '\''$ONTO'\''. |
| 110 | (all conflicts fixed: run "git rebase --continue") |
| 111 | |
| 112 | Changes to be committed: |
| 113 | (use "git restore --staged <file>..." to unstage) |
| 114 | modified: main.txt |
| 115 | |
| 116 | Untracked files not listed (use -u option to show untracked files) |
| 117 | EOF |
| 118 | git status --untracked-files=no >actual && |
| 119 | test_cmp expected actual |
| 120 | ' |
| 121 | |
| 122 | |
| 123 | test_expect_success 'prepare for rebase_i_conflicts' ' |
| 124 | git reset --hard main && |
| 125 | git checkout -b rebase_i_conflicts && |
| 126 | test_commit one_unmerge main.txt one_unmerge && |
| 127 | git branch rebase_i_conflicts_second && |
| 128 | test_commit one_main main.txt one_main && |
| 129 | git checkout rebase_i_conflicts_second && |
| 130 | test_commit one_second main.txt one_second |
| 131 | ' |
| 132 | |
| 133 | |
| 134 | test_expect_success 'status during rebase -i when conflicts unresolved' ' |
| 135 | test_when_finished "git rebase --abort" && |
| 136 | ONTO=$(git rev-parse --short rebase_i_conflicts) && |
| 137 | LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) && |
| 138 | test_must_fail git rebase -i rebase_i_conflicts && |
| 139 | cat >expected <<EOF && |
| 140 | interactive rebase in progress; onto $ONTO |
| 141 | Last command done (1 command done): |
| 142 | pick $LAST_COMMIT # one_second |
| 143 | No commands remaining. |
| 144 | You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. |
| 145 | (fix conflicts and then run "git rebase --continue") |
| 146 | (use "git rebase --skip" to skip this patch) |
| 147 | (use "git rebase --abort" to check out the original branch) |
| 148 | |
| 149 | Unmerged paths: |
| 150 | (use "git restore --staged <file>..." to unstage) |
| 151 | (use "git add <file>..." to mark resolution) |
| 152 | both modified: main.txt |
| 153 | |
| 154 | no changes added to commit (use "git add" and/or "git commit -a") |
| 155 | EOF |
| 156 | git status --untracked-files=no >actual && |
| 157 | test_cmp expected actual |
| 158 | ' |
| 159 | |
| 160 | |
| 161 | test_expect_success 'status during rebase -i after resolving conflicts' ' |
| 162 | git reset --hard rebase_i_conflicts_second && |
| 163 | test_when_finished "git rebase --abort" && |
| 164 | ONTO=$(git rev-parse --short rebase_i_conflicts) && |
| 165 | LAST_COMMIT=$(git rev-parse --short rebase_i_conflicts_second) && |
| 166 | test_must_fail git rebase -i rebase_i_conflicts && |
| 167 | git add main.txt && |
| 168 | cat >expected <<EOF && |
| 169 | interactive rebase in progress; onto $ONTO |
| 170 | Last command done (1 command done): |
| 171 | pick $LAST_COMMIT # one_second |
| 172 | No commands remaining. |
| 173 | You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO'\''. |
| 174 | (all conflicts fixed: run "git rebase --continue") |
| 175 | |
| 176 | Changes to be committed: |
| 177 | (use "git restore --staged <file>..." to unstage) |
| 178 | modified: main.txt |
| 179 | |
| 180 | Untracked files not listed (use -u option to show untracked files) |
| 181 | EOF |
| 182 | git status --untracked-files=no >actual && |
| 183 | test_cmp expected actual |
| 184 | ' |
| 185 | |
| 186 | |
| 187 | test_expect_success 'status when rebasing -i in edit mode' ' |
| 188 | git reset --hard main && |
| 189 | git checkout -b rebase_i_edit && |
| 190 | test_commit one_rebase_i main.txt one && |
| 191 | test_commit two_rebase_i main.txt two && |
| 192 | COMMIT2=$(git rev-parse --short rebase_i_edit) && |
| 193 | test_commit three_rebase_i main.txt three && |
| 194 | COMMIT3=$(git rev-parse --short rebase_i_edit) && |
| 195 | FAKE_LINES="1 edit 2" && |
| 196 | export FAKE_LINES && |
| 197 | test_when_finished "git rebase --abort" && |
| 198 | ONTO=$(git rev-parse --short HEAD~2) && |
| 199 | git rebase -i HEAD~2 && |
| 200 | cat >expected <<EOF && |
| 201 | interactive rebase in progress; onto $ONTO |
| 202 | Last commands done (2 commands done): |
| 203 | pick $COMMIT2 # two_rebase_i |
| 204 | edit $COMMIT3 # three_rebase_i |
| 205 | No commands remaining. |
| 206 | You are currently editing a commit while rebasing branch '\''rebase_i_edit'\'' on '\''$ONTO'\''. |
| 207 | (use "git commit --amend" to amend the current commit) |
| 208 | (use "git rebase --continue" once you are satisfied with your changes) |
| 209 | |
| 210 | nothing to commit (use -u to show untracked files) |
| 211 | EOF |
| 212 | git status --untracked-files=no >actual && |
| 213 | test_cmp expected actual |
| 214 | ' |
| 215 | |
| 216 | |
| 217 | test_expect_success 'status when splitting a commit' ' |
| 218 | git reset --hard main && |
| 219 | git checkout -b split_commit && |
| 220 | test_commit one_split main.txt one && |
| 221 | test_commit two_split main.txt two && |
| 222 | COMMIT2=$(git rev-parse --short split_commit) && |
| 223 | test_commit three_split main.txt three && |
| 224 | COMMIT3=$(git rev-parse --short split_commit) && |
| 225 | test_commit four_split main.txt four && |
| 226 | COMMIT4=$(git rev-parse --short split_commit) && |
| 227 | FAKE_LINES="reword 1 edit 2 fixup_-C 3" && |
| 228 | export FAKE_LINES && |
| 229 | test_when_finished "git rebase --abort" && |
| 230 | ONTO=$(git rev-parse --short HEAD~3) && |
| 231 | git rebase -i HEAD~3 && |
| 232 | git reset HEAD^ && |
| 233 | cat >expected <<EOF && |
| 234 | interactive rebase in progress; onto $ONTO |
| 235 | Last commands done (2 commands done): |
| 236 | reword $COMMIT2 # two_split |
| 237 | edit $COMMIT3 # three_split |
| 238 | Next command to do (1 remaining command): |
| 239 | fixup -C $COMMIT4 # four_split |
| 240 | (use "git rebase --edit-todo" to view and edit) |
| 241 | You are currently splitting a commit while rebasing branch '\''split_commit'\'' on '\''$ONTO'\''. |
| 242 | (Once your working directory is clean, run "git rebase --continue") |
| 243 | |
| 244 | Changes not staged for commit: |
| 245 | (use "git add <file>..." to update what will be committed) |
| 246 | (use "git restore <file>..." to discard changes in working directory) |
| 247 | modified: main.txt |
| 248 | |
| 249 | no changes added to commit (use "git add" and/or "git commit -a") |
| 250 | EOF |
| 251 | git status --untracked-files=no >actual && |
| 252 | test_cmp expected actual |
| 253 | ' |
| 254 | |
| 255 | |
| 256 | test_expect_success 'status after editing the last commit with --amend during a rebase -i' ' |
| 257 | git reset --hard main && |
| 258 | git checkout -b amend_last && |
| 259 | test_commit one_amend main.txt one && |
| 260 | test_commit two_amend main.txt two && |
| 261 | test_commit three_amend main.txt three && |
| 262 | COMMIT3=$(git rev-parse --short amend_last) && |
| 263 | test_commit four_amend main.txt four && |
| 264 | COMMIT4=$(git rev-parse --short amend_last) && |
| 265 | FAKE_LINES="1 2 edit 3" && |
| 266 | export FAKE_LINES && |
| 267 | test_when_finished "git rebase --abort" && |
| 268 | ONTO=$(git rev-parse --short HEAD~3) && |
| 269 | git rebase -i HEAD~3 && |
| 270 | git commit --amend -m "foo" && |
| 271 | cat >expected <<EOF && |
| 272 | interactive rebase in progress; onto $ONTO |
| 273 | Last commands done (3 commands done): |
| 274 | pick $COMMIT3 # three_amend |
| 275 | edit $COMMIT4 # four_amend |
| 276 | (see more in file .git/rebase-merge/done) |
| 277 | No commands remaining. |
| 278 | You are currently editing a commit while rebasing branch '\''amend_last'\'' on '\''$ONTO'\''. |
| 279 | (use "git commit --amend" to amend the current commit) |
| 280 | (use "git rebase --continue" once you are satisfied with your changes) |
| 281 | |
| 282 | nothing to commit (use -u to show untracked files) |
| 283 | EOF |
| 284 | git status --untracked-files=no >actual && |
| 285 | test_cmp expected actual |
| 286 | ' |
| 287 | |
| 288 | |
| 289 | test_expect_success 'prepare for several edits' ' |
| 290 | git reset --hard main && |
| 291 | git checkout -b several_edits && |
| 292 | test_commit one_edits main.txt one && |
| 293 | test_commit two_edits main.txt two && |
| 294 | test_commit three_edits main.txt three && |
| 295 | test_commit four_edits main.txt four |
| 296 | ' |
| 297 | |
| 298 | |
| 299 | test_expect_success 'status: (continue first edit) second edit' ' |
| 300 | FAKE_LINES="edit 1 edit 2 drop 3" && |
| 301 | export FAKE_LINES && |
| 302 | test_when_finished "git rebase --abort" && |
| 303 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 304 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 305 | COMMIT4=$(git rev-parse --short several_edits) && |
| 306 | ONTO=$(git rev-parse --short HEAD~3) && |
| 307 | git rebase -i HEAD~3 && |
| 308 | git rebase --continue && |
| 309 | cat >expected <<EOF && |
| 310 | interactive rebase in progress; onto $ONTO |
| 311 | Last commands done (2 commands done): |
| 312 | edit $COMMIT2 # two_edits |
| 313 | edit $COMMIT3 # three_edits |
| 314 | Next command to do (1 remaining command): |
| 315 | drop $COMMIT4 # four_edits |
| 316 | (use "git rebase --edit-todo" to view and edit) |
| 317 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 318 | (use "git commit --amend" to amend the current commit) |
| 319 | (use "git rebase --continue" once you are satisfied with your changes) |
| 320 | |
| 321 | nothing to commit (use -u to show untracked files) |
| 322 | EOF |
| 323 | git status --untracked-files=no >actual && |
| 324 | test_cmp expected actual |
| 325 | ' |
| 326 | |
| 327 | |
| 328 | test_expect_success 'status: (continue first edit) second edit and split' ' |
| 329 | git reset --hard several_edits && |
| 330 | FAKE_LINES="edit 1 edit 2 squash 3" && |
| 331 | export FAKE_LINES && |
| 332 | test_when_finished "git rebase --abort" && |
| 333 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 334 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 335 | COMMIT4=$(git rev-parse --short several_edits) && |
| 336 | ONTO=$(git rev-parse --short HEAD~3) && |
| 337 | git rebase -i HEAD~3 && |
| 338 | git rebase --continue && |
| 339 | git reset HEAD^ && |
| 340 | cat >expected <<EOF && |
| 341 | interactive rebase in progress; onto $ONTO |
| 342 | Last commands done (2 commands done): |
| 343 | edit $COMMIT2 # two_edits |
| 344 | edit $COMMIT3 # three_edits |
| 345 | Next command to do (1 remaining command): |
| 346 | squash $COMMIT4 # four_edits |
| 347 | (use "git rebase --edit-todo" to view and edit) |
| 348 | You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 349 | (Once your working directory is clean, run "git rebase --continue") |
| 350 | |
| 351 | Changes not staged for commit: |
| 352 | (use "git add <file>..." to update what will be committed) |
| 353 | (use "git restore <file>..." to discard changes in working directory) |
| 354 | modified: main.txt |
| 355 | |
| 356 | no changes added to commit (use "git add" and/or "git commit -a") |
| 357 | EOF |
| 358 | git status --untracked-files=no >actual && |
| 359 | test_cmp expected actual |
| 360 | ' |
| 361 | |
| 362 | |
| 363 | test_expect_success 'status: (continue first edit) second edit and amend' ' |
| 364 | git reset --hard several_edits && |
| 365 | FAKE_LINES="edit 1 edit 2 fixup 3" && |
| 366 | export FAKE_LINES && |
| 367 | test_when_finished "git rebase --abort" && |
| 368 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 369 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 370 | COMMIT4=$(git rev-parse --short several_edits) && |
| 371 | ONTO=$(git rev-parse --short HEAD~3) && |
| 372 | git rebase -i HEAD~3 && |
| 373 | git rebase --continue && |
| 374 | git commit --amend -m "foo" && |
| 375 | cat >expected <<EOF && |
| 376 | interactive rebase in progress; onto $ONTO |
| 377 | Last commands done (2 commands done): |
| 378 | edit $COMMIT2 # two_edits |
| 379 | edit $COMMIT3 # three_edits |
| 380 | Next command to do (1 remaining command): |
| 381 | fixup $COMMIT4 # four_edits |
| 382 | (use "git rebase --edit-todo" to view and edit) |
| 383 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 384 | (use "git commit --amend" to amend the current commit) |
| 385 | (use "git rebase --continue" once you are satisfied with your changes) |
| 386 | |
| 387 | nothing to commit (use -u to show untracked files) |
| 388 | EOF |
| 389 | git status --untracked-files=no >actual && |
| 390 | test_cmp expected actual |
| 391 | ' |
| 392 | |
| 393 | |
| 394 | test_expect_success 'status: (amend first edit) second edit' ' |
| 395 | git reset --hard several_edits && |
| 396 | FAKE_LINES="edit 1 edit 2 fixup_-c 3" && |
| 397 | export FAKE_LINES && |
| 398 | test_when_finished "git rebase --abort" && |
| 399 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 400 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 401 | COMMIT4=$(git rev-parse --short several_edits) && |
| 402 | ONTO=$(git rev-parse --short HEAD~3) && |
| 403 | git rebase -i HEAD~3 && |
| 404 | git commit --amend -m "a" && |
| 405 | git rebase --continue && |
| 406 | cat >expected <<EOF && |
| 407 | interactive rebase in progress; onto $ONTO |
| 408 | Last commands done (2 commands done): |
| 409 | edit $COMMIT2 # two_edits |
| 410 | edit $COMMIT3 # three_edits |
| 411 | Next command to do (1 remaining command): |
| 412 | fixup -c $COMMIT4 # four_edits |
| 413 | (use "git rebase --edit-todo" to view and edit) |
| 414 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 415 | (use "git commit --amend" to amend the current commit) |
| 416 | (use "git rebase --continue" once you are satisfied with your changes) |
| 417 | |
| 418 | nothing to commit (use -u to show untracked files) |
| 419 | EOF |
| 420 | git status --untracked-files=no >actual && |
| 421 | test_cmp expected actual |
| 422 | ' |
| 423 | |
| 424 | |
| 425 | test_expect_success 'status: (amend first edit) second edit and split' ' |
| 426 | git reset --hard several_edits && |
| 427 | FAKE_LINES="edit 1 edit 2 3" && |
| 428 | export FAKE_LINES && |
| 429 | test_when_finished "git rebase --abort" && |
| 430 | ONTO=$(git rev-parse --short HEAD~3) && |
| 431 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 432 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 433 | COMMIT4=$(git rev-parse --short several_edits) && |
| 434 | git rebase -i HEAD~3 && |
| 435 | git commit --amend -m "b" && |
| 436 | git rebase --continue && |
| 437 | git reset HEAD^ && |
| 438 | cat >expected <<EOF && |
| 439 | interactive rebase in progress; onto $ONTO |
| 440 | Last commands done (2 commands done): |
| 441 | edit $COMMIT2 # two_edits |
| 442 | edit $COMMIT3 # three_edits |
| 443 | Next command to do (1 remaining command): |
| 444 | pick $COMMIT4 # four_edits |
| 445 | (use "git rebase --edit-todo" to view and edit) |
| 446 | You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 447 | (Once your working directory is clean, run "git rebase --continue") |
| 448 | |
| 449 | Changes not staged for commit: |
| 450 | (use "git add <file>..." to update what will be committed) |
| 451 | (use "git restore <file>..." to discard changes in working directory) |
| 452 | modified: main.txt |
| 453 | |
| 454 | no changes added to commit (use "git add" and/or "git commit -a") |
| 455 | EOF |
| 456 | git status --untracked-files=no >actual && |
| 457 | test_cmp expected actual |
| 458 | ' |
| 459 | |
| 460 | |
| 461 | test_expect_success 'status: (amend first edit) second edit and amend' ' |
| 462 | git reset --hard several_edits && |
| 463 | test_when_finished "git rebase --abort" && |
| 464 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 465 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 466 | COMMIT4=$(git rev-parse --short several_edits) && |
| 467 | ONTO=$(git rev-parse --short HEAD~3) && |
| 468 | cat >todo <<-EOF && |
| 469 | edit several_edits^^ # two_edits |
| 470 | edit several_edits^ # three_edits |
| 471 | merge $(git rev-parse main) $(git rev-parse several_edits) |
| 472 | EOF |
| 473 | ( |
| 474 | set_replace_editor todo && |
| 475 | git rebase -i HEAD~3 |
| 476 | ) && |
| 477 | git commit --amend -m "c" && |
| 478 | git rebase --continue && |
| 479 | git commit --amend -m "d" && |
| 480 | cat >expected <<EOF && |
| 481 | interactive rebase in progress; onto $ONTO |
| 482 | Last commands done (2 commands done): |
| 483 | edit $COMMIT2 # two_edits |
| 484 | edit $COMMIT3 # three_edits |
| 485 | Next command to do (1 remaining command): |
| 486 | merge $(git rev-parse --short main) $COMMIT4 |
| 487 | (use "git rebase --edit-todo" to view and edit) |
| 488 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 489 | (use "git commit --amend" to amend the current commit) |
| 490 | (use "git rebase --continue" once you are satisfied with your changes) |
| 491 | |
| 492 | nothing to commit (use -u to show untracked files) |
| 493 | EOF |
| 494 | git status --untracked-files=no >actual && |
| 495 | test_cmp expected actual |
| 496 | ' |
| 497 | |
| 498 | |
| 499 | test_expect_success 'status: (split first edit) second edit' ' |
| 500 | git reset --hard several_edits && |
| 501 | FAKE_LINES="edit 1 edit 2 3" && |
| 502 | export FAKE_LINES && |
| 503 | test_when_finished "git rebase --abort" && |
| 504 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 505 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 506 | COMMIT4=$(git rev-parse --short several_edits) && |
| 507 | ONTO=$(git rev-parse --short HEAD~3) && |
| 508 | git rebase -i HEAD~3 && |
| 509 | git reset HEAD^ && |
| 510 | git add main.txt && |
| 511 | git commit -m "e" && |
| 512 | git rebase --continue && |
| 513 | cat >expected <<EOF && |
| 514 | interactive rebase in progress; onto $ONTO |
| 515 | Last commands done (2 commands done): |
| 516 | edit $COMMIT2 # two_edits |
| 517 | edit $COMMIT3 # three_edits |
| 518 | Next command to do (1 remaining command): |
| 519 | pick $COMMIT4 # four_edits |
| 520 | (use "git rebase --edit-todo" to view and edit) |
| 521 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 522 | (use "git commit --amend" to amend the current commit) |
| 523 | (use "git rebase --continue" once you are satisfied with your changes) |
| 524 | |
| 525 | nothing to commit (use -u to show untracked files) |
| 526 | EOF |
| 527 | git status --untracked-files=no >actual && |
| 528 | test_cmp expected actual |
| 529 | ' |
| 530 | |
| 531 | |
| 532 | test_expect_success 'status: (split first edit) second edit and split' ' |
| 533 | git reset --hard several_edits && |
| 534 | test_when_finished "git rebase --abort" && |
| 535 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 536 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 537 | COMMIT4=$(git rev-parse --short several_edits) && |
| 538 | cat >todo <<-EOF && |
| 539 | edit several_edits^^ # two_edits |
| 540 | edit several_edits^ # three_edits |
| 541 | reset $(git rev-parse main) |
| 542 | merge -C several_edits topic # title |
| 543 | EOF |
| 544 | ONTO=$(git rev-parse --short HEAD~3) && |
| 545 | ( |
| 546 | set_replace_editor todo && |
| 547 | git rebase -i HEAD~3 |
| 548 | ) && |
| 549 | git reset HEAD^ && |
| 550 | git add main.txt && |
| 551 | git commit --amend -m "f" && |
| 552 | git rebase --continue && |
| 553 | git reset HEAD^ && |
| 554 | cat >expected <<EOF && |
| 555 | interactive rebase in progress; onto $ONTO |
| 556 | Last commands done (2 commands done): |
| 557 | edit $COMMIT2 # two_edits |
| 558 | edit $COMMIT3 # three_edits |
| 559 | Next commands to do (2 remaining commands): |
| 560 | reset $(git rev-parse --short main) |
| 561 | merge -C $COMMIT4 topic # title |
| 562 | (use "git rebase --edit-todo" to view and edit) |
| 563 | You are currently splitting a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 564 | (Once your working directory is clean, run "git rebase --continue") |
| 565 | |
| 566 | Changes not staged for commit: |
| 567 | (use "git add <file>..." to update what will be committed) |
| 568 | (use "git restore <file>..." to discard changes in working directory) |
| 569 | modified: main.txt |
| 570 | |
| 571 | no changes added to commit (use "git add" and/or "git commit -a") |
| 572 | EOF |
| 573 | git status --untracked-files=no >actual && |
| 574 | test_cmp expected actual |
| 575 | ' |
| 576 | |
| 577 | |
| 578 | test_expect_success 'status: (split first edit) second edit and amend' ' |
| 579 | git reset --hard several_edits && |
| 580 | test_when_finished "git rebase --abort" && |
| 581 | git branch cafe main && |
| 582 | COMMIT2=$(git rev-parse --short several_edits^^) && |
| 583 | COMMIT3=$(git rev-parse --short several_edits^) && |
| 584 | cat >todo <<-EOF && |
| 585 | edit several_edits^^ # two_edits |
| 586 | edit several_edits^ # three_edits |
| 587 | update-ref refs/heads/main |
| 588 | reset cafe |
| 589 | EOF |
| 590 | ONTO=$(git rev-parse --short HEAD~3) && |
| 591 | ( |
| 592 | set_replace_editor todo && |
| 593 | git rebase -i HEAD~3 |
| 594 | ) && |
| 595 | git reset HEAD^ && |
| 596 | git add main.txt && |
| 597 | git commit --amend -m "g" && |
| 598 | git rebase --continue && |
| 599 | git commit --amend -m "h" && |
| 600 | cat >expected <<EOF && |
| 601 | interactive rebase in progress; onto $ONTO |
| 602 | Last commands done (2 commands done): |
| 603 | edit $COMMIT2 # two_edits |
| 604 | edit $COMMIT3 # three_edits |
| 605 | Next commands to do (2 remaining commands): |
| 606 | update-ref refs/heads/main |
| 607 | reset cafe |
| 608 | (use "git rebase --edit-todo" to view and edit) |
| 609 | You are currently editing a commit while rebasing branch '\''several_edits'\'' on '\''$ONTO'\''. |
| 610 | (use "git commit --amend" to amend the current commit) |
| 611 | (use "git rebase --continue" once you are satisfied with your changes) |
| 612 | |
| 613 | nothing to commit (use -u to show untracked files) |
| 614 | EOF |
| 615 | git status --untracked-files=no >actual && |
| 616 | test_cmp expected actual |
| 617 | ' |
| 618 | |
| 619 | test_expect_success 'rebase in a linked worktree' ' |
| 620 | test_might_fail git rebase --abort && |
| 621 | git worktree add wt && |
| 622 | test_when_finished "test_might_fail git -C wt rebase --abort; |
| 623 | git worktree remove wt" && |
| 624 | GIT_SEQUENCE_EDITOR="echo break >" git -C wt rebase -i HEAD && |
| 625 | git -C wt status >actual && |
| 626 | test_grep "interactive rebase in progress" actual |
| 627 | ' |
| 628 | |
| 629 | test_expect_success 'prepare am_session' ' |
| 630 | git reset --hard main && |
| 631 | git checkout -b am_session && |
| 632 | test_commit one_am one.txt "one" && |
| 633 | test_commit two_am two.txt "two" && |
| 634 | test_commit three_am three.txt "three" |
| 635 | ' |
| 636 | |
| 637 | |
| 638 | test_expect_success 'status in an am session: file already exists' ' |
| 639 | git checkout -b am_already_exists && |
| 640 | test_when_finished "rm Maildir/* && git am --abort" && |
| 641 | git format-patch -1 -oMaildir && |
| 642 | test_must_fail git am Maildir/*.patch && |
| 643 | cat >expected <<\EOF && |
| 644 | On branch am_already_exists |
| 645 | You are in the middle of an am session. |
| 646 | (fix conflicts and then run "git am --continue") |
| 647 | (use "git am --skip" to skip this patch) |
| 648 | (use "git am --abort" to restore the original branch) |
| 649 | |
| 650 | nothing to commit (use -u to show untracked files) |
| 651 | EOF |
| 652 | git status --untracked-files=no >actual && |
| 653 | test_cmp expected actual |
| 654 | ' |
| 655 | |
| 656 | |
| 657 | test_expect_success 'status in an am session: file does not exist' ' |
| 658 | git reset --hard am_session && |
| 659 | git checkout -b am_not_exists && |
| 660 | git rm three.txt && |
| 661 | git commit -m "delete three.txt" && |
| 662 | test_when_finished "rm Maildir/* && git am --abort" && |
| 663 | git format-patch -1 -oMaildir && |
| 664 | test_must_fail git am Maildir/*.patch && |
| 665 | cat >expected <<\EOF && |
| 666 | On branch am_not_exists |
| 667 | You are in the middle of an am session. |
| 668 | (fix conflicts and then run "git am --continue") |
| 669 | (use "git am --skip" to skip this patch) |
| 670 | (use "git am --abort" to restore the original branch) |
| 671 | |
| 672 | nothing to commit (use -u to show untracked files) |
| 673 | EOF |
| 674 | git status --untracked-files=no >actual && |
| 675 | test_cmp expected actual |
| 676 | ' |
| 677 | |
| 678 | |
| 679 | test_expect_success 'status in an am session: empty patch' ' |
| 680 | git reset --hard am_session && |
| 681 | git checkout -b am_empty && |
| 682 | test_when_finished "rm Maildir/* && git am --abort" && |
| 683 | git format-patch -3 -oMaildir && |
| 684 | git rm one.txt two.txt three.txt && |
| 685 | git commit -m "delete all am_empty" && |
| 686 | echo error >Maildir/0002-two_am.patch && |
| 687 | test_must_fail git am Maildir/*.patch && |
| 688 | cat >expected <<\EOF && |
| 689 | On branch am_empty |
| 690 | You are in the middle of an am session. |
| 691 | The current patch is empty. |
| 692 | (use "git am --skip" to skip this patch) |
| 693 | (use "git am --allow-empty" to record this patch as an empty commit) |
| 694 | (use "git am --abort" to restore the original branch) |
| 695 | |
| 696 | nothing to commit (use -u to show untracked files) |
| 697 | EOF |
| 698 | git status --untracked-files=no >actual && |
| 699 | test_cmp expected actual |
| 700 | ' |
| 701 | |
| 702 | |
| 703 | test_expect_success 'status when bisecting' ' |
| 704 | git reset --hard main && |
| 705 | git checkout -b bisect && |
| 706 | test_commit one_bisect main.txt one && |
| 707 | test_commit two_bisect main.txt two && |
| 708 | test_commit three_bisect main.txt three && |
| 709 | test_when_finished "git bisect reset" && |
| 710 | git bisect start && |
| 711 | git bisect bad && |
| 712 | git bisect good one_bisect && |
| 713 | TGT=$(git rev-parse --short two_bisect) && |
| 714 | cat >expected <<EOF && |
| 715 | HEAD detached at $TGT |
| 716 | You are currently bisecting, started from branch '\''bisect'\''. |
| 717 | (use "git bisect reset" to get back to the original branch) |
| 718 | |
| 719 | nothing to commit (use -u to show untracked files) |
| 720 | EOF |
| 721 | git status --untracked-files=no >actual && |
| 722 | test_cmp expected actual |
| 723 | ' |
| 724 | |
| 725 | |
| 726 | test_expect_success 'status when bisecting while rebasing' ' |
| 727 | git reset --hard main && |
| 728 | test_when_finished "git rebase --abort" && |
| 729 | ONTO=$(git rev-parse --short HEAD^) && |
| 730 | FAKE_LINES="break" git rebase -i HEAD^ && |
| 731 | test_when_finished "git checkout -" && |
| 732 | git checkout -b bisect_while_rebasing && |
| 733 | test_when_finished "git bisect reset" && |
| 734 | git bisect start && |
| 735 | cat >expected <<EOF && |
| 736 | On branch bisect_while_rebasing |
| 737 | Last command done (1 command done): |
| 738 | break |
| 739 | No commands remaining. |
| 740 | You are currently editing a commit while rebasing branch '\''bisect'\'' on '\''$ONTO'\''. |
| 741 | (use "git commit --amend" to amend the current commit) |
| 742 | (use "git rebase --continue" once you are satisfied with your changes) |
| 743 | |
| 744 | You are currently bisecting, started from branch '\''bisect_while_rebasing'\''. |
| 745 | (use "git bisect reset" to get back to the original branch) |
| 746 | |
| 747 | nothing to commit (use -u to show untracked files) |
| 748 | EOF |
| 749 | git status --untracked-files=no >actual && |
| 750 | test_cmp expected actual |
| 751 | ' |
| 752 | |
| 753 | |
| 754 | test_expect_success 'status when rebase --apply conflicts with statushints disabled' ' |
| 755 | git reset --hard main && |
| 756 | git checkout -b statushints_disabled && |
| 757 | test_when_finished "git config --local advice.statushints true" && |
| 758 | git config --local advice.statushints false && |
| 759 | test_commit one_statushints main.txt one && |
| 760 | test_commit two_statushints main.txt two && |
| 761 | test_commit three_statushints main.txt three && |
| 762 | test_when_finished "git rebase --abort" && |
| 763 | ONTO=$(git rev-parse --short HEAD^^) && |
| 764 | test_must_fail git rebase --apply HEAD^ --onto HEAD^^ && |
| 765 | cat >expected <<EOF && |
| 766 | rebase in progress; onto $ONTO |
| 767 | You are currently rebasing branch '\''statushints_disabled'\'' on '\''$ONTO'\''. |
| 768 | |
| 769 | Unmerged paths: |
| 770 | both modified: main.txt |
| 771 | |
| 772 | no changes added to commit |
| 773 | EOF |
| 774 | git status --untracked-files=no >actual && |
| 775 | test_cmp expected actual |
| 776 | ' |
| 777 | |
| 778 | |
| 779 | test_expect_success 'prepare for cherry-pick conflicts' ' |
| 780 | git reset --hard main && |
| 781 | git checkout -b cherry_branch && |
| 782 | test_commit one_cherry main.txt one && |
| 783 | test_commit two_cherries main.txt two && |
| 784 | git checkout -b cherry_branch_second && |
| 785 | test_commit second_cherry main.txt second && |
| 786 | git checkout cherry_branch && |
| 787 | test_commit three_cherries main.txt three |
| 788 | ' |
| 789 | |
| 790 | |
| 791 | test_expect_success 'status when cherry-picking before resolving conflicts' ' |
| 792 | test_when_finished "git cherry-pick --abort" && |
| 793 | test_must_fail git cherry-pick cherry_branch_second && |
| 794 | TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && |
| 795 | cat >expected <<EOF && |
| 796 | On branch cherry_branch |
| 797 | You are currently cherry-picking commit $TO_CHERRY_PICK. |
| 798 | (fix conflicts and run "git cherry-pick --continue") |
| 799 | (use "git cherry-pick --skip" to skip this patch) |
| 800 | (use "git cherry-pick --abort" to cancel the cherry-pick operation) |
| 801 | |
| 802 | Unmerged paths: |
| 803 | (use "git add <file>..." to mark resolution) |
| 804 | both modified: main.txt |
| 805 | |
| 806 | no changes added to commit (use "git add" and/or "git commit -a") |
| 807 | EOF |
| 808 | git status --untracked-files=no >actual && |
| 809 | test_cmp expected actual |
| 810 | ' |
| 811 | |
| 812 | |
| 813 | test_expect_success 'status when cherry-picking after resolving conflicts' ' |
| 814 | git reset --hard cherry_branch && |
| 815 | test_when_finished "git cherry-pick --abort" && |
| 816 | test_must_fail git cherry-pick cherry_branch_second && |
| 817 | TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && |
| 818 | echo end >main.txt && |
| 819 | git add main.txt && |
| 820 | cat >expected <<EOF && |
| 821 | On branch cherry_branch |
| 822 | You are currently cherry-picking commit $TO_CHERRY_PICK. |
| 823 | (all conflicts fixed: run "git cherry-pick --continue") |
| 824 | (use "git cherry-pick --skip" to skip this patch) |
| 825 | (use "git cherry-pick --abort" to cancel the cherry-pick operation) |
| 826 | |
| 827 | Changes to be committed: |
| 828 | modified: main.txt |
| 829 | |
| 830 | Untracked files not listed (use -u option to show untracked files) |
| 831 | EOF |
| 832 | git status --untracked-files=no >actual && |
| 833 | test_cmp expected actual |
| 834 | ' |
| 835 | |
| 836 | test_expect_success 'status when cherry-picking multiple commits' ' |
| 837 | git reset --hard cherry_branch && |
| 838 | test_when_finished "git cherry-pick --abort" && |
| 839 | test_must_fail git cherry-pick cherry_branch_second one_cherry && |
| 840 | TO_CHERRY_PICK=$(git rev-parse --short CHERRY_PICK_HEAD) && |
| 841 | cat >expected <<EOF && |
| 842 | On branch cherry_branch |
| 843 | You are currently cherry-picking commit $TO_CHERRY_PICK. |
| 844 | (fix conflicts and run "git cherry-pick --continue") |
| 845 | (use "git cherry-pick --skip" to skip this patch) |
| 846 | (use "git cherry-pick --abort" to cancel the cherry-pick operation) |
| 847 | |
| 848 | Unmerged paths: |
| 849 | (use "git add <file>..." to mark resolution) |
| 850 | both modified: main.txt |
| 851 | |
| 852 | no changes added to commit (use "git add" and/or "git commit -a") |
| 853 | EOF |
| 854 | git status --untracked-files=no >actual && |
| 855 | test_cmp expected actual |
| 856 | ' |
| 857 | |
| 858 | test_expect_success 'status when cherry-picking after committing conflict resolution' ' |
| 859 | git reset --hard cherry_branch && |
| 860 | test_when_finished "git cherry-pick --abort" && |
| 861 | test_must_fail git cherry-pick cherry_branch_second one_cherry && |
| 862 | echo end >main.txt && |
| 863 | git commit -a && |
| 864 | cat >expected <<EOF && |
| 865 | On branch cherry_branch |
| 866 | Cherry-pick currently in progress. |
| 867 | (run "git cherry-pick --continue" to continue) |
| 868 | (use "git cherry-pick --skip" to skip this patch) |
| 869 | (use "git cherry-pick --abort" to cancel the cherry-pick operation) |
| 870 | |
| 871 | nothing to commit (use -u to show untracked files) |
| 872 | EOF |
| 873 | git status --untracked-files=no >actual && |
| 874 | test_cmp expected actual |
| 875 | ' |
| 876 | |
| 877 | test_expect_success 'status shows cherry-pick with invalid oid' ' |
| 878 | mkdir .git/sequencer && |
| 879 | test_write_lines "pick invalid-oid" >.git/sequencer/todo && |
| 880 | git status --untracked-files=no >actual 2>err && |
| 881 | git cherry-pick --quit && |
| 882 | test_must_be_empty err && |
| 883 | test_cmp expected actual |
| 884 | ' |
| 885 | |
| 886 | test_expect_success 'status does not show error if .git/sequencer is a file' ' |
| 887 | test_when_finished "rm .git/sequencer" && |
| 888 | test_write_lines hello >.git/sequencer && |
| 889 | git status --untracked-files=no 2>err && |
| 890 | test_must_be_empty err |
| 891 | ' |
| 892 | |
| 893 | test_expect_success 'status showing detached at and from a tag' ' |
| 894 | test_commit atag tagging && |
| 895 | git checkout atag && |
| 896 | cat >expected <<\EOF && |
| 897 | HEAD detached at atag |
| 898 | nothing to commit (use -u to show untracked files) |
| 899 | EOF |
| 900 | git status --untracked-files=no >actual && |
| 901 | test_cmp expected actual && |
| 902 | |
| 903 | git reset --hard HEAD^ && |
| 904 | cat >expected <<\EOF && |
| 905 | HEAD detached from atag |
| 906 | nothing to commit (use -u to show untracked files) |
| 907 | EOF |
| 908 | git status --untracked-files=no >actual && |
| 909 | test_cmp expected actual |
| 910 | ' |
| 911 | |
| 912 | test_expect_success 'status while reverting commit (conflicts)' ' |
| 913 | git checkout main && |
| 914 | echo before >to-revert.txt && |
| 915 | test_commit before to-revert.txt && |
| 916 | echo old >to-revert.txt && |
| 917 | test_commit old to-revert.txt && |
| 918 | echo new >to-revert.txt && |
| 919 | test_commit new to-revert.txt && |
| 920 | TO_REVERT=$(git rev-parse --short HEAD^) && |
| 921 | test_must_fail git revert $TO_REVERT && |
| 922 | cat >expected <<EOF && |
| 923 | On branch main |
| 924 | You are currently reverting commit $TO_REVERT. |
| 925 | (fix conflicts and run "git revert --continue") |
| 926 | (use "git revert --skip" to skip this patch) |
| 927 | (use "git revert --abort" to cancel the revert operation) |
| 928 | |
| 929 | Unmerged paths: |
| 930 | (use "git restore --staged <file>..." to unstage) |
| 931 | (use "git add <file>..." to mark resolution) |
| 932 | both modified: to-revert.txt |
| 933 | |
| 934 | no changes added to commit (use "git add" and/or "git commit -a") |
| 935 | EOF |
| 936 | git status --untracked-files=no >actual && |
| 937 | test_cmp expected actual |
| 938 | ' |
| 939 | |
| 940 | test_expect_success 'status while reverting commit (conflicts resolved)' ' |
| 941 | echo reverted >to-revert.txt && |
| 942 | git add to-revert.txt && |
| 943 | cat >expected <<EOF && |
| 944 | On branch main |
| 945 | You are currently reverting commit $TO_REVERT. |
| 946 | (all conflicts fixed: run "git revert --continue") |
| 947 | (use "git revert --skip" to skip this patch) |
| 948 | (use "git revert --abort" to cancel the revert operation) |
| 949 | |
| 950 | Changes to be committed: |
| 951 | (use "git restore --staged <file>..." to unstage) |
| 952 | modified: to-revert.txt |
| 953 | |
| 954 | Untracked files not listed (use -u option to show untracked files) |
| 955 | EOF |
| 956 | git status --untracked-files=no >actual && |
| 957 | test_cmp expected actual |
| 958 | ' |
| 959 | |
| 960 | test_expect_success 'status after reverting commit' ' |
| 961 | git revert --continue && |
| 962 | cat >expected <<\EOF && |
| 963 | On branch main |
| 964 | nothing to commit (use -u to show untracked files) |
| 965 | EOF |
| 966 | git status --untracked-files=no >actual && |
| 967 | test_cmp expected actual |
| 968 | ' |
| 969 | |
| 970 | test_expect_success 'status while reverting after committing conflict resolution' ' |
| 971 | test_when_finished "git revert --abort" && |
| 972 | git reset --hard new && |
| 973 | test_must_fail git revert old new && |
| 974 | echo reverted >to-revert.txt && |
| 975 | git commit -a && |
| 976 | cat >expected <<EOF && |
| 977 | On branch main |
| 978 | Revert currently in progress. |
| 979 | (run "git revert --continue" to continue) |
| 980 | (use "git revert --skip" to skip this patch) |
| 981 | (use "git revert --abort" to cancel the revert operation) |
| 982 | |
| 983 | nothing to commit (use -u to show untracked files) |
| 984 | EOF |
| 985 | git status --untracked-files=no >actual && |
| 986 | test_cmp expected actual |
| 987 | ' |
| 988 | |
| 989 | test_expect_success 'prepare for different number of commits rebased' ' |
| 990 | git reset --hard main && |
| 991 | git checkout -b several_commits && |
| 992 | test_commit one_commit main.txt one && |
| 993 | test_commit two_commit main.txt two && |
| 994 | test_commit three_commit main.txt three && |
| 995 | test_commit four_commit main.txt four |
| 996 | ' |
| 997 | |
| 998 | test_expect_success 'status: one command done nothing remaining' ' |
| 999 | FAKE_LINES="exec_exit_15" && |
| 1000 | export FAKE_LINES && |
| 1001 | test_when_finished "git rebase --abort" && |
| 1002 | ONTO=$(git rev-parse --short HEAD~3) && |
| 1003 | test_must_fail git rebase -i HEAD~3 && |
| 1004 | cat >expected <<EOF && |
| 1005 | interactive rebase in progress; onto $ONTO |
| 1006 | Last command done (1 command done): |
| 1007 | exec exit 15 |
| 1008 | No commands remaining. |
| 1009 | You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''. |
| 1010 | (use "git commit --amend" to amend the current commit) |
| 1011 | (use "git rebase --continue" once you are satisfied with your changes) |
| 1012 | |
| 1013 | nothing to commit (use -u to show untracked files) |
| 1014 | EOF |
| 1015 | git status --untracked-files=no >actual && |
| 1016 | test_cmp expected actual |
| 1017 | ' |
| 1018 | |
| 1019 | test_expect_success 'status: two commands done with some white lines in done file' ' |
| 1020 | FAKE_LINES="1 > exec_exit_15 2 3" && |
| 1021 | export FAKE_LINES && |
| 1022 | test_when_finished "git rebase --abort" && |
| 1023 | ONTO=$(git rev-parse --short HEAD~3) && |
| 1024 | COMMIT4=$(git rev-parse --short HEAD) && |
| 1025 | COMMIT3=$(git rev-parse --short HEAD^) && |
| 1026 | COMMIT2=$(git rev-parse --short HEAD^^) && |
| 1027 | test_must_fail git rebase -i HEAD~3 && |
| 1028 | cat >expected <<EOF && |
| 1029 | interactive rebase in progress; onto $ONTO |
| 1030 | Last commands done (2 commands done): |
| 1031 | pick $COMMIT2 # two_commit |
| 1032 | exec exit 15 |
| 1033 | Next commands to do (2 remaining commands): |
| 1034 | pick $COMMIT3 # three_commit |
| 1035 | pick $COMMIT4 # four_commit |
| 1036 | (use "git rebase --edit-todo" to view and edit) |
| 1037 | You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''. |
| 1038 | (use "git commit --amend" to amend the current commit) |
| 1039 | (use "git rebase --continue" once you are satisfied with your changes) |
| 1040 | |
| 1041 | nothing to commit (use -u to show untracked files) |
| 1042 | EOF |
| 1043 | git status --untracked-files=no >actual && |
| 1044 | test_cmp expected actual |
| 1045 | ' |
| 1046 | |
| 1047 | test_expect_success 'status: two remaining commands with some white lines in todo file' ' |
| 1048 | FAKE_LINES="1 2 exec_exit_15 3 > 4" && |
| 1049 | export FAKE_LINES && |
| 1050 | test_when_finished "git rebase --abort" && |
| 1051 | ONTO=$(git rev-parse --short HEAD~4) && |
| 1052 | COMMIT4=$(git rev-parse --short HEAD) && |
| 1053 | COMMIT3=$(git rev-parse --short HEAD^) && |
| 1054 | COMMIT2=$(git rev-parse --short HEAD^^) && |
| 1055 | test_must_fail git rebase -i HEAD~4 && |
| 1056 | cat >expected <<EOF && |
| 1057 | interactive rebase in progress; onto $ONTO |
| 1058 | Last commands done (3 commands done): |
| 1059 | pick $COMMIT2 # two_commit |
| 1060 | exec exit 15 |
| 1061 | (see more in file .git/rebase-merge/done) |
| 1062 | Next commands to do (2 remaining commands): |
| 1063 | pick $COMMIT3 # three_commit |
| 1064 | pick $COMMIT4 # four_commit |
| 1065 | (use "git rebase --edit-todo" to view and edit) |
| 1066 | You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''. |
| 1067 | (use "git commit --amend" to amend the current commit) |
| 1068 | (use "git rebase --continue" once you are satisfied with your changes) |
| 1069 | |
| 1070 | nothing to commit (use -u to show untracked files) |
| 1071 | EOF |
| 1072 | git status --untracked-files=no >actual && |
| 1073 | test_cmp expected actual |
| 1074 | ' |
| 1075 | |
| 1076 | test_expect_success 'status: handle not-yet-started rebase -i gracefully' ' |
| 1077 | ONTO=$(git rev-parse --short HEAD^) && |
| 1078 | COMMIT=$(git rev-parse --short HEAD) && |
| 1079 | EDITOR="git status --untracked-files=no >actual" git rebase -i HEAD^ && |
| 1080 | cat >expected <<EOF && |
| 1081 | On branch several_commits |
| 1082 | No commands done. |
| 1083 | Next command to do (1 remaining command): |
| 1084 | pick $COMMIT # four_commit |
| 1085 | (use "git rebase --edit-todo" to view and edit) |
| 1086 | You are currently editing a commit while rebasing branch '\''several_commits'\'' on '\''$ONTO'\''. |
| 1087 | (use "git commit --amend" to amend the current commit) |
| 1088 | (use "git rebase --continue" once you are satisfied with your changes) |
| 1089 | |
| 1090 | nothing to commit (use -u to show untracked files) |
| 1091 | EOF |
| 1092 | test_cmp expected actual |
| 1093 | ' |
| 1094 | |
| 1095 | test_done |