]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7402-submodule-rebase.sh
l10n: fr v2.23.0 round 2
[thirdparty/git.git] / t / t7402-submodule-rebase.sh
CommitLineData
6848d58c
JS
1#!/bin/sh
2#
3# Copyright (c) 2008 Johannes Schindelin
4#
5
4ae6d469 6test_description='Test rebasing, stashing, etc. with submodules'
6848d58c
JS
7
8. ./test-lib.sh
9
10test_expect_success setup '
11
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 &&
4ae6d469
JH
23 git commit -m file-and-submodule -a &&
24 git branch added-submodule
6848d58c
JS
25
26'
27
28test_expect_success 'rebase with a dirty submodule' '
29
30 (cd submodule &&
31 echo 3rd line >> file &&
32 test_tick &&
33 git commit -m fork -a) &&
34 echo unrelated >> file2 &&
35 git add file2 &&
36 test_tick &&
37 git commit -m unrelated file2 &&
38 echo other line >> file &&
39 test_tick &&
40 git commit -m update file &&
41 CURRENT=$(cd submodule && git rev-parse HEAD) &&
42 EXPECTED=$(git rev-parse HEAD~2:submodule) &&
43 GIT_TRACE=1 git rebase --onto HEAD~2 HEAD^ &&
44 STORED=$(git rev-parse HEAD:submodule) &&
45 test $EXPECTED = $STORED &&
46 test $CURRENT = $(cd submodule && git rev-parse HEAD)
47
48'
49
50cat > fake-editor.sh << \EOF
51#!/bin/sh
52echo $EDITOR_TEXT
53EOF
54chmod a+x fake-editor.sh
55
56test_expect_success 'interactive rebase with a dirty submodule' '
57
58 test submodule = $(git diff --name-only) &&
59 HEAD=$(git rev-parse HEAD) &&
60 GIT_EDITOR="\"$(pwd)/fake-editor.sh\"" EDITOR_TEXT="pick $HEAD" \
61 git rebase -i HEAD^ &&
62 test submodule = $(git diff --name-only)
63
64'
65
66test_expect_success 'rebase with dirty file and submodule fails' '
67
68 echo yet another line >> file &&
69 test_tick &&
70 git commit -m next file &&
71 echo rewrite > file &&
72 test_tick &&
73 git commit -m rewrite file &&
74 echo dirty > file &&
d492b31c 75 test_must_fail git rebase --onto HEAD~2 HEAD^
6848d58c
JS
76
77'
78
79test_expect_success 'stash with a dirty submodule' '
80
81 echo new > file &&
82 CURRENT=$(cd submodule && git rev-parse HEAD) &&
83 git stash &&
84 test new != $(cat file) &&
85 test submodule = $(git diff --name-only) &&
86 test $CURRENT = $(cd submodule && git rev-parse HEAD) &&
87 git stash apply &&
88 test new = $(cat file) &&
89 test $CURRENT = $(cd submodule && git rev-parse HEAD)
90
91'
92
4ae6d469
JH
93test_expect_success 'rebasing submodule that should conflict' '
94 git reset --hard &&
95 git checkout added-submodule &&
96 git add submodule &&
97 test_tick &&
98 git commit -m third &&
99 (
100 cd submodule &&
101 git commit --allow-empty -m extra
102 ) &&
103 git add submodule &&
104 test_tick &&
105 git commit -m fourth &&
106
107 test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 &&
108 git ls-files -s submodule >actual &&
109 (
110 cd submodule &&
111 echo "160000 $(git rev-parse HEAD^) 1 submodule" &&
112 echo "160000 $(git rev-parse HEAD^^) 2 submodule" &&
113 echo "160000 $(git rev-parse HEAD) 3 submodule"
114 ) >expect &&
115 test_cmp expect actual
116'
117
6848d58c 118test_done