finishing up sync in view branch

sync: When run in a view branch, avoid updating synced/ branches, or trying
to merge anything from remotes.

Sponsored-by: Erik Bjäreholt on Patreon
This commit is contained in:
Joey Hess 2023-02-10 15:27:42 -04:00
parent 9e59ebea52
commit c2b3e870df
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 13 additions and 6 deletions

View file

@ -11,6 +11,8 @@ git-annex (10.20230127) UNRELEASED; urgency=medium
* sync: Avoid pushing view branches to remotes. * sync: Avoid pushing view branches to remotes.
* sync: When run in a view branch, refresh the view branch to reflect any * sync: When run in a view branch, refresh the view branch to reflect any
changes that have been made to the parent branch or metadata. changes that have been made to the parent branch or metadata.
* sync: When run in a view branch, avoid updating synced/ branches,
or trying to merge anything from remotes.
* Support http urls that contain ":" that is not followed by a port * Support http urls that contain ":" that is not followed by a port
number, the same as git does. number, the same as git does.
* sync: Warn when the adjusted basis ref cannot be found, as happens eg when * sync: Warn when the adjusted basis ref cannot be found, as happens eg when

View file

@ -409,10 +409,13 @@ mergeLocal' _ _ currbranch@(Nothing, _) = inRepo Git.Branch.currentUnsafe >>= \c
-- Returns the branch that should be merged, if any. -- Returns the branch that should be merged, if any.
needMerge :: CurrBranch -> Git.Branch -> Annex (Maybe Git.Branch) needMerge :: CurrBranch -> Git.Branch -> Annex (Maybe Git.Branch)
needMerge currbranch headbranch = ifM (allM id checks) needMerge currbranch headbranch
( return (Just syncbranch) | is_branchView headbranch = return Nothing
, return Nothing | otherwise =
) ifM (allM id checks)
( return (Just syncbranch)
, return Nothing
)
where where
syncbranch = syncBranch headbranch syncbranch = syncBranch headbranch
checks = case currbranch of checks = case currbranch of
@ -463,7 +466,7 @@ updateBranches (Just branch, madj) = do
giveup $ "failed to update view" giveup $ "failed to update view"
-- Update the sync branch to match the new state of the branch -- Update the sync branch to match the new state of the branch
inRepo $ updateBranch (syncBranch branch) branch inRepo $ updateBranch (syncBranch branch) (fromViewBranch branch)
updateBranch :: Git.Branch -> Git.Branch -> Git.Repo -> IO () updateBranch :: Git.Branch -> Git.Branch -> Git.Repo -> IO ()
updateBranch syncbranch updateto g = updateBranch syncbranch updateto g =
@ -582,7 +585,9 @@ mergeRemote remote currbranch mergeconfig o = ifM isBareRepo
(mapM (merge currbranch mergeconfig o Git.Branch.ManualCommit . remoteBranch remote) =<< getlist) (mapM (merge currbranch mergeconfig o Git.Branch.ManualCommit . remoteBranch remote) =<< getlist)
tomerge = filterM (changed remote) tomerge = filterM (changed remote)
branchlist Nothing = [] branchlist Nothing = []
branchlist (Just branch) = [origBranch branch, syncBranch branch] branchlist (Just branch)
| is_branchView branch = []
| otherwise = [origBranch branch, syncBranch branch]
pushRemote :: SyncOptions -> Remote -> CurrBranch -> CommandStart pushRemote :: SyncOptions -> Remote -> CurrBranch -> CommandStart
pushRemote _o _remote (Nothing, _) = stop pushRemote _o _remote (Nothing, _) = stop