]>
Commit | Line | Data |
---|---|---|
83e77a25 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Junio C Hamano | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git update-index --again test. |
83e77a25 JH |
7 | ' |
8 | ||
9 | . ./test-lib.sh | |
10 | ||
7cbae724 | 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 && | |
736f2efc | 16 | cat >expected <<-EOF && |
17 | 100644 $(git hash-object file1) 0 file1 | |
18 | 100644 $(git hash-object file2) 0 file2 | |
19 | EOF | |
7cbae724 | 20 | cmp current expected |
21 | ' | |
83e77a25 | 22 | |
7cbae724 | 23 | test_expect_success 'update-index --again' ' |
24 | rm -f file1 && | |
83e77a25 | 25 | echo hello everybody >file2 && |
5be60078 | 26 | if git update-index --again |
83e77a25 JH |
27 | then |
28 | echo should have refused to remove file1 | |
29 | exit 1 | |
30 | else | |
31 | echo happy - failed as expected | |
32 | fi && | |
7cbae724 | 33 | git ls-files -s >current && |
34 | cmp current expected | |
35 | ' | |
83e77a25 | 36 | |
7cbae724 | 37 | test_expect_success 'update-index --remove --again' ' |
38 | git update-index --remove --again && | |
39 | git ls-files -s >current && | |
736f2efc | 40 | cat >expected <<-EOF && |
41 | 100644 $(git hash-object file2) 0 file2 | |
42 | EOF | |
7cbae724 | 43 | cmp current expected |
44 | ' | |
83e77a25 | 45 | |
0cb0e143 | 46 | test_expect_success 'first commit' 'git commit -m initial' |
83e77a25 | 47 | |
7cbae724 | 48 | test_expect_success 'update-index again' ' |
49 | mkdir -p dir1 && | |
83e77a25 JH |
50 | echo hello world >dir1/file3 && |
51 | echo goodbye people >file2 && | |
5be60078 | 52 | git update-index --add file2 dir1/file3 && |
a48fcd83 | 53 | echo hello everybody >file2 && |
83e77a25 | 54 | echo happy >dir1/file3 && |
5be60078 JH |
55 | git update-index --again && |
56 | git ls-files -s >current && | |
736f2efc | 57 | cat >expected <<-EOF && |
58 | 100644 $(git hash-object dir1/file3) 0 dir1/file3 | |
59 | 100644 $(git hash-object file2) 0 file2 | |
60 | EOF | |
7cbae724 | 61 | cmp current expected |
62 | ' | |
83e77a25 | 63 | |
736f2efc | 64 | file2=$(git hash-object file2) |
7cbae724 | 65 | test_expect_success 'update-index --update from subdir' ' |
66 | echo not so happy >file2 && | |
fd4ec4f2 | 67 | (cd dir1 && |
83e77a25 | 68 | cat ../file2 >file3 && |
fd4ec4f2 JL |
69 | git update-index --again |
70 | ) && | |
5be60078 | 71 | git ls-files -s >current && |
736f2efc | 72 | cat >expected <<-EOF && |
73 | 100644 $(git hash-object dir1/file3) 0 dir1/file3 | |
74 | 100644 $file2 0 file2 | |
75 | EOF | |
dcbaa0b3 | 76 | test_cmp expected current |
7cbae724 | 77 | ' |
83e77a25 | 78 | |
7cbae724 | 79 | test_expect_success 'update-index --update with pathspec' ' |
80 | echo very happy >file2 && | |
22293b9c | 81 | cat file2 >dir1/file3 && |
5be60078 JH |
82 | git update-index --again dir1/ && |
83 | git ls-files -s >current && | |
736f2efc | 84 | cat >expected <<-EOF && |
85 | 100644 $(git hash-object dir1/file3) 0 dir1/file3 | |
86 | 100644 $file2 0 file2 | |
87 | EOF | |
7cbae724 | 88 | cmp current expected |
89 | ' | |
83e77a25 | 90 | |
22293b9c | 91 | test_done |