support --unlock-present adjustment of view branches

When generating the view, check if the key is present.

When syncing in a view branch with an adjustment, run adjustedBranchRefreshFull
the same as is done when syncing in other adjusted branches. This is
needed because the docs for git-annex adjust --unlock-present suggest
using git-annex sync to update the branch when annex.adjustedbranchrefresh
is not set.

Note that, with annex.adjustedbranchrefresh set, it just works! The
adjusted branch gets updated in the usual way and it doesn't matter that
there's a view branch underneath.

And of course, re-running git-annex adjut --unlock-present also works,
as suggested in the docs.

Sponsored-by: Erik Bjäreholt on Patreon
This commit is contained in:
Joey Hess 2023-02-27 15:29:28 -04:00
parent 7d839176c3
commit 1c4f4b449a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 40 additions and 11 deletions

View file

@ -451,23 +451,26 @@ updateBranches (Just branch, madj) = do
]
unless ok $
giveup $ "failed to update view"
case madj' of
Nothing -> noop
Just adj -> updateadjustedbranch adj
-- When in an adjusted branch, propigate any changes
-- made to it back to the original branch. The adjusted
-- branch may also need to be updated, if the adjustment
-- is not stable, and the usual configuration does not
-- update it.
-- made to it back to the original branch.
Nothing -> case madj of
Just adj -> do
let origbranch = branch
propigateAdjustedCommits origbranch adj
unless (adjustmentIsStable adj) $
annexAdjustedBranchRefresh <$> Annex.getGitConfig >>= \case
0 -> adjustedBranchRefreshFull adj origbranch
_ -> return ()
propigateAdjustedCommits branch adj
updateadjustedbranch adj
Nothing -> noop
-- Update the sync branch to match the new state of the branch
inRepo $ updateBranch (syncBranch branch) (fromViewBranch branch)
where
-- The adjusted branch may also need to be updated, if the adjustment
-- is not stable, and the usual configuration does not update it.
updateadjustedbranch adj = unless (adjustmentIsStable adj) $
annexAdjustedBranchRefresh <$> Annex.getGitConfig >>= \case
0 -> adjustedBranchRefreshFull adj branch
_ -> return ()
updateBranch :: Git.Branch -> Git.Branch -> Git.Repo -> IO ()
updateBranch syncbranch updateto g =