support --unlock-present adjustment of view branches
authorJoey Hess <joeyh@joeyh.name>
Mon, 27 Feb 2023 19:29:28 +0000 (15:29 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 27 Feb 2023 19:37:57 +0000 (15:37 -0400)
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
Annex/View.hs
CHANGELOG
Command/Sync.hs
doc/git-annex-adjust.mdwn
doc/git-annex-view.mdwn

index 35ba205707305b1d9484fd32f67436de22ac683c..55ac5ba0970b7517efe5a4f1b963d79cba719ca7 100644 (file)
@@ -33,6 +33,7 @@ import Annex.GitOverlay
 import Annex.Link
 import Annex.CatFile
 import Annex.Concurrent
+import Annex.Content.Presence
 import Logs
 import Logs.MetaData
 import Logs.View
@@ -510,6 +511,15 @@ applyView'' mkviewedfile getfilemetadata view madj l clean conv = do
                Nothing -> stagesymlink uh f k
                Just (LinkAdjustment UnlockAdjustment) ->
                        stagepointerfile uh f k mtreeitemtype
+               Just (LinkPresentAdjustment UnlockPresentAdjustment) ->
+                       ifM (inAnnex k)
+                               ( stagepointerfile uh f k mtreeitemtype
+                               , stagesymlink uh f k
+                               )
+               Just (PresenceAdjustment HideMissingAdjustment _) ->
+                       whenM (inAnnex k)
+                               ( stagesymlink uh f k
+                               )
                _ -> stagesymlink uh f k
 
        stagesymlink uh f k = do
index 0f7c7ce6c76db5de4ec6a52b7c89a58a419316e8..407f6a238a8ddf38d8b521bf18b71be95f7e62b6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,11 @@
+git-annex (10.20230228) UNRELEASED; urgency=medium
+
+  * Support adjusted view branches. Using git-annex view in an adjusted
+    branch, or git-annex adjust in a view branch will enter an adjusted
+    view branch. --unlock and --unlock-present adjustments are supported.
+
+ -- Joey Hess <id@joeyh.name>  Mon, 27 Feb 2023 12:31:14 -0400
+
 git-annex (10.20230227) upstream; urgency=medium
 
   * Fix more breakage caused by git's fix for CVE-2022-24765, this time
index f37895059212657fe5cbc373fca5f8aaee020c79..8a977cfc2c60cda65e94298549279134d768f438 100644 (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 = 
index 746e2870692907f5f331521d25e51bc0a21db8b3..fd573ec904568dceda6a77c02e5c0faac715c194 100644 (file)
@@ -59,7 +59,7 @@ and will also propagate commits back to the original branch.
 
 * `--lock`
 
-  Lock all annexed file in the adjusted branch. This may be preferred
+  Lock all annexed files in the adjusted branch. This may be preferred
   by those who like seeing broken symlinks when the content of an
   annexed file is not present.
 
@@ -128,6 +128,8 @@ and will also propagate commits back to the original branch.
 
 [[git-annex-sync]](1)
 
+[[git-annex-view]](1)
+
 # AUTHOR
 
 Joey Hess <id@joeyh.name>
index 21824205737a2bbbe6b7935a30ab1e00290dd196..f1a22d2f85821bb49585abd7ae6e9391027185fa 100644 (file)
@@ -44,6 +44,10 @@ into the `_` directory and committing will unset the metadata.
 The name of the `_` directory can be changed using the annex.viewunsetdirectory
 git config.
 
+In a view, annexed files are usually locked, but when both this command
+and [[git-annex-adjust]](1) are used, files in the view will be
+adjusted.
+
 # OPTIONS
 
 * The [[git-annex-common-options]](1) can be used.
@@ -62,6 +66,8 @@ git config.
 
 [[git-annex-vcycle]](1)
 
+[[git-annex-adjust]](1)
+
 # AUTHOR
 
 Joey Hess <id@joeyh.name>