#!/bin/sh global test_description := ''more git add -u'' source ./test-lib.sh test_expect_success setup ' >xyzzy && _empty=$(git hash-object --stdin yomin && >caskly && if test_have_prereq SYMLINKS; then ln -s frotz nitfol && T_letter=T else printf %s frotz > nitfol && T_letter=M fi && mkdir rezrov && >rezrov/bozbar && git add caskly xyzzy yomin nitfol rezrov/bozbar && test_tick && git commit -m initial ' test_expect_success modify ' rm -f xyzzy yomin nitfol caskly && # caskly disappears (not a submodule) mkdir caskly && # nitfol changes from symlink to regular >nitfol && # rezrov/bozbar disappears rm -fr rezrov && if test_have_prereq SYMLINKS; then ln -s xyzzy rezrov else printf %s xyzzy > rezrov fi && # xyzzy disappears (not a submodule) mkdir xyzzy && echo gnusto >xyzzy/bozbar && # yomin gets replaced with a submodule mkdir yomin && >yomin/yomin && ( cd yomin && git init && git add yomin && git commit -m "sub initial" ) && yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) && # yonk is added and then turned into a submodule # this should appear as T in diff-files and as A in diff-index >yonk && git add yonk && rm -f yonk && mkdir yonk && >yonk/yonk && ( cd yonk && git init && git add yonk && git commit -m "sub initial" ) && yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) && # zifmia is added and then removed # this should appear in diff-files but not in diff-index. >zifmia && git add zifmia && rm -f zifmia && mkdir zifmia && { git ls-tree -r HEAD | sed -e "s/^/:/" -e " / caskly/{ s/ caskly/ $_z40 D&/ s/blob/000000/ } / nitfol/{ s/ nitfol/ $_z40 $T_letter&/ s/blob/100644/ } / rezrov.bozbar/{ s/ rezrov.bozbar/ $_z40 D&/ s/blob/000000/ } / xyzzy/{ s/ xyzzy/ $_z40 D&/ s/blob/000000/ } / yomin/{ s/ yomin/ $_z40 T&/ s/blob/160000/ } " } >expect && { cat expect echo ":100644 160000 $_empty $_z40 T yonk" echo ":100644 000000 $_empty $_z40 D zifmia" } >expect-files && { cat expect echo ":000000 160000 $_z40 $_z40 A yonk" } >expect-index && { echo "100644 $_empty 0 nitfol" echo "160000 $yomin 0 yomin" echo "160000 $yonk 0 yonk" } >expect-final ' test_expect_success diff-files ' git diff-files --raw >actual && test_cmp expect-files actual ' test_expect_success diff-index ' git diff-index --raw HEAD -- >actual && test_cmp expect-index actual ' test_expect_success 'add -u' ' rm -f ".git/saved-index" && cp -p ".git/index" ".git/saved-index" && git add -u && git ls-files -s >actual && test_cmp expect-final actual ' test_expect_success 'commit -a' ' if test -f ".git/saved-index" then rm -f ".git/index" && mv ".git/saved-index" ".git/index" fi && git commit -m "second" -a && git ls-files -s >actual && test_cmp expect-final actual && rm -f .git/index && git read-tree HEAD && git ls-files -s >actual && test_cmp expect-final actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"more git add -u">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\t>xyzzy &&\n"> <"\t_empty=$(git hash-object --stdin <"\t>yomin &&\n"> <"\t>caskly &&\n"> <"\tif test_have_prereq SYMLINKS; then\n"> <"\t\tln -s frotz nitfol &&\n"> <"\t\tT_letter=T\n"> <"\telse\n"> <"\t\tprintf %s frotz > nitfol &&\n"> <"\t\tT_letter=M\n"> <"\tfi &&\n"> <"\tmkdir rezrov &&\n"> <"\t>rezrov/bozbar &&\n"> <"\tgit add caskly xyzzy yomin nitfol rezrov/bozbar &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\tgit commit -m initial\n"> <"\n"> ) } ) (C {(test_expect_success)} {(modify)} { (SQ <"\n"> <"\trm -f xyzzy yomin nitfol caskly &&\n"> <"\t# caskly disappears (not a submodule)\n"> <"\tmkdir caskly &&\n"> <"\t# nitfol changes from symlink to regular\n"> <"\t>nitfol &&\n"> <"\t# rezrov/bozbar disappears\n"> <"\trm -fr rezrov &&\n"> <"\tif test_have_prereq SYMLINKS; then\n"> <"\t\tln -s xyzzy rezrov\n"> <"\telse\n"> <"\t\tprintf %s xyzzy > rezrov\n"> <"\tfi &&\n"> <"\t# xyzzy disappears (not a submodule)\n"> <"\tmkdir xyzzy &&\n"> <"\techo gnusto >xyzzy/bozbar &&\n"> <"\t# yomin gets replaced with a submodule\n"> <"\tmkdir yomin &&\n"> <"\t>yomin/yomin &&\n"> <"\t(\n"> <"\t\tcd yomin &&\n"> <"\t\tgit init &&\n"> <"\t\tgit add yomin &&\n"> <"\t\tgit commit -m \"sub initial\"\n"> <"\t) &&\n"> <"\tyomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) &&\n"> <"\t# yonk is added and then turned into a submodule\n"> <"\t# this should appear as T in diff-files and as A in diff-index\n"> <"\t>yonk &&\n"> <"\tgit add yonk &&\n"> <"\trm -f yonk &&\n"> <"\tmkdir yonk &&\n"> <"\t>yonk/yonk &&\n"> <"\t(\n"> <"\t\tcd yonk &&\n"> <"\t\tgit init &&\n"> <"\t\tgit add yonk &&\n"> <"\t\tgit commit -m \"sub initial\"\n"> <"\t) &&\n"> <"\tyonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) &&\n"> <"\t# zifmia is added and then removed\n"> <"\t# this should appear in diff-files but not in diff-index.\n"> <"\t>zifmia &&\n"> <"\tgit add zifmia &&\n"> <"\trm -f zifmia &&\n"> <"\tmkdir zifmia &&\n"> <"\t{\n"> <"\t\tgit ls-tree -r HEAD |\n"> <"\t\tsed -e \"s/^/:/\" -e \"\n"> <"\t\t\t/\tcaskly/{\n"> <"\t\t\t\ts/\tcaskly/ $_z40 D&/\n"> <"\t\t\t\ts/blob/000000/\n"> <"\t\t\t}\n"> <"\t\t\t/\tnitfol/{\n"> <"\t\t\t\ts/\tnitfol/ $_z40 $T_letter&/\n"> <"\t\t\t\ts/blob/100644/\n"> <"\t\t\t}\n"> <"\t\t\t/\trezrov.bozbar/{\n"> <"\t\t\t\ts/\trezrov.bozbar/ $_z40 D&/\n"> <"\t\t\t\ts/blob/000000/\n"> <"\t\t\t}\n"> <"\t\t\t/\txyzzy/{\n"> <"\t\t\t\ts/\txyzzy/ $_z40 D&/\n"> <"\t\t\t\ts/blob/000000/\n"> <"\t\t\t}\n"> <"\t\t\t/\tyomin/{\n"> <"\t\t\t s/\tyomin/ $_z40 T&/\n"> <"\t\t\t\ts/blob/160000/\n"> <"\t\t\t}\n"> <"\t\t\"\n"> <"\t} >expect &&\n"> <"\t{\n"> <"\t\tcat expect\n"> <"\t\techo \":100644 160000 $_empty $_z40 T\tyonk\"\n"> <"\t\techo \":100644 000000 $_empty $_z40 D\tzifmia\"\n"> <"\t} >expect-files &&\n"> <"\t{\n"> <"\t\tcat expect\n"> <"\t\techo \":000000 160000 $_z40 $_z40 A\tyonk\"\n"> <"\t} >expect-index &&\n"> <"\t{\n"> <"\t\techo \"100644 $_empty 0\tnitfol\"\n"> <"\t\techo \"160000 $yomin 0\tyomin\"\n"> <"\t\techo \"160000 $yonk 0\tyonk\"\n"> <"\t} >expect-final\n"> ) } ) (C {(test_expect_success)} {(diff-files)} {(SQ <"\n"> <"\tgit diff-files --raw >actual &&\n"> <"\ttest_cmp expect-files actual\n">)} ) (C {(test_expect_success)} {(diff-index)} { (SQ <"\n"> <"\tgit diff-index --raw HEAD -- >actual &&\n"> <"\ttest_cmp expect-index actual\n">) } ) (C {(test_expect_success)} {(SQ <"add -u">)} { (SQ <"\n"> <"\trm -f \".git/saved-index\" &&\n"> <"\tcp -p \".git/index\" \".git/saved-index\" &&\n"> <"\tgit add -u &&\n"> <"\tgit ls-files -s >actual &&\n"> <"\ttest_cmp expect-final actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"commit -a">)} { (SQ <"\n"> <"\tif test -f \".git/saved-index\"\n"> <"\tthen\n"> <"\t\trm -f \".git/index\" &&\n"> <"\t\tmv \".git/saved-index\" \".git/index\"\n"> <"\tfi &&\n"> <"\tgit commit -m \"second\" -a &&\n"> <"\tgit ls-files -s >actual &&\n"> <"\ttest_cmp expect-final actual &&\n"> <"\trm -f .git/index &&\n"> <"\tgit read-tree HEAD &&\n"> <"\tgit ls-files -s >actual &&\n"> <"\ttest_cmp expect-final actual\n"> ) } ) (C {(test_done)}) ] )