On Mon, Jun 18, 2012 at 03:28:24PM -0400, Tim Henigan wrote: > When running 'git diff --quiet <file1> <file2>', if file1 or file2 > is outside the repository, it will exit(0) even if the files differ. > It should exit(1) when they differ. Can we explain in the commit message a bit about why the patch works? If I hadn't just dug into this a few days ago, the patch would be somewhat confusing. Maybe something like: The problem comes from checking diff_options's found_changes member to see whether any changes were found. This flag is set only when we actually run xdiff and it finds a change. However, the diff machinery will optimize out the actual xdiff call when it is not necessary (i.e., when we are doing a straight byte-for-byte comparison and do not care about the output). As a result, this flag was never set, and we must check the HAS_CHANGES flag instead, just like the regular index-aware diff code paths do. I am also tempted to suggest that found_changes be renamed to xdiff_found_changes or something similar, because it really is quite misleading as-is. > diff --git a/diff-no-index.c b/diff-no-index.c > index f0b0010..b935d2a 100644 > --- a/diff-no-index.c > +++ b/diff-no-index.c > @@ -273,5 +273,6 @@ void diff_no_index(struct rev_info *revs, > * The return code for --no-index imitates diff(1): > * 0 = no changes, 1 = changes, else error > */ > - exit(revs->diffopt.found_changes); > + int result = diff_result_code(&revs->diffopt, 0); > + exit(result); This is a declaration-after-statement, no? We try to stick to C89, which does not allow this. I don't see any reason why the extra variable could not be removed entirely: exit(diff_result_code(&revs->diffopt, 0)); -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html