#!/bin/sh # # Copyright (c) 2005 Junio C Hamano # global test_description := ''git ls-files -k and -m flags test. This test prepares the following in the cache: path0 - a file path1 - a symlink path2/file2 - a file in a directory path3/file3 - a file in a directory pathx/ju - a file in a directory submod1/ - a submodule submod2/ - another submodule and the following on the filesystem: path0/file0 - a file in a directory path1/file1 - a file in a directory path2 - a file path3 - a symlink path4 - a file path5 - a symlink path6/file6 - a file in a directory pathx/ju/nk - a file in a directory to be killed submod1/ - a submodule (modified from the cache) submod2/ - a submodule (matches the cache) git ls-files -k should report that existing filesystem objects path0/*, path1/*, path2 and path3 to be killed. Also for modification test, the cache and working tree have: path7 - an empty file, modified to a non-empty file. path8 - a non-empty file, modified to an empty file. path9 - an empty file, cache dirtied. path10 - a non-empty file, cache dirtied. We should report path0, path1, path2/file2, path3/file3, path7 and path8 modified without reporting path9 and path10. submod1 is also modified. '' source ./test-lib.sh test_expect_success 'git update-index --add to add various paths.' ' date >path0 && test_ln_s_add xyzzy path1 && mkdir path2 path3 pathx && date >path2/file2 && date >path3/file3 && >pathx/ju && : >path7 && date >path8 && : >path9 && date >path10 && git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 && git init submod1 && git -C submod1 commit --allow-empty -m "empty 1" && git init submod2 && git -C submod2 commit --allow-empty -m "empty 2" && git update-index --add submod[12] && ( cd submod1 && git commit --allow-empty -m "empty 1 (updated)" ) && rm -fr path? # leave path10 alone ' test_expect_success 'git ls-files -k to show killed files.' ' date >path2 && if test_have_prereq SYMLINKS then ln -s frotz path3 && ln -s nitfol path5 else date >path3 && date >path5 fi && mkdir -p path0 path1 path6 pathx/ju && date >path0/file0 && date >path1/file1 && date >path6/file6 && date >path7 && : >path8 && : >path9 && touch path10 && >pathx/ju/nk && cat >.expected <<-\EOF path0/file0 path1/file1 path2 path3 pathx/ju/nk EOF ' test_expect_success 'git ls-files -k output (w/o icase)' ' git ls-files -k >.output && test_cmp .expected .output ' test_expect_success 'git ls-files -k output (w/ icase)' ' git -c core.ignorecase=true ls-files -k >.output && test_cmp .expected .output ' test_expect_success 'git ls-files -m to show modified files.' ' git ls-files -m >.output ' test_expect_success 'validate git ls-files -m output.' ' cat >.expected <<-\EOF && path0 path1 path2/file2 path3/file3 path7 path8 pathx/ju submod1 EOF test_cmp .expected .output ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git ls-files -k and -m flags test.\n"> <"\n"> <"This test prepares the following in the cache:\n"> <"\n"> <" path0 - a file\n"> <" path1 - a symlink\n"> <" path2/file2 - a file in a directory\n"> <" path3/file3 - a file in a directory\n"> <" pathx/ju - a file in a directory\n"> <" submod1/\t- a submodule\n"> <" submod2/\t- another submodule\n"> <"\n"> <"and the following on the filesystem:\n"> <"\n"> <" path0/file0 - a file in a directory\n"> <" path1/file1 - a file in a directory\n"> <" path2 - a file\n"> <" path3 - a symlink\n"> <" path4\t- a file\n"> <" path5\t- a symlink\n"> <" path6/file6 - a file in a directory\n"> <" pathx/ju/nk - a file in a directory to be killed\n"> <" submod1/\t- a submodule (modified from the cache)\n"> <" submod2/\t- a submodule (matches the cache)\n"> <"\n"> <"git ls-files -k should report that existing filesystem objects\n"> <"path0/*, path1/*, path2 and path3 to be killed.\n"> <"\n"> <"Also for modification test, the cache and working tree have:\n"> <"\n"> <" path7 - an empty file, modified to a non-empty file.\n"> <" path8 - a non-empty file, modified to an empty file.\n"> <" path9\t- an empty file, cache dirtied.\n"> <" path10\t- a non-empty file, cache dirtied.\n"> <"\n"> <"We should report path0, path1, path2/file2, path3/file3, path7 and path8\n"> <"modified without reporting path9 and path10. submod1 is also modified.\n"> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"git update-index --add to add various paths.">)} { (SQ <"\n"> <"\tdate >path0 &&\n"> <"\ttest_ln_s_add xyzzy path1 &&\n"> <"\tmkdir path2 path3 pathx &&\n"> <"\tdate >path2/file2 &&\n"> <"\tdate >path3/file3 &&\n"> <"\t>pathx/ju &&\n"> <"\t: >path7 &&\n"> <"\tdate >path8 &&\n"> <"\t: >path9 &&\n"> <"\tdate >path10 &&\n"> <"\tgit update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 &&\n"> <"\tgit init submod1 &&\n"> <"\tgit -C submod1 commit --allow-empty -m \"empty 1\" &&\n"> <"\tgit init submod2 &&\n"> <"\tgit -C submod2 commit --allow-empty -m \"empty 2\" &&\n"> <"\tgit update-index --add submod[12] &&\n"> <"\t(\n"> <"\t\tcd submod1 &&\n"> <"\t\tgit commit --allow-empty -m \"empty 1 (updated)\"\n"> <"\t) &&\n"> <"\trm -fr path?\t# leave path10 alone\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files -k to show killed files.">)} { (SQ <"\n"> <"\tdate >path2 &&\n"> <"\tif test_have_prereq SYMLINKS\n"> <"\tthen\n"> <"\t\tln -s frotz path3 &&\n"> <"\t\tln -s nitfol path5\n"> <"\telse\n"> <"\t\tdate >path3 &&\n"> <"\t\tdate >path5\n"> <"\tfi &&\n"> <"\tmkdir -p path0 path1 path6 pathx/ju &&\n"> <"\tdate >path0/file0 &&\n"> <"\tdate >path1/file1 &&\n"> <"\tdate >path6/file6 &&\n"> <"\tdate >path7 &&\n"> <"\t: >path8 &&\n"> <"\t: >path9 &&\n"> <"\ttouch path10 &&\n"> <"\t>pathx/ju/nk &&\n"> <"\tcat >.expected <<-\\EOF\n"> <"\tpath0/file0\n"> <"\tpath1/file1\n"> <"\tpath2\n"> <"\tpath3\n"> <"\tpathx/ju/nk\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files -k output (w/o icase)">)} {(SQ <"\n"> <"\tgit ls-files -k >.output &&\n"> <"\ttest_cmp .expected .output\n">)} ) (C {(test_expect_success)} {(SQ <"git ls-files -k output (w/ icase)">)} { (SQ <"\n"> <"\tgit -c core.ignorecase=true ls-files -k >.output &&\n"> <"\ttest_cmp .expected .output\n"> ) } ) (C {(test_expect_success)} {(SQ <"git ls-files -m to show modified files.">)} {(SQ <"\n"> <"\tgit ls-files -m >.output\n">)} ) (C {(test_expect_success)} {(SQ <"validate git ls-files -m output.">)} { (SQ <"\n"> <"\tcat >.expected <<-\\EOF &&\n"> <"\tpath0\n"> <"\tpath1\n"> <"\tpath2/file2\n"> <"\tpath3/file3\n"> <"\tpath7\n"> <"\tpath8\n"> <"\tpathx/ju\n"> <"\tsubmod1\n"> <"\tEOF\n"> <"\ttest_cmp .expected .output\n"> ) } ) (C {(test_done)}) ] )