Fixes #5203.

Check whether `dir` is empty before trying `git add --all`.
This is needed for git 1.8.5.
test/git*.jl: don't use `echo` to read-and-write from processes.

This is one of those areas where our current process I/O stuff is
very awkward. Making write_and_readchomp an available function is
not a good solution either. The whole thing needs some design work.
Merge pull request #5209 from MichaelHatherly/mh/gitaddfix

Fixes #5203.