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

Re: [PATCH] checkout: add --progress option

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 30, 2015, 19:37 UTC
Message-ID
<xmqq4mh8kv0e.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20151030193151.GB5336@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 21 quoted lines
> I sometimes find it confusing when there are two variables with very
> similar meanings (option_progress and show_progress here). I wonder if
> we could use one variable, like:
>
>   static int show_progress = -1;
>   ...
>   OPT_BOOL(0, "progress", &show_progress, ...);
>   ...
>   parse_options(...);
>   if (show_progress < 0) {
> 	if (opts.quiet)
> 		show_progress = 0;
> 	else
> 		show_progress = isatty(2);
>   }
>
> That somehow is much clearer to me, especially around the behavior of
> "-q --progress". Mine does the opposite of what you wrote above, but I
> think it makes more sense.
>
> I can live with it either way, though. :)

Actually, using a single variable is my preference. In this case I wanted to illustrate that the value parsed by parse_options() does not have to be the one that is used in the final location deep in the callchain for educational purposes, and I found it clearer to use two separate variables in the illustration.

Previous: Jeff KingNext: Edmundo Carmona Antoranz
Message 7 of 16 in “checkout: add --progress option”
  1. checkout: add --progress optionEdmundo Carmona Antoranz, Oct 30, 2015
  2. Junio C HamanoOct 30, 2015
  3. Eric SunshineOct 30, 2015
  4. Junio C HamanoOct 30, 2015
  5. Eric SunshineOct 30, 2015
  6. Jeff KingOct 30, 2015
  7. Junio C HamanoOct 30, 2015
  8. Edmundo Carmona AntoranzOct 31, 2015
  9. Edmundo Carmona AntoranzOct 31, 2015
  10. Edmundo Carmona AntoranzOct 31, 2015
  11. Junio C HamanoOct 31, 2015
  12. Edmundo Carmona AntoranzOct 31, 2015
  13. Edmundo Carmona AntoranzOct 31, 2015
  14. Jeff KingOct 31, 2015
  15. Eric SunshineNov 1, 2015
  16. Edmundo Carmona AntoranzNov 1, 2015

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.