diff options
author | Joey Hess <joey@kitenet.net> | 2014-04-17 18:41:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-04-17 18:41:24 -0400 |
commit | e23a4eb3c9e9a6bc39a5a59fe45300e8fdfb0916 (patch) | |
tree | d3a75a3f65edb6f8a02b7ce54553e3a9960fcc34 /CmdLine | |
parent | e9b6c350b15a93d82affadfabca18b3e95840cb1 (diff) |
findref: New command, like find but shows files in a specified git ref.
Diffstat (limited to 'CmdLine')
-rw-r--r-- | CmdLine/GitAnnex.hs | 2 | ||||
-rw-r--r-- | CmdLine/Seek.hs | 16 | ||||
-rw-r--r-- | CmdLine/Usage.hs | 2 |
3 files changed, 20 insertions, 0 deletions
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs index 523c3f055..c37e44a2d 100644 --- a/CmdLine/GitAnnex.hs +++ b/CmdLine/GitAnnex.hs @@ -49,6 +49,7 @@ import qualified Command.Unlock import qualified Command.Lock import qualified Command.PreCommit import qualified Command.Find +import qualified Command.FindRef import qualified Command.Whereis import qualified Command.List import qualified Command.Log @@ -158,6 +159,7 @@ cmds = concat , Command.DropUnused.def , Command.AddUnused.def , Command.Find.def + , Command.FindRef.def , Command.Whereis.def , Command.List.def , Command.Log.def 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) diff --git a/CmdLine/Usage.hs b/CmdLine/Usage.hs index 1d0bba954..6e0a1ca80 100644 --- a/CmdLine/Usage.hs +++ b/CmdLine/Usage.hs @@ -93,6 +93,8 @@ paramFormat :: String paramFormat = "FORMAT" paramFile :: String paramFile = "FILE" +paramRef :: String +paramRef = "REF" paramGroup :: String paramGroup = "GROUP" paramExpression :: String |