blob: 94ea88e384e6219c7d47c6c9fb8409640623680d [file] [log] [blame]
Jens Lehmannc7e69162014-06-19 22:12:51 +02001#!/bin/sh
2
3test_description='rebase can handle submodules'
4
Patrick Steinhardtcc395d62024-05-27 13:46:06 +02005TEST_PASSES_SANITIZE_LEAK=true
Jens Lehmannc7e69162014-06-19 22:12:51 +02006. ./test-lib.sh
7. "$TEST_DIRECTORY"/lib-submodule-update.sh
8. "$TEST_DIRECTORY"/lib-rebase.sh
9
10git_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 Liu5b0ac092020-06-24 04:50:18 -040021 may_only_be_test_must_fail "$2" &&
22 $2 git rebase "$1"
Jens Lehmannc7e69162014-06-19 22:12:51 +020023}
24
Denton Liuaa061802020-06-11 13:41:49 -040025test_submodule_switch_func "git_rebase"
Jens Lehmannc7e69162014-06-19 22:12:51 +020026
27git_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ð Bjarmason1d758722022-06-03 13:15:08 +020039 mkdir .git/info &&
Jens Lehmannc7e69162014-06-19 22:12:51 +020040 echo "fake-editor.sh" >.git/info/exclude &&
Denton Liu5b0ac092020-06-24 04:50:18 -040041 may_only_be_test_must_fail "$2" &&
42 $2 git rebase -i "$1"
Jens Lehmannc7e69162014-06-19 22:12:51 +020043}
44
Denton Liuaa061802020-06-11 13:41:49 -040045test_submodule_switch_func "git_rebase_interactive"
Jens Lehmannc7e69162014-06-19 22:12:51 +020046
Brandon Williamsc6d8ccf2017-11-06 14:08:19 -080047test_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 Blauf8d510e2022-07-29 15:20:28 -040052 git -c protocol.file.allow=always \
53 -C super submodule add ../sub &&
Brandon Williamsc6d8ccf2017-11-06 14:08:19 -080054 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 Lehmannc7e69162014-06-19 22:12:51 +020065test_done