git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jim Meyering <jim@meyering.net>
Date
May 22, 2009, 14:01 UTC
Message-ID
<87k549dyne.fsf@meyering.net>

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.

Next: Junio C Hamano
Message 1 of 9 in “git-diff: must --exit-code work with --ignore* options?”
  1. Jim MeyeringMay 22, 2009
  2. Junio C HamanoMay 22, 2009
  3. Jim MeyeringMay 22, 2009
  4. Junio C HamanoMay 22, 2009
  5. Jim MeyeringMay 23, 2009
  6. Jim MeyeringAug 30, 2009
  7. Junio C HamanoAug 30, 2009
  8. Jim MeyeringAug 30, 2009
  9. Thell FowlerSep 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.