view: Refuse to enter a view when no branch is currently checked out.

This commit is contained in:
Joey Hess 2014-03-02 16:00:56 -04:00
parent 06e39e6a79
commit 0ac8912f9c
2 changed files with 5 additions and 6 deletions

View file

@ -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