git-add: make the entry stat-clean after re-adding the same contents
[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 &&
43b98acc 19 echo initial >foo &&
a4882c27
JH
20 mkdir dir1 dir2 &&
21 echo initial >dir1/sub1 &&
22 echo initial >dir1/sub2 &&
23 echo initial >dir2/sub3 &&
43b98acc 24 git add check dir1 dir2 top foo &&
a4882c27
JH
25 test_tick
26 git-commit -m initial &&
27
28 echo changed >check &&
29 echo changed >top &&
30 echo changed >dir2/sub3 &&
31 rm -f dir1/sub1 &&
32 echo other >dir2/other
93c44d49
JK
33'
34
a4882c27
JH
35test_expect_success update '
36 git add -u dir1 dir2
93c44d49 37'
93c44d49 38
a4882c27
JH
39test_expect_success 'update noticed a removal' '
40 test "$(git-ls-files dir1/sub1)" = ""
41'
93c44d49 42
a4882c27
JH
43test_expect_success 'update touched correct path' '
44 test "$(git-diff-files --name-status dir2/sub3)" = ""
45'
93c44d49 46
a4882c27
JH
47test_expect_success 'update did not touch other tracked files' '
48 test "$(git-diff-files --name-status check)" = "M check" &&
49 test "$(git-diff-files --name-status top)" = "M top"
50'
93c44d49 51
a4882c27
JH
52test_expect_success 'update did not touch untracked files' '
53 test "$(git-ls-files dir2/other)" = ""
54'
93c44d49 55
a4882c27 56test_expect_success 'cache tree has not been corrupted' '
93c44d49 57
a4882c27
JH
58 git ls-files -s |
59 sed -e "s/ 0 / /" >expect &&
60 git ls-tree -r $(git write-tree) |
61 sed -e "s/ blob / /" >current &&
62 diff -u expect current
63
64'
93c44d49 65
2ed2c222
SZ
66test_expect_success 'update from a subdirectory' '
67 (
68 cd dir1 &&
69 echo more >sub2 &&
70 git add -u sub2
71 )
72'
73
74test_expect_success 'change gets noticed' '
75
76 test "$(git diff-files --name-status dir1)" = ""
77
78'
93c44d49 79
43b98acc
BS
80test_expect_success 'replace a file with a symlink' '
81
82 rm foo &&
83 ln -s top foo &&
84 git add -u -- foo
85
86'
87
93c44d49 88test_done