#!/bin/sh # # Copyright (c) 2005 Junio C Hamano # global test_description := ''git ls-files test (--others should pick up symlinks). This test runs git ls-files --others with the following on the filesystem. path0 - a file path1 - a symlink path2/file2 - a file in a directory path3-junk - a file to confuse things path3/file3 - a file in a directory path4 - an empty directory '' source ./test-lib.sh test_expect_success 'setup ' ' date >path0 && if test_have_prereq SYMLINKS then ln -s xyzzy path1 else date >path1 fi && mkdir path2 path3 path4 && date >path2/file2 && date >path2-junk && date >path3/file3 && date >path3-junk && git update-index --add path3-junk path3/file3 ' test_expect_success 'setup: expected output' ' cat >expected1 <<-\EOF && expected1 expected2 expected3 output path0 path1 path2-junk path2/file2 EOF sed -e "s|path2/file2|path2/|" expected2 && cp expected2 expected3 && echo path4/ >>expected2 ' test_expect_success 'ls-files --others' ' git ls-files --others >output && test_cmp expected1 output ' test_expect_success 'ls-files --others --directory' ' git ls-files --others --directory >output && test_cmp expected2 output ' test_expect_success '--no-empty-directory hides empty directory' ' git ls-files --others --directory --no-empty-directory >output && test_cmp expected3 output ' test_expect_success 'ls-files --others handles non-submodule .git' ' mkdir not-a-submodule && echo foo >not-a-submodule/.git && git ls-files -o >output && test_cmp expected1 output ' test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' ' git init super && git init sub && ( cd sub && >a && git add a && git commit -m sub && git pack-refs --all ) && ( cd super && "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" ../sub sub git ls-files --others --exclude-standard >../actual ) && echo sub/ >expect && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git ls-files test (--others should pick up symlinks).\n"> <"\n"> <"This test runs git ls-files --others with the following on the\n"> <"filesystem.\n"> <"\n"> <" path0 - a file\n"> <" path1\t- a symlink\n"> <" path2/file2 - a file in a directory\n"> <" path3-junk - a file to confuse things\n"> <" path3/file3 - a file in a directory\n"> <" path4 - an empty directory\n"> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"setup ">)} { (SQ <"\n"> <"\tdate >path0 &&\n"> <"\tif test_have_prereq SYMLINKS\n"> <"\tthen\n"> <"\t\tln -s xyzzy path1\n"> <"\telse\n"> <"\t\tdate >path1\n"> <"\tfi &&\n"> <"\tmkdir path2 path3 path4 &&\n"> <"\tdate >path2/file2 &&\n"> <"\tdate >path2-junk &&\n"> <"\tdate >path3/file3 &&\n"> <"\tdate >path3-junk &&\n"> <"\tgit update-index --add path3-junk path3/file3\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: expected output">)} { (SQ <"\n"> <"\tcat >expected1 <<-\\EOF &&\n"> <"\texpected1\n"> <"\texpected2\n"> <"\texpected3\n"> <"\toutput\n"> <"\tpath0\n"> <"\tpath1\n"> <"\tpath2-junk\n"> <"\tpath2/file2\n"> <"\tEOF\n"> <"\n"> <"\tsed -e \"s|path2/file2|path2/|\" expected2 &&\n"> <"\tcp expected2 expected3 &&\n"> <"\techo path4/ >>expected2\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-files --others">)} {(SQ <"\n"> <"\tgit ls-files --others >output &&\n"> <"\ttest_cmp expected1 output\n">)} ) (C {(test_expect_success)} {(SQ <"ls-files --others --directory">)} { (SQ <"\n"> <"\tgit ls-files --others --directory >output &&\n"> <"\ttest_cmp expected2 output\n"> ) } ) (C {(test_expect_success)} {(SQ <"--no-empty-directory hides empty directory">)} { (SQ <"\n"> <"\tgit ls-files --others --directory --no-empty-directory >output &&\n"> <"\ttest_cmp expected3 output\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-files --others handles non-submodule .git">)} { (SQ <"\n"> <"\tmkdir not-a-submodule &&\n"> <"\techo foo >not-a-submodule/.git &&\n"> <"\tgit ls-files -o >output &&\n"> <"\ttest_cmp expected1 output\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"ls-files --others with symlinked submodule">)} { (SQ <"\n"> <"\tgit init super &&\n"> <"\tgit init sub &&\n"> <"\t(\n"> <"\t\tcd sub &&\n"> <"\t\t>a &&\n"> <"\t\tgit add a &&\n"> <"\t\tgit commit -m sub &&\n"> <"\t\tgit pack-refs --all\n"> <"\t) &&\n"> <"\t(\n"> <"\t\tcd super &&\n"> < "\t\t\"$SHELL_PATH\" \"$TEST_DIRECTORY/../contrib/workdir/git-new-workdir\" ../sub sub\n" > <"\t\tgit ls-files --others --exclude-standard >../actual\n"> <"\t) &&\n"> <"\techo sub/ >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )