fix --from overriding annex-ignore
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
This commit is contained in:
parent
060259b750
commit
1654572bc1
9 changed files with 32 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 $
|
||||
|
|
|
@ -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
|
||||
|
|
18
Remote.hs
18
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)
|
||||
|
|
|
@ -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`
|
||||
|
||||
|
|
Loading…
Reference in a new issue