079b35a1a8
When constructing views, metadata is available about the location of the file in the view's reference branch. Allows incorporating parts of the directory hierarchy in a view. For example `git annex view tag=* podcasts/=*` makes a view in the form tag/showname. Performance impact: I benchmarked git annex view tag=* in the conference proceedings repo to take 6.459s before this change, and 6.544s after. FWIW, I considered making the syntax for this be podcasts/*, which might be easier for the user to learn. However, I think it's not as good: * The user has to then juggle two different syntaxes, and podcasts/* will be expanded by the shell so they also need to quote it, while podcasts/=* is unlikely to be expanded by the shell. * It would allow for things like podcasts/*/* and *.mp3 which do not map well into views. This commit was sponsored by Aurélien Pinceaux.
36 lines
1.1 KiB
Haskell
36 lines
1.1 KiB
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2014 Joey Hess <joey@kitenet.net>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.VAdd where
|
|
|
|
import Common.Annex
|
|
import Command
|
|
import Annex.View
|
|
import Command.View (parseViewParam, checkoutViewBranch)
|
|
|
|
def :: [Command]
|
|
def = [notBareRepo $ notDirect $ command "vadd" (paramRepeating "FIELD=GLOB")
|
|
seek SectionMetaData "add subdirs to current view"]
|
|
|
|
seek :: CommandSeek
|
|
seek = withWords start
|
|
|
|
start :: [String] -> CommandStart
|
|
start params = do
|
|
showStart "vadd" ""
|
|
withCurrentView $ \view -> do
|
|
let (view', change) = refineView view $
|
|
map parseViewParam $ reverse params
|
|
case change of
|
|
Unchanged -> do
|
|
showNote "unchanged"
|
|
next $ next $ return True
|
|
Narrowing -> next $ next $ do
|
|
if visibleViewSize view' == visibleViewSize view
|
|
then error "That would not add an additional level of directory structure to the view. To filter the view, use vfilter instead of vadd."
|
|
else checkoutViewBranch view' narrowView
|
|
Widening -> error "Widening view to match more files is not currently supported."
|