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

Re: [PATCH] diff: alias -q to --quiet

From
Jeff King <peff@peff.net>
Date
Oct 13, 2017, 17:56 UTC
Message-ID
<20171013175656.qitarz6lvrppyb5f@sigill.intra.peff.net>
In-Reply-To
<20171013164415.6632-1-asottile@umich.edu>
On Fri, Oct 13, 2017 at 09:44:15AM -0700, Anthony Sottile wrote:
> Previously, `-q` was silently ignored:

I'm not sure if is totally ignored. Normally if we have an unknown options we'd complain:

  $ git diff -x
  error: invalid option: -x
but we don't with "-q". Why?
In builtin/diff.c:471, we can see:
  else if (!strcmp(argv[1], "-q"))
          options |= DIFF_SILENT_ON_REMOVED;
So it _does_ do something, just not what you expected.

But wait, that's not the whole story. We convert "-q" into SILENT_ON_REMOVED in git-diff-files and in git-diff (when we're acting like diff-files). But nobody ever seems to check it!

Running "git log -p -SSILENT_ON_REMOVED" turns up two interesting commits:

  - 95a7c546b0 (diff: deprecate -q option to diff-files, 2013-07-17)
  - c48f6816f0 (diff: remove "diff-files -q" in a version of Git in a
    distant future, 2013-07-18).

So we dropped "-q" a few years ago and added a deprecation notice. "git tag --contains 95a7c546b0" tells us that happened in v1.8.5, which shipped in Nov 2013.

And then in v2.0.0 (May 2014) we tried to drop "-q" completely. Looking over c48f6816f0, I _think_ it's a mistake that "-q" became a silent noop there. That commit should have ripped out the remaining bits that set the SILENT_ON_REMOVED flag, and "-q" would have become an error.

So there are two separate questions/tasks:
  1. Should we remove the special handling of "-q" leftover from this
     deprecation? I think the answer is yes.
  2. Should we teach the diff machinery as a whole to treat "-q" as a
     synonym for "--quiet".
     Probably yes, but it's less clear to me that this won't have funny
     interactions. Are there other commands which use the diff-options
     parser via setup_revisions(), but expect "-q" to be left in the
     output so that they can handle it themselves?
     It looks like git-log does so, but it pulls the "-q" out before
     handing the remainder to setup_revisions(). And anyway, it just
     converts the option into a quiet diff (though it does in a way
     that's different than the rest of the diff code -- that might bear
     investigating on its own).
     Grepping for 'q' and OPT__QUIET, I don't see any others, but I
     didn't spend very much time digging.
-Peff
Previous: Anthony SottileNext: Junio C Hamano
Message 2 of 4 in “diff: alias -q to --quiet”
  1. diff: alias -q to --quietAnthony Sottile, Oct 13, 2017
  2. Jeff KingOct 13, 2017
  3. Junio C HamanoOct 14, 2017
  4. Jeff KingOct 16, 2017

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.