From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Odd "git diff" breakage
Date: Mon, 31 Mar 2014 11:38:39 -0700 [thread overview]
Message-ID: <xmqq38hy6wnk.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqq7g7a6x0g.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Mon, 31 Mar 2014 11:30:55 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
>> I hit this oddity when not remembering the right syntax for --color-words..
>>
>> Try this (outside of a git repository):
>>
>> touch a b
>> git diff -u --color=words a b
>>
>> and watch it scroll (infinitely) printing out
>>
>> error: option `color' expects "always", "auto", or "never"
>>
>> forever.
>>
>> I haven't tried to root-cause it, since I'm supposed to be merging stuff..
>>
>> Linus
>
> Hmph, interesting. "outside a repository" is the key, it seems.
> And I can see it all the way down to 1.7.3 (at least).
diff_opt_parse() returns the number of options parsed, or often
returns error() which is defined to return -1. Yes, return value
of 0 is "I don't understand that option", which should cause the
caller to say that, but negative return should not be forgotten.
diff-no-index.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index c554691..265709b 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -198,7 +198,7 @@ void diff_no_index(struct rev_info *revs,
i++;
else {
j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
- if (!j)
+ if (j <= 0)
die("invalid diff option/value: %s", argv[i]);
i += j;
}
next prev parent reply other threads:[~2014-03-31 18:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-31 18:05 Odd "git diff" breakage Linus Torvalds
2014-03-31 18:30 ` Junio C Hamano
2014-03-31 18:35 ` Linus Torvalds
2014-03-31 18:38 ` Junio C Hamano [this message]
2014-03-31 18:47 ` [PATCH] diff-no-index: correctly diagnose error return from diff_opt_parse() Junio C Hamano
2014-03-31 19:14 ` Linus Torvalds
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=xmqq38hy6wnk.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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