Commit | Line | Data |
---|---|---|
1736855c JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='subtree merge strategy' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success setup ' | |
8 | ||
a48fcd83 | 9 | s="1 2 3 4 5 6 7 8" && |
1736855c JH |
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 | |
21 | ||
22 | ' | |
23 | ||
24 | test_expect_success 'subtree available and works like recursive' ' | |
25 | ||
26 | git merge -s subtree side && | |
27 | for i in mundo $s world; do echo $i; done >expect && | |
82ebb0b6 | 28 | test_cmp expect hello |
1736855c JH |
29 | |
30 | ' | |
31 | ||
419e3833 MV |
32 | test_expect_success 'setup' ' |
33 | mkdir git-gui && | |
34 | cd git-gui && | |
35 | git init && | |
36 | echo git-gui > git-gui.sh && | |
37 | o1=$(git hash-object git-gui.sh) && | |
38 | git add git-gui.sh && | |
39 | git commit -m "initial git-gui" && | |
40 | cd .. && | |
41 | mkdir git && | |
42 | cd git && | |
43 | git init && | |
44 | echo git >git.c && | |
45 | o2=$(git hash-object git.c) && | |
46 | git add git.c && | |
47 | git commit -m "initial git" | |
48 | ' | |
49 | ||
50 | test_expect_success 'initial merge' ' | |
51 | git remote add -f gui ../git-gui && | |
52 | git merge -s ours --no-commit gui/master && | |
53 | git read-tree --prefix=git-gui/ -u gui/master && | |
54 | git commit -m "Merge git-gui as our subdirectory" && | |
e3cba962 | 55 | git checkout -b work && |
419e3833 MV |
56 | git ls-files -s >actual && |
57 | ( | |
58 | echo "100644 $o1 0 git-gui/git-gui.sh" | |
59 | echo "100644 $o2 0 git.c" | |
60 | ) >expected && | |
3af82863 | 61 | test_cmp expected actual |
419e3833 MV |
62 | ' |
63 | ||
64 | test_expect_success 'merge update' ' | |
65 | cd ../git-gui && | |
66 | echo git-gui2 > git-gui.sh && | |
67 | o3=$(git hash-object git-gui.sh) && | |
68 | git add git-gui.sh && | |
e3cba962 | 69 | git checkout -b master2 && |
419e3833 MV |
70 | git commit -m "update git-gui" && |
71 | cd ../git && | |
e3cba962 | 72 | git pull -s subtree gui master2 && |
419e3833 MV |
73 | git ls-files -s >actual && |
74 | ( | |
75 | echo "100644 $o3 0 git-gui/git-gui.sh" | |
76 | echo "100644 $o2 0 git.c" | |
77 | ) >expected && | |
3af82863 | 78 | test_cmp expected actual |
419e3833 MV |
79 | ' |
80 | ||
e3cba962 AP |
81 | test_expect_success 'initial ambiguous subtree' ' |
82 | cd ../git && | |
83 | git reset --hard master && | |
84 | git checkout -b master2 && | |
85 | git merge -s ours --no-commit gui/master && | |
86 | git read-tree --prefix=git-gui2/ -u gui/master && | |
87 | git commit -m "Merge git-gui2 as our subdirectory" && | |
88 | git checkout -b work2 && | |
89 | git ls-files -s >actual && | |
90 | ( | |
91 | echo "100644 $o1 0 git-gui/git-gui.sh" | |
92 | echo "100644 $o1 0 git-gui2/git-gui.sh" | |
93 | echo "100644 $o2 0 git.c" | |
94 | ) >expected && | |
95 | test_cmp expected actual | |
96 | ' | |
97 | ||
98 | test_expect_success 'merge using explicit' ' | |
99 | cd ../git && | |
100 | git reset --hard master2 && | |
101 | git pull -Xsubtree=git-gui gui master2 && | |
102 | git ls-files -s >actual && | |
103 | ( | |
104 | echo "100644 $o3 0 git-gui/git-gui.sh" | |
105 | echo "100644 $o1 0 git-gui2/git-gui.sh" | |
106 | echo "100644 $o2 0 git.c" | |
107 | ) >expected && | |
108 | test_cmp expected actual | |
109 | ' | |
110 | ||
111 | test_expect_success 'merge2 using explicit' ' | |
112 | cd ../git && | |
113 | git reset --hard master2 && | |
114 | git pull -Xsubtree=git-gui2 gui master2 && | |
115 | git ls-files -s >actual && | |
116 | ( | |
117 | echo "100644 $o1 0 git-gui/git-gui.sh" | |
118 | echo "100644 $o3 0 git-gui2/git-gui.sh" | |
119 | echo "100644 $o2 0 git.c" | |
120 | ) >expected && | |
121 | test_cmp expected actual | |
122 | ' | |
123 | ||
1736855c | 124 | test_done |