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