diff options
author | 2014-04-17 18:41:24 -0400 | |
---|---|---|
committer | 2014-04-17 18:41:24 -0400 | |
commit | e23a4eb3c9e9a6bc39a5a59fe45300e8fdfb0916 (patch) | |
tree | d3a75a3f65edb6f8a02b7ce54553e3a9960fcc34 /CmdLine/Seek.hs | |
parent | e9b6c350b15a93d82affadfabca18b3e95840cb1 (diff) |
findref: New command, like find but shows files in a specified git ref.
Diffstat (limited to 'CmdLine/Seek.hs')
-rw-r--r-- | CmdLine/Seek.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index abbe52af8..431b2e118 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -19,6 +19,8 @@ import qualified Annex import qualified Git import qualified Git.Command import qualified Git.LsFiles as LsFiles +import qualified Git.LsTree as LsTree +import Git.FilePath import qualified Limit import CmdLine.Option import CmdLine.Action @@ -49,6 +51,20 @@ withFilesNotInGit skipdotfiles a params go l = seekActions $ prepFiltered a $ return $ concat $ segmentPaths params l +withFilesInRefs :: (FilePath -> Key -> CommandStart) -> CommandSeek +withFilesInRefs a = mapM_ go + where + go r = do + matcher <- Limit.getMatcher + l <- inRepo $ LsTree.lsTree (Git.Ref r) + forM_ l $ \i -> do + let f = getTopFilePath $ LsTree.file i + v <- catKey (Git.Ref $ LsTree.sha i) (LsTree.mode i) + case v of + Nothing -> noop + Just k -> whenM (matcher $ MatchingKey k) $ + void $ commandAction $ a f k + withPathContents :: ((FilePath, FilePath) -> CommandStart) -> CommandSeek withPathContents a params = seekActions $ map a . concat <$> liftIO (mapM get params) |