Merge branch 'maint'
[git/jnareb-git.git] / t / t3410-rebase-preserve-dropped-merges.sh
blob5816415aafe02f03ede5e1afb6f2e92dedc4b3da
1 #!/bin/sh
3 # Copyright (c) 2008 Stephen Haberman
6 test_description='git rebase preserve merges
8 This test runs git rebase with preserve merges and ensures commits
9 dropped by the --cherry-pick flag have their childrens parents
10 rewritten.
12 . ./test-lib.sh
14 # set up two branches like this:
16 # A - B - C - D - E
17 # \
18 # F - G - H
19 # \
20 # I
22 # where B, D and G touch the same file.
24 test_expect_success 'setup' '
25 : > file1 &&
26 git add file1 &&
27 test_tick &&
28 git commit -m A &&
29 git tag A &&
30 echo 1 > file1 &&
31 test_tick &&
32 git commit -m B file1 &&
33 : > file2 &&
34 git add file2 &&
35 test_tick &&
36 git commit -m C &&
37 echo 2 > file1 &&
38 test_tick &&
39 git commit -m D file1 &&
40 : > file3 &&
41 git add file3 &&
42 test_tick &&
43 git commit -m E &&
44 git tag E &&
45 git checkout -b branch1 A &&
46 : > file4 &&
47 git add file4 &&
48 test_tick &&
49 git commit -m F &&
50 git tag F &&
51 echo 3 > file1 &&
52 test_tick &&
53 git commit -m G file1 &&
54 git tag G &&
55 : > file5 &&
56 git add file5 &&
57 test_tick &&
58 git commit -m H &&
59 git tag H &&
60 git checkout -b branch2 F &&
61 : > file6 &&
62 git add file6 &&
63 test_tick &&
64 git commit -m I &&
65 git tag I
68 # A - B - C - D - E
69 # \ \ \
70 # F - G - H -- L \ --> L
71 # \ | \
72 # I -- G2 -- J -- K I -- K
73 # G2 = same changes as G
74 test_expect_success 'skip same-resolution merges with -p' '
75 git checkout branch1 &&
76 ! git merge E &&
77 echo 23 > file1 &&
78 git add file1 &&
79 git commit -m L &&
80 git checkout branch2 &&
81 echo 3 > file1 &&
82 git commit -a -m G2 &&
83 ! git merge E &&
84 echo 23 > file1 &&
85 git add file1 &&
86 git commit -m J &&
87 echo file7 > file7 &&
88 git add file7 &&
89 git commit -m K &&
90 GIT_EDITOR=: git rebase -i -p branch1 &&
91 test $(git rev-parse branch2^^) = $(git rev-parse branch1) &&
92 test "23" = "$(cat file1)" &&
93 test "" = "$(cat file6)" &&
94 test "file7" = "$(cat file7)" &&
96 git checkout branch1 &&
97 git reset --hard H &&
98 git checkout branch2 &&
99 git reset --hard I
102 # A - B - C - D - E
103 # \ \ \
104 # F - G - H -- L \ --> L
105 # \ | \
106 # I -- G2 -- J -- K I -- G2 -- K
107 # G2 = different changes as G
108 test_expect_success 'keep different-resolution merges with -p' '
109 git checkout branch1 &&
110 ! git merge E &&
111 echo 23 > file1 &&
112 git add file1 &&
113 git commit -m L &&
114 git checkout branch2 &&
115 echo 4 > file1 &&
116 git commit -a -m G2 &&
117 ! git merge E &&
118 echo 24 > file1 &&
119 git add file1 &&
120 git commit -m J &&
121 echo file7 > file7 &&
122 git add file7 &&
123 git commit -m K &&
124 ! GIT_EDITOR=: git rebase -i -p branch1 &&
125 echo 234 > file1 &&
126 git add file1 &&
127 GIT_EDITOR=: git rebase --continue &&
128 test $(git rev-parse branch2^^^) = $(git rev-parse branch1) &&
129 test "234" = "$(cat file1)" &&
130 test "" = "$(cat file6)" &&
131 test "file7" = "$(cat file7)" &&
133 git checkout branch1 &&
134 git reset --hard H &&
135 git checkout branch2 &&
136 git reset --hard I
139 test_done