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: When run in a view branch, refresh the view branch to reflect any
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
number, the same as git does.
* 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.
needMerge :: CurrBranch -> Git.Branch -> Annex (Maybe Git.Branch)
needMerge currbranch headbranch = ifM (allM id checks)
( return (Just syncbranch)
, return Nothing
)
needMerge currbranch headbranch
| is_branchView headbranch = return Nothing
| otherwise =
ifM (allM id checks)
( return (Just syncbranch)
, return Nothing
)
where
syncbranch = syncBranch headbranch
checks = case currbranch of
@ -463,7 +466,7 @@ updateBranches (Just branch, madj) = do
giveup $ "failed to update view"
-- 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 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)
tomerge = filterM (changed remote)
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 _o _remote (Nothing, _) = stop