Fix a bug in find --branch in the previous version

inAnnex check was lost for that code path. To avoid more such mistakes,
made withKeyOptions check it when the AnnexedFileSeeker specifies.
This commit is contained in:
Joey Hess 2020-07-24 12:05:28 -04:00
parent 2d771a7d32
commit 00865cdae8
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 20 additions and 14 deletions

View file

@ -7,6 +7,7 @@ git-annex (8.20200720.2) UNRELEASED; urgency=medium
* Fix a hang when using git-annex with an old openssh 7.2p2, which had
some weird inheriting of ssh FDs by sshd. Bug was introduced in
git-annex version 7.20200202.7.
* Fix a bug in find --branch in the previous version.
-- Joey Hess <id@joeyh.name> Tue, 21 Jul 2020 12:58:30 -0400

View file

@ -128,7 +128,7 @@ batchAnnexedFilesMatching fmt seeker = batchFilesMatching fmt $
whenAnnexed $ \f k -> case checkContentPresent seeker of
Just v -> do
present <- inAnnex k
if (present == v)
if present == v
then startAction seeker f k
else return Nothing
Nothing -> startAction seeker f k

View file

@ -166,21 +166,27 @@ withNothing _ _ = giveup "This command takes no parameters."
withKeyOptions
:: Maybe KeyOptions
-> Bool
-> AnnexedFileSeeker
-> ((Key, ActionItem) -> CommandSeek)
-> ([WorkTreeItem] -> CommandSeek)
-> [WorkTreeItem]
-> CommandSeek
withKeyOptions ko auto keyaction = withKeyOptions' ko auto mkkeyaction
withKeyOptions ko auto seeker keyaction = withKeyOptions' ko auto mkkeyaction
where
mkkeyaction = do
matcher <- Limit.getMatcher
return $ \v@(k, ai) ->
return $ \v@(k, ai) -> checkseeker k $
let i = case ai of
ActionItemBranchFilePath (BranchFilePath _ topf) _ ->
MatchingKey k (AssociatedFile $ Just $ getTopFilePath topf)
_ -> MatchingKey k (AssociatedFile Nothing)
in whenM (matcher i) $
keyaction v
checkseeker k a = case checkContentPresent seeker of
Nothing -> a
Just v -> do
present <- inAnnex k
when (present == v) a
withKeyOptions'
:: Maybe KeyOptions

View file

@ -47,7 +47,7 @@ seek :: CopyOptions -> CommandSeek
seek o = startConcurrency commandStages $ do
case batchOption o of
NoBatch -> withKeyOptions
(keyOptions o) (autoMode o)
(keyOptions o) (autoMode o) seeker
(commandAction . Command.Move.startKey (fromToOptions o) Command.Move.RemoveNever)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (copyFiles o)

View file

@ -55,7 +55,7 @@ seek :: DropOptions -> CommandSeek
seek o = startConcurrency commandStages $
case batchOption o of
Batch fmt -> batchAnnexedFilesMatching fmt seeker
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
NoBatch -> withKeyOptions (keyOptions o) (autoMode o) seeker
(commandAction . startKeys o)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (dropFiles o)

View file

@ -65,7 +65,7 @@ seek o = do
, usesLocationLog = False
}
case batchOption o of
NoBatch -> withKeyOptions (keyOptions o) False
NoBatch -> withKeyOptions (keyOptions o) False seeker
(commandAction . startKeys o)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (findThese o)

View file

@ -97,7 +97,7 @@ seek o = startConcurrency commandStages $ do
, checkContentPresent = Nothing
, usesLocationLog = True
}
withKeyOptions (keyOptions o) False
withKeyOptions (keyOptions o) False seeker
(\kai -> commandAction . startKey from i kai =<< getNumCopies)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (fsckFiles o)

View file

@ -46,7 +46,7 @@ seek o = startConcurrency downloadStages $ do
, usesLocationLog = True
}
case batchOption o of
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
NoBatch -> withKeyOptions (keyOptions o) (autoMode o) seeker
(commandAction . startKeys from)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (getFiles o)
@ -66,8 +66,7 @@ start o from file key = start' expensivecheck from key afile ai
startKeys :: Maybe Remote -> (Key, ActionItem) -> CommandStart
startKeys from (key, ai) = checkFailedTransferDirection ai Download $
stopUnless (not <$> inAnnex key) $
start' (return True) from key (AssociatedFile Nothing) ai
start' (return True) from key (AssociatedFile Nothing) ai
start' :: Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> CommandStart
start' expensivecheck from key afile ai =

View file

@ -86,7 +86,7 @@ seek o = case batchOption o of
GetAll -> withFilesInGitAnnex ww
Set _ -> withFilesInGitAnnexNonRecursive ww
"Not recursively setting metadata. Use --force to do that."
withKeyOptions (keyOptions o) False
withKeyOptions (keyOptions o) False seeker
(commandAction . startKeys c o)
(seekaction seeker)
=<< workTreeItems ww (forFiles o)

View file

@ -42,7 +42,7 @@ instance DeferredParseClass MirrorOptions where
seek :: MirrorOptions -> CommandSeek
seek o = startConcurrency stages $
withKeyOptions (keyOptions o) False
withKeyOptions (keyOptions o) False seeker
(commandAction . startKey o (AssociatedFile Nothing))
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (mirrorFiles o)

View file

@ -61,7 +61,7 @@ seek o = startConcurrency stages $ do
, usesLocationLog = False
}
case batchOption o of
NoBatch -> withKeyOptions (keyOptions o) False
NoBatch -> withKeyOptions (keyOptions o) False seeker
(commandAction . startKey (fromToOptions o) (removeWhen o))
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (moveFiles o)

View file

@ -58,7 +58,7 @@ seek o = do
}
case batchOption o of
NoBatch -> do
withKeyOptions (keyOptions o) False
withKeyOptions (keyOptions o) False seeker
(commandAction . startKeys o m)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (whereisFiles o)