git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Barr <david.barr@cordelta.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Heiko Voigt <hvoigt@hvoigt.net>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH] RFC: help.autocorrect prompt
Date: Mon, 6 Sep 2010 17:16:22 +1000	[thread overview]
Message-ID: <201009061716.22468.david.barr@cordelta.com> (raw)
In-Reply-To: <20100906025949.GA23594@burratino>

 
> Any particular significance to INT_MAX rather than, e.g., -1 here?
> (Just curious; it seems unlikely someone would use INT_MAX and
> accidentally trip on this.)

> Not a problem introduced by your patch: should we be checking for
> out-of-range (e.g., negative) values?

The existing docs say that negative values correspond to immediate execution,
zero to never, and positive to a delay in deciseconds.

As noted, I chose INT_MAX as a rather unlikely conscious choice (~7 years).

> > @@ -342,7 +346,10 @@ const char *help_unknown_cmd(const char *cmd)
> >                       "which does not exist.\n"
> >                       "Continuing under the assumption that you meant 
'%s'\n",
> >                       cmd, assumed);
> > -             if (autocorrect > 0) {
> > +             if (autocorrect == INT_MAX) {
> > +                     if (strcmp("y", git_getpass("Continue? (y/n) ")))
> > +                             exit(1);
> 
> Funny. :)
> 
> It might be better to actually always write this prompt to the
> terminal, rather than popping up a gui $GIT_ASKPASS if the user has
> set that up.  Maybe something like Heiko Voigt's "mingw: make failures
> to unlike or move raise a question" (9229029, 2010-02-21 from
> 4msysgit.git):
> 
>         if (!isatty(STDIN_FILENO) || !isatty(STDERR_FILENO))
>                 exit(1);
>         fprintf(stderr, "Continue? (y/n) ");
>         if (!fgets(answer, sizeof(answer), stdin))
>                 exit(1)
>         if (*answer != 'y' && *answer != 'Y')
>                 exit(1);
> 
> > +             } else if (autocorrect > 0) {
> >                       fprintf(stderr, "in %0.1f seconds automatically...
\n",
> >                               (float)autocorrect/10.0);
> >                       poll(NULL, 0, autocorrect * 100);

That looks much nicer, I was hoping for such a suggestion.

--
David Barr.

  reply	other threads:[~2010-09-06  7:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06  2:28 [PATCH] RFC: help.autocorrect prompt David Barr
2010-09-06  2:59 ` Jonathan Nieder
2010-09-06  7:16   ` David Barr [this message]
2010-09-06  7:27   ` [PATCH] " David Barr

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=201009061716.22468.david.barr@cordelta.com \
    --to=david.barr@cordelta.com \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=johannes.schindelin@gmx.de \
    --cc=jrnieder@gmail.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).