aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-09-09 15:55:13 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-09-09 15:55:13 -0400
commitd1264039dd069ff5579dee2740ffd9051a976dd6 (patch)
tree669cfac4da778d870aaadbe02173dde478269749
parent43248e937b033d0cf8a0635e76939168e61011ad (diff)
Make full option parsing be done when not in a git repo, so --help can be displayed for commands that require a git repo, etc.
-rw-r--r--CmdLine.hs29
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/--help_should_not_demand_being_in_the_git_repo.mdwn1
3 files changed, 23 insertions, 9 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index a512d868d..e6ee0c2e6 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -36,8 +36,9 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
Annex.eval state $ do
checkEnvironment
forM_ fields $ uncurry Annex.setField
- (cmd, seek, globalconfig) <- parsewith cmdparser
+ (cmd, seek, globalconfig) <- parsewith False cmdparser
(\a -> inRepo $ a . Just)
+ (liftIO . O.handleParseResult)
when (cmdnomessages cmd) $
Annex.setOutput QuietOutput
getParsed globalconfig
@@ -47,20 +48,30 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
performCommandAction cmd seek $
shutdown $ cmdnocommit cmd
go (Left norepo) = do
- (_, a, _globalconfig) <- parsewith
- (fromMaybe (throw norepo) . cmdnorepo)
- (\a -> a =<< Git.Config.global)
- a
+ let ingitrepo = \a -> a =<< Git.Config.global
+ -- Parse command line with full cmdparser first,
+ -- so that help can be displayed for bad parses
+ -- even when not run in a repo.
+ res <- parsewith False cmdparser ingitrepo return
+ case res of
+ Failure _ -> void (O.handleParseResult res)
+ _ -> do
+ -- Parse command line in norepo mode.
+ (_, a, _globalconfig) <- parsewith True
+ (fromMaybe (throw norepo) . cmdnorepo)
+ ingitrepo
+ O.handleParseResult
+ a
- parsewith getparser ingitrepo =
+ parsewith secondrun getparser ingitrepo handleresult =
case parseCmd progname progdesc globaloptions allargs allcmds getparser of
O.Failure _ -> do
-- parse failed, so fall back to
-- fuzzy matching, or to showing usage
- when fuzzy $
+ when (fuzzy && not secondrun) $
ingitrepo autocorrect
- liftIO (O.handleParseResult (parseCmd progname progdesc globaloptions correctedargs allcmds getparser))
- res -> liftIO (O.handleParseResult res)
+ handleresult (parseCmd progname progdesc globaloptions correctedargs allcmds getparser)
+ res -> handleresult res
where
autocorrect = Git.AutoCorrect.prepare (fromJust inputcmdname) cmdname cmds
(fuzzy, cmds, inputcmdname, args) = findCmd fuzzyok allargs allcmds
diff --git a/debian/changelog b/debian/changelog
index e1c85a0a5..d0f16cf05 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ git-annex (5.20150825) UNRELEASED; urgency=medium
* info: Support querying info of individual files in direct mode.
* unused: Fix reversion in 5.20150727 that broke parsing of the
--unused-refspec option. Thanks, Øyvind A. Holm.
+ * Make full option parsing be done when not in a git repo, so --help
+ can be displayed for commands that require a git repo, etc.
-- Joey Hess <id@joeyh.name> Tue, 01 Sep 2015 14:46:18 -0700
diff --git a/doc/bugs/--help_should_not_demand_being_in_the_git_repo.mdwn b/doc/bugs/--help_should_not_demand_being_in_the_git_repo.mdwn
index 0a7aa43fb..83ba3319f 100644
--- a/doc/bugs/--help_should_not_demand_being_in_the_git_repo.mdwn
+++ b/doc/bugs/--help_should_not_demand_being_in_the_git_repo.mdwn
@@ -22,3 +22,4 @@ remote types: git gcrypt S3 bup directory rsync web bittorrent webdav tahoe glac
YES -- lots of luck ;)
+> [[fixed|done]] --[[Joey]]