aboutsummaryrefslogtreecommitdiff
path: root/Git/DiffTree.hs
diff options
context:
space:
mode:
authorGravatar guilhem <guilhem@fripost.org>2013-08-26 19:01:48 +0200
committerGravatar Joey Hess <joey@kitenet.net>2013-08-26 13:50:09 -0400
commit2e8389360c1180cc85547e0d555cabdd3813980c (patch)
treeef1deecc31cae8db3b8925e198c770607e79ee75 /Git/DiffTree.hs
parent499a3e6da79d752dab0b4c62c0f0e17db82aa2d6 (diff)
Unused: bugfix
Detect staged files that are not in the working tree.
Diffstat (limited to 'Git/DiffTree.hs')
-rw-r--r--Git/DiffTree.hs20
1 files changed, 16 insertions, 4 deletions
diff --git a/Git/DiffTree.hs b/Git/DiffTree.hs
index 8f85fcc34..62330612c 100644
--- a/Git/DiffTree.hs
+++ b/Git/DiffTree.hs
@@ -10,6 +10,7 @@ module Git.DiffTree (
diffTree,
diffTreeRecursive,
diffIndex,
+ diffWorkTree,
) where
import Numeric
@@ -44,12 +45,23 @@ diffTreeRecursive src dst = getdiff (Param "diff-tree")
{- Diffs between a tree and the index. Does nothing if there is not yet a
- commit in the repository. -}
diffIndex :: Ref -> Repo -> IO ([DiffTreeItem], IO Bool)
-diffIndex ref repo = do
+diffIndex ref = diffIndex' ref [Param "--cached"]
+
+{- Diffs between a tree and the working tree. Does nothing if there is not
+ - yet a commit in the repository, of if the repository is bare. -}
+diffWorkTree :: Ref -> Repo -> IO ([DiffTreeItem], IO Bool)
+diffWorkTree ref repo =
+ ifM (Git.Ref.headExists repo)
+ ( diffIndex' ref [] repo
+ , return ([], return True)
+ )
+
+diffIndex' :: Ref -> [CommandParam] -> Repo -> IO ([DiffTreeItem], IO Bool)
+diffIndex' ref params repo =
ifM (Git.Ref.headExists repo)
( getdiff (Param "diff-index")
- [ Param "--cached"
- , Param $ show ref
- ] repo
+ ( params ++ [Param $ show ref] )
+ repo
, return ([], return True)
)