get rid of need to run pre-commit hook when assistant commits in direct mode
That hook updates associated file bookkeeping info for direct mode. But, everything already called addAssociatedFile when adding/changing a file. It only needed to also call removeAssociatedFile when deleting a file, or a directory. This should make bulk adds faster, by some possibly significant amount. Bulk removals may be a little slower, since it has to use catKeyFile now on each removed file, but will still be faster than adds.
This commit is contained in:
parent
cb575cbe91
commit
ebee93a837
2 changed files with 14 additions and 11 deletions
|
@ -157,23 +157,21 @@ commitStaged = do
|
||||||
case v of
|
case v of
|
||||||
Left _ -> return False
|
Left _ -> return False
|
||||||
Right _ -> do
|
Right _ -> do
|
||||||
direct <- isDirect
|
|
||||||
let params = nomessage $ catMaybes
|
|
||||||
[ Just $ Param "--quiet"
|
|
||||||
{- In indirect mode, avoid running the
|
|
||||||
- usual git-annex pre-commit hook;
|
|
||||||
- watch does the same symlink fixing,
|
|
||||||
- and we don't want to deal with unlocked
|
|
||||||
- files in these commits. -}
|
|
||||||
, if direct then Nothing else Just $ Param "--no-verify"
|
|
||||||
]
|
|
||||||
{- Empty commits may be made if tree changes cancel
|
{- Empty commits may be made if tree changes cancel
|
||||||
- each other out, etc. Git returns nonzero on those,
|
- each other out, etc. Git returns nonzero on those,
|
||||||
- so don't propigate out commit failures. -}
|
- so don't propigate out commit failures. -}
|
||||||
void $ inRepo $ catchMaybeIO .
|
void $ inRepo $ catchMaybeIO .
|
||||||
Git.Command.runQuiet (Param "commit" : params)
|
Git.Command.runQuiet
|
||||||
|
(Param "commit" : nomessage params)
|
||||||
return True
|
return True
|
||||||
where
|
where
|
||||||
|
params =
|
||||||
|
[ Param "--quiet"
|
||||||
|
{- Avoid running the usual pre-commit hook;
|
||||||
|
- the Watcher does the same symlink fixing,
|
||||||
|
- and direct mode bookkeeping updating. -}
|
||||||
|
, Param "--no-verify"
|
||||||
|
]
|
||||||
nomessage ps
|
nomessage ps
|
||||||
| Git.Version.older "1.7.2" =
|
| Git.Version.older "1.7.2" =
|
||||||
Param "-m" : Param "autocommit" : ps
|
Param "-m" : Param "autocommit" : ps
|
||||||
|
|
|
@ -300,6 +300,11 @@ onDel file _ = do
|
||||||
|
|
||||||
onDel' :: FilePath -> Annex ()
|
onDel' :: FilePath -> Annex ()
|
||||||
onDel' file = do
|
onDel' file = do
|
||||||
|
whenM isDirect $ do
|
||||||
|
mkey <- catKeyFile file
|
||||||
|
case mkey of
|
||||||
|
Nothing -> noop
|
||||||
|
Just key -> void $ removeAssociatedFile key file
|
||||||
Annex.Queue.addUpdateIndex =<<
|
Annex.Queue.addUpdateIndex =<<
|
||||||
inRepo (Git.UpdateIndex.unstageFile file)
|
inRepo (Git.UpdateIndex.unstageFile file)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue