aboutsummaryrefslogtreecommitdiff
path: root/Command/View.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-02 16:00:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-02 16:00:56 -0400
commite3cfcfb6d8f5bdb198813b065df07e9665262770 (patch)
tree46a39ced3c0308a578b1f47b9d3da16f744dfd18 /Command/View.hs
parent3a6b9a7fdea3b4acea43a51d4656efe62f36238c (diff)
view: Refuse to enter a view when no branch is currently checked out.
Diffstat (limited to 'Command/View.hs')
-rw-r--r--Command/View.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/Command/View.hs b/Command/View.hs
index 155b6057d..93b045c39 100644
--- a/Command/View.hs
+++ b/Command/View.hs
@@ -45,13 +45,11 @@ paramView :: String
paramView = paramPair (paramRepeating "TAG") (paramRepeating "FIELD=VALUE")
mkView :: [String] -> Annex View
-mkView params = do
- v <- View <$> viewbranch <*> pure []
- return $ fst $ refineView v $
- map parseViewParam $ reverse params
+mkView params = go =<< inRepo Git.Branch.current
where
- viewbranch = fromMaybe (error "not on any branch!")
- <$> inRepo Git.Branch.current
+ go Nothing = error "not on any branch!"
+ go (Just b) = return $ fst $ refineView (View b []) $
+ map parseViewParam $ reverse params
checkoutViewBranch :: View -> (View -> Annex Git.Branch) -> CommandCleanup
checkoutViewBranch view mkbranch = do