fix --from overriding annex-ignore
authorJoey Hess <joeyh@joeyh.name>
Thu, 30 Nov 2023 19:11:57 +0000 (15:11 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 30 Nov 2023 19:12:07 +0000 (15:12 -0400)
Make git-annex get/copy/move --from foo override configuration of
remote.foo.annex-ignore, as documented.

This already worked for remotes supporting hasKeyCheap. For others though,
git-annex copy --from foo would silently not do anything, while
git-annex copy --to foo would use the annex-ignored remote.

Also improved the annex-ignore docs, to reflect that `git-annex get`
without --from will skip using annex-ignored remotes, for example.

Sponsored-by: Dartmouth College's DANDI project
Annex/NumCopies.hs
Assistant/TransferQueue.hs
CHANGELOG
Command/CheckPresentKey.hs
Command/Get.hs
Command/Move.hs
Command/Sync.hs
Remote.hs
doc/git-annex.mdwn

index a3c6f92dcde983f91b31d0b8bcea4bd534b86575..1d8722a3d4dd5599e7c6d21546ea658b4cea7a9a 100644 (file)
@@ -317,7 +317,7 @@ pluralCopies _ = "copies"
 verifiableCopies :: Key -> [UUID] -> Annex ([UnVerifiedCopy], [VerifiedCopy])
 verifiableCopies key exclude = do
        locs <- Remote.keyLocations key
-       (remotes, trusteduuids) <- Remote.remoteLocations locs
+       (remotes, trusteduuids) <- Remote.remoteLocations (Remote.IncludeIgnored False) locs
                =<< trustGet Trusted
        untrusteduuids <- trustGet UnTrusted
        let exclude' = exclude ++ untrusteduuids
index d2d245b7b1f3f1461499ae1e6591b8b8e3282b31..571899bb6dd8c67786ccfc00a3bae9d9e23f6834 100644 (file)
@@ -93,7 +93,7 @@ queueTransfersMatching matching reason schedule k f direction
                                filter (\r -> not (inset s r || Remote.readonly r))
                                        (syncDataRemotes st)
          where
-               locs = S.fromList . map Remote.uuid <$> Remote.keyPossibilities k
+               locs = S.fromList . map Remote.uuid <$> Remote.keyPossibilities (Remote.IncludeIgnored False) k
                inset s r = S.member (Remote.uuid r) s
        gentransfer r = Transfer
                { transferDirection = direction
index e84825010995d7c74cbeedfb76ae979070b9d39b..3fdedb9023d1859462105b33defe87804faff85b 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+git-annex (10.20231130) UNRELEASED; urgency=medium
+
+  * Make git-annex get/copy/move --from foo override configuration of 
+    remote.foo.annex-ignore, as documented.
+
+ -- Joey Hess <id@joeyh.name>  Thu, 30 Nov 2023 14:48:12 -0400
+
 git-annex (10.20231129) upstream; urgency=medium
 
   * Fix bug in git-annex copy --from --to that skipped files that were
index f3b4ef921c04b6627e418c4bb4e4ac1578873fe7..efefc71aeb9f6a6332ebbff958ff6a58f58cfa3a 100644 (file)
@@ -51,7 +51,7 @@ check :: String -> Maybe Remote -> Annex Result
 check ks mr = case mr of
        Just r -> go Nothing [r]
        Nothing -> do
-               mostlikely <- Remote.keyPossibilities k
+               mostlikely <- Remote.keyPossibilities (Remote.IncludeIgnored False) k
                otherremotes <- flip Remote.remotesWithoutUUID 
                        (map Remote.uuid mostlikely)
                        <$> remoteList
index 7d3d4a2ef14d8989787b6a8e7e34b62b77ef8c29..2dd48456f47e67711a49e7080ded250075a8bd40 100644 (file)
@@ -87,7 +87,8 @@ perform key afile = stopUnless (getKey key afile) $
 {- Try to find a copy of the file in one of the remotes,
  - and copy it to here. -}
 getKey :: Key -> AssociatedFile -> Annex Bool
-getKey key afile = getKey' key afile =<< Remote.keyPossibilities key
+getKey key afile = getKey' key afile
+       =<< Remote.keyPossibilities (Remote.IncludeIgnored False) key
 
 getKey' :: Key -> AssociatedFile -> [Remote] -> Annex Bool
 getKey' key afile = dispatch
index 2e450b3e4a2e36915ba7445f5a4494f38079c01e..59bdf9ecada29539238f3510c062359a57e2fcd0 100644 (file)
@@ -146,7 +146,7 @@ toStart' dest removewhen afile key ai si = do
 
 expectedPresent :: Remote -> Key -> Annex Bool
 expectedPresent dest key = do
-       remotes <- Remote.keyPossibilities key
+       remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
        return $ dest `elem` remotes
 
 toPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
@@ -249,7 +249,7 @@ fromOk src key
   where
        checklog = do
                u <- getUUID
-               remotes <- Remote.keyPossibilities key
+               remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
                return $ u /= Remote.uuid src && elem src remotes
 
 fromPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform
@@ -326,7 +326,7 @@ fromDrop src destuuid deststartedwithcopy key afile adjusttocheck =
 toHereStart :: RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> CommandStart
 toHereStart removewhen afile key ai si = 
        startingNoMessage (OnlyActionOn key ai) $ do
-               rs <- Remote.keyPossibilities key
+               rs <- Remote.keyPossibilities (Remote.IncludeIgnored False) key
                forM_ rs $ \r ->
                        includeCommandAction $
                                starting (describeMoveAction removewhen) ai si $
index fcdc807f1fcf5840db4f1f41d2aa009aa02f717b..851776f95f20094a94a911978faea10170163691 100644 (file)
@@ -897,7 +897,7 @@ seekSyncContent o rs currbranch = do
 syncFile :: SyncOptions -> Either (Maybe (Bloom Key)) (Key -> Annex ()) -> [Remote] -> AssociatedFile -> Key -> Annex Bool
 syncFile o ebloom rs af k = do
        inhere <- inAnnex k
-       locs <- map Remote.uuid <$> Remote.keyPossibilities k
+       locs <- map Remote.uuid <$> Remote.keyPossibilities (Remote.IncludeIgnored False) k
        let (have, lack) = partition (\r -> Remote.uuid r `elem` locs) rs
 
        got <- anyM id =<< handleget have inhere
index 93b2e30f8783e2922335063da1e454fd4fa4f3e8..1638777277c021dcf1344d953eb76a62f52a48be 100644 (file)
--- a/Remote.hs
+++ b/Remote.hs
@@ -47,6 +47,7 @@ module Remote (
        remotesWithUUID,
        remotesWithoutUUID,
        keyLocations,
+       IncludeIgnored(..),
        keyPossibilities,
        remoteLocations,
        nameToUUID,
@@ -299,13 +300,16 @@ remotesWithoutUUID rs us = filter (\r -> uuid r `notElem` us) rs
 keyLocations :: Key -> Annex [UUID]
 keyLocations key = trustExclude DeadTrusted =<< loggedLocations key
 
+{- Whether to include remotes that have annex-ignore set. -}
+newtype IncludeIgnored = IncludeIgnored Bool
+
 {- Cost ordered lists of remotes that the location log indicates
  - may have a key.
  -
  - Also includes remotes with remoteAnnexSpeculatePresent set.
  -}
-keyPossibilities :: Key -> Annex [Remote]
-keyPossibilities key = do
+keyPossibilities :: IncludeIgnored -> Key -> Annex [Remote]
+keyPossibilities ii key = do
        u <- getUUID
        -- uuids of all remotes that are recorded to have the key
        locations <- filter (/= u) <$> keyLocations key
@@ -315,19 +319,21 @@ keyPossibilities key = do
        -- there are unlikely to be many speclocations, so building a Set
        -- is not worth the expense
        let locations' = speclocations ++ filter (`notElem` speclocations) locations
-       fst <$> remoteLocations locations' []
+       fst <$> remoteLocations ii locations' []
 
 {- Given a list of locations of a key, and a list of all
  - trusted repositories, generates a cost-ordered list of
  - remotes that contain the key, and a list of trusted locations of the key.
  -}
-remoteLocations :: [UUID] -> [UUID] -> Annex ([Remote], [UUID])
-remoteLocations locations trusted = do
+remoteLocations :: IncludeIgnored -> [UUID] -> [UUID] -> Annex ([Remote], [UUID])
+remoteLocations (IncludeIgnored ii) locations trusted = do
        let validtrustedlocations = nub locations `intersect` trusted
 
        -- remotes that match uuids that have the key
        allremotes <- remoteList 
-               >>= filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . gitconfig)
+               >>= if not ii
+                       then filterM (not <$$> liftIO . getDynamicConfig . remoteAnnexIgnore . gitconfig)
+                       else return
        let validremotes = remotesWithUUID allremotes locations
 
        return (sortBy (comparing cost) validremotes, validtrustedlocations)
index dfcd600c49ad17d597be6411c5d2d297ec83ebb9..750ad923f0a3ed6d6db36cdadeb905a32b2adb6e 100644 (file)
@@ -1388,9 +1388,9 @@ Remotes are configured using these settings in `.git/config`.
 
 * `remote.<name>.annex-ignore`
 
-  If set to `true`, prevents git-annex
-  from storing annexed file contents on this remote by default.
-  (You can still request it be used by the `--from` and `--to` options.)
+  If set to `true`, prevents git-annex from storing or retrieving annexed
+  file contents on this remote by default. 
+  (You can still request it be used with the `--from` and `--to` options.)
 
   This is, for example, useful if the remote is located somewhere
   without git-annex-shell. (For example, if it's on GitHub).
@@ -1399,7 +1399,7 @@ Remotes are configured using these settings in `.git/config`.
 
   This does not prevent `git-annex sync`, `git-annex pull`, `git-annex push`,
   `git-annex assist` or the `git-annex assistant` from operating on the
-  git repository.
+  git repository. It only affects annexed content.
 
 * `remote.<name>.annex-ignore-command`