{"thread":{"id":"9174","subject":"[PATCH] Test case for \"git diff\" outside a git repo","startedAt":"2007-07-23T13:22:48Z","lastAt":"2007-07-24T09:24:45Z","messageCount":3,"participants":["Steven Grimm","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"48307","messageId":"20070723132248.GA24122@midwinter.com","threadId":"9174","inReplyTo":null,"subject":"[PATCH] Test case for \"git diff\" outside a git repo","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-07-23T13:22:48Z","receivedAt":"2007-07-23T13:22:48Z","isPatch":true,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"Signed-off-by: Steven Grimm <koreth@midwinter.com>\n---\n\tgit-diff --quiet is pretty broken right now. If you do\n\t\"strace git diff --quiet file1 file2\" you will see that\n\tit never calls open() on either file! And it always\n\treturns a zero exit code whether or not the files are\n\tdifferent.\n\n\tI'm trying to follow the code to figure out what's going on,\n\tbut meanwhile, here's a test case. Perhaps someone more\n\tfamiliar with the diff code will beat me to a fix.\n\n t/t4021-diff-norepo.sh |   26 ++++++++++++++++++++++++++\n 1 files changed, 26 insertions(+), 0 deletions(-)\n create mode 100755 t/t4021-diff-norepo.sh\n\ndiff --git a/t/t4021-diff-norepo.sh b/t/t4021-diff-norepo.sh\nnew file mode 100755\nindex 0000000..dfee3d7\n--- /dev/null\n+++ b/t/t4021-diff-norepo.sh\n@@ -0,0 +1,26 @@\n+#!/bin/sh\n+\n+test_description='test git diff outside a repo'\n+\n+. ./test-lib.sh\n+\n+rm -rf .git\n+\n+test_expect_success setup '\n+\n+\techo content1 >file1a &&\n+\techo content1 >file1b &&\n+\techo content2 >file2\n+'\n+\n+test_expect_success 'zero return value with --quiet for different files' '\n+\n+\tgit diff --quiet file1a file2\n+'\n+\n+test_expect_success 'nonzero return value with --quiet for identical files' '\n+\n+\t! git diff --quiet file1a file1b >/dev/null\n+'\n+\n+test_done\n-- \n1.5.3.rc2.4.g726f9\n"},{"id":"48397","messageId":"7vy7h6ib0b.fsf@assigned-by-dhcp.cox.net","threadId":"9174","inReplyTo":"20070723132248.GA24122@midwinter.com","subject":"Re: [PATCH] Test case for \"git diff\" outside a git repo","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-24T06:14:28Z","receivedAt":"2007-07-24T06:14:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Steven Grimm <koreth@midwinter.com> writes:\n>\n>> Signed-off-by: Steven Grimm <koreth@midwinter.com>\n>> ---\n>> \tgit-diff --quiet is pretty broken right now. If you do\n>> \t\"strace git diff --quiet file1 file2\" you will see that\n>> \tit never calls open() on either file! And it always\n>> \treturns a zero exit code whether or not the files are\n>> \tdifferent.\n>>\n>> \tI'm trying to follow the code to figure out what's going on,\n>> \tbut meanwhile, here's a test case. Perhaps someone more\n>> \tfamiliar with the diff code will beat me to a fix.\n\nThe code to do \"untracked diff\" is an ugly stepchild and not\nreally part of git-diff proper.  In fact, --quiet also is an\nafterthought and I would not be too surprised if the \"untracked\ndiff\" code does not work with it.\n\n>> diff --git a/t/t4021-diff-norepo.sh b/t/t4021-diff-norepo.sh\n>> new file mode 100755\n>> index 0000000..dfee3d7\n>> --- /dev/null\n>> +++ b/t/t4021-diff-norepo.sh\n>> @@ -0,0 +1,26 @@\n>> +#!/bin/sh\n>> +\n>> +test_description='test git diff outside a repo'\n>> +\n>> +. ./test-lib.sh\n>> +\n>> +rm -rf .git\n\nUnless you are testing the t/ directory and git.git suite from a\ntarball, the only effect of this is to make t/trash controlled\nby its ../../.git repository (i.e. the git.git repository).  You\nare still inside a git repository.\n"},{"id":"48414","messageId":"Pine.LNX.4.64.0707241024350.14781@racer.site","threadId":"9174","inReplyTo":"7vy7h6ib0b.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Test case for \"git diff\" outside a git repo","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-24T09:24:45Z","receivedAt":"2007-07-24T09:24:45Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 23 Jul 2007, Junio C Hamano wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > Steven Grimm <koreth@midwinter.com> writes:\n> >\n> >> Signed-off-by: Steven Grimm <koreth@midwinter.com>\n> >> ---\n> >> \tgit-diff --quiet is pretty broken right now. If you do\n> >> \t\"strace git diff --quiet file1 file2\" you will see that\n> >> \tit never calls open() on either file! And it always\n> >> \treturns a zero exit code whether or not the files are\n> >> \tdifferent.\n> >>\n> >> \tI'm trying to follow the code to figure out what's going on,\n> >> \tbut meanwhile, here's a test case. Perhaps someone more\n> >> \tfamiliar with the diff code will beat me to a fix.\n> \n> The code to do \"untracked diff\" is an ugly stepchild and not really part \n> of git-diff proper.  In fact, --quiet also is an afterthought and I \n> would not be too surprised if the \"untracked diff\" code does not work \n> with it.\n\nNot that ugly, mind you.  Every third day or so I congratulate myself for \nhaving \"git diff --color-words\" or \"git diff -M\", without having to suffer \ninitialising a git repository.\n\nBut yes, I agree, the --quiet code came after the --no-index code, and \nthus it is well possible that the latter ignores the former.\n\n> >> diff --git a/t/t4021-diff-norepo.sh b/t/t4021-diff-norepo.sh\n> >> new file mode 100755\n> >> index 0000000..dfee3d7\n> >> --- /dev/null\n> >> +++ b/t/t4021-diff-norepo.sh\n> >> @@ -0,0 +1,26 @@\n> >> +#!/bin/sh\n> >> +\n> >> +test_description='test git diff outside a repo'\n> >> +\n> >> +. ./test-lib.sh\n> >> +\n> >> +rm -rf .git\n> \n> Unless you are testing the t/ directory and git.git suite from a \n> tarball, the only effect of this is to make t/trash controlled by its \n> ../../.git repository (i.e. the git.git repository).  You are still \n> inside a git repository.\n\nYes, this is no good.\n\nHowever, you can force --no-index.  IMHO that is the way to go.\n\nCiao,\nDscho\n"}]}