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 /GitRepo.hs | |
parent | 61b7f3dea3b54ead64cd5e957da28c83e7c25c85 (diff) |
Avoid multiple calls to git ls-files when passed eg, "*".
Diffstat (limited to 'GitRepo.hs')
-rw-r--r-- | GitRepo.hs | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/GitRepo.hs b/GitRepo.hs index 1ce6b8aec..122b5cc60 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -230,41 +230,39 @@ 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] -inRepo repo l = pipeNullSplit repo - ["ls-files", "--cached", "--exclude-standard", "-z", "--", l] - -{- Passed a location, recursively scans for all files that are not checked - - into git, and not gitignored. -} -notInRepo :: Repo -> FilePath -> IO [FilePath] -notInRepo repo l = pipeNullSplit repo - ["ls-files", "--others", "--exclude-standard", "-z", "--", l] - -{- Passed a location, returns a list of the files, staged for - - commit, that are being added, moved, or changed (but not deleted). -} -stagedFiles :: Repo -> FilePath -> IO [FilePath] -stagedFiles repo l = pipeNullSplit repo +{- Scans for files that are checked into git at the specified locations. -} +inRepo :: Repo -> [FilePath] -> IO [FilePath] +inRepo repo l = pipeNullSplit repo $ + ["ls-files", "--cached", "--exclude-standard", "-z", "--"] ++ l + +{- Scans for files at the specified locations that are not checked into git, + - and not gitignored. -} +notInRepo :: Repo -> [FilePath] -> IO [FilePath] +notInRepo repo l = pipeNullSplit repo $ + ["ls-files", "--others", "--exclude-standard", "-z", "--"] ++ l + +{- Returns a list of the files, staged for commit, that are being added, + - moved, or changed (but not deleted), from the specified locations. -} +stagedFiles :: Repo -> [FilePath] -> IO [FilePath] +stagedFiles repo l = pipeNullSplit repo $ ["diff", "--cached", "--name-only", "--diff-filter=ACMRT", "-z", - "--", l] + "--"] ++ l -{- Passed a location, returns a list of the files, staged for - - commit, whose type has changed. -} -typeChangedStagedFiles :: Repo -> FilePath -> IO [FilePath] +{- Returns a list of the files in the specified locations that are staged + - for commit, and whose type has changed. -} +typeChangedStagedFiles :: Repo -> [FilePath] -> IO [FilePath] typeChangedStagedFiles repo l = typeChangedFiles' repo l ["--cached"] -{- Passed a location, returns a list of the files whose type has changed. - - Files only staged for commit will not be included. -} -typeChangedFiles :: Repo -> FilePath -> IO [FilePath] +{- Returns a list of the files in the specified locations whose type has + - changed. Files only staged for commit will not be included. -} +typeChangedFiles :: Repo -> [FilePath] -> IO [FilePath] typeChangedFiles repo l = typeChangedFiles' repo l [] -typeChangedFiles' :: Repo -> FilePath -> [String] -> IO [FilePath] +typeChangedFiles' :: Repo -> [FilePath] -> [String] -> IO [FilePath] typeChangedFiles' repo l middle = pipeNullSplit repo $ start ++ middle ++ end where start = ["diff", "--name-only", "--diff-filter=T", "-z"] - end = ["--", l] - + end = ["--"] ++ l {- Reads null terminated output of a git command (as enabled by the -z - parameter), and splits it into a list of files. -} |