{"thread":{"id":"24473","subject":"[PATCH] t7810: test git grep --no-index from a bare repository","startedAt":"2010-07-23T00:22:52Z","lastAt":"2010-07-23T00:22:52Z","messageCount":1,"participants":["Nguyễn Thái Ngọc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"146029","messageId":"1279844572-17780-1-git-send-email-pclouds@gmail.com","threadId":"24473","inReplyTo":null,"subject":"[PATCH] t7810: test git grep --no-index from a bare repository","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-07-23T00:22:52Z","receivedAt":"2010-07-23T00:22:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"From: Jonathan Nieder <jrnieder@gmail.com>\n\nIf git grep --no-index is to be a general-purpose replacement for\nstandard grep, then it should work even for examining the content of a\n.git directory.  The current implementation has some problems:\n\n * .git/info/exclude is honored though it shouldn’t be\n * when run from within a .git directory, grep --no-index searches\n   the entire .git directory instead of just directories below\n   the current working directory.\n\nThe last few tests (which demonstrate that grep --no-index looks for\n.git/info/exclude even when no repository is involved) are by Duy.\nAny bugs in the other tests are my fault.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n The original version. Good thing anyway, with or without tp/setup series.\n\n t/t7810-grep.sh |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 116 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex 8a63227..7329433 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -494,6 +494,98 @@ test_expect_success 'inside git repository but with --no-index' '\n \t)\n '\n \n+test_expect_success 'set up bare repository' '\n+\n+\trm -fr bare &&\n+\tmkdir -p bare/basis/sub &&\n+\techo hello >bare/basis/file1 &&\n+\techo world >bare/basis/sub/file2 &&\n+\techo \".*o*\" >bare/basis/.gitignore &&\n+\t(\n+\t\tcd bare/basis &&\n+\t\tgit init &&\n+\t\tgit ls-files --other | git update-index --add --stdin &&\n+\t\ttree=$(git write-tree) &&\n+\t\tcommit=$(printf \"basis\\n\" | git commit-tree \"$tree\") &&\n+\t\tgit update-ref -m init refs/heads/master \"$commit\" &&\n+\t\tgit update-index --refresh &&\n+\t\tgit diff-index --exit-code HEAD\n+\t) &&\n+\tgit clone --no-checkout --bare bare/basis bare/d.git &&\n+\tmkdir -p bare/d.git/sub &&\n+\techo olleh >bare/d.git/fich1 &&\n+\techo dlrow >bare/d.git/sub/file2 &&\n+\techo \"file2\" >bare/d.git/.gitignore &&\n+\techo \"o*\" >>bare/d.git/.gitignore\n+\t{\n+\t\techo \"HEAD:.gitignore:.*o*\" &&\n+\t\techo HEAD:file1:hello &&\n+\t\techo HEAD:sub/file2:world\n+\t} >bare/expect.full &&\n+\t: >bare/expect.empty &&\n+\techo file2:dlrow >bare/expect.sub\n+'\n+\n+test_expect_success 'in bare repo, grep without --no-index or --cached fails' '\n+\t(\n+\t\tcd bare/d.git &&\n+\t\ttest_must_fail git grep o >../actual.plain 2>../actual.msg &&\n+\t\tgrep \"work tree\" ../actual.msg &&\n+\t\ttest_cmp ../expect.empty ../actual.plain &&\n+\t\tcd sub &&\n+\t\ttest_must_fail git grep o >../../actual.sub 2>../../actual.msg &&\n+\t\ttest_cmp ../../expect.empty ../../actual.sub &&\n+\t\tgrep \"work tree\" ../../actual.msg\n+\t)\n+'\n+\n+test_expect_success 'in bare repo, --cached and HEAD ignore working dir' '\n+\n+\t(\n+\t\tcd bare/d.git &&\n+\t\ttest_must_fail git grep --cached o >../actual.cached 2>../actual.msg &&\n+\t\ttest_cmp ../expect.empty ../actual.cached &&\n+\t\t! grep fatal ../actual.msg &&\n+\t\tgit grep -e o HEAD >../actual.full &&\n+\t\ttest_cmp ../expect.full ../actual.full &&\n+\t\tcd sub &&\n+\t\ttest_must_fail git grep o >../../actual.sub 2>../../actual.msg &&\n+\t\ttest_cmp ../../expect.empty ../../actual.sub &&\n+\t\tgit grep -e o HEAD >../../actual.full-sub &&\n+\t\ttest_cmp ../../expect.full ../../actual.full-sub\n+\t)\n+'\n+\n+test_expect_success '--no-index from a bare repository' '\n+\trm -f bare/d.git/info/exclude &&\n+\t(\n+\t\tcd bare/d.git &&\n+\t\tgit grep --no-index o >../actual.noindex &&\n+\t\tgrep \"^fich1:olleh\\$\" ../actual.noindex &&\n+\t\tgrep \"^.gitignore:o[*]\\$\" ../actual.noindex &&\n+\t\t! grep file2 ../actual.noindex\n+\t)\n+'\n+\n+test_expect_failure '--no-index from a subdirectory of a bare repository' '\n+\t(\n+\t\tcd bare/d.git/sub &&\n+\t\tgit grep --no-index o >../../actual.sub &&\n+\t\ttest_cmp ../../expect.sub ../../actual.sub\n+\t)\n+'\n+\n+test_expect_failure '--no-index neglects info/exclude in bare repo' '\n+\techo \"fich1\" >bare/d.git/info/exclude &&\n+\t(\n+\t\tcd bare/d.git &&\n+\t\tgit grep --no-index o >../actual.noindex &&\n+\t\tgrep \"^fich1:olleh\\$\" ../actual.noindex &&\n+\t\tgrep \"^.gitignore:o[*]\\$\" ../actual.noindex &&\n+\t\t! grep file2 ../actual.noindex\n+\t)\n+'\n+\n test_expect_success 'setup double-dash tests' '\n cat >double-dash <<EOF &&\n --\n@@ -527,4 +619,28 @@ test_expect_success 'grep -e -- -- path' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'Setup fake .git' '\n+\tcd t &&\n+\tGIT_CEILING_DIRECTORIES=\"`pwd`\" &&\n+\texport GIT_CEILING_DIRECTORIES &&\n+\tcd a &&\n+\tmkdir -p .git/info &&\n+\tcd ../..\n+\n+'\n+\n+test_expect_failure 'Ignore fake .git/info/exclude' '\n+\t(\n+\t\tcd t/a &&\n+\t\techo v > .git/info/exclude &&\n+\t\tgit grep --no-index vvv . &&\n+\t\trm .git/info/exclude\n+\t)\n+'\n+\n+test_expect_success 'Unsetup fake .git' '\n+\trm -rf t/a &&\n+\tunset GIT_CEILING_DIRECTORIES\n+'\n+\n test_done\n-- \n1.7.1.rc1.69.g24c2f7\n"}]}