GitSync: support sync-depth (bug 552814)

Support sync-depth for shallow sync, using git reset --merge just
like in the earlier implementation that was reverted in commit
ab840ac982d3c8b676b89f6bedd14e85dd06870f. Also, run git gc --auto
in the foreground, in order to trigger periodic housekeeping and
hopefully avoid errors from automatic git gc calls as reported in
bug 599008.

The default sync-depth is unlimited, which means that default
behavior remains unchanged (unlike the previous implementation that
was reverted).

Bug: https://bugs.gentoo.org/552814
Bug: https://bugs.gentoo.org/599008
3 files changed