Backport gclient fixes

Backport #2342 and #2347, as crosswalk-8 also uses git and needs the same fix.