diff options
author | guilhem <guilhem@fripost.org> | 2013-08-26 19:01:48 +0200 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-08-26 13:50:09 -0400 |
commit | 2e8389360c1180cc85547e0d555cabdd3813980c (patch) | |
tree | ef1deecc31cae8db3b8925e198c770607e79ee75 /Git | |
parent | 499a3e6da79d752dab0b4c62c0f0e17db82aa2d6 (diff) |
Unused: bugfix
Detect staged files that are not in the working tree.
Diffstat (limited to 'Git')
-rw-r--r-- | Git/DiffTree.hs | 20 |
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) ) |