3 test_description='subtree merge strategy'
7 test_expect_success setup '
10 for i in $s; do echo $i; done >hello &&
12 git commit -m initial &&
13 git checkout -b side &&
16 git commit -m second &&
17 git checkout master &&
18 for i in mundo $s; do echo $i; done >hello &&
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 &&
32 test_expect_success 'setup branch sub' '
33 git checkout --orphan sub &&
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' '
52 test_expect_success 'update branch 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' '
64 echo git-gui > git-gui.sh &&
65 o1=$(git hash-object git-gui.sh) &&
67 git commit -m "initial git-gui" &&
73 o2=$(git hash-object 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"
89 test_cmp expected actual
92 test_expect_success 'merge update' '
94 echo git-gui2 > git-gui.sh &&
95 o3=$(git hash-object git-gui.sh) &&
97 git checkout -b master2 &&
98 git commit -m "update git-gui" &&
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"
106 test_cmp expected actual
109 test_expect_success 'initial ambiguous subtree' '
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"
123 test_cmp expected actual
126 test_expect_success 'merge using explicit' '
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"
136 test_cmp expected actual
139 test_expect_success 'merge2 using explicit' '
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"
149 test_cmp expected actual