#!/bin/sh global test_description := ''basic ls-files tests This test runs git ls-files with various unusual or malformed command-line arguments. '' source ./test-lib.sh >empty test_expect_success 'ls-files in empty repository' ' git ls-files >actual && test_cmp empty actual ' test_expect_success 'ls-files with nonexistent path' ' git ls-files doesnotexist >actual && test_cmp empty actual ' test_expect_success 'ls-files with nonsense option' ' test_expect_code 129 git ls-files --nonsense 2>actual && test_i18ngrep "[Uu]sage: git ls-files" actual ' test_expect_success 'ls-files -h in corrupt repository' ' mkdir broken && ( cd broken && git init && >.git/index && test_expect_code 129 git ls-files -h >usage 2>&1 ) && test_i18ngrep "[Uu]sage: git ls-files " broken/usage ' test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' ' mkdir subs && ln -s nosuch link && ln -s ../nosuch subs/link && git add link subs/link && git ls-files -s link subs/link >expect && git ls-files -s "$(pwd)/link" "$(pwd)/subs/link" >actual && test_cmp expect actual && ( cd subs && git ls-files -s link >../expect && git ls-files -s "$(pwd)/link" >../actual ) && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"basic ls-files tests\n"> <"\n"> <"This test runs git ls-files with various unusual or malformed\n"> <"command-line arguments.\n"> ) } spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (SimpleCommand redirects:[(Redir op_id:Redir_Great fd:-1 arg_word:{(empty)} spids:[18])]) (C {(test_expect_success)} {(SQ <"ls-files in empty repository">)} {(SQ <"\n"> <"\tgit ls-files >actual &&\n"> <"\ttest_cmp empty actual\n">)} ) (C {(test_expect_success)} {(SQ <"ls-files with nonexistent path">)} {(SQ <"\n"> <"\tgit ls-files doesnotexist >actual &&\n"> <"\ttest_cmp empty actual\n">)} ) (C {(test_expect_success)} {(SQ <"ls-files with nonsense option">)} { (SQ <"\n"> <"\ttest_expect_code 129 git ls-files --nonsense 2>actual &&\n"> <"\ttest_i18ngrep \"[Uu]sage: git ls-files\" actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"ls-files -h in corrupt repository">)} { (SQ <"\n"> <"\tmkdir broken &&\n"> <"\t(\n"> <"\t\tcd broken &&\n"> <"\t\tgit init &&\n"> <"\t\t>.git/index &&\n"> <"\t\ttest_expect_code 129 git ls-files -h >usage 2>&1\n"> <"\t) &&\n"> <"\ttest_i18ngrep \"[Uu]sage: git ls-files \" broken/usage\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"ls-files with absolute paths to symlinks">)} { (SQ <"\n"> <"\tmkdir subs &&\n"> <"\tln -s nosuch link &&\n"> <"\tln -s ../nosuch subs/link &&\n"> <"\tgit add link subs/link &&\n"> <"\tgit ls-files -s link subs/link >expect &&\n"> <"\tgit ls-files -s \"$(pwd)/link\" \"$(pwd)/subs/link\" >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\t(\n"> <"\t\tcd subs &&\n"> <"\t\tgit ls-files -s link >../expect &&\n"> <"\t\tgit ls-files -s \"$(pwd)/link\" >../actual\n"> <"\t) &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )