summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-09-19 14:48:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-09-19 14:48:42 -0400
commit2ec103cb68110deee36e8445d7320d0297ed4342 (patch)
treea57c1f474343773854f726b3ca3531af2d4cfbcd /Git
parent5f90fe2a343ba513682513d1b1b8019f85b1ac9f (diff)
sync, pre-commit, indirect: Avoid unnecessarily catting non-symlink files from git, which can be so large it runs out of memory.
Diffstat (limited to 'Git')
-rw-r--r--Git/LsFiles.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index e2e29ea36..8a5d4bd6a 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -28,6 +28,9 @@ import Git.Command
import Git.Types
import Git.Sha
+import Numeric
+import System.Posix.Types
+
{- Scans for files that are checked into git at the specified locations. -}
inRepo :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
inRepo l = pipeNullSplit $ Params "ls-files --cached -z --" : map File l
@@ -78,16 +81,16 @@ staged' ps l = pipeNullSplit $ prefix ++ ps ++ suffix
{- Returns details about files that are staged in the index,
- as well as files not yet in git. Skips ignored files. -}
-stagedOthersDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
+stagedOthersDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha, Maybe FileMode)], IO Bool)
stagedOthersDetails = stagedDetails' [Params "--others --exclude-standard"]
{- Returns details about all files that are staged in the index. -}
-stagedDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
+stagedDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha, Maybe FileMode)], IO Bool)
stagedDetails = stagedDetails' []
{- Gets details about staged files, including the Sha of their staged
- contents. -}
-stagedDetails' :: [CommandParam] -> [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
+stagedDetails' :: [CommandParam] -> [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha, Maybe FileMode)], IO Bool)
stagedDetails' ps l repo = do
(ls, cleanup) <- pipeNullSplit params repo
return (map parse ls, cleanup)
@@ -95,10 +98,12 @@ stagedDetails' ps l repo = do
params = Params "ls-files --stage -z" : ps ++
Param "--" : map File l
parse s
- | null file = (s, Nothing)
- | otherwise = (file, extractSha $ take shaSize $ drop 7 metadata)
+ | null file = (s, Nothing, Nothing)
+ | otherwise = (file, extractSha $ take shaSize rest, readmode mode)
where
(metadata, file) = separate (== '\t') s
+ (mode, rest) = separate (== ' ') metadata
+ readmode = headMaybe . readOct >=*> fst
{- Returns a list of the files in the specified locations that are staged
- for commit, and whose type has changed. -}