diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-30 23:19:33 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-30 23:19:33 -0400 |
commit | c2651d64bc8a384f8669879c051577ee61da27ed (patch) | |
tree | ef94012f6fc43e5dc72f3c28e5998596142fa6b7 /GitRepo.hs | |
parent | 963bfa967369511bbe3261860c3609b5ae9554ec (diff) |
Fixed memory leak; git-annex no longer reads the whole file list from git before starting, and will be much faster with large repos.
Diffstat (limited to 'GitRepo.hs')
-rw-r--r-- | GitRepo.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/GitRepo.hs b/GitRepo.hs index c8ba77133..b6670e2eb 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -27,6 +27,7 @@ module GitRepo ( configTrue, run, pipeRead, + hPipeRead, attributes, remotes, remotesAdd, @@ -198,6 +199,17 @@ pipeRead repo params = assertLocal repo $ do ret <- hGetContentsStrict h return ret +{- Like pipeRead, but does not read output strictly; recommended + - for git commands that produce a lot of output that will be processed + - lazily. + - + - ONLY AFTER the string has been read completely, You must call either + - getProcessStatus or forceSuccess on the PipeHandle. Zombies will result + - otherwise.-} +hPipeRead :: Repo -> [String] -> IO (PipeHandle, String) +hPipeRead repo params = assertLocal repo $ do + pipeFrom "git" (gitCommandLine repo params) + {- Passed a location, recursively scans for all files that - are checked into git at that location. -} inRepo :: Repo -> FilePath -> IO [FilePath] @@ -221,7 +233,9 @@ stagedFiles repo location = pipeNullSplit repo - parameter), and splits it into a list of files. -} pipeNullSplit :: Repo -> [String] -> IO [FilePath] pipeNullSplit repo params = do - fs0 <- pipeRead repo params + -- XXX handle is left open, this is ok for git-annex, but may need + -- to be cleaned up for other uses. + (handle, fs0) <- hPipeRead repo params return $ split0 fs0 where split0 s = filter (not . null) $ split "\0" s |