Tentative fix for #3174

This wraps the generation of git gem binstubs in the same exclusive lock
that is used by installing threads. Since generating binstubs _also_
generates the entire gem, it seems like there were install threads
stepping on each other while writing the gem itself and while writing
the gem to add the binstubs.

Ultimately, I think we should stop writing out all the files for each
gem twice, which seems to be what is happening here. It’s more important
to fix the exceptions first, though. :)