WIP: Fixes #5203.

Check whether `dir` is empty before trying `git add --all`.
This is needed for git 1.8.5.