]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2200-add-update.sh
send-pack: do not send unknown object name from ".have" to pack-objects
[thirdparty/git.git] / t / t2200-add-update.sh
CommitLineData
93c44d49
JK
1#!/bin/sh
2
25487bde 3test_description='git add -u
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
25487bde
JH
12only the updates to dir/sub.
13
14Also tested are "git add -u" without limiting, and "git add -u"
15without contents changes.'
93c44d49
JK
16
17. ./test-lib.sh
18
a4882c27
JH
19test_expect_success setup '
20 echo initial >check &&
21 echo initial >top &&
43b98acc 22 echo initial >foo &&
a4882c27
JH
23 mkdir dir1 dir2 &&
24 echo initial >dir1/sub1 &&
25 echo initial >dir1/sub2 &&
26 echo initial >dir2/sub3 &&
43b98acc 27 git add check dir1 dir2 top foo &&
a4882c27 28 test_tick
0cb0e143 29 git commit -m initial &&
a4882c27
JH
30
31 echo changed >check &&
32 echo changed >top &&
33 echo changed >dir2/sub3 &&
34 rm -f dir1/sub1 &&
35 echo other >dir2/other
93c44d49
JK
36'
37
a4882c27
JH
38test_expect_success update '
39 git add -u dir1 dir2
93c44d49 40'
93c44d49 41
a4882c27 42test_expect_success 'update noticed a removal' '
0cb0e143 43 test "$(git ls-files dir1/sub1)" = ""
a4882c27 44'
93c44d49 45
a4882c27 46test_expect_success 'update touched correct path' '
0cb0e143 47 test "$(git diff-files --name-status dir2/sub3)" = ""
a4882c27 48'
93c44d49 49
a4882c27 50test_expect_success 'update did not touch other tracked files' '
0cb0e143
NS
51 test "$(git diff-files --name-status check)" = "M check" &&
52 test "$(git diff-files --name-status top)" = "M top"
a4882c27 53'
93c44d49 54
a4882c27 55test_expect_success 'update did not touch untracked files' '
0cb0e143 56 test "$(git ls-files dir2/other)" = ""
a4882c27 57'
93c44d49 58
a4882c27 59test_expect_success 'cache tree has not been corrupted' '
93c44d49 60
a4882c27
JH
61 git ls-files -s |
62 sed -e "s/ 0 / /" >expect &&
63 git ls-tree -r $(git write-tree) |
64 sed -e "s/ blob / /" >current &&
82ebb0b6 65 test_cmp expect current
a4882c27
JH
66
67'
93c44d49 68
2ed2c222
SZ
69test_expect_success 'update from a subdirectory' '
70 (
71 cd dir1 &&
72 echo more >sub2 &&
73 git add -u sub2
74 )
75'
76
77test_expect_success 'change gets noticed' '
78
79 test "$(git diff-files --name-status dir1)" = ""
80
81'
93c44d49 82
43b98acc
BS
83test_expect_success 'replace a file with a symlink' '
84
85 rm foo &&
86 ln -s top foo &&
87 git add -u -- foo
88
89'
90
25487bde
JH
91test_expect_success 'add everything changed' '
92
93 git add -u &&
94 test -z "$(git diff-files)"
95
96'
97
98test_expect_success 'touch and then add -u' '
99
100 touch check &&
101 git add -u &&
102 test -z "$(git diff-files)"
103
104'
105
106test_expect_success 'touch and then add explicitly' '
107
108 touch check &&
109 git add check &&
110 test -z "$(git diff-files)"
111
112'
113
38ed1d89
JH
114test_expect_success 'add -n -u should not add but just report' '
115
116 (
117 echo "add '\''check'\''" &&
118 echo "remove '\''top'\''"
119 ) >expect &&
120 before=$(git ls-files -s check top) &&
121 echo changed >>check &&
122 rm -f top &&
123 git add -n -u >actual &&
124 after=$(git ls-files -s check top) &&
125
126 test "$before" = "$after" &&
127 test_cmp expect actual
128
129'
130
93c44d49 131test_done