Fix handing of autocorrection when running outside a git repository.

Old behavior was to take the first fuzzy match. Now, it checks the globa
git config, and runs the normal fuzzy handling, including failing to run a
semi-random command by default.
This commit is contained in:
Joey Hess 2014-08-23 16:51:33 -07:00
parent 6f80bacbf5
commit 4405650828
3 changed files with 10 additions and 6 deletions

View file

@ -41,9 +41,9 @@ fuzzymatches input showchoice choices = fst $ unzip $
{- Takes action based on git's autocorrect configuration, in preparation for
- an autocorrected command being run. -}
prepare :: String -> (c -> String) -> [c] -> Repo -> IO ()
prepare :: String -> (c -> String) -> [c] -> Maybe Repo -> IO ()
prepare input showmatch matches r =
case readish $ Git.Config.get "help.autocorrect" "0" r of
case readish . Git.Config.get "help.autocorrect" "0" =<< r of
Just n
| n == 0 -> list
| n < 0 -> warn