@@ -12,7 +12,7 @@ and issues a git add -u with path limiting on "dir" to add
1212only the updates to dir/sub.
1313
1414Also tested are "git add -u" without limiting, and "git add -u"
15- without contents changes. '
15+ without contents changes, and other conditions '
1616
1717. ./test-lib.sh
1818
@@ -128,4 +128,52 @@ test_expect_success 'add -n -u should not add but just report' '
128128
129129'
130130
131+ test_expect_success ' add -u resolves unmerged paths' '
132+ git reset --hard &&
133+ one=$(echo 1 | git hash-object -w --stdin) &&
134+ two=$(echo 2 | git hash-object -w --stdin) &&
135+ three=$(echo 3 | git hash-object -w --stdin) &&
136+ {
137+ for path in path1 path2
138+ do
139+ echo "100644 $one 1 $path"
140+ echo "100644 $two 2 $path"
141+ echo "100644 $three 3 $path"
142+ done
143+ echo "100644 $one 1 path3"
144+ echo "100644 $one 1 path4"
145+ echo "100644 $one 3 path5"
146+ echo "100644 $one 3 path6"
147+ } |
148+ git update-index --index-info &&
149+ echo 3 >path1 &&
150+ echo 2 >path3 &&
151+ echo 2 >path5 &&
152+ git add -u &&
153+ git ls-files -s "path?" >actual &&
154+ {
155+ echo "100644 $three 0 path1"
156+ echo "100644 $one 1 path3"
157+ echo "100644 $one 1 path4"
158+ echo "100644 $one 3 path5"
159+ echo "100644 $one 3 path6"
160+ } >expect &&
161+ test_cmp expect actual &&
162+
163+ # Bonus tests. Explicit resolving
164+ git add path3 path5 &&
165+ test_must_fail git add path4 &&
166+ test_must_fail git add path6 &&
167+ git rm path4 &&
168+ git rm path6 &&
169+
170+ git ls-files -s "path?" >actual &&
171+ {
172+ echo "100644 $three 0 path1"
173+ echo "100644 $two 0 path3"
174+ echo "100644 $two 0 path5"
175+ } >expect
176+
177+ '
178+
131179test_done
0 commit comments