3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git update-index --again test.
11 test_expect_success 'update-index --add' '
12 echo hello world >file1 &&
13 echo goodbye people >file2 &&
14 git update-index --add file1 file2 &&
15 git ls-files -s >current &&
16 cat >expected <<-EOF &&
17 100644 $(git hash-object file1) 0 file1
18 100644 $(git hash-object file2) 0 file2
23 test_expect_success 'update-index --again' '
25 echo hello everybody >file2 &&
26 if git update-index --again
28 echo should have refused to remove file1
31 echo happy - failed as expected
33 git ls-files -s >current &&
37 test_expect_success 'update-index --remove --again' '
38 git update-index --remove --again &&
39 git ls-files -s >current &&
40 cat >expected <<-EOF &&
41 100644 $(git hash-object file2) 0 file2
46 test_expect_success 'first commit' 'git commit -m initial'
48 test_expect_success 'update-index again' '
50 echo hello world >dir1/file3 &&
51 echo goodbye people >file2 &&
52 git update-index --add file2 dir1/file3 &&
53 echo hello everybody >file2 &&
54 echo happy >dir1/file3 &&
55 git update-index --again &&
56 git ls-files -s >current &&
57 cat >expected <<-EOF &&
58 100644 $(git hash-object dir1/file3) 0 dir1/file3
59 100644 $(git hash-object file2) 0 file2
64 file2=$(git hash-object file2)
65 test_expect_success 'update-index --update from subdir' '
66 echo not so happy >file2 &&
68 cat ../file2 >file3 &&
69 git update-index --again
71 git ls-files -s >current &&
72 cat >expected <<-EOF &&
73 100644 $(git hash-object dir1/file3) 0 dir1/file3
76 test_cmp expected current
79 test_expect_success 'update-index --update with pathspec' '
80 echo very happy >file2 &&
81 cat file2 >dir1/file3 &&
82 git update-index --again dir1/ &&
83 git ls-files -s >current &&
84 cat >expected <<-EOF &&
85 100644 $(git hash-object dir1/file3) 0 dir1/file3