Revert "MinGW: Add missing file mode bit defines"
[git/mingw/4msysgit/gitPS1fix.git] / t / t7402-submodule-rebase.sh
blobf919c8d34de41b2ec3fe08c217dd2c6276cf8472
1 #!/bin/sh
3 # Copyright (c) 2008 Johannes Schindelin
6 test_description='Test rebasing and stashing with dirty submodules'
8 . ./test-lib.sh
10 test_expect_success setup '
12 echo file > file &&
13 git add file &&
14 test_tick &&
15 git commit -m initial &&
16 git clone . submodule &&
17 git add submodule &&
18 test_tick &&
19 git commit -m submodule &&
20 echo second line >> file &&
21 (cd submodule && git pull) &&
22 test_tick &&
23 git commit -m file-and-submodule -a
27 test_expect_success 'rebase with a dirty submodule' '
29 (cd submodule &&
30 echo 3rd line >> file &&
31 test_tick &&
32 git commit -m fork -a) &&
33 echo unrelated >> file2 &&
34 git add file2 &&
35 test_tick &&
36 git commit -m unrelated file2 &&
37 echo other line >> file &&
38 test_tick &&
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
50 #!/bin/sh
51 echo $EDITOR_TEXT
52 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 &&
68 test_tick &&
69 git commit -m next file &&
70 echo rewrite > file &&
71 test_tick &&
72 git commit -m rewrite file &&
73 echo dirty > file &&
74 test_must_fail git rebase --onto HEAD~2 HEAD^
78 test_expect_success 'stash with a dirty submodule' '
80 echo new > file &&
81 CURRENT=$(cd submodule && git rev-parse HEAD) &&
82 git stash &&
83 test new != $(cat file) &&
84 test submodule = $(git diff --name-only) &&
85 test $CURRENT = $(cd submodule && git rev-parse HEAD) &&
86 git stash apply &&
87 test new = $(cat file) &&
88 test $CURRENT = $(cd submodule && git rev-parse HEAD)
92 test_done