From c2651d64bc8a384f8669879c051577ee61da27ed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 30 Oct 2010 23:19:33 -0400 Subject: [PATCH] Fixed memory leak; git-annex no longer reads the whole file list from git before starting, and will be much faster with large repos. --- GitRepo.hs | 16 +++++++++++++++- debian/changelog | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/GitRepo.hs b/GitRepo.hs index c8ba77133c..b6670e2ebe 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 diff --git a/debian/changelog b/debian/changelog index d6cc73e49e..70e9052231 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ git-annex (0.03) UNRELEASED; urgency=low * Fix SIGINT handling. * Fix handling of files with unusual characters in their name. * Support building with Debian stable's ghc. + * Fixed memory leak; git-annex no longer reads the whole file list + from git before starting, and will be much faster with large repos. -- Joey Hess Thu, 28 Oct 2010 13:46:59 -0400