overwrite old adjusted view branch
authorJoey Hess <joeyh@joeyh.name>
Mon, 27 Feb 2023 18:35:27 +0000 (14:35 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 27 Feb 2023 18:35:27 +0000 (14:35 -0400)
When git-annex adjust is run in a view branch, and the adjusted branch
already exists, overwrite the old adjusted branch with the new one
without being forced.

Usually overwriting an adjusted branch is avoided because it could lose
data. But when a view branch has been adjusted, there is no data to lose
in the adjusted branch, because the only changes that can be made of
significance are to move files between directories. Which changes
metadata on commit. And the old branch has already been committed.

Sponsored-by: Lawrence Brogan on Patreon
Annex/AdjustedBranch.hs

index af3d46aae6c12f3c399d1675d1e562098934225e..1bc44ea2a27019291e24df5d234ccf4167f62e33 100644 (file)
@@ -1,6 +1,6 @@
 {- adjusted branch
  -
- - Copyright 2016-2020 Joey Hess <id@joeyh.name>
+ - Copyright 2016-2023 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -67,6 +67,7 @@ import Annex.CurrentBranch
 import Types.CleanupActions
 import qualified Database.Keys
 import Config
+import Logs.View (is_branchView)
 
 import qualified Data.Map as M
 
@@ -207,7 +208,7 @@ enterAdjustedBranch adj = inRepo Git.Branch.current >>= \case
        go currbranch = do
                let origbranch = fromAdjustedBranch currbranch
                let adjbranch = adjBranch $ originalToAdjusted origbranch adj
-               ifM (inRepo (Git.Ref.exists adjbranch) <&&> (not <$> Annex.getRead Annex.force))
+               ifM (inRepo (Git.Ref.exists adjbranch) <&&> (not <$> Annex.getRead Annex.force) <&&> pure (not (is_branchView origbranch)))
                        ( do
                                mapM_ (warning . unwords)
                                        [ [ "adjusted branch"