unannex, uninit: Avoid running git rm once per annexed file, for a large speedup.

This commit is contained in:
Joey Hess 2021-02-22 12:56:11 -04:00
parent cddf2343b2
commit 62d5a73bdd
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 21 additions and 6 deletions

View file

@ -28,6 +28,8 @@ git-annex (8.20210128) UNRELEASED; urgency=medium
rather than doing it in a second pass. rather than doing it in a second pass.
* Bugfix: fsck --from a ssh remote did not actually check that the * Bugfix: fsck --from a ssh remote did not actually check that the
content on the remote is not corrupted. content on the remote is not corrupted.
* unannex, uninit: Avoid running git rm once per annexed file,
for a large speedup.
-- Joey Hess <id@joeyh.name> Thu, 28 Jan 2021 12:34:32 -0400 -- Joey Hess <id@joeyh.name> Thu, 28 Jan 2021 12:34:32 -0400

View file

@ -1,6 +1,6 @@
{- git-annex command {- git-annex command
- -
- Copyright 2010-2013 Joey Hess <id@joeyh.name> - Copyright 2010-2021 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -10,7 +10,7 @@ module Command.Unannex where
import Command import Command
import qualified Annex import qualified Annex
import Annex.Perms import Annex.Perms
import qualified Git.Command import qualified Annex.Queue
import Utility.CopyFile import Utility.CopyFile
import qualified Database.Keys import qualified Database.Keys
import Git.FilePath import Git.FilePath
@ -42,14 +42,13 @@ start si file key =
perform :: RawFilePath -> Key -> CommandPerform perform :: RawFilePath -> Key -> CommandPerform
perform file key = do perform file key = do
liftIO $ removeFile (fromRawFilePath file) liftIO $ removeFile (fromRawFilePath file)
inRepo $ Git.Command.run Annex.Queue.addCommand [] "rm"
[ Param "rm" [ Param "--cached"
, Param "--cached"
, Param "--force" , Param "--force"
, Param "--quiet" , Param "--quiet"
, Param "--" , Param "--"
, File (fromRawFilePath file)
] ]
[fromRawFilePath file]
next $ cleanup file key next $ cleanup file key
cleanup :: RawFilePath -> Key -> CommandCleanup cleanup :: RawFilePath -> Key -> CommandCleanup

View file

@ -20,3 +20,5 @@ git annex 8.20210127-g42239bc
[[!meta author=yoh]] [[!meta author=yoh]]
[[!tag projects/datalad]] [[!tag projects/datalad]]
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,12 @@
[[!comment format=mdwn
username="joey"
subject="""comment 1"""
date="2021-02-22T16:45:46Z"
content="""
Also unannex is slow the same way. Looks like it can easily be fixed using
git command queueing; I see no reason the rm needs to happen before
changes to the working tree, as --cached makes the rm only operate on the
index.
Rest seem fast enough.
"""]]