summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-23 16:51:33 -0700
committerGravatar Joey Hess <joey@kitenet.net>2014-08-23 16:51:33 -0700
commit17a18df10a576ad8ffc54524b21ae3b4feb7becd (patch)
tree38b16a7a9cf26a74cb7e62bda663ef822790c2e5 /CmdLine.hs
parent6759f6700c7c7645886909d052cb092a704f7d31 (diff)
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.
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index a8d071ddf..606390130 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -26,6 +26,7 @@ import Common.Annex
import qualified Annex
import qualified Git
import qualified Git.AutoCorrect
+import qualified Git.Config
import Annex.Content
import Annex.Environment
import Command
@@ -44,7 +45,8 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
state <- Annex.new g
Annex.eval state $ do
checkEnvironment
- checkfuzzy
+ when fuzzy $
+ inRepo $ autocorrect . Just
forM_ fields $ uncurry Annex.setField
when (cmdnomessages cmd) $
Annex.setOutput QuietOutput
@@ -54,13 +56,14 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
startup
performCommandAction cmd params
shutdown $ cmdnocommit cmd
- go _flags params (Left e) =
+ go _flags params (Left e) = do
+ when fuzzy $
+ autocorrect =<< Git.Config.global
maybe (throw e) (\a -> a params) (cmdnorepo cmd)
err msg = msg ++ "\n\n" ++ usage header allcmds
cmd = Prelude.head cmds
(fuzzy, cmds, name, args) = findCmd fuzzyok allargs allcmds err
- checkfuzzy = when fuzzy $
- inRepo $ Git.AutoCorrect.prepare name cmdname cmds
+ autocorrect = Git.AutoCorrect.prepare name cmdname cmds
{- Parses command line params far enough to find the Command to run, and
- returns the remaining params.