unannex: Clean up use of git commit -a.
This was more complex than would be expected. unannex has to use git commit -a since it's removing files from git; git commit filelist won't do. Allow commands to be added to the Git queue that have no associated files, and run such commands once.
This commit is contained in:
parent
0c46cbab09
commit
ded2591124
10 changed files with 26 additions and 20 deletions
|
@ -21,10 +21,10 @@ import Utility
|
|||
|
||||
{- Adds a git command to the queue, possibly running previously queued
|
||||
- actions if enough have accumulated. -}
|
||||
add :: String -> [CommandParam] -> FilePath -> Annex ()
|
||||
add command params file = do
|
||||
add :: String -> [CommandParam] -> [FilePath] -> Annex ()
|
||||
add command params files = do
|
||||
q <- getState repoqueue
|
||||
store $ Git.Queue.add q command params file
|
||||
store $ Git.Queue.add q command params files
|
||||
|
||||
{- Runs the queue if it is full. Should be called periodically. -}
|
||||
flushWhenFull :: Annex ()
|
||||
|
|
|
@ -87,6 +87,6 @@ cleanup file key = do
|
|||
|
||||
force <- Annex.getState Annex.force
|
||||
if force
|
||||
then AnnexQueue.add "add" [Param "-f", Param "--"] file
|
||||
else AnnexQueue.add "add" [Param "--"] file
|
||||
then AnnexQueue.add "add" [Param "-f", Param "--"] [file]
|
||||
else AnnexQueue.add "add" [Param "--"] [file]
|
||||
return True
|
||||
|
|
|
@ -44,5 +44,5 @@ perform file link = do
|
|||
|
||||
cleanup :: FilePath -> CommandCleanup
|
||||
cleanup file = do
|
||||
AnnexQueue.add "add" [Param "--"] file
|
||||
AnnexQueue.add "add" [Param "--"] [file]
|
||||
return True
|
||||
|
|
|
@ -45,5 +45,5 @@ perform file = do
|
|||
|
||||
cleanup :: FilePath -> CommandCleanup
|
||||
cleanup file = do
|
||||
AnnexQueue.add "add" [Param "--"] file
|
||||
AnnexQueue.add "add" [Param "--"] [file]
|
||||
return True
|
||||
|
|
|
@ -33,5 +33,5 @@ perform file = do
|
|||
-- Checkout from HEAD to get rid of any changes that might be
|
||||
-- staged in the index, and get back to the previous symlink to
|
||||
-- the content.
|
||||
AnnexQueue.add "checkout" [Param "HEAD", Param "--"] file
|
||||
AnnexQueue.add "checkout" [Param "HEAD", Param "--"] [file]
|
||||
next $ return True -- no cleanup needed
|
||||
|
|
|
@ -78,6 +78,6 @@ cleanup file key = do
|
|||
-- Commit staged changes at end to avoid confusing the
|
||||
-- pre-commit hook if this file is later added back to
|
||||
-- git as a normal, non-annexed file.
|
||||
AnnexQueue.add "commit" [Params "-a -m", Param "content removed from git annex"] "-a"
|
||||
AnnexQueue.add "commit" [Params "-a -m", Param "content removed from git annex"] []
|
||||
|
||||
return True
|
||||
|
|
17
Git/Queue.hs
17
Git/Queue.hs
|
@ -53,15 +53,15 @@ empty :: Queue
|
|||
empty = Queue 0 M.empty
|
||||
|
||||
{- Adds an action to a queue. -}
|
||||
add :: Queue -> String -> [CommandParam] -> FilePath -> Queue
|
||||
add (Queue n m) subcommand params file = Queue (n + 1) m'
|
||||
add :: Queue -> String -> [CommandParam] -> [FilePath] -> Queue
|
||||
add (Queue n m) subcommand params files = Queue (n + 1) m'
|
||||
where
|
||||
action = Action subcommand params
|
||||
-- There are probably few items in the map, but there
|
||||
-- can be a lot of files per item. So, optimise adding
|
||||
-- files.
|
||||
m' = M.insertWith' const action files m
|
||||
files = file:(M.findWithDefault [] action m)
|
||||
m' = M.insertWith' const action fs m
|
||||
fs = files ++ (M.findWithDefault [] action m)
|
||||
|
||||
{- Number of items in a queue. -}
|
||||
size :: Queue -> Int
|
||||
|
@ -79,11 +79,14 @@ flush repo (Queue _ m) = do
|
|||
|
||||
{- Runs an Action on a list of files in a git repository.
|
||||
-
|
||||
- Complicated by commandline length limits. -}
|
||||
- Complicated by commandline length limits.
|
||||
-
|
||||
- Intentionally runs the command even if the list of files is empty;
|
||||
- this allows queueing commands that do not need a list of files. -}
|
||||
runAction :: Repo -> Action -> [FilePath] -> IO ()
|
||||
runAction repo action files = unless (null files) runxargs
|
||||
runAction repo action files =
|
||||
pOpen WriteToPipe "xargs" ("-0":"git":params) feedxargs
|
||||
where
|
||||
runxargs = pOpen WriteToPipe "xargs" ("-0":"git":params) feedxargs
|
||||
params = toCommand $ gitCommandLine repo
|
||||
(Param (getSubcommand action):getParams action)
|
||||
feedxargs h = hPutStr h $ join "\0" files
|
||||
|
|
|
@ -104,7 +104,7 @@ updateSymlinks = do
|
|||
link <- calcGitLink f k
|
||||
liftIO $ removeFile f
|
||||
liftIO $ createSymbolicLink link f
|
||||
AnnexQueue.add "add" [Param "--"] f
|
||||
AnnexQueue.add "add" [Param "--"] [f]
|
||||
|
||||
moveLocationLogs :: Annex ()
|
||||
moveLocationLogs = do
|
||||
|
@ -134,9 +134,9 @@ moveLocationLogs = do
|
|||
old <- readLog f
|
||||
new <- readLog dest
|
||||
writeLog dest (old++new)
|
||||
AnnexQueue.add "add" [Param "--"] dest
|
||||
AnnexQueue.add "add" [Param "--"] f
|
||||
AnnexQueue.add "rm" [Param "--quiet", Param "-f", Param "--"] f
|
||||
AnnexQueue.add "add" [Param "--"] [dest]
|
||||
AnnexQueue.add "add" [Param "--"] [f]
|
||||
AnnexQueue.add "rm" [Param "--quiet", Param "-f", Param "--"] [f]
|
||||
|
||||
oldlog2key :: FilePath -> Maybe (FilePath, Key)
|
||||
oldlog2key l =
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -3,6 +3,7 @@ git-annex (3.20110708) UNRELEASED; urgency=low
|
|||
* add: Be even more robust to avoid ever leaving the file seemingly deleted.
|
||||
* Bugfix: Make add ../ work.
|
||||
* Support the standard git -c name=value
|
||||
* unannex: Clean up use of git commit -a.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Thu, 07 Jul 2011 21:28:49 -0400
|
||||
|
||||
|
|
|
@ -11,3 +11,5 @@ This doesn't look right:
|
|||
simons 16543 0.3 0.0 15644 1744 pts/1 SN+ 04:14 2:13 | | \_ git --git-dir=/home/simons/annex/.git --work-tree=/home/simons/annex cat-file --batch
|
||||
simons 14224 0.0 0.0 100744 796 pts/1 SN+ 14:10 0:00 | | \_ xargs -0 git --git-dir=/home/simons/annex/.git --work-tree=/home/simons/annex commit -a -m content removed from git annex
|
||||
simons 14225 0.4 0.1 32684 18652 pts/1 DN+ 14:10 0:00 | | \_ git --git-dir=/home/simons/annex/.git --work-tree=/home/simons/annex commit -a -m content removed from git annex -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a -a
|
||||
|
||||
> [[Fixed|done]] --[[Joey]]
|
||||
|
|
Loading…
Add table
Reference in a new issue