Fix git tools to compute git directory "properly".

This is not very robust, but at least it doesn't make things worse.