summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-07-14 16:56:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-07-14 17:15:37 -0400
commitded259112449f592bc42207e89c82268f3795f12 (patch)
tree6a3e624445cbd063e32f3f0247a552f0ff47074a
parent0c46cbab09af8cc8761668885e58944d397b856d (diff)
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.
-rw-r--r--AnnexQueue.hs6
-rw-r--r--Command/Add.hs4
-rw-r--r--Command/Fix.hs2
-rw-r--r--Command/FromKey.hs2
-rw-r--r--Command/Lock.hs2
-rw-r--r--Command/Unannex.hs2
-rw-r--r--Git/Queue.hs17
-rw-r--r--Upgrade/V1.hs8
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/git_command_line_constructed_by_unannex_command_has_tons_of_redundant_-a_paramters.mdwn2
10 files changed, 26 insertions, 20 deletions
diff --git a/AnnexQueue.hs b/AnnexQueue.hs
index 4c35adfb8..b1678df07 100644
--- a/AnnexQueue.hs
+++ b/AnnexQueue.hs
@@ -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 ()
diff --git a/Command/Add.hs b/Command/Add.hs
index 5c7cad044..51b95b9b5 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -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
diff --git a/Command/Fix.hs b/Command/Fix.hs
index 60627e9df..47b0c4c9a 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -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
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index fb9ab0775..d59f1de39 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -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
diff --git a/Command/Lock.hs b/Command/Lock.hs
index e55cd9e79..d39df5f33 100644
--- a/Command/Lock.hs
+++ b/Command/Lock.hs
@@ -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
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index f22503ee0..d3623ed99 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -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
diff --git a/Git/Queue.hs b/Git/Queue.hs
index e1ec0cd31..e080476b7 100644
--- a/Git/Queue.hs
+++ b/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
diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs
index c0bbeebaf..165a48262 100644
--- a/Upgrade/V1.hs
+++ b/Upgrade/V1.hs
@@ -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 =
diff --git a/debian/changelog b/debian/changelog
index 673084d2d..9a7c3e7b0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/bugs/git_command_line_constructed_by_unannex_command_has_tons_of_redundant_-a_paramters.mdwn b/doc/bugs/git_command_line_constructed_by_unannex_command_has_tons_of_redundant_-a_paramters.mdwn
index 80bf562ec..181b02b5c 100644
--- a/doc/bugs/git_command_line_constructed_by_unannex_command_has_tons_of_redundant_-a_paramters.mdwn
+++ b/doc/bugs/git_command_line_constructed_by_unannex_command_has_tons_of_redundant_-a_paramters.mdwn
@@ -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]]