Re: [PATCH 4/4] allow recovery from command name typos
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- May 7, 2012, 09:43 UTC
- Message-ID
- <878vh4con4.fsf@thomas.inf.ethz.ch>
- In-Reply-To
- <CALUzUxqXrsB8XfQL6vOiQo1pLHNRjxRUxJLRiK_mcSU8fvTSCg@mail.gmail.com>
Tay Ray Chuan <rctay89@gmail.com> writes:
Show 21 quoted lines
> On Sun, May 6, 2012 at 4:21 PM, Jeff King <peff@peff.net> wrote: >> On Sun, May 06, 2012 at 02:55:30PM +0800, Tay Ray Chuan wrote: >> >>> $ git sh --pretty=oneline >>> git: 'sh' is not a git command. See 'git --help'. >>> >>> Did you mean one of these? >>> 1: show >>> 2: push >>> [1/2/.../n] 1 >> >> Ugh. Please protect this with a config variable that defaults to >> "off". It is very un-Unix to prompt unexpectedly, and I suspect a lot >> of people would be annoyed by this behavior changing by default (I know >> I would be). >> >> -Peff > > While I agree there should be a config to protect this, I was hoping > this would be useful to users on the terminal who make the occasional > slip-up, without having to do any prior configuration.
We already have help.autocorrect. It defaults to 0, which results in
$ g rebest
git: 'rebest' is not a git command. See 'git --help'.
Did you mean one of these?
rebase
reset
revertBut it can also be a timeout in deciseconds, after which the match is automatically executed (if there is only one). You could hijack it by
* making 'ask' mean your new feature
* making 'off' etc. be the same as 0 for sanity
* making the default value be like 0, but with an extra message such as
Use 'git config --global help.autocorrect ask' to let me prompt for
the correct command.though I'm sure you can improve on the wording.
--
Thomas Rast
trast@{inf,student}.ethz.ch