| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Yann Dirson |
| 4 | # |
| 5 | |
| 6 | test_description='Test the "rebase" command.' |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | test_expect_success \ |
| 11 | 'Setup a multi-commit branch and fork an stgit stack' \ |
| 12 | ' |
| 13 | echo foo > file1 && |
| 14 | git add file1 && |
| 15 | git commit -m a && |
| 16 | echo foo > file2 && |
| 17 | git add file2 && |
| 18 | git commit -m b && |
| 19 | |
| 20 | stg branch --create stack && |
| 21 | stg new p -m . && |
| 22 | echo bar >> file1 && |
| 23 | stg refresh |
| 24 | ' |
| 25 | |
| 26 | test_expect_success \ |
| 27 | 'Rebase to previous commit' \ |
| 28 | ' |
| 29 | stg rebase master~1 && |
| 30 | test `stg id stack:{base}` = `git rev-parse master~1` && |
| 31 | test `stg series --applied -c` = 1 |
| 32 | ' |
| 33 | |
| 34 | test_expect_success \ |
| 35 | 'Attempt rebase to non-existing commit' \ |
| 36 | ' |
| 37 | command_error stg rebase not-a-ref |
| 38 | ' |
| 39 | |
| 40 | test_expect_success \ |
| 41 | 'Check patches were re-applied' \ |
| 42 | ' |
| 43 | test $(stg series --applied -c) = 1 |
| 44 | ' |
| 45 | |
| 46 | test_done |