summaryrefslogtreecommitdiff
path: root/GitRepo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-02-01 21:58:47 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-02-01 22:02:19 -0400
commit0e7984a79354135f265d2342608953104d15db2e (patch)
tree6b8e59e6ca893cb05baff374c78accc4e284dfad /GitRepo.hs
parentc77ac11acc10efc23acfa3d81e1deaac11cb724f (diff)
add check for unclean tree
Diffstat (limited to 'GitRepo.hs')
-rw-r--r--GitRepo.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index 4e69544d4..031a9cbe2 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -38,6 +38,7 @@ module GitRepo (
inRepo,
notInRepo,
stagedFiles,
+ stagedFilesNotDeleted,
changedUnstagedFiles,
checkAttr,
decodeGitFile,
@@ -243,12 +244,20 @@ notInRepo :: Repo -> [FilePath] -> IO [FilePath]
notInRepo repo l = pipeNullSplit repo $
["ls-files", "--others", "--exclude-standard", "-z", "--"] ++ l
+{- Returns a list of all files that are staged for commit. -}
+stagedFiles :: Repo -> [FilePath] -> IO [FilePath]
+stagedFiles repo l = stagedFiles' repo 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
+stagedFilesNotDeleted :: Repo -> [FilePath] -> IO [FilePath]
+stagedFilesNotDeleted repo l = stagedFiles' repo l ["--diff-filter=ACMRT"]
+
+stagedFiles' :: Repo -> [FilePath] -> [String] -> IO [FilePath]
+stagedFiles' repo l middle = pipeNullSplit repo $ start ++ middle ++ end
+ where
+ start = ["diff", "--cached", "--name-only", "-z"]
+ end = ["--"] ++ l
{- Returns a list of files that have unstaged changes. -}
changedUnstagedFiles :: Repo -> [FilePath] -> IO [FilePath]