summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-12 19:20:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-12 19:20:38 -0400
commit3e55a8f164d67d5bd1ef86ae2f38fb2c6c3a51b2 (patch)
treea3115943cd1b5a86f9419a8042f469655234937a /Git
parentdb6cbec803a17d8e7eebdd3443713b8ea6ddb091 (diff)
direct mode committing
Diffstat (limited to 'Git')
-rw-r--r--Git/LsFiles.hs20
1 files changed, 14 insertions, 6 deletions
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index e264dee8b..45c830cd6 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -10,7 +10,7 @@ module Git.LsFiles (
notInRepo,
staged,
stagedNotDeleted,
- notStaged,
+ stagedDetails,
typeChanged,
typeChangedStaged,
Conflicting(..),
@@ -53,13 +53,21 @@ staged' ps l = pipeNullSplit $ prefix ++ ps ++ suffix
prefix = [Params "diff --cached --name-only -z"]
suffix = Param "--" : map File l
-{- Returns a list of all files that have unstaged changes. This includes
- - any new files, that have not been added yet. -}
-notStaged :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
-notStaged l repo = pipeNullSplit params repo
+{- Returns details about files that are staged in the index
+ - (including the Sha of their staged contents),
+ - as well as files not yet in git. -}
+stagedDetails :: [FilePath] -> Repo -> IO ([(FilePath, Maybe Sha)], IO Bool)
+stagedDetails l repo = do
+ (ls, cleanup) <- pipeNullSplit params repo
+ return (map parse ls, cleanup)
where
- params = [Params "ls-files --others --deleted --modified --exclude-standard -z --"] ++
+ params = [Params "ls-files --others --exclude-standard --stage -z --"] ++
map File l
+ parse s
+ | null file = (s, Nothing)
+ | otherwise = (file, extractSha $ take shaSize $ drop 7 metadata)
+ where
+ (metadata, file) = separate (== '\t') s
{- Returns a list of the files in the specified locations that are staged
- for commit, and whose type has changed. -}