3 # Copyright (c) 2006 Junio C Hamano
6 test_description
='git update-index --again test.
9 TEST_PASSES_SANITIZE_LEAK
=true
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
24 test_expect_success
'update-index --again' '
26 echo hello everybody >file2 &&
27 if git update-index --again
29 echo should have refused to remove file1
32 echo happy - failed as expected
34 git ls-files -s >current &&
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
47 test_expect_success
'first commit' 'git commit -m initial'
49 test_expect_success
'update-index again' '
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
65 file2
=$
(git hash-object file2
)
66 test_expect_success
'update-index --update from subdir' '
67 echo not so happy >file2 &&
69 cat ../file2 >file3 &&
70 git update-index --again
72 git ls-files -s >current &&
73 cat >expected <<-EOF &&
74 100644 $(git hash-object dir1/file3) 0 dir1/file3
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