From: Jeff King <peff@peff.net>
To: Edmundo Carmona Antoranz <eantoranz@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH] checkout: add --progress option
Date: Sat, 31 Oct 2015 16:07:02 -0400 [thread overview]
Message-ID: <20151031200702.GA4115@sigill.intra.peff.net> (raw)
In-Reply-To: <CAOc6etapqKNAXxNycAx9g9VTJXnnCxuXj5eU7giKvZUy5s8X3Q@mail.gmail.com>
On Sat, Oct 31, 2015 at 12:14:39PM -0600, Edmundo Carmona Antoranz wrote:
> 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".
> 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
next prev parent reply other threads:[~2015-10-31 20:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 1:23 [PATCH] checkout: add --progress option Edmundo Carmona Antoranz
2015-10-30 17:04 ` Junio C Hamano
2015-10-30 18:12 ` Eric Sunshine
2015-10-30 18:48 ` Junio C Hamano
2015-10-30 19:04 ` Eric Sunshine
2015-10-30 19:31 ` Jeff King
2015-10-30 19:37 ` Junio C Hamano
2015-10-31 0:58 ` Edmundo Carmona Antoranz
2015-10-31 1:08 ` Edmundo Carmona Antoranz
2015-10-31 2:11 ` Edmundo Carmona Antoranz
2015-10-31 17:37 ` Junio C Hamano
2015-10-31 17:42 ` Edmundo Carmona Antoranz
2015-10-31 18:14 ` Edmundo Carmona Antoranz
2015-10-31 20:07 ` Jeff King [this message]
2015-11-01 0:45 ` Eric Sunshine
2015-11-01 16:50 ` Edmundo Carmona Antoranz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151031200702.GA4115@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=eantoranz@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).