aa0350ff49
* view: New field?=glob and ?tag syntax that includes a directory "_" in the view for files that do not have the specified metadata set. * Added annex.viewunsetdirectory git config to change the name of the "_" directory in a view. When in a view using the new syntax, old git-annex will fail to parse the view log. It errors with "Not in a view.", which is not ideal. But that only affects view commands. annex.viewunsetdirectory is included in the View for a couple of reasons. One is to avoid needing to warn the user that it should not be changed when in a view, since that would confuse git-annex. Another reason is that it helped with plumbing the value through to some pure functions. annex.viewunsetdirectory is actually mangled the same as any other view directory. So if it's configured to something like "N/A", there won't be multiple levels of directories, which would also confuse git-annex. Sponsored-By: Jack Hill on Patreon
31 lines
1,010 B
Haskell
31 lines
1,010 B
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.VFilter where
|
|
|
|
import Command
|
|
import qualified Annex
|
|
import Annex.View
|
|
import Command.View (paramView, checkoutViewBranch)
|
|
|
|
cmd :: Command
|
|
cmd = notBareRepo $
|
|
command "vfilter" SectionMetaData "filter current view"
|
|
paramView (withParams seek)
|
|
|
|
seek :: CmdParams -> CommandSeek
|
|
seek = withWords (commandAction . start)
|
|
|
|
start :: [String] -> CommandStart
|
|
start params = starting "vfilter" (ActionItemOther Nothing) (SeekInput params) $
|
|
withCurrentView $ \view -> do
|
|
vu <- annexViewUnsetDirectory <$> Annex.getGitConfig
|
|
let view' = filterView view $
|
|
map (parseViewParam vu) (reverse params)
|
|
next $ if visibleViewSize view' > visibleViewSize view
|
|
then giveup "That would add an additional level of directory structure to the view, rather than filtering it. If you want to do that, use vadd instead of vfilter."
|
|
else checkoutViewBranch view' narrowView
|