Merge branch 'dl/test-must-fail-fixes-3'
[git.git] / t / t6029-merge-subtree.sh
blob793f0c8bf38aba350542c0710f509a1c69b33a9b
1 #!/bin/sh
3 test_description='subtree merge strategy'
5 . ./test-lib.sh
7 test_expect_success setup '
9 s="1 2 3 4 5 6 7 8" &&
10 for i in $s; do echo $i; done >hello &&
11 git add hello &&
12 git commit -m initial &&
13 git checkout -b side &&
14 echo >>hello world &&
15 git add hello &&
16 git commit -m second &&
17 git checkout master &&
18 for i in mundo $s; do echo $i; done >hello &&
19 git add hello &&
20 git commit -m master
24 test_expect_success 'subtree available and works like recursive' '
26 git merge -s subtree side &&
27 for i in mundo $s world; do echo $i; done >expect &&
28 test_cmp expect hello
32 test_expect_success 'setup branch sub' '
33 git checkout --orphan sub &&
34 git rm -rf . &&
35 test_commit foo
38 test_expect_success 'setup branch main' '
39 git checkout -b main master &&
40 git merge -s ours --no-commit --allow-unrelated-histories sub &&
41 git read-tree --prefix=dir/ -u sub &&
42 git commit -m "initial merge of sub into main" &&
43 test_path_is_file dir/foo.t &&
44 test_path_is_file hello
47 test_expect_success 'update branch sub' '
48 git checkout sub &&
49 test_commit bar
52 test_expect_success 'update branch main' '
53 git checkout main &&
54 git merge -s subtree sub -m "second merge of sub into main" &&
55 test_path_is_file dir/bar.t &&
56 test_path_is_file dir/foo.t &&
57 test_path_is_file hello
60 test_expect_success 'setup' '
61 mkdir git-gui &&
62 cd git-gui &&
63 git init &&
64 echo git-gui > git-gui.sh &&
65 o1=$(git hash-object git-gui.sh) &&
66 git add git-gui.sh &&
67 git commit -m "initial git-gui" &&
68 cd .. &&
69 mkdir git &&
70 cd git &&
71 git init &&
72 echo git >git.c &&
73 o2=$(git hash-object git.c) &&
74 git add git.c &&
75 git commit -m "initial git"
78 test_expect_success 'initial merge' '
79 git remote add -f gui ../git-gui &&
80 git merge -s ours --no-commit --allow-unrelated-histories gui/master &&
81 git read-tree --prefix=git-gui/ -u gui/master &&
82 git commit -m "Merge git-gui as our subdirectory" &&
83 git checkout -b work &&
84 git ls-files -s >actual &&
86 echo "100644 $o1 0 git-gui/git-gui.sh" &&
87 echo "100644 $o2 0 git.c"
88 ) >expected &&
89 test_cmp expected actual
92 test_expect_success 'merge update' '
93 cd ../git-gui &&
94 echo git-gui2 > git-gui.sh &&
95 o3=$(git hash-object git-gui.sh) &&
96 git add git-gui.sh &&
97 git checkout -b master2 &&
98 git commit -m "update git-gui" &&
99 cd ../git &&
100 git pull -s subtree gui master2 &&
101 git ls-files -s >actual &&
103 echo "100644 $o3 0 git-gui/git-gui.sh" &&
104 echo "100644 $o2 0 git.c"
105 ) >expected &&
106 test_cmp expected actual
109 test_expect_success 'initial ambiguous subtree' '
110 cd ../git &&
111 git reset --hard master &&
112 git checkout -b master2 &&
113 git merge -s ours --no-commit gui/master &&
114 git read-tree --prefix=git-gui2/ -u gui/master &&
115 git commit -m "Merge git-gui2 as our subdirectory" &&
116 git checkout -b work2 &&
117 git ls-files -s >actual &&
119 echo "100644 $o1 0 git-gui/git-gui.sh" &&
120 echo "100644 $o1 0 git-gui2/git-gui.sh" &&
121 echo "100644 $o2 0 git.c"
122 ) >expected &&
123 test_cmp expected actual
126 test_expect_success 'merge using explicit' '
127 cd ../git &&
128 git reset --hard master2 &&
129 git pull -Xsubtree=git-gui gui master2 &&
130 git ls-files -s >actual &&
132 echo "100644 $o3 0 git-gui/git-gui.sh" &&
133 echo "100644 $o1 0 git-gui2/git-gui.sh" &&
134 echo "100644 $o2 0 git.c"
135 ) >expected &&
136 test_cmp expected actual
139 test_expect_success 'merge2 using explicit' '
140 cd ../git &&
141 git reset --hard master2 &&
142 git pull -Xsubtree=git-gui2 gui master2 &&
143 git ls-files -s >actual &&
145 echo "100644 $o1 0 git-gui/git-gui.sh" &&
146 echo "100644 $o3 0 git-gui2/git-gui.sh" &&
147 echo "100644 $o2 0 git.c"
148 ) >expected &&
149 test_cmp expected actual
152 test_done