From: David Barr <david.barr@cordelta.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: David Barr <david.barr@cordelta.com>
Subject: [PATCH] RFC: help.autocorrect prompt
Date: Mon, 6 Sep 2010 12:28:26 +1000 [thread overview]
Message-ID: <1283740106-11411-1-git-send-email-david.barr@cordelta.com> (raw)
Added a new configuration value for help.autocorrect.
A value of 'prompt' causes git to wait for confirmation
before executing the assumed command.
---
help.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/help.c b/help.c
index 7f4928e..924ce60 100644
--- a/help.c
+++ b/help.c
@@ -267,8 +267,12 @@ static struct cmdnames aliases;
static int git_unknown_cmd_config(const char *var, const char *value, void *cb)
{
- if (!strcmp(var, "help.autocorrect"))
- autocorrect = git_config_int(var,value);
+ if (!strcmp(var, "help.autocorrect")) {
+ if (!strcmp(value, "prompt"))
+ autocorrect = INT_MAX;
+ else
+ autocorrect = git_config_int(var,value);
+ }
/* Also use aliases for command lookup */
if (!prefixcmp(var, "alias."))
add_cmdname(&aliases, var + 6, strlen(var + 6));
@@ -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);
+ } else if (autocorrect > 0) {
fprintf(stderr, "in %0.1f seconds automatically...\n",
(float)autocorrect/10.0);
poll(NULL, 0, autocorrect * 100);
--
1.7.0.4
next reply other threads:[~2010-09-06 2:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 2:28 David Barr [this message]
2010-09-06 2:59 ` [PATCH] RFC: help.autocorrect prompt Jonathan Nieder
2010-09-06 7:16 ` David Barr
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=1283740106-11411-1-git-send-email-david.barr@cordelta.com \
--to=david.barr@cordelta.com \
--cc=git@vger.kernel.org \
/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).