fix git-annex add regression on deleted file

Fix a regression in 10.20220624 that caused git-annex add to crash when
there was an unstaged deletion.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-08-19 12:49:17 -04:00
parent 15c0cff2da
commit 94029995fa
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 35 additions and 17 deletions

View file

@ -88,19 +88,17 @@ seek o = startConcurrency commandStages $ do
addunlockedmatcher <- addUnlockedMatcher
annexdotfiles <- getGitConfigVal annexDotFiles
let gofile includingsmall (si, file) = case largeFilesOverride o of
Nothing -> do
s <- liftIO $ R.getSymbolicLinkStatus file
ifM (pure (annexdotfiles || not (dotfile file))
<&&> (checkFileMatcher largematcher file
<||> Annex.getRead Annex.force))
( start dr si file addunlockedmatcher
, if includingsmall
then ifM (annexAddSmallFiles <$> Annex.getGitConfig)
( startSmall dr si file s
, stop
)
else stop
)
Nothing -> ifM (pure (annexdotfiles || not (dotfile file))
<&&> (checkFileMatcher largematcher file
<||> Annex.getRead Annex.force))
( start dr si file addunlockedmatcher
, if includingsmall
then ifM (annexAddSmallFiles <$> Annex.getGitConfig)
( startSmall dr si file
, stop
)
else stop
)
Just True -> start dr si file addunlockedmatcher
Just False -> startSmallOverridden dr si file
case batchOption o of
@ -132,10 +130,13 @@ seek o = startConcurrency commandStages $ do
dr = dryRunOption o
{- Pass file off to git-add. -}
startSmall :: DryRun -> SeekInput -> RawFilePath -> FileStatus -> CommandStart
startSmall dr si file s =
starting "add" (ActionItemTreeFile file) si $
addSmall dr file s
startSmall :: DryRun -> SeekInput -> RawFilePath -> CommandStart
startSmall dr si file =
liftIO (catchMaybeIO $ R.getSymbolicLinkStatus file) >>= \case
Just s ->
starting "add" (ActionItemTreeFile file) si $
addSmall dr file s
Nothing -> stop
addSmall :: DryRun -> RawFilePath -> FileStatus -> CommandPerform
addSmall dr file s = do