aboutsummaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-07 13:55:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-07 14:07:25 -0400
commitff03a89236956904b617e02468102e5d390306bd (patch)
tree7095a8d9b4491c2c777cf0d39ad8d4f0da3c6c1e /Git
parent8aec790a7aefba4dc2e8e0d219d333c12ad585e3 (diff)
add new status command
This works for both direct and indirect mode. It may need some performance tuning. Note that unlike git status, it only shows the status of the work tree, not the status of the index. So only one status letter, not two .. and since files that have been added and not yet committed do not differ between the work tree and the index, they are not shown. Might want to add display of the index vs the last commit eventually. This commit was sponsored by an unknown bitcoin contributor, whose contribution as been going up lately! ;)
Diffstat (limited to 'Git')
-rw-r--r--Git/LsFiles.hs7
-rw-r--r--Git/Ref.hs14
2 files changed, 21 insertions, 0 deletions
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index 98cbac58e..8aaa09067 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -11,6 +11,7 @@ module Git.LsFiles (
allFiles,
deleted,
modified,
+ modifiedOthers,
staged,
stagedNotDeleted,
stagedOthersDetails,
@@ -65,6 +66,12 @@ modified l repo = pipeNullSplit params repo
where
params = [Params "ls-files --modified -z --"] ++ map File l
+{- Files that have been modified or are not checked into git. -}
+modifiedOthers :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
+modifiedOthers l repo = pipeNullSplit params repo
+ where
+ params = [Params "ls-files --modified --others -z --"] ++ map File l
+
{- Returns a list of all files that are staged for commit. -}
staged :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
staged = staged' []
diff --git a/Git/Ref.hs b/Git/Ref.hs
index 5057180d1..6ce1b8784 100644
--- a/Git/Ref.hs
+++ b/Git/Ref.hs
@@ -41,6 +41,20 @@ under dir r = Ref $ dir ++ "/" ++
underBase :: String -> Ref -> Ref
underBase dir r = Ref $ dir ++ "/" ++ show (base r)
+{- A Ref that can be used to refer to a file in the repository, as staged
+ - in the index.
+ -
+ - Prefixing the file with ./ makes this work even if in a subdirectory
+ - of a repo.
+ -}
+fileRef :: FilePath -> Ref
+fileRef f = Ref $ ":./" ++ f
+
+{- A Ref that can be used to refer to a file in the repository as it
+ - appears in a given Ref. -}
+fileFromRef :: Ref -> FilePath -> Ref
+fileFromRef (Ref r) f = let (Ref fr) = fileRef f in Ref (r ++ fr)
+
{- Checks if a ref exists. -}
exists :: Ref -> Repo -> IO Bool
exists ref = runBool