Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='more git add -u' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 7 | test_expect_success setup ' |
| 8 | >xyzzy && |
| 9 | _empty=$(git hash-object --stdin <xyzzy) && |
| 10 | >yomin && |
| 11 | >caskly && |
Johannes Sixt | 704a314 | 2009-03-04 22:38:24 +0100 | [diff] [blame] | 12 | if test_have_prereq SYMLINKS; then |
| 13 | ln -s frotz nitfol && |
| 14 | T_letter=T |
| 15 | else |
| 16 | printf %s frotz > nitfol && |
| 17 | T_letter=M |
| 18 | fi && |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 19 | mkdir rezrov && |
| 20 | >rezrov/bozbar && |
| 21 | git add caskly xyzzy yomin nitfol rezrov/bozbar && |
| 22 | |
| 23 | test_tick && |
| 24 | git commit -m initial |
| 25 | |
| 26 | ' |
| 27 | |
| 28 | test_expect_success modify ' |
| 29 | rm -f xyzzy yomin nitfol caskly && |
| 30 | # caskly disappears (not a submodule) |
| 31 | mkdir caskly && |
| 32 | # nitfol changes from symlink to regular |
| 33 | >nitfol && |
| 34 | # rezrov/bozbar disappears |
| 35 | rm -fr rezrov && |
Johannes Sixt | 704a314 | 2009-03-04 22:38:24 +0100 | [diff] [blame] | 36 | if test_have_prereq SYMLINKS; then |
| 37 | ln -s xyzzy rezrov |
| 38 | else |
| 39 | printf %s xyzzy > rezrov |
| 40 | fi && |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 41 | # xyzzy disappears (not a submodule) |
| 42 | mkdir xyzzy && |
| 43 | echo gnusto >xyzzy/bozbar && |
| 44 | # yomin gets replaced with a submodule |
| 45 | mkdir yomin && |
| 46 | >yomin/yomin && |
| 47 | ( |
| 48 | cd yomin && |
| 49 | git init && |
| 50 | git add yomin && |
| 51 | git commit -m "sub initial" |
| 52 | ) && |
| 53 | yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) && |
| 54 | # yonk is added and then turned into a submodule |
| 55 | # this should appear as T in diff-files and as A in diff-index |
| 56 | >yonk && |
| 57 | git add yonk && |
| 58 | rm -f yonk && |
| 59 | mkdir yonk && |
| 60 | >yonk/yonk && |
| 61 | ( |
| 62 | cd yonk && |
| 63 | git init && |
| 64 | git add yonk && |
| 65 | git commit -m "sub initial" |
| 66 | ) && |
| 67 | yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) && |
| 68 | # zifmia is added and then removed |
| 69 | # this should appear in diff-files but not in diff-index. |
| 70 | >zifmia && |
| 71 | git add zifmia && |
| 72 | rm -f zifmia && |
| 73 | mkdir zifmia && |
| 74 | { |
| 75 | git ls-tree -r HEAD | |
| 76 | sed -e "s/^/:/" -e " |
| 77 | / caskly/{ |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 78 | s/ caskly/ $ZERO_OID D&/ |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 79 | s/blob/000000/ |
| 80 | } |
| 81 | / nitfol/{ |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 82 | s/ nitfol/ $ZERO_OID $T_letter&/ |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 83 | s/blob/100644/ |
| 84 | } |
| 85 | / rezrov.bozbar/{ |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 86 | s/ rezrov.bozbar/ $ZERO_OID D&/ |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 87 | s/blob/000000/ |
| 88 | } |
| 89 | / xyzzy/{ |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 90 | s/ xyzzy/ $ZERO_OID D&/ |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 91 | s/blob/000000/ |
| 92 | } |
| 93 | / yomin/{ |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 94 | s/ yomin/ $ZERO_OID T&/ |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 95 | s/blob/160000/ |
| 96 | } |
| 97 | " |
| 98 | } >expect && |
| 99 | { |
| 100 | cat expect |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 101 | echo ":100644 160000 $_empty $ZERO_OID T yonk" |
| 102 | echo ":100644 000000 $_empty $ZERO_OID D zifmia" |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 103 | } >expect-files && |
| 104 | { |
| 105 | cat expect |
brian m. carlson | 8125a58 | 2018-05-13 02:24:13 +0000 | [diff] [blame] | 106 | echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk" |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 107 | } >expect-index && |
| 108 | { |
| 109 | echo "100644 $_empty 0 nitfol" |
| 110 | echo "160000 $yomin 0 yomin" |
| 111 | echo "160000 $yonk 0 yonk" |
| 112 | } >expect-final |
| 113 | ' |
| 114 | |
Junio C Hamano | f58dbf2 | 2008-03-30 17:30:08 -0700 | [diff] [blame] | 115 | test_expect_success diff-files ' |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 116 | git diff-files --raw >actual && |
Brandon Casey | 2b14d07 | 2008-07-22 16:17:43 -0500 | [diff] [blame] | 117 | test_cmp expect-files actual |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 118 | ' |
| 119 | |
Junio C Hamano | 948dd34 | 2008-03-30 17:29:48 -0700 | [diff] [blame] | 120 | test_expect_success diff-index ' |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 121 | git diff-index --raw HEAD -- >actual && |
Brandon Casey | 2b14d07 | 2008-07-22 16:17:43 -0500 | [diff] [blame] | 122 | test_cmp expect-index actual |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 123 | ' |
| 124 | |
Junio C Hamano | f58dbf2 | 2008-03-30 17:30:08 -0700 | [diff] [blame] | 125 | test_expect_success 'add -u' ' |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 126 | rm -f ".git/saved-index" && |
| 127 | cp -p ".git/index" ".git/saved-index" && |
| 128 | git add -u && |
| 129 | git ls-files -s >actual && |
Brandon Casey | 2b14d07 | 2008-07-22 16:17:43 -0500 | [diff] [blame] | 130 | test_cmp expect-final actual |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 131 | ' |
| 132 | |
Junio C Hamano | f58dbf2 | 2008-03-30 17:30:08 -0700 | [diff] [blame] | 133 | test_expect_success 'commit -a' ' |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 134 | if test -f ".git/saved-index" |
| 135 | then |
| 136 | rm -f ".git/index" && |
| 137 | mv ".git/saved-index" ".git/index" |
| 138 | fi && |
| 139 | git commit -m "second" -a && |
| 140 | git ls-files -s >actual && |
Brandon Casey | 2b14d07 | 2008-07-22 16:17:43 -0500 | [diff] [blame] | 141 | test_cmp expect-final actual && |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 142 | rm -f .git/index && |
| 143 | git read-tree HEAD && |
| 144 | git ls-files -s >actual && |
Brandon Casey | 2b14d07 | 2008-07-22 16:17:43 -0500 | [diff] [blame] | 145 | test_cmp expect-final actual |
Junio C Hamano | 6301f30 | 2008-03-30 17:28:05 -0700 | [diff] [blame] | 146 | ' |
| 147 | |
| 148 | test_done |