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.
This commit is contained in:
parent
700d5683a9
commit
08c03b2af3
11 changed files with 77 additions and 27 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
)
|
||||
|
||||
|
|
21
Git/Ref.hs
21
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue