@@ -18,7 +18,9 @@ immediately.
deciseconds (0.1 sec).
- "never": don't run or show any suggested command.
- "prompt": show the suggestion and prompt for confirmation to run
-the command.
+the command. The default choice at the prompt is "No"
+ - "prompt-yes": show the suggestion and prompt for confirmation to run
+the command. The default choice at the prompt is "Yes"
help.htmlPath::
Specify the path where the HTML documentation resides. File system paths
@@ -552,6 +552,7 @@ struct help_unknown_cmd_config {
struct cmdnames aliases;
};
+#define AUTOCORRECT_PROMPT_YES (-5)
#define AUTOCORRECT_SHOW (-4)
#define AUTOCORRECT_PROMPT (-3)
#define AUTOCORRECT_NEVER (-2)
@@ -570,6 +571,8 @@ static int parse_autocorrect(const char *value)
if (!strcmp(value, "prompt"))
return AUTOCORRECT_PROMPT;
+ if (!strcmp(value, "prompt-yes"))
+ return AUTOCORRECT_PROMPT_YES;
if (!strcmp(value, "never"))
return AUTOCORRECT_NEVER;
if (!strcmp(value, "immediate"))
@@ -650,6 +653,9 @@ char *help_unknown_cmd(const char *cmd)
if ((cfg.autocorrect == AUTOCORRECT_PROMPT) && (!isatty(0) || !isatty(2)))
cfg.autocorrect = AUTOCORRECT_NEVER;
+ if ((cfg.autocorrect == AUTOCORRECT_PROMPT_YES) && (!isatty(0) || !isatty(2)))
+ cfg.autocorrect = AUTOCORRECT_IMMEDIATELY;
+
if (cfg.autocorrect == AUTOCORRECT_NEVER) {
fprintf_ln(stderr, _("git: '%s' is not a git command. See 'git --help'."), cmd);
exit(1);
@@ -738,6 +744,15 @@ char *help_unknown_cmd(const char *cmd)
if (!(starts_with(answer, "y") ||
starts_with(answer, "Y")))
exit(1);
+ } else if (cfg.autocorrect == AUTOCORRECT_PROMPT_YES) {
+ char *answer;
+ struct strbuf msg = STRBUF_INIT;
+ strbuf_addf(&msg, _("Run '%s' instead [Y/n]? "), assumed);
+ answer = git_prompt(msg.buf, PROMPT_ECHO);
+ strbuf_release(&msg);
+ if (starts_with(answer, "n") ||
+ starts_with(answer, "N"))
+ exit(1);
} else {
fprintf_ln(stderr,
_("Continuing in %0.1f seconds, "