1 #!/bin/sh
3 test_description='git add -u with path limiting
5 This test creates a working tree state with three files:
7 top (previously committed, modified)
8 dir/sub (previously committed, modified)
9 dir/other (untracked)
11 and issues a git add -u with path limiting on "dir" to add
12 only the updates to dir/sub.'
14 . ./test-lib.sh
16 test_expect_success setup '
17 echo initial >check &&
18 echo initial >top &&
19 mkdir dir1 dir2 &&
20 echo initial >dir1/sub1 &&
21 echo initial >dir1/sub2 &&
22 echo initial >dir2/sub3 &&
23 git add check dir1 dir2 top &&
24 test_tick
25 git-commit -m initial &&
27 echo changed >check &&
28 echo changed >top &&
29 echo changed >dir2/sub3 &&
30 rm -f dir1/sub1 &&
31 echo other >dir2/other
32 '
34 test_expect_success update '
35 git add -u dir1 dir2
36 '
38 test_expect_success 'update noticed a removal' '
39 test "$(git-ls-files dir1/sub1)" = ""
40 '
42 test_expect_success 'update touched correct path' '
43 test "$(git-diff-files --name-status dir2/sub3)" = ""
44 '
46 test_expect_success 'update did not touch other tracked files' '
47 test "$(git-diff-files --name-status check)" = "M check" &&
48 test "$(git-diff-files --name-status top)" = "M top"
49 '
51 test_expect_success 'update did not touch untracked files' '
52 test "$(git-ls-files dir2/other)" = ""
53 '
55 test_expect_success 'cache tree has not been corrupted' '
57 git ls-files -s |
58 sed -e "s/ 0 / /" >expect &&
59 git ls-tree -r $(git write-tree) |
60 sed -e "s/ blob / /" >current &&
61 diff -u expect current
63 '
65 test_expect_success 'update from a subdirectory' '
66 (
67 cd dir1 &&
68 echo more >sub2 &&
69 git add -u sub2
70 )
71 '
73 test_expect_success 'change gets noticed' '
75 test "$(git diff-files --name-status dir1)" = ""
77 '
79 test_done