Documentation/git-archive.txt: a couple of clarifications.
[git/git.git] / t / t2200-add-update.sh
CommitLineData
93c44d49
JK
1#!/bin/sh
2
5be60078 3test_description='git add -u with path limiting
93c44d49
JK
4
5This test creates a working tree state with three files:
6
7 top (previously committed, modified)
8 dir/sub (previously committed, modified)
9 dir/other (untracked)
10
5be60078 11and issues a git add -u with path limiting on "dir" to add
93c44d49
JK
12only the updates to dir/sub.'
13
14. ./test-lib.sh
15
a4882c27
JH
16test_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 &&
26
27 echo changed >check &&
28 echo changed >top &&
29 echo changed >dir2/sub3 &&
30 rm -f dir1/sub1 &&
31 echo other >dir2/other
93c44d49
JK
32'
33
a4882c27
JH
34test_expect_success update '
35 git add -u dir1 dir2
93c44d49 36'
93c44d49 37
a4882c27
JH
38test_expect_success 'update noticed a removal' '
39 test "$(git-ls-files dir1/sub1)" = ""
40'
93c44d49 41
a4882c27
JH
42test_expect_success 'update touched correct path' '
43 test "$(git-diff-files --name-status dir2/sub3)" = ""
44'
93c44d49 45
a4882c27
JH
46test_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'
93c44d49 50
a4882c27
JH
51test_expect_success 'update did not touch untracked files' '
52 test "$(git-ls-files dir2/other)" = ""
53'
93c44d49 54
a4882c27 55test_expect_success 'cache tree has not been corrupted' '
93c44d49 56
a4882c27
JH
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
62
63'
93c44d49 64
2ed2c222
SZ
65test_expect_success 'update from a subdirectory' '
66 (
67 cd dir1 &&
68 echo more >sub2 &&
69 git add -u sub2
70 )
71'
72
73test_expect_success 'change gets noticed' '
74
75 test "$(git diff-files --name-status dir1)" = ""
76
77'
93c44d49
JK
78
79test_done