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

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

From
Jeff King <peff@peff.net>
Date
Oct 31, 2015, 20:07 UTC
Message-ID
<20151031200702.GA4115@sigill.intra.peff.net>
In-Reply-To
<CAOc6etapqKNAXxNycAx9g9VTJXnnCxuXj5eU7giKvZUy5s8X3Q@mail.gmail.com>
On Sat, Oct 31, 2015 at 12:14:39PM -0600, Edmundo Carmona Antoranz wrote:
Show 17 quoted lines
> On Sat, Oct 31, 2015 at 11:42 AM, Edmundo Carmona Antoranz
> <eantoranz@gmail.com> wrote:
> > On Sat, Oct 31, 2015 at 11:37 AM, Junio C Hamano <gitster@pobox.com> wrote:
> >> I do find what Peff showed us a lot easier to follow.
> >>
> >>         if (opts.show_progress < 0) {
> >>                 if (opts.quiet)
> >>                         opts.show_progress = 0;
> >>                 else
> >>                         opts.show_progress = isatty(2);
> >>         }
> >>
> >
> > Ok.... let me rewrite it that way. Other than that, the other things are ok?
> 
> In Peff's implementation I think he uses -1 as --no-progress, 1 as
> --progress and 0 as undefined, right?

I didn't mean to, though I don't promise I didn't send something buggy. It looks right to me, though:

  if (opts.show_progress < 0) { /* if the user didn't say... */
          if (opts.quiet)
		opts.show_progress = 0; /* quiet means "no progress" */
	  else
		opts.show_progress = isatty(2); /* returns 0/1 bool */
  }
> In my implementation I'm using -1 as undefined and 0 as --no-progress.
> What would be the standard approach?
That's standard. And "1" is "--progress".
Show 14 quoted lines
> From what I can see on
> parse_options's behavior, if you select --no-progress, the variable
> ends up with a 0, which makes me think I'm using the right approach.
> 
> End result with my assumptions would be:
> 
>         if (opts.show_progress) {
>                 /* user selected --progress or didn't specify */
>                 if (opts.quiet) {
>                         opts.show_progress = 0;
>                 } else if (opts.show_progress < 0) {
>                         opts.show_progress = isatty(2);
>                 }
>         }

The difference between mine and yours is that in mine, "--progress" trumps "--quiet", whereas it is the other way around in yours. I don't know if it is a huge deal, but mine makes more sense to me (because "--progress" is more specific than "--quiet", which might silence other messages, too).

-Peff
Previous: Edmundo Carmona AntoranzNext: Eric Sunshine
Message 14 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.