make git-status use a pager
[git.git] / t / t2200-add-update.sh
blobb664341926071a3286ba949dc09b5e62b280e79a
1 #!/bin/sh
3 test_description='git add -u
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 Also tested are "git add -u" without limiting, and "git add -u"
15 without contents changes.'
17 . ./test-lib.sh
19 test_expect_success setup '
20 echo initial >check &&
21 echo initial >top &&
22 echo initial >foo &&
23 mkdir dir1 dir2 &&
24 echo initial >dir1/sub1 &&
25 echo initial >dir1/sub2 &&
26 echo initial >dir2/sub3 &&
27 git add check dir1 dir2 top foo &&
28 test_tick
29 git-commit -m initial &&
31 echo changed >check &&
32 echo changed >top &&
33 echo changed >dir2/sub3 &&
34 rm -f dir1/sub1 &&
35 echo other >dir2/other
38 test_expect_success update '
39 git add -u dir1 dir2
42 test_expect_success 'update noticed a removal' '
43 test "$(git-ls-files dir1/sub1)" = ""
46 test_expect_success 'update touched correct path' '
47 test "$(git-diff-files --name-status dir2/sub3)" = ""
50 test_expect_success 'update did not touch other tracked files' '
51 test "$(git-diff-files --name-status check)" = "M check" &&
52 test "$(git-diff-files --name-status top)" = "M top"
55 test_expect_success 'update did not touch untracked files' '
56 test "$(git-ls-files dir2/other)" = ""
59 test_expect_success 'cache tree has not been corrupted' '
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 &&
65 test_cmp expect current
69 test_expect_success 'update from a subdirectory' '
71 cd dir1 &&
72 echo more >sub2 &&
73 git add -u sub2
77 test_expect_success 'change gets noticed' '
79 test "$(git diff-files --name-status dir1)" = ""
83 test_expect_success 'replace a file with a symlink' '
85 rm foo &&
86 ln -s top foo &&
87 git add -u -- foo
91 test_expect_success 'add everything changed' '
93 git add -u &&
94 test -z "$(git diff-files)"
98 test_expect_success 'touch and then add -u' '
100 touch check &&
101 git add -u &&
102 test -z "$(git diff-files)"
106 test_expect_success 'touch and then add explicitly' '
108 touch check &&
109 git add check &&
110 test -z "$(git diff-files)"
114 test_done