better name for fallback sync refs

Don't expose these as branches in refs/heads/. Instead hide them away in
refs/synced/ where only show-ref will find them.

Make unused only look at branches and tags, not these other things,
so it won't care if some stale sync ref used to use a file.

This means they don't need to be deleted, which could have
led to an incoming sync being missed.
This commit is contained in:
Joey Hess 2012-09-16 23:09:08 -04:00
parent 2081a31fda
commit ba744c84a4
4 changed files with 15 additions and 20 deletions

View file

@ -90,7 +90,7 @@ pushToRemotes threadname now st mpushmap remotes = do
go True branch g u remotes go True branch g u remotes
where where
go _ Nothing _ _ _ = return True -- no branch, so nothing to do go _ Nothing _ _ _ = return True -- no branch, so nothing to do
go shouldretry (Just branch) g u rs = do go shouldretry (Just branch) g u rs = do
debug threadname debug threadname
[ "pushing to" [ "pushing to"
, show rs , show rs
@ -133,12 +133,12 @@ pushToRemotes threadname now st mpushmap remotes = do
, Param $ refspec branch , Param $ refspec branch
] g ] g
where where
{- Push to refs/synced/uuid/branch; this
- avoids cluttering up the branch display. -}
refspec b = concat refspec b = concat
[ s [ s
, ":" , ":"
, show $ Git.Ref.base $ , "refs" </> "synced" </> fromUUID u </> s
Command.Sync.syncBranch $ Git.Ref $
"fallback" </> fromUUID u </> s
] ]
where s = show $ Git.Ref.base b where s = show $ Git.Ref.base b

View file

@ -15,18 +15,17 @@ import qualified Annex.Branch
import qualified Git import qualified Git
import qualified Git.Merge import qualified Git.Merge
import qualified Git.Branch import qualified Git.Branch
import qualified Git.Command as Git
thisThread :: ThreadName thisThread :: ThreadName
thisThread = "Merger" thisThread = "Merger"
{- This thread watches for changes to .git/refs/heads/synced/, {- This thread watches for changes to .git/refs/, looking for
- which indicate incoming pushes. It merges those pushes into the - incoming pushes. It merges those pushes into the currently
- currently checked out branch. -} - checked out branch. -}
mergeThread :: ThreadState -> NamedThread mergeThread :: ThreadState -> NamedThread
mergeThread st = thread $ do mergeThread st = thread $ do
g <- runThreadState st $ fromRepo id g <- runThreadState st $ fromRepo id
let dir = Git.localGitDir g </> "refs" </> "heads" </> "synced" let dir = Git.localGitDir g </> "refs"
createDirectoryIfMissing True dir createDirectoryIfMissing True dir
let hook a = Just $ runHandler g a let hook a = Just $ runHandler g a
let hooks = mkWatchHooks let hooks = mkWatchHooks
@ -82,11 +81,6 @@ onAdd g file _
, show current , show current
] ]
void $ Git.Merge.mergeNonInteractive changedbranch g void $ Git.Merge.mergeNonInteractive changedbranch g
when ("fallback/" `isInfixOf` (show changedbranch)) $
void $ Git.runBool "branch"
[ Param "-D"
, Param $ show changedbranch
] g
go _ = noop go _ = noop
equivBranches :: Git.Ref -> Git.Ref -> Bool equivBranches :: Git.Ref -> Git.Ref -> Bool
@ -100,6 +94,6 @@ isAnnexBranch f = n `isSuffixOf` f
n = "/" ++ show Annex.Branch.name n = "/" ++ show Annex.Branch.name
fileToBranch :: FilePath -> Git.Ref fileToBranch :: FilePath -> Git.Ref
fileToBranch f = Git.Ref $ "refs" </> "heads" </> base fileToBranch f = Git.Ref $ "refs" </> base
where where
base = Prelude.last $ split "/refs/heads/" f base = Prelude.last $ split "/refs/" f

View file

@ -251,7 +251,9 @@ withKeysReferencedInGit a = do
rs <- relevantrefs <$> showref rs <- relevantrefs <$> showref
forM_ rs (withKeysReferencedInGitRef a) forM_ rs (withKeysReferencedInGitRef a)
where where
showref = inRepo $ Git.Command.pipeRead [Param "show-ref"] {- List heads and tags, but not other refs used in syncing. -}
showref = inRepo $ Git.Command.pipeRead
[Param "show-ref", Param "--heads", Param "--tags"]
relevantrefs = map (Git.Ref . snd) . relevantrefs = map (Git.Ref . snd) .
nubBy uniqref . nubBy uniqref .
filter ourbranches . filter ourbranches .

View file

@ -49,9 +49,8 @@ sha branch repo = process <$> showref repo
{- List of (refs, branches) matching a given ref spec. -} {- List of (refs, branches) matching a given ref spec. -}
matching :: Ref -> Repo -> IO [(Ref, Branch)] matching :: Ref -> Repo -> IO [(Ref, Branch)]
matching ref repo = do matching ref repo = map gen . lines <$>
r <- pipeRead [Param "show-ref", Param $ show ref] repo pipeRead [Param "show-ref", Param $ show ref] repo
return $ map gen (lines r)
where where
gen l = let (r, b) = separate (== ' ') l in gen l = let (r, b) = separate (== ' ') l in
(Ref r, Ref b) (Ref r, Ref b)