]>
Commit | Line | Data |
---|---|---|
2b459b48 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='difference in submodules' | |
4 | ||
5 | . ./test-lib.sh | |
bfdbee98 | 6 | . "$TEST_DIRECTORY"/diff-lib.sh |
2b459b48 JH |
7 | |
8 | _z40=0000000000000000000000000000000000000000 | |
9 | test_expect_success setup ' | |
10 | test_tick && | |
11 | test_create_repo sub && | |
12 | ( | |
13 | cd sub && | |
14 | echo hello >world && | |
15 | git add world && | |
16 | git commit -m submodule | |
17 | ) && | |
18 | ||
19 | test_tick && | |
20 | echo frotz >nitfol && | |
21 | git add nitfol sub && | |
22 | git commit -m superproject && | |
23 | ||
24 | ( | |
25 | cd sub && | |
26 | echo goodbye >world && | |
27 | git add world && | |
28 | git commit -m "submodule #2" | |
29 | ) && | |
30 | ||
31 | set x $( | |
32 | cd sub && | |
33 | git rev-list HEAD | |
34 | ) && | |
8e08b419 JH |
35 | echo ":160000 160000 $3 $_z40 M sub" >expect && |
36 | subtip=$3 subprev=$2 | |
2b459b48 JH |
37 | ' |
38 | ||
39 | test_expect_success 'git diff --raw HEAD' ' | |
40 | git diff --raw --abbrev=40 HEAD >actual && | |
82ebb0b6 | 41 | test_cmp expect actual |
2b459b48 JH |
42 | ' |
43 | ||
44 | test_expect_success 'git diff-index --raw HEAD' ' | |
45 | git diff-index --raw HEAD >actual.index && | |
82ebb0b6 | 46 | test_cmp expect actual.index |
2b459b48 JH |
47 | ' |
48 | ||
49 | test_expect_success 'git diff-files --raw' ' | |
50 | git diff-files --raw >actual.files && | |
82ebb0b6 | 51 | test_cmp expect actual.files |
2b459b48 JH |
52 | ' |
53 | ||
8e08b419 JH |
54 | expect_from_to () { |
55 | printf "%sSubproject commit %s\n+Subproject commit %s\n" \ | |
56 | "-" "$1" "$2" | |
57 | } | |
58 | ||
59 | test_expect_success 'git diff HEAD' ' | |
60 | git diff HEAD >actual && | |
61 | sed -e "1,/^@@/d" actual >actual.body && | |
62 | expect_from_to >expect.body $subtip $subprev && | |
63 | test_cmp expect.body actual.body | |
64 | ' | |
65 | ||
66 | test_expect_success 'git diff HEAD with dirty submodule (work tree)' ' | |
67 | echo >>sub/world && | |
68 | git diff HEAD >actual && | |
69 | sed -e "1,/^@@/d" actual >actual.body && | |
70 | expect_from_to >expect.body $subtip $subprev-dirty && | |
71 | test_cmp expect.body actual.body | |
72 | ' | |
73 | ||
74 | test_expect_success 'git diff HEAD with dirty submodule (index)' ' | |
75 | ( | |
76 | cd sub && | |
77 | git reset --hard && | |
78 | echo >>world && | |
79 | git add world | |
80 | ) && | |
81 | git diff HEAD >actual && | |
82 | sed -e "1,/^@@/d" actual >actual.body && | |
83 | expect_from_to >expect.body $subtip $subprev-dirty && | |
84 | test_cmp expect.body actual.body | |
85 | ' | |
86 | ||
87 | test_expect_success 'git diff HEAD with dirty submodule (untracked)' ' | |
88 | ( | |
89 | cd sub && | |
90 | git reset --hard && | |
91 | git clean -qfdx && | |
92 | >cruft | |
93 | ) && | |
94 | git diff HEAD >actual && | |
95 | sed -e "1,/^@@/d" actual >actual.body && | |
96 | expect_from_to >expect.body $subtip $subprev-dirty && | |
97 | test_cmp expect.body actual.body | |
98 | ' | |
99 | ||
100 | test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)' ' | |
101 | git commit -m "x" sub && | |
102 | echo >>sub/world && | |
103 | git diff HEAD >actual && | |
104 | sed -e "1,/^@@/d" actual >actual.body && | |
105 | expect_from_to >expect.body $subprev $subprev-dirty && | |
106 | test_cmp expect.body actual.body | |
107 | ' | |
108 | ||
109 | test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' ' | |
110 | ( | |
111 | cd sub && | |
112 | git reset --hard && | |
113 | echo >>world && | |
114 | git add world | |
115 | ) && | |
116 | git diff HEAD >actual && | |
117 | sed -e "1,/^@@/d" actual >actual.body && | |
118 | expect_from_to >expect.body $subprev $subprev-dirty && | |
119 | test_cmp expect.body actual.body | |
120 | ' | |
121 | ||
122 | test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)' ' | |
123 | ( | |
124 | cd sub && | |
125 | git reset --hard && | |
126 | git clean -qfdx && | |
127 | >cruft | |
128 | ) && | |
129 | git diff HEAD >actual && | |
130 | sed -e "1,/^@@/d" actual >actual.body && | |
131 | expect_from_to >expect.body $subprev $subprev-dirty && | |
132 | test_cmp expect.body actual.body | |
133 | ' | |
134 | ||
1392a377 | 135 | test_expect_success 'git diff (empty submodule dir)' ' |
7c08a2a6 PY |
136 | : >empty && |
137 | rm -rf sub/* sub/.git && | |
138 | git diff > actual.empty && | |
139 | test_cmp empty actual.empty | |
140 | ' | |
141 | ||
7dae8b21 JH |
142 | test_expect_success 'conflicted submodule setup' ' |
143 | ||
144 | # 39 efs | |
145 | c=fffffffffffffffffffffffffffffffffffffff | |
146 | ( | |
147 | echo "000000 $_z40 0 sub" | |
148 | echo "160000 1$c 1 sub" | |
149 | echo "160000 2$c 2 sub" | |
150 | echo "160000 3$c 3 sub" | |
151 | ) | git update-index --index-info && | |
152 | echo >expect.nosub '\''diff --cc sub | |
153 | index 2ffffff,3ffffff..0000000 | |
154 | --- a/sub | |
155 | +++ b/sub | |
156 | @@@ -1,1 -1,1 +1,1 @@@ | |
157 | - Subproject commit 2fffffffffffffffffffffffffffffffffffffff | |
158 | -Subproject commit 3fffffffffffffffffffffffffffffffffffffff | |
159 | ++Subproject commit 0000000000000000000000000000000000000000'\'' && | |
160 | ||
161 | hh=$(git rev-parse HEAD) && | |
162 | sed -e "s/$_z40/$hh/" expect.nosub >expect.withsub | |
163 | ||
164 | ' | |
165 | ||
166 | test_expect_success 'combined (empty submodule)' ' | |
167 | rm -fr sub && mkdir sub && | |
168 | git diff >actual && | |
169 | test_cmp expect.nosub actual | |
170 | ' | |
171 | ||
172 | test_expect_success 'combined (with submodule)' ' | |
173 | rm -fr sub && | |
174 | git clone --no-checkout . sub && | |
175 | git diff >actual && | |
176 | test_cmp expect.withsub actual | |
177 | ' | |
178 | ||
179 | ||
180 | ||
2b459b48 | 181 | test_done |