aboutsummaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs50
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. -}