avoid sync pushing view branches to remotes, and better view branch names
* sync: Avoid pushing view branches to remotes. * Changed the name of view branches to include the parent branch. Existing view branches checked out using an old name will still work. It does not seem useful for sync to push view branches around, because the information in a view branch can entirely be derived from other information in git. And sync doesn't push adjusted branches around either. The better view branch names make it more in line with adjusted branch names, but were also needed to make fromViewBranch be able to return the original branch name. Kept the old view branch names still working. But, when those branches exist in a repo, sync will still try to push them as before. Avoiding that would need more complicated and/or expensive changes to sync. Sponsored-By: Boyd Stephen Smith Jr. on Patreon
This commit is contained in:
parent
b9d59cf721
commit
a11d6e0baf
3 changed files with 49 additions and 17 deletions
|
@ -21,7 +21,6 @@ module Command.Sync (
|
|||
commitMsg,
|
||||
pushBranch,
|
||||
updateBranch,
|
||||
syncBranch,
|
||||
updateBranches,
|
||||
seekExportContent,
|
||||
parseUnrelatedHistoriesOption,
|
||||
|
@ -60,6 +59,7 @@ import Annex.UUID
|
|||
import Logs.UUID
|
||||
import Logs.Export
|
||||
import Logs.PreferredContent
|
||||
import Logs.View (fromViewBranch)
|
||||
import Annex.AutoMerge
|
||||
import Annex.AdjustedBranch
|
||||
import Annex.AdjustedBranch.Merge
|
||||
|
@ -310,7 +310,10 @@ merge currbranch mergeconfig o commitmode tomerge = do
|
|||
(b, _) -> autoMergeFrom tomerge b mergeconfig commitmode canresolvemerge
|
||||
|
||||
syncBranch :: Git.Branch -> Git.Branch
|
||||
syncBranch = Git.Ref.underBase "refs/heads/synced" . fromAdjustedBranch
|
||||
syncBranch = Git.Ref.underBase "refs/heads/synced" . origBranch
|
||||
|
||||
origBranch :: Git.Branch -> Git.Branch
|
||||
origBranch = fromViewBranch . fromAdjustedBranch
|
||||
|
||||
remoteBranch :: Remote -> Git.Ref -> Git.Ref
|
||||
remoteBranch remote = Git.Ref.underBase $ "refs/remotes/" ++ Remote.name remote
|
||||
|
@ -565,7 +568,7 @@ mergeRemote remote currbranch mergeconfig o = ifM isBareRepo
|
|||
(mapM (merge currbranch mergeconfig o Git.Branch.ManualCommit . remoteBranch remote) =<< getlist)
|
||||
tomerge = filterM (changed remote)
|
||||
branchlist Nothing = []
|
||||
branchlist (Just branch) = [fromAdjustedBranch branch, syncBranch branch]
|
||||
branchlist (Just branch) = [origBranch branch, syncBranch branch]
|
||||
|
||||
pushRemote :: SyncOptions -> Remote -> CurrBranch -> CommandStart
|
||||
pushRemote _o _remote (Nothing, _) = stop
|
||||
|
@ -654,7 +657,7 @@ pushBranch :: Remote -> Maybe Git.Branch -> MessageState -> Git.Repo -> IO Bool
|
|||
pushBranch remote mbranch ms g = directpush `after` annexpush `after` syncpush
|
||||
where
|
||||
syncpush = flip Git.Command.runBool g $ pushparams $ catMaybes
|
||||
[ (refspec . fromAdjustedBranch) <$> mbranch
|
||||
[ (refspec . origBranch) <$> mbranch
|
||||
, Just $ Git.Branch.forcePush $ refspec Annex.Branch.name
|
||||
]
|
||||
annexpush = void $ tryIO $ flip Git.Command.runQuiet g $ pushparams
|
||||
|
@ -673,7 +676,7 @@ pushBranch remote mbranch ms g = directpush `after` annexpush `after` syncpush
|
|||
-- will want to see that one.
|
||||
Just branch -> do
|
||||
let p = flip Git.Command.gitCreateProcess g $ pushparams
|
||||
[ Git.fromRef $ Git.Ref.base $ fromAdjustedBranch branch ]
|
||||
[ Git.fromRef $ Git.Ref.base $ origBranch branch ]
|
||||
(transcript, ok) <- processTranscript' p Nothing
|
||||
when (not ok && not ("denyCurrentBranch" `isInfixOf` transcript)) $
|
||||
hPutStr stderr transcript
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue