* adb: Added ignorefinderror configuration parameter.
* Avoid crashing when run in a bare git repo that somehow contains an
index file.
+ * Reject combinations of --batch (or --batch-keys) with options like
+ --all or --key or with filenames.
-- Joey Hess <id@joeyh.name> Mon, 03 Jan 2022 14:01:14 -0400
batchseeker (opts, NoBatch, params) =
mapM_ (\p -> go NoBatch opts (SeekInput [p], p)) params
- batchseeker (opts, batchmode@(Batch fmt), _) =
- batchInput fmt (pure . Right) (go batchmode opts)
+ batchseeker (opts, batchmode@(Batch fmt), params) =
+ batchOnly Nothing params $
+ batchInput fmt (pure . Right) (go batchmode opts)
go batchmode opts (si, p) =
unlessM (handler opts si p) $
, providedMimeEncoding = Nothing
, providedLinkType = Nothing
}
+
+batchOnly :: Maybe KeyOptions -> CmdParams -> Annex () -> Annex ()
+batchOnly Nothing [] a = a
+batchOnly _ _ _ = giveup "Cannot combine batch option with file or key options"
+
Batch fmt
| updateOnly o ->
giveup "--update --batch is not supported"
- | otherwise -> batchFiles fmt gofile
+ | otherwise -> batchOnly Nothing (addThese o) $
+ batchFiles fmt gofile
NoBatch -> do
-- Avoid git ls-files complaining about files that
-- are not known to git yet, since this will add
then void $ commandAction $
startWeb addunlockedmatcher o' si u
else checkUrl addunlockedmatcher r o' si u
- forM_ (addUrls o) (\u -> go (SeekInput [u], (o, u)))
case batchOption o of
- Batch fmt -> batchInput fmt (pure . parseBatchInput o) go
- NoBatch -> noop
+ Batch fmt -> batchOnly Nothing (addUrls o) $
+ batchInput fmt (pure . parseBatchInput o) go
+ NoBatch -> forM_ (addUrls o) (\u -> go (SeekInput [u], (o, u)))
parseBatchInput :: AddUrlOptions -> String -> Either String (AddUrlOptions, URLString)
parseBatchInput o s
(commandAction . keyaction)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (copyFiles o)
- Batch fmt -> batchAnnexed fmt seeker keyaction
+ Batch fmt -> batchOnly (keyOptions o) (copyFiles o) $
+ batchAnnexed fmt seeker keyaction
where
ww = WarnUnmatchLsFiles
(commandAction . startKeys o from)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (dropFiles o)
- Batch fmt -> batchAnnexed fmt seeker (startKeys o from)
+ Batch fmt -> batchOnly (keyOptions o) (dropFiles o) $
+ batchAnnexed fmt seeker (startKeys o from)
where
ww = WarnUnmatchLsFiles
seek o = do
unlessM (Annex.getState Annex.force) $
giveup "dropkey can cause data loss; use --force if you're sure you want to do this"
- withKeys (commandAction . start) (toDrop o)
case batchOption o of
- Batch fmt -> batchInput fmt (pure . parsekey) $
- batchCommandAction . start
- NoBatch -> noop
+ NoBatch -> withKeys (commandAction . start) (toDrop o)
+ Batch fmt -> batchOnly Nothing (toDrop o) $
+ batchInput fmt (pure . parsekey) $
+ batchCommandAction . start
where
parsekey = maybe (Left "bad key") Right . deserializeKey
(commandAction . startKeys o)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (findThese o)
- Batch fmt -> batchAnnexedFiles fmt seeker
+ Batch fmt -> batchOnly (keyOptions o) (findThese o) $
+ batchAnnexedFiles fmt seeker
where
ww = WarnUnmatchLsFiles
seek o = do
matcher <- addUnlockedMatcher
case (batchOption o, keyFilePairs o) of
- (Batch fmt, _) -> seekBatch matcher fmt
+ (Batch fmt, _) -> batchOnly Nothing (keyFilePairs o) $
+ seekBatch matcher fmt
-- older way of enabling batch input, does not support BatchNull
(NoBatch, []) -> seekBatch matcher (BatchFormat BatchLine (BatchKeys False))
(NoBatch, ps) -> do
(commandAction . startKeys from)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (getFiles o)
- Batch fmt -> batchAnnexed fmt seeker (startKeys from)
+ Batch fmt -> batchOnly (keyOptions o) (getFiles o) $
+ batchAnnexed fmt seeker (startKeys from)
where
ww = WarnUnmatchLsFiles
seek :: InfoOptions -> CommandSeek
seek o = case batchOption o of
NoBatch -> withWords (commandAction . start o) (infoFor o)
- Batch fmt -> batchInput fmt (pure . Right) (itemInfo o)
+ Batch fmt -> batchOnly Nothing (infoFor o) $
+ batchInput fmt (pure . Right) (itemInfo o)
start :: InfoOptions -> [String] -> CommandStart
start o [] = do
Batch fmt -> withMessageState $ \s -> case outputType s of
JSONOutput _ -> ifM limited
( giveup "combining --batch with file matching options is not currently supported"
- , batchInput fmt parseJSONInput
- (commandAction . batchCommandStart . startBatch)
+ , batchOnly (keyOptions o) (forFiles o) $
+ batchInput fmt parseJSONInput
+ (commandAction . batchCommandStart . startBatch)
)
_ -> giveup "--batch is currently only supported in --json mode"
(commandAction . keyaction)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (moveFiles o)
- Batch fmt -> batchAnnexed fmt seeker keyaction
+ Batch fmt -> batchOnly (keyOptions o) (moveFiles o) $
+ batchAnnexed fmt seeker keyaction
where
seeker = AnnexedFileSeeker
{ startAction = start (fromToOptions o) (removeWhen o)
seek :: ReKeyOptions -> CommandSeek
seek o = case batchOption o of
- Batch fmt -> batchInput fmt batchParser
- (batchCommandAction . uncurry start)
+ Batch fmt -> batchOnly Nothing (reKeyThese o) $
+ batchInput fmt batchParser
+ (batchCommandAction . uncurry start)
NoBatch -> withPairs
(\(si, p) -> commandAction (start si (parsekey p)))
(reKeyThese o)
seek :: RegisterUrlOptions -> CommandSeek
seek o = case (batchOption o, keyUrlPairs o) of
- (Batch (BatchFormat sep _), _) ->
+ (Batch (BatchFormat sep _), _) -> batchOnly Nothing (keyUrlPairs o) $
commandAction $ startMass setUrlPresent sep
-- older way of enabling batch input, does not support BatchNull
(NoBatch, []) -> commandAction $ startMass setUrlPresent BatchLine
seek :: RmUrlOptions -> CommandSeek
seek o = case batchOption o of
- Batch fmt -> batchInput fmt batchParser (batchCommandAction . start)
+ Batch fmt -> batchOnly Nothing (rmThese o) $
+ batchInput fmt batchParser (batchCommandAction . start)
NoBatch -> withPairs (commandAction . start) (rmThese o)
-- Split on the last space, since a FilePath can contain whitespace,
seek :: SetPresentKeyOptions -> CommandSeek
seek o = case batchOption o of
- Batch fmt -> batchInput fmt
- (pure . parseKeyStatus . words)
- (batchCommandAction . uncurry start)
+ Batch fmt -> batchOnly Nothing (params o) $
+ batchInput fmt
+ (pure . parseKeyStatus . words)
+ (batchCommandAction . uncurry start)
NoBatch -> either giveup (commandAction . start (SeekInput (params o)))
(parseKeyStatus $ params o)
(commandAction . startKeys o m)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww (whereisFiles o)
- Batch fmt -> batchAnnexed fmt seeker (startKeys o m)
+ Batch fmt -> batchOnly (keyOptions o) (whereisFiles o) $
+ batchAnnexed fmt seeker (startKeys o m)
where
ww = WarnUnmatchLsFiles
### What version of git-annex are you using? On what operating system?
`8.20211231+git140-gc3817495f-1~ndall+1`
+
+> [[fixed|done]] --[[Joey]]