From: Jeff King <peff@peff.net>
To: Tim Henigan <tim.henigan@gmail.com>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH] diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changes
Date: Fri, 15 Jun 2012 15:13:53 -0400 [thread overview]
Message-ID: <20120615191353.GA26473@sigill.intra.peff.net> (raw)
In-Reply-To: <20120615184030.GC14843@sigill.intra.peff.net>
On Fri, Jun 15, 2012 at 02:40:30PM -0400, Jeff King wrote:
> I suspect what you actually want is to set DIFF_FROM_CONTENTS in the
> no-index case, since we by definition do not have a pair of sha1s to
> compare. But it may also be that diff.c could detect this case
> automatically. I'd have to look closer.
This works for me:
diff --git a/diff.c b/diff.c
index 77edd50..27231d2 100644
--- a/diff.c
+++ b/diff.c
@@ -3228,7 +3228,8 @@ int diff_setup_done(struct diff_options *options)
if (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||
DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||
- DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))
+ DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL) ||
+ DIFF_OPT_TST(options, NO_INDEX))
DIFF_OPT_SET(options, DIFF_FROM_CONTENTS);
else
DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);
One could also set DIFF_FROM_CONTENTS manually in diff_on_index, but
note that diff_setup_done unsets it (which seems odd; who would have set
it in the first place if they did not want to override it? I think that
else clause can simply be dropped).
-Peff
PS Your test should probably be spelled with test_expect_code, like:
diff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh
index cdb9202..0b83235 100755
--- a/t/t4035-diff-quiet.sh
+++ b/t/t4035-diff-quiet.sh
@@ -77,4 +77,8 @@ test_expect_success 'git diff-index --cached HEAD' '
}
'
+test_expect_success 'git diff <tracked file> <file outside repo>' '
+ test_expect_code 1 git diff --quiet c /dev/null
+'
+
test_done
next prev parent reply other threads:[~2012-06-15 19:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 17:31 [PATCH] diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changes Tim Henigan
2012-06-15 18:40 ` Jeff King
2012-06-15 19:13 ` Jeff King [this message]
2012-06-15 18:45 ` Junio C Hamano
2012-06-15 19:37 ` Jeff King
2012-06-15 19:56 ` Tim Henigan
2012-06-15 20:08 ` Junio C Hamano
2012-06-15 20:24 ` Jeff King
2012-06-15 20:44 ` Junio C Hamano
2012-06-15 20:10 ` Junio C Hamano
2012-06-18 17:51 ` Tim Henigan
2012-06-18 18:00 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120615191353.GA26473@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tim.henigan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).