find: New subcommand.

This commit is contained in:
Joey Hess 2010-11-14 12:35:05 -04:00
parent 54d0f73e67
commit a5c4dd9743
5 changed files with 47 additions and 0 deletions

View file

@ -28,6 +28,7 @@ import qualified Command.Fsck
import qualified Command.Unlock
import qualified Command.Lock
import qualified Command.PreCommit
import qualified Command.Find
subCmds :: [SubCommand]
subCmds =
@ -61,6 +62,8 @@ subCmds =
"fix up symlinks to point to annexed content"
, SubCommand "fsck" maybepath Command.Fsck.seek
"check for problems"
, SubCommand "find" maybepath Command.Find.seek
"lists available files"
]
where
path = "PATH ..."

View file

@ -158,6 +158,13 @@ withAll w a params = do
w a [Git.workTree g]
else w a params
{- Provides a default parameter to a with search. -}
withDefault :: String-> SubCmdSeekStrings -> SubCmdSeekStrings
withDefault d w a params = do
if null params
then w a [d]
else w a params
{- filter out files from the state directory -}
notState :: FilePath -> Bool
notState f = stateLoc /= take (length stateLoc) f

24
Command/Find.hs Normal file
View file

@ -0,0 +1,24 @@
{- git-annex command
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Find where
import Control.Monad (when)
import Control.Monad.State (liftIO)
import Command
import Core
seek :: [SubCmdSeek]
seek = [withDefault "." withFilesInGit start]
{- Output a list of files. -}
start :: SubCmdStartString
start file = isAnnexed file $ \(key, _) -> do
exists <- inAnnex key
when (exists) $ liftIO $ putStrLn file
return Nothing

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
git-annex (0.07) UNRELEASED; urgency=low
* find: New subcommand.
-- Joey Hess <joeyh@debian.org> Sun, 14 Nov 2010 12:34:49 -0400
git-annex (0.06) unstable; urgency=low
* fsck: Check if annex.numcopies is satisfied.

View file

@ -166,6 +166,13 @@ Many git-annex subcommands will stage changes for later `git commit` by you.
With parameters, only the specified files are checked.
* find [path ...]
Outputs a list of annexed files whose content is currently present.
With no parameters, defaults to finding all files in the current directory
and its subdirectories.
# OPTIONS
* --force