Subject: git-diff: must --exit-code work with --ignore* options?

From: Jim Meyering <[email-masked]>
Date: Fri, 22 May 2009 16:01:57 +0200

git-diff's --quiet option works how I'd expect with --ignore-space-at-eol
as long as I'm also using --no-index:

    $ echo>b; echo \ >c; git diff --no-index --quiet --ignore-space-at-eol b c \
      && echo good
    good

But in what I think of as normal operation (i.e., without --no-index),
--exit-code (or --quiet) makes git-diff say there were differences,
even when they have been ignored:

    # do this in an empty directory
    $ git init -q; echo>k; git add .; git commit -q -m. .; echo \ >k
    $ git diff --ignore-space-at-eol --quiet || echo bad
    bad

Same problem with --ignore-space-change.

-------------------
In the surprising case, builtin-diff.c's builtin_diff_files calls
diff_result_code, which returns nonzero due to this:

          if (diff_queued_diff.nr)
                  DIFF_OPT_SET(options, HAS_CHANGES);
          else
                  DIFF_OPT_CLR(options, HAS_CHANGES);

However, the queued diffs may contain only ignorable changes.

With --no-index, it takes a different code path and uses
diffopt.found_changes to produce the desired exit status.