Use git references to manage lifetime of cache entries

Summary:
The idea is that there is a cache directory for git. This directory knows the
current git reference the project is at, and thus guesses the lifetime of cache
entry.

Basically, it makes sure that for a given node, there is only one cache entry
per git reference. We use this behavior because we consider that usually a
developer will switch between branches but very rarely switch between detached
HEAD states.

All cache entries have a refcount for counting the number of git references
that need it. When this refcount reaches 0, the cache entry is deleted.

Test Plan:
Create a git repository and multiple branches, switch between them
and build.

Reviewers: NicolasDP

Reviewed By: NicolasDP

Differential Revision: http://91.121.199.76/D59