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

Re: [PATCH] Add an optional argument for --color options

From
Jeff King <peff@peff.net>
Date
Feb 14, 2010, 06:44 UTC
Message-ID
<20100214064408.GB20630@coredump.intra.peff.net>
In-Reply-To
<1266098475-21929-1-git-send-email-lodatom@gmail.com>
On Sat, Feb 13, 2010 at 05:01:15PM -0500, Mark Lodato wrote:
Show 7 quoted lines
> Make git-branch, git-show-branch, git-grep, and all the diff-based
> programs accept an optional argument <when> for --color.  The argument
> is a colorbool: "always", "never", or "auto".  If no argument is given,
> "always" is used;  --no-color is an alias for --color=never.  This makes
> the command-line interface consistent with other GNU tools, such as `ls'
> and `grep', and with the git-config color options.  Note that, without
> an argument, --color and --no-color work exactly as before.

I think this is a sensible change, and reading over the patch it looks fine to me.

> If the argument is not valid for a diff-family program, a completely
> unhelpful usage message is shown.  It seems that all the other diff
> options silently ignore invalid inputs, so this is consistent.  Perhaps
> this aspect should be tweaked.

Hmm...the only one I see that silently ignores is "--submodule=bogus". But it seems that "git log -Bfoobar" fails but does not print a useful message. Probably both should be fixed, and your option should follow the same convention as those.

>  Documentation/technical/api-parse-options.txt |   12 ++++++++++++

Ooh, api documentation. It is nice to review a patch that is thorough. :)

My only complaint in that respect is that there are no tests. However, I'm not sure we can get a very satisfying test, since the test scripts may or may not have stdout going to a tty.

-Peff
Previous: Mark LodatoNext: Jonathan Nieder
Message 2 of 11 in “Add an optional argument for --color options”
  1. Add an optional argument for --color optionsMark Lodato, Feb 13, 2010
  2. Jeff KingFeb 14, 2010
  3. Jonathan NiederFeb 14, 2010
  4. Mark LodatoFeb 14, 2010
  5. Jonathan NiederFeb 15, 2010
  6. Jeff KingFeb 15, 2010
  7. Usage messages produced by parseopt (Re: [PATCH] Add an optional argument for --color options)Jonathan Nieder, Feb 15, 2010
  8. Jeff KingFeb 15, 2010
  9. Junio C HamanoFeb 15, 2010
  10. Junio C HamanoFeb 14, 2010
  11. Mark LodatoFeb 14, 2010

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.