3 # Copyright (c) 2008 Johannes Schindelin
6 test_description='Test rebasing and stashing with dirty submodules'
10 test_expect_success setup '
15 git commit -m initial &&
16 git clone . submodule &&
19 git commit -m submodule &&
20 echo second line >> file &&
21 (cd submodule && git pull) &&
23 git commit -m file-and-submodule -a
27 test_expect_success 'rebase with a dirty submodule' '
30 echo 3rd line >> file &&
32 git commit -m fork -a) &&
33 echo unrelated >> file2 &&
36 git commit -m unrelated file2 &&
37 echo other line >> file &&
39 git commit -m update file &&
40 CURRENT=$(cd submodule && git rev-parse HEAD) &&
41 EXPECTED=$(git rev-parse HEAD~2:submodule) &&
42 GIT_TRACE=1 git rebase --onto HEAD~2 HEAD^ &&
43 STORED=$(git rev-parse HEAD:submodule) &&
44 test $EXPECTED = $STORED &&
45 test $CURRENT = $(cd submodule && git rev-parse HEAD)
49 cat > fake-editor.sh << \EOF
53 chmod a+x fake-editor.sh
55 test_expect_success 'interactive rebase with a dirty submodule' '
57 test submodule = $(git diff --name-only) &&
58 HEAD=$(git rev-parse HEAD) &&
59 GIT_EDITOR="\"$(pwd)/fake-editor.sh\"" EDITOR_TEXT="pick $HEAD" \
60 git rebase -i HEAD^ &&
61 test submodule = $(git diff --name-only)
65 test_expect_success 'rebase with dirty file and submodule fails' '
67 echo yet another line >> file &&
69 git commit -m next file &&
70 echo rewrite > file &&
72 git commit -m rewrite file &&
74 test_must_fail git rebase --onto HEAD~2 HEAD^
78 test_expect_success 'stash with a dirty submodule' '
81 CURRENT=$(cd submodule && git rev-parse HEAD) &&
83 test new != $(cat file) &&
84 test submodule = $(git diff --name-only) &&
85 test $CURRENT = $(cd submodule && git rev-parse HEAD) &&
87 test new = $(cat file) &&
88 test $CURRENT = $(cd submodule && git rev-parse HEAD)