make startup scan for deleted files work in direct mode
git add --update cannot be used, because it'll stage typechanged direct mode files. Intead, use ls-files to find deleted files, and stage them ourselves. It seems that no commit was made before when the scan staged deleted files. (Probably masked since if files were added, a commit happened then..) Now that I'm doing the staging, I was also able to fix that bug.
This commit is contained in:
parent
c6d2bbe402
commit
95db595e91
2 changed files with 23 additions and 8 deletions
|
@ -27,9 +27,10 @@ import Utility.Types.DirWatcher
|
||||||
import Utility.Lsof
|
import Utility.Lsof
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import qualified Annex.Queue
|
import qualified Annex.Queue
|
||||||
import qualified Git.Command
|
import qualified Git
|
||||||
import qualified Git.UpdateIndex
|
import qualified Git.UpdateIndex
|
||||||
import qualified Git.HashObject
|
import qualified Git.HashObject
|
||||||
|
import qualified Git.LsFiles as LsFiles
|
||||||
import qualified Backend
|
import qualified Backend
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
|
@ -83,9 +84,15 @@ startupScan scanner = do
|
||||||
|
|
||||||
-- Notice any files that were deleted before
|
-- Notice any files that were deleted before
|
||||||
-- watching was started.
|
-- watching was started.
|
||||||
liftAnnex $ do
|
top <- liftAnnex $ fromRepo Git.repoPath
|
||||||
inRepo $ Git.Command.run "add" [Param "--update"]
|
(fs, cleanup) <- liftAnnex $ inRepo $ LsFiles.deleted [top]
|
||||||
showAction "started"
|
forM_ fs $ \f -> do
|
||||||
|
liftAnnex $ Annex.Queue.addUpdateIndex =<<
|
||||||
|
inRepo (Git.UpdateIndex.unstageFile f)
|
||||||
|
maybe noop recordChange =<< madeChange f RmChange
|
||||||
|
void $ liftIO $ cleanup
|
||||||
|
|
||||||
|
liftAnnex $ showAction "started"
|
||||||
|
|
||||||
modifyDaemonStatus_ $ \s -> s { scanComplete = True }
|
modifyDaemonStatus_ $ \s -> s { scanComplete = True }
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
module Git.LsFiles (
|
module Git.LsFiles (
|
||||||
inRepo,
|
inRepo,
|
||||||
notInRepo,
|
notInRepo,
|
||||||
|
deleted,
|
||||||
staged,
|
staged,
|
||||||
stagedNotDeleted,
|
stagedNotDeleted,
|
||||||
stagedDetails,
|
stagedDetails,
|
||||||
|
@ -38,6 +39,13 @@ notInRepo include_ignored l repo = pipeNullSplit params repo
|
||||||
| include_ignored = []
|
| include_ignored = []
|
||||||
| otherwise = [Param "--exclude-standard"]
|
| otherwise = [Param "--exclude-standard"]
|
||||||
|
|
||||||
|
{- Returns a list of files in the specified locations that have been
|
||||||
|
- deleted. -}
|
||||||
|
deleted :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
|
deleted l repo = pipeNullSplit params repo
|
||||||
|
where
|
||||||
|
params = [Params "ls-files --deleted -z --"] ++ map File l
|
||||||
|
|
||||||
{- Returns a list of all files that are staged for commit. -}
|
{- Returns a list of all files that are staged for commit. -}
|
||||||
staged :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
staged :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
staged = staged' []
|
staged = staged' []
|
||||||
|
@ -112,7 +120,7 @@ data Unmerged = Unmerged
|
||||||
- 1 = old version, can be ignored
|
- 1 = old version, can be ignored
|
||||||
- 2 = us
|
- 2 = us
|
||||||
- 3 = them
|
- 3 = them
|
||||||
- If a line is omitted, that side deleted the file.
|
- If a line is omitted, that side removed the file.
|
||||||
-}
|
-}
|
||||||
unmerged :: [FilePath] -> Repo -> IO ([Unmerged], IO Bool)
|
unmerged :: [FilePath] -> Repo -> IO ([Unmerged], IO Bool)
|
||||||
unmerged l repo = do
|
unmerged l repo = do
|
||||||
|
@ -157,11 +165,11 @@ reduceUnmerged c (i:is) = reduceUnmerged (new:c) rest
|
||||||
, unmergedBlobType = Conflicting blobtypeA blobtypeB
|
, unmergedBlobType = Conflicting blobtypeA blobtypeB
|
||||||
, unmergedSha = Conflicting shaA shaB
|
, unmergedSha = Conflicting shaA shaB
|
||||||
}
|
}
|
||||||
findsib templatei [] = ([], deleted templatei)
|
findsib templatei [] = ([], removed templatei)
|
||||||
findsib templatei (l:ls)
|
findsib templatei (l:ls)
|
||||||
| ifile l == ifile templatei = (ls, l)
|
| ifile l == ifile templatei = (ls, l)
|
||||||
| otherwise = (l:ls, deleted templatei)
|
| otherwise = (l:ls, removed templatei)
|
||||||
deleted templatei = templatei
|
removed templatei = templatei
|
||||||
{ isus = not (isus templatei)
|
{ isus = not (isus templatei)
|
||||||
, iblobtype = Nothing
|
, iblobtype = Nothing
|
||||||
, isha = Nothing
|
, isha = Nothing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue