summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-14 12:35:05 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-14 12:35:05 -0400
commita5c4dd974396d1dc9c3e55381215a904fa997cd2 (patch)
tree8f7f98fab145050b7f99ffe3358a7b616f171dd9
parent54d0f73e67135ec675953d608d0780dfbb130f5d (diff)
find: New subcommand.
-rw-r--r--CmdLine.hs3
-rw-r--r--Command.hs7
-rw-r--r--Command/Find.hs24
-rw-r--r--debian/changelog6
-rw-r--r--doc/git-annex.mdwn7
5 files changed, 47 insertions, 0 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index a683be5c5..caf727946 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -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 ..."
diff --git a/Command.hs b/Command.hs
index 40a21cacc..60d82d09f 100644
--- a/Command.hs
+++ b/Command.hs
@@ -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
diff --git a/Command/Find.hs b/Command/Find.hs
new file mode 100644
index 000000000..db0589fea
--- /dev/null
+++ b/Command/Find.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 64973557f..07eceae6c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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.
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 61a5962f1..c496ca0d8 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -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