decorate: add clear_decoration() function
[git.git] / t / t2101-update-index-reupdate.sh
blobe3c7acdbf9125d68d72d983ed692ce6851f785bd
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git update-index --again test.
9 TEST_PASSES_SANITIZE_LEAK=true
10 . ./test-lib.sh
12 test_expect_success 'update-index --add' '
13 echo hello world >file1 &&
14 echo goodbye people >file2 &&
15 git update-index --add file1 file2 &&
16 git ls-files -s >current &&
17 cat >expected <<-EOF &&
18 100644 $(git hash-object file1) 0 file1
19 100644 $(git hash-object file2) 0 file2
20 EOF
21 cmp current expected
24 test_expect_success 'update-index --again' '
25 rm -f file1 &&
26 echo hello everybody >file2 &&
27 if git update-index --again
28 then
29 echo should have refused to remove file1
30 exit 1
31 else
32 echo happy - failed as expected
33 fi &&
34 git ls-files -s >current &&
35 cmp current expected
38 test_expect_success 'update-index --remove --again' '
39 git update-index --remove --again &&
40 git ls-files -s >current &&
41 cat >expected <<-EOF &&
42 100644 $(git hash-object file2) 0 file2
43 EOF
44 cmp current expected
47 test_expect_success 'first commit' 'git commit -m initial'
49 test_expect_success 'update-index again' '
50 mkdir -p dir1 &&
51 echo hello world >dir1/file3 &&
52 echo goodbye people >file2 &&
53 git update-index --add file2 dir1/file3 &&
54 echo hello everybody >file2 &&
55 echo happy >dir1/file3 &&
56 git update-index --again &&
57 git ls-files -s >current &&
58 cat >expected <<-EOF &&
59 100644 $(git hash-object dir1/file3) 0 dir1/file3
60 100644 $(git hash-object file2) 0 file2
61 EOF
62 cmp current expected
65 file2=$(git hash-object file2)
66 test_expect_success 'update-index --update from subdir' '
67 echo not so happy >file2 &&
68 (cd dir1 &&
69 cat ../file2 >file3 &&
70 git update-index --again
71 ) &&
72 git ls-files -s >current &&
73 cat >expected <<-EOF &&
74 100644 $(git hash-object dir1/file3) 0 dir1/file3
75 100644 $file2 0 file2
76 EOF
77 test_cmp expected current
80 test_expect_success 'update-index --update with pathspec' '
81 echo very happy >file2 &&
82 cat file2 >dir1/file3 &&
83 git update-index --again dir1/ &&
84 git ls-files -s >current &&
85 cat >expected <<-EOF &&
86 100644 $(git hash-object dir1/file3) 0 dir1/file3
87 100644 $file2 0 file2
88 EOF
89 cmp current expected
92 test_done