diff options
author | Joey Hess <joey@kitenet.net> | 2010-12-23 21:53:32 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-12-23 21:58:58 -0400 |
commit | 346c7a025780e011cdfdbb7eb27281f808a8de92 (patch) | |
tree | 3e8c9caef53105878f9378fbcd08e821ebe8540e /Command.hs | |
parent | 61b7f3dea3b54ead64cd5e957da28c83e7c25c85 (diff) |
Avoid multiple calls to git ls-files when passed eg, "*".
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Command.hs b/Command.hs index 69b9dee9f..e30904d0f 100644 --- a/Command.hs +++ b/Command.hs @@ -107,14 +107,14 @@ isAnnexed file a = do withFilesInGit :: SubCmdSeekStrings withFilesInGit a params = do repo <- Annex.gitRepo - files <- liftIO $ mapM (Git.inRepo repo) params - files' <- filterFiles $ foldl (++) [] files + files <- liftIO $ Git.inRepo repo params + files' <- filterFiles files return $ map a files' withAttrFilesInGit :: String -> SubCmdSeekAttrFiles withAttrFilesInGit attr a params = do repo <- Annex.gitRepo - files <- liftIO $ mapM (Git.inRepo repo) params - files' <- filterFiles $ foldl (++) [] files + files <- liftIO $ Git.inRepo repo params + files' <- filterFiles files pairs <- liftIO $ Git.checkAttr repo attr files' return $ map a pairs withFilesMissing :: SubCmdSeekStrings @@ -129,8 +129,8 @@ withFilesMissing a params = do withFilesNotInGit :: SubCmdSeekBackendFiles withFilesNotInGit a params = do repo <- Annex.gitRepo - newfiles <- liftIO $ mapM (Git.notInRepo repo) params - newfiles' <- filterFiles $ foldl (++) [] newfiles + newfiles <- liftIO $ Git.notInRepo repo params + newfiles' <- filterFiles newfiles backendPairs a newfiles' withString :: SubCmdSeekStrings withString a params = return [a $ unwords params] @@ -139,21 +139,20 @@ withStrings a params = return $ map a params withFilesToBeCommitted :: SubCmdSeekStrings withFilesToBeCommitted a params = do repo <- Annex.gitRepo - tocommit <- liftIO $ mapM (Git.stagedFiles repo) params - tocommit' <- filterFiles $ foldl (++) [] tocommit + tocommit <- liftIO $ Git.stagedFiles repo params + tocommit' <- filterFiles tocommit return $ map a tocommit' withFilesUnlocked :: SubCmdSeekBackendFiles withFilesUnlocked = withFilesUnlocked' Git.typeChangedFiles withFilesUnlockedToBeCommitted :: SubCmdSeekBackendFiles withFilesUnlockedToBeCommitted = withFilesUnlocked' Git.typeChangedStagedFiles -withFilesUnlocked' :: (Git.Repo -> FilePath -> IO [FilePath]) -> SubCmdSeekBackendFiles +withFilesUnlocked' :: (Git.Repo -> [FilePath] -> IO [FilePath]) -> SubCmdSeekBackendFiles withFilesUnlocked' typechanged a params = do -- unlocked files have changed type from a symlink to a regular file repo <- Annex.gitRepo - typechangedfiles <- liftIO $ mapM (typechanged repo) params + typechangedfiles <- liftIO $ typechanged repo params unlockedfiles <- liftIO $ filterM notSymlink $ - map (\f -> Git.workTree repo ++ "/" ++ f) $ - foldl (++) [] typechangedfiles + map (\f -> Git.workTree repo ++ "/" ++ f) typechangedfiles unlockedfiles' <- filterFiles unlockedfiles backendPairs a unlockedfiles' withKeys :: SubCmdSeekStrings |