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:
parent
6f80bacbf5
commit
4405650828
3 changed files with 10 additions and 6 deletions
11
CmdLine.hs
11
CmdLine.hs
|
@ -26,6 +26,7 @@ import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import qualified Git.AutoCorrect
|
import qualified Git.AutoCorrect
|
||||||
|
import qualified Git.Config
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Environment
|
import Annex.Environment
|
||||||
import Command
|
import Command
|
||||||
|
@ -44,7 +45,8 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
|
||||||
state <- Annex.new g
|
state <- Annex.new g
|
||||||
Annex.eval state $ do
|
Annex.eval state $ do
|
||||||
checkEnvironment
|
checkEnvironment
|
||||||
checkfuzzy
|
when fuzzy $
|
||||||
|
inRepo $ autocorrect . Just
|
||||||
forM_ fields $ uncurry Annex.setField
|
forM_ fields $ uncurry Annex.setField
|
||||||
when (cmdnomessages cmd) $
|
when (cmdnomessages cmd) $
|
||||||
Annex.setOutput QuietOutput
|
Annex.setOutput QuietOutput
|
||||||
|
@ -54,13 +56,14 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
|
||||||
startup
|
startup
|
||||||
performCommandAction cmd params
|
performCommandAction cmd params
|
||||||
shutdown $ cmdnocommit cmd
|
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)
|
maybe (throw e) (\a -> a params) (cmdnorepo cmd)
|
||||||
err msg = msg ++ "\n\n" ++ usage header allcmds
|
err msg = msg ++ "\n\n" ++ usage header allcmds
|
||||||
cmd = Prelude.head cmds
|
cmd = Prelude.head cmds
|
||||||
(fuzzy, cmds, name, args) = findCmd fuzzyok allargs allcmds err
|
(fuzzy, cmds, name, args) = findCmd fuzzyok allargs allcmds err
|
||||||
checkfuzzy = when fuzzy $
|
autocorrect = Git.AutoCorrect.prepare name cmdname cmds
|
||||||
inRepo $ Git.AutoCorrect.prepare name cmdname cmds
|
|
||||||
|
|
||||||
{- Parses command line params far enough to find the Command to run, and
|
{- Parses command line params far enough to find the Command to run, and
|
||||||
- returns the remaining params.
|
- returns the remaining params.
|
||||||
|
|
|
@ -41,9 +41,9 @@ fuzzymatches input showchoice choices = fst $ unzip $
|
||||||
|
|
||||||
{- Takes action based on git's autocorrect configuration, in preparation for
|
{- Takes action based on git's autocorrect configuration, in preparation for
|
||||||
- an autocorrected command being run. -}
|
- 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 =
|
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
|
Just n
|
||||||
| n == 0 -> list
|
| n == 0 -> list
|
||||||
| n < 0 -> warn
|
| n < 0 -> warn
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -6,6 +6,7 @@ git-annex (5.20140818) UNRELEASED; urgency=medium
|
||||||
* When accessing a local remote, shut down git-cat-file processes
|
* When accessing a local remote, shut down git-cat-file processes
|
||||||
afterwards, to ensure that remotes on removable media can be unmounted.
|
afterwards, to ensure that remotes on removable media can be unmounted.
|
||||||
Closes: #758630
|
Closes: #758630
|
||||||
|
* Fix handing of autocorrection when running outside a git repository.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Tue, 19 Aug 2014 12:52:41 -0400
|
-- Joey Hess <joeyh@debian.org> Tue, 19 Aug 2014 12:52:41 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue