blob: ba069dccbdf56197b0e93831fdb1316853d54ef4 [file] [log] [blame]
Jens Lehmannc7e69162014-06-19 22:12:51 +02001#!/bin/sh
2
3test_description='rebase can handle submodules'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-submodule-update.sh
7. "$TEST_DIRECTORY"/lib-rebase.sh
8
9git_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 Liu5b0ac092020-06-24 04:50:18 -040020 may_only_be_test_must_fail "$2" &&
21 $2 git rebase "$1"
Jens Lehmannc7e69162014-06-19 22:12:51 +020022}
23
Denton Liuaa061802020-06-11 13:41:49 -040024test_submodule_switch_func "git_rebase"
Jens Lehmannc7e69162014-06-19 22:12:51 +020025
26git_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ð Bjarmason1d758722022-06-03 13:15:08 +020038 mkdir .git/info &&
Jens Lehmannc7e69162014-06-19 22:12:51 +020039 echo "fake-editor.sh" >.git/info/exclude &&
Denton Liu5b0ac092020-06-24 04:50:18 -040040 may_only_be_test_must_fail "$2" &&
41 $2 git rebase -i "$1"
Jens Lehmannc7e69162014-06-19 22:12:51 +020042}
43
Denton Liuaa061802020-06-11 13:41:49 -040044test_submodule_switch_func "git_rebase_interactive"
Jens Lehmannc7e69162014-06-19 22:12:51 +020045
Brandon Williamsc6d8ccf2017-11-06 14:08:19 -080046test_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 Blauf8d510e2022-07-29 15:20:28 -040051 git -c protocol.file.allow=always \
52 -C super submodule add ../sub &&
Brandon Williamsc6d8ccf2017-11-06 14:08:19 -080053 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 Lehmannc7e69162014-06-19 22:12:51 +020064test_done