Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ad1c3fb

Browse files
committed
diff-no-index: correctly diagnose error return from 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bbc4e8 commit ad1c3fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

diff-no-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void diff_no_index(struct rev_info *revs,
244244
i++;
245245
else {
246246
j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
247-
if (!j)
247+
if (j <= 0)
248248
die("invalid diff option/value: %s", argv[i]);
249249
i += j;
250250
}

0 commit comments

Comments
 (0)