Compatibility with older git versions; improved cache handling

Change-Id: I0792bab2524b94405626bbfd5af2a2e9222f4fc2
Reviewed-on: http://review.couchbase.org/41980
Reviewed-by: Chris Hillery <ceej@couchbase.com>
Tested-by: Chris Hillery <ceej@couchbase.com>