summaryrefslogtreecommitdiff
path: root/diff-no-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-31 11:47:17 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-31 11:48:26 -0700
commitad1c3fbd26d0aae50abfb3c7d654f7229ba9370d (patch)
tree5d6cd777569113a94d32580d3580dd713f5f1305 /diff-no-index.c
parent7bbc4e8fdb33e0a8e42e77cc05460d4c4f615f4d (diff)
downloadgit-ad1c3fbd26d0aae50abfb3c7d654f7229ba9370d.tar.gz
diff-no-index: correctly diagnose error return from diff_opt_parse()jc/fix-diff-no-index-diff-opt-parse
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 did not process that option at all", which should cause the caller to say that, but negative return should not be forgotten. This bug caused "diff --no-index" to infinitely show the same error message because the returned value was used to decrement the loop control variable, e.g. $ git diff --no-index --color=words a b error: option `color' expects "always", "auto", or "never" error: option `color' expects "always", "auto", or "never" ... Instead, make it act like so: $ git diff --no-index --color=words a b error: option `color' expects "always", "auto", or "never" fatal: invalid diff option/value: --color=words Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-no-index.c')
-rw-r--r--diff-no-index.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/diff-no-index.c b/diff-no-index.c
index 00a8eefde9..ecf929336d 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -244,7 +244,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;
}