summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-21 18:24:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-21 18:24:29 -0400
commitb6ebb173e7b5d4d07577cb2918e7d1a24fbc1f60 (patch)
tree8c994e00b091c448d80737aa99bbc181701eee04 /Git
parent14f2a42ca4131a7a51a9e10a94521639b971bccd (diff)
XMPP: Avoid redundant and unncessary pushes. Note that this breaks compatibility with previous versions of git-annex, which will refuse to accept any XMPP pushes from this version.
Diffstat (limited to 'Git')
-rw-r--r--Git/Branch.hs3
-rw-r--r--Git/DiffTree.hs5
-rw-r--r--Git/Ref.hs21
-rw-r--r--Git/Types.hs2
4 files changed, 19 insertions, 12 deletions
diff --git a/Git/Branch.hs b/Git/Branch.hs
index 41ae2559e..d4a684016 100644
--- a/Git/Branch.hs
+++ b/Git/Branch.hs
@@ -13,6 +13,7 @@ import Common
import Git
import Git.Sha
import Git.Command
+import Git.Ref (headRef)
{- The currently checked out branch.
-
@@ -35,7 +36,7 @@ current r = do
{- The current branch, which may not really exist yet. -}
currentUnsafe :: Repo -> IO (Maybe Git.Ref)
currentUnsafe r = parse . firstLine
- <$> pipeReadStrict [Param "symbolic-ref", Param "HEAD"] r
+ <$> pipeReadStrict [Param "symbolic-ref", Param $ show headRef] r
where
parse l
| null l = Nothing
diff --git a/Git/DiffTree.hs b/Git/DiffTree.hs
index f122a4fb5..cf8a37600 100644
--- a/Git/DiffTree.hs
+++ b/Git/DiffTree.hs
@@ -46,7 +46,10 @@ diffTreeRecursive src dst = getdiff (Param "diff-tree")
diffIndex :: Repo -> IO ([DiffTreeItem], IO Bool)
diffIndex repo = do
ifM (Git.Ref.headExists repo)
- ( getdiff (Param "diff-index") [Param "--cached", Param "HEAD"] repo
+ ( getdiff (Param "diff-index")
+ [ Param "--cached"
+ , Param $ show Git.Ref.headRef
+ ] repo
, return ([], return True)
)
diff --git a/Git/Ref.hs b/Git/Ref.hs
index c98802cb7..d6e31897c 100644
--- a/Git/Ref.hs
+++ b/Git/Ref.hs
@@ -1,6 +1,6 @@
{- git ref stuff
-
- - Copyright 2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2011-2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -13,6 +13,9 @@ import Git.Command
import Data.Char (chr)
+headRef :: Ref
+headRef = Ref "HEAD"
+
{- Converts a fully qualified git ref into a user-visible string. -}
describe :: Ref -> String
describe = show . base
@@ -54,18 +57,18 @@ sha branch repo = process <$> showref repo
process [] = Nothing
process s = Just $ Ref $ firstLine s
-{- List of (refs, branches) matching a given ref spec. -}
-matching :: Ref -> Repo -> IO [(Ref, Branch)]
-matching ref repo = map gen . lines <$>
- pipeReadStrict [Param "show-ref", Param $ show ref] repo
+{- List of (shas, branches) matching a given ref or refs. -}
+matching :: [Ref] -> Repo -> IO [(Sha, Branch)]
+matching refs repo = map gen . lines <$>
+ pipeReadStrict (Param "show-ref" : map (Param . show) refs) repo
where
gen l = let (r, b) = separate (== ' ') l
in (Ref r, Ref b)
-{- List of (refs, branches) matching a given ref spec.
- - Duplicate refs are filtered out. -}
-matchingUniq :: Ref -> Repo -> IO [(Ref, Branch)]
-matchingUniq ref repo = nubBy uniqref <$> matching ref repo
+{- List of (shas, branches) matching a given ref spec.
+ - Duplicate shas are filtered out. -}
+matchingUniq :: [Ref] -> Repo -> IO [(Sha, Branch)]
+matchingUniq refs repo = nubBy uniqref <$> matching refs repo
where
uniqref (a, _) (b, _) = a == b
diff --git a/Git/Types.hs b/Git/Types.hs
index 57e5ca6e2..4765aad6c 100644
--- a/Git/Types.hs
+++ b/Git/Types.hs
@@ -41,7 +41,7 @@ data Repo = Repo
{- A git ref. Can be a sha1, or a branch or tag name. -}
newtype Ref = Ref String
- deriving (Eq)
+ deriving (Eq, Ord)
instance Show Ref where
show (Ref v) = v