Auto merge of #4919 - alexcrichton:faster-git-clone, r=matklad
authorbors <bors@rust-lang.org>
Mon, 8 Jan 2018 18:04:53 +0000 (18:04 +0000)
committerbors <bors@rust-lang.org>
Mon, 8 Jan 2018 18:04:53 +0000 (18:04 +0000)
commitc4003c4fbb2cb780a5545c540dc75688684f6788
treee933c0e7f6d8a19e59538ceae0d304976afe4ae4
parent93bf2a3c9ab88984b72a612df6ff7c08a3e2f36e
parent5cca4e8c2496a1925a549c26c02ad11dd105c7a4
Auto merge of #4919 - alexcrichton:faster-git-clone, r=matklad

Leverage local links on git checkouts

This commit updates the handling of git checkouts from the database to use
hardlinks if possible, speeding up this operation for large repositories
significantly.

As a refresher, Cargo caches git repositories in a few locations to speed up
local usage of git repositories. Cargo has a "database" folder which is a bare
checkout of any git repository Cargo has cached historically. This database
folder contains effectively a bunch of databases for remote repos that are
updated periodically.

When actually building a crate Cargo will clone this database into a different
location, the checkouts folder. Each rev we build (ever) is cached in the
checkouts folder. This means that once a checkout directory is created it's
frozen for all of time.

This latter step is what this commit is optimizing. When checking out the
database onto the local filesystem at a particular revision. Previously we were
instructing libgit2 to fall back to a "git aware" transport which was
exceedingly slow on some systems for filesystem-to-filesystem transfers. This
optimization (we just forgot to turn it on in libgit2) is a longstanding one and
should speed this up significantly!

Closes #4604