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 -> [UUID] -> Annex ([UnVerifiedCopy], [VerifiedCopy])
|
||||||
verifiableCopies key exclude = do
|
verifiableCopies key exclude = do
|
||||||
locs <- Remote.keyLocations key
|
locs <- Remote.keyLocations key
|
||||||
(remotes, trusteduuids) <- Remote.remoteLocations locs
|
(remotes, trusteduuids) <- Remote.remoteLocations (Remote.IncludeIgnored False) locs
|
||||||
=<< trustGet Trusted
|
=<< trustGet Trusted
|
||||||
untrusteduuids <- trustGet UnTrusted
|
untrusteduuids <- trustGet UnTrusted
|
||||||
let exclude' = exclude ++ untrusteduuids
|
let exclude' = exclude ++ untrusteduuids
|
||||||
|
|
|
@ -93,7 +93,7 @@ queueTransfersMatching matching reason schedule k f direction
|
||||||
filter (\r -> not (inset s r || Remote.readonly r))
|
filter (\r -> not (inset s r || Remote.readonly r))
|
||||||
(syncDataRemotes st)
|
(syncDataRemotes st)
|
||||||
where
|
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
|
inset s r = S.member (Remote.uuid r) s
|
||||||
gentransfer r = Transfer
|
gentransfer r = Transfer
|
||||||
{ transferDirection = direction
|
{ 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
|
git-annex (10.20231129) upstream; urgency=medium
|
||||||
|
|
||||||
* Fix bug in git-annex copy --from --to that skipped files that were
|
* 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
|
check ks mr = case mr of
|
||||||
Just r -> go Nothing [r]
|
Just r -> go Nothing [r]
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
mostlikely <- Remote.keyPossibilities k
|
mostlikely <- Remote.keyPossibilities (Remote.IncludeIgnored False) k
|
||||||
otherremotes <- flip Remote.remotesWithoutUUID
|
otherremotes <- flip Remote.remotesWithoutUUID
|
||||||
(map Remote.uuid mostlikely)
|
(map Remote.uuid mostlikely)
|
||||||
<$> remoteList
|
<$> 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,
|
{- Try to find a copy of the file in one of the remotes,
|
||||||
- and copy it to here. -}
|
- and copy it to here. -}
|
||||||
getKey :: Key -> AssociatedFile -> Annex Bool
|
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 -> AssociatedFile -> [Remote] -> Annex Bool
|
||||||
getKey' key afile = dispatch
|
getKey' key afile = dispatch
|
||||||
|
|
|
@ -146,7 +146,7 @@ toStart' dest removewhen afile key ai si = do
|
||||||
|
|
||||||
expectedPresent :: Remote -> Key -> Annex Bool
|
expectedPresent :: Remote -> Key -> Annex Bool
|
||||||
expectedPresent dest key = do
|
expectedPresent dest key = do
|
||||||
remotes <- Remote.keyPossibilities key
|
remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
|
||||||
return $ dest `elem` remotes
|
return $ dest `elem` remotes
|
||||||
|
|
||||||
toPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
toPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
||||||
|
@ -249,7 +249,7 @@ fromOk src key
|
||||||
where
|
where
|
||||||
checklog = do
|
checklog = do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
remotes <- Remote.keyPossibilities key
|
remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
|
||||||
return $ u /= Remote.uuid src && elem src remotes
|
return $ u /= Remote.uuid src && elem src remotes
|
||||||
|
|
||||||
fromPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform
|
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 -> AssociatedFile -> Key -> ActionItem -> SeekInput -> CommandStart
|
||||||
toHereStart removewhen afile key ai si =
|
toHereStart removewhen afile key ai si =
|
||||||
startingNoMessage (OnlyActionOn key ai) $ do
|
startingNoMessage (OnlyActionOn key ai) $ do
|
||||||
rs <- Remote.keyPossibilities key
|
rs <- Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
||||||
forM_ rs $ \r ->
|
forM_ rs $ \r ->
|
||||||
includeCommandAction $
|
includeCommandAction $
|
||||||
starting (describeMoveAction removewhen) ai si $
|
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 :: SyncOptions -> Either (Maybe (Bloom Key)) (Key -> Annex ()) -> [Remote] -> AssociatedFile -> Key -> Annex Bool
|
||||||
syncFile o ebloom rs af k = do
|
syncFile o ebloom rs af k = do
|
||||||
inhere <- inAnnex k
|
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
|
let (have, lack) = partition (\r -> Remote.uuid r `elem` locs) rs
|
||||||
|
|
||||||
got <- anyM id =<< handleget have inhere
|
got <- anyM id =<< handleget have inhere
|
||||||
|
|
18
Remote.hs
18
Remote.hs
|
@ -47,6 +47,7 @@ module Remote (
|
||||||
remotesWithUUID,
|
remotesWithUUID,
|
||||||
remotesWithoutUUID,
|
remotesWithoutUUID,
|
||||||
keyLocations,
|
keyLocations,
|
||||||
|
IncludeIgnored(..),
|
||||||
keyPossibilities,
|
keyPossibilities,
|
||||||
remoteLocations,
|
remoteLocations,
|
||||||
nameToUUID,
|
nameToUUID,
|
||||||
|
@ -299,13 +300,16 @@ remotesWithoutUUID rs us = filter (\r -> uuid r `notElem` us) rs
|
||||||
keyLocations :: Key -> Annex [UUID]
|
keyLocations :: Key -> Annex [UUID]
|
||||||
keyLocations key = trustExclude DeadTrusted =<< loggedLocations key
|
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
|
{- Cost ordered lists of remotes that the location log indicates
|
||||||
- may have a key.
|
- may have a key.
|
||||||
-
|
-
|
||||||
- Also includes remotes with remoteAnnexSpeculatePresent set.
|
- Also includes remotes with remoteAnnexSpeculatePresent set.
|
||||||
-}
|
-}
|
||||||
keyPossibilities :: Key -> Annex [Remote]
|
keyPossibilities :: IncludeIgnored -> Key -> Annex [Remote]
|
||||||
keyPossibilities key = do
|
keyPossibilities ii key = do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
-- uuids of all remotes that are recorded to have the key
|
-- uuids of all remotes that are recorded to have the key
|
||||||
locations <- filter (/= u) <$> keyLocations key
|
locations <- filter (/= u) <$> keyLocations key
|
||||||
|
@ -315,19 +319,21 @@ keyPossibilities key = do
|
||||||
-- there are unlikely to be many speclocations, so building a Set
|
-- there are unlikely to be many speclocations, so building a Set
|
||||||
-- is not worth the expense
|
-- is not worth the expense
|
||||||
let locations' = speclocations ++ filter (`notElem` speclocations) locations
|
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
|
{- Given a list of locations of a key, and a list of all
|
||||||
- trusted repositories, generates a cost-ordered list of
|
- trusted repositories, generates a cost-ordered list of
|
||||||
- remotes that contain the key, and a list of trusted locations of the key.
|
- remotes that contain the key, and a list of trusted locations of the key.
|
||||||
-}
|
-}
|
||||||
remoteLocations :: [UUID] -> [UUID] -> Annex ([Remote], [UUID])
|
remoteLocations :: IncludeIgnored -> [UUID] -> [UUID] -> Annex ([Remote], [UUID])
|
||||||
remoteLocations locations trusted = do
|
remoteLocations (IncludeIgnored ii) locations trusted = do
|
||||||
let validtrustedlocations = nub locations `intersect` trusted
|
let validtrustedlocations = nub locations `intersect` trusted
|
||||||
|
|
||||||
-- remotes that match uuids that have the key
|
-- remotes that match uuids that have the key
|
||||||
allremotes <- remoteList
|
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
|
let validremotes = remotesWithUUID allremotes locations
|
||||||
|
|
||||||
return (sortBy (comparing cost) validremotes, validtrustedlocations)
|
return (sortBy (comparing cost) validremotes, validtrustedlocations)
|
||||||
|
|
|
@ -1388,9 +1388,9 @@ Remotes are configured using these settings in `.git/config`.
|
||||||
|
|
||||||
* `remote.<name>.annex-ignore`
|
* `remote.<name>.annex-ignore`
|
||||||
|
|
||||||
If set to `true`, prevents git-annex
|
If set to `true`, prevents git-annex from storing or retrieving annexed
|
||||||
from storing annexed file contents on this remote by default.
|
file contents on this remote by default.
|
||||||
(You can still request it be used by the `--from` and `--to` options.)
|
(You can still request it be used with the `--from` and `--to` options.)
|
||||||
|
|
||||||
This is, for example, useful if the remote is located somewhere
|
This is, for example, useful if the remote is located somewhere
|
||||||
without git-annex-shell. (For example, if it's on GitHub).
|
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`,
|
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-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`
|
* `remote.<name>.annex-ignore-command`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue