summaryrefslogtreecommitdiff
path: root/Command/PreCommit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-11 14:54:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-11 14:54:29 -0400
commitdffe9499630a8dded76b23ef762f03aa264dc45c (patch)
tree5dcbfff9b0a5ba070c85336fcb643f6a528816f4 /Command/PreCommit.hs
parent8a8987579f8efe290e5084202a416f72eec491a6 (diff)
Optimize both pre-commit and lock subcommands.
isLocked was doing the expensive check before the cheap one. Let's not fork git diff twice per file when committing, especially. git diff is still run more than strictly necessary (ie, more than once) if multiple unlocked files are being committed. But much better now.
Diffstat (limited to 'Command/PreCommit.hs')
-rw-r--r--Command/PreCommit.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs
index cd6ce6f08..72cece8d5 100644
--- a/Command/PreCommit.hs
+++ b/Command/PreCommit.hs
@@ -22,7 +22,7 @@ import qualified Command.Add
start :: SubCmdStartString
start file = do
-- If a file is unlocked for edit, add its new content to the
- -- annex, -}
+ -- annex. -}
locked <- Command.Lock.isLocked file
when (not locked) $ do
pairs <- Backend.chooseBackends [file]
@@ -30,7 +30,8 @@ start file = do
unless (ok) $ do
error $ "failed to add " ++ file ++ "; canceling commit"
-- git commit will have staged the file's content;
- -- drop that and stage the symlink
+ -- drop that and run command queued by Add.state to
+ -- stage the symlink
g <- Annex.gitRepo
liftIO $ Git.run g ["reset", "-q", "--", file]
Annex.queueRun