Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='rebase can handle submodules' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | . "$TEST_DIRECTORY"/lib-submodule-update.sh |
| 7 | . "$TEST_DIRECTORY"/lib-rebase.sh |
| 8 | |
| 9 | git_rebase () { |
| 10 | git status -su >expect && |
| 11 | ls -1pR * >>expect && |
| 12 | git checkout -b ours HEAD && |
| 13 | echo x >>file1 && |
| 14 | git add file1 && |
| 15 | git commit -m add_x && |
| 16 | git revert HEAD && |
| 17 | git status -su >actual && |
| 18 | ls -1pR * >>actual && |
| 19 | test_cmp expect actual && |
Denton Liu | 5b0ac09 | 2020-06-24 04:50:18 -0400 | [diff] [blame] | 20 | may_only_be_test_must_fail "$2" && |
| 21 | $2 git rebase "$1" |
Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 22 | } |
| 23 | |
Denton Liu | aa06180 | 2020-06-11 13:41:49 -0400 | [diff] [blame] | 24 | test_submodule_switch_func "git_rebase" |
Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 25 | |
| 26 | git_rebase_interactive () { |
| 27 | git status -su >expect && |
| 28 | ls -1pR * >>expect && |
| 29 | git checkout -b ours HEAD && |
| 30 | echo x >>file1 && |
| 31 | git add file1 && |
| 32 | git commit -m add_x && |
| 33 | git revert HEAD && |
| 34 | git status -su >actual && |
| 35 | ls -1pR * >>actual && |
| 36 | test_cmp expect actual && |
| 37 | set_fake_editor && |
Ævar Arnfjörð Bjarmason | 1d75872 | 2022-06-03 13:15:08 +0200 | [diff] [blame] | 38 | mkdir .git/info && |
Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 39 | echo "fake-editor.sh" >.git/info/exclude && |
Denton Liu | 5b0ac09 | 2020-06-24 04:50:18 -0400 | [diff] [blame] | 40 | may_only_be_test_must_fail "$2" && |
| 41 | $2 git rebase -i "$1" |
Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Denton Liu | aa06180 | 2020-06-11 13:41:49 -0400 | [diff] [blame] | 44 | test_submodule_switch_func "git_rebase_interactive" |
Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 45 | |
Brandon Williams | c6d8ccf | 2017-11-06 14:08:19 -0800 | [diff] [blame] | 46 | test_expect_success 'rebase interactive ignores modified submodules' ' |
| 47 | test_when_finished "rm -rf super sub" && |
| 48 | git init sub && |
| 49 | git -C sub commit --allow-empty -m "Initial commit" && |
| 50 | git init super && |
Taylor Blau | f8d510e | 2022-07-29 15:20:28 -0400 | [diff] [blame] | 51 | git -c protocol.file.allow=always \ |
| 52 | -C super submodule add ../sub && |
Brandon Williams | c6d8ccf | 2017-11-06 14:08:19 -0800 | [diff] [blame] | 53 | git -C super config submodule.sub.ignore dirty && |
| 54 | >super/foo && |
| 55 | git -C super add foo && |
| 56 | git -C super commit -m "Initial commit" && |
| 57 | test_commit -C super a && |
| 58 | test_commit -C super b && |
| 59 | test_commit -C super/sub c && |
| 60 | set_fake_editor && |
| 61 | git -C super rebase -i HEAD^^ |
| 62 | ' |
| 63 | |
Jens Lehmann | c7e6916 | 2014-06-19 22:12:51 +0200 | [diff] [blame] | 64 | test_done |