1#!/bin/sh
23
test_description='git-add -u with path limiting
45
This test creates a working tree state with three files:
67
top (previously committed, modified)
8dir/sub (previously committed, modified)
9dir/other (untracked)
1011
and issues a git-add -u with path limiting on "dir" to add
12only the updates to dir/sub.'
1314
. ./test-lib.sh
1516
test_expect_success setup '
17echo initial >check &&
18echo initial >top &&
19mkdir dir1 dir2 &&
20echo initial >dir1/sub1 &&
21echo initial >dir1/sub2 &&
22echo initial >dir2/sub3 &&
23git add check dir1 dir2 top &&
24test_tick
25git-commit -m initial &&
2627
echo changed >check &&
28echo changed >top &&
29echo changed >dir2/sub3 &&
30rm -f dir1/sub1 &&
31echo other >dir2/other
32'
3334
test_expect_success update '
35git add -u dir1 dir2
36'
3738
test_expect_success 'update noticed a removal' '
39test "$(git-ls-files dir1/sub1)" = ""
40'
4142
test_expect_success 'update touched correct path' '
43test "$(git-diff-files --name-status dir2/sub3)" = ""
44'
4546
test_expect_success 'update did not touch other tracked files' '
47test "$(git-diff-files --name-status check)" = "M check" &&
48test "$(git-diff-files --name-status top)" = "M top"
49'
5051
test_expect_success 'update did not touch untracked files' '
52test "$(git-ls-files dir2/other)" = ""
53'
5455
test_expect_success 'cache tree has not been corrupted' '
5657
git ls-files -s |
58sed -e "s/ 0 / /" >expect &&
59git ls-tree -r $(git write-tree) |
60sed -e "s/ blob / /" >current &&
61diff -u expect current
6263
'
6465
test_done