avoid making empty commits

This doesn't avoid it sometimes attempting to commit when there are no
changes. Typically that happens when a change is pushed in from another
repo; the watcher sees the file and tries to stage it, resulting in an
empty commit. Really fixing that would probably use more CPU than
occasionally trying to make an empty commit.

However, this does save a lot of unnecessary work, as those empty commits
had to be synced out, which no longer happens.
This commit is contained in:
Joey Hess 2012-09-18 14:30:35 -04:00
parent 9f05d19108
commit ba27483c6a

View file

@ -74,17 +74,18 @@ commitThread st changechan commitchan transferqueue dstatus = thread $ runEvery
commitStaged :: Annex Bool
commitStaged = do
Annex.Queue.flush
inRepo $ Git.Command.runBool "commit"
void $ inRepo $ Git.Command.runBool "commit"
[ Param "--allow-empty-message"
, Param "-m", Param ""
-- Empty commits may be made if tree changes cancel
-- each other out, etc
, Param "--allow-empty"
-- 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.
, Param "--quiet"
]
{- Empty commits may be made if tree changes cancel
- each other out, etc. Git returns nonzero on those, so
- don't propigate out commit failures. -}
return True
{- Decide if now is a good time to make a commit.
- Note that the list of change times has an undefined order.