Hello all, the Cargo team would like to cast a wider net in asking for feedback about a recent change in rust-lang/cargo#8364. Historically Cargo has treated these two dependency directives as exactly equivalent (the first desugars to the second):
[dependencies]
foo = { git = "https://example.org/foo" }
foo = { git = "https://example.org/foo", branch = "master" }
Unfortunately this means though that repositories whose default branch is not called master
are not supported well, you have historically needed to type branch = "other-name"
to actually depend on that git repository.
In rust-lang/cargo#8364 Cargo's behavior changed to interpret the two dependency directives above as distinct, the first being "whatever HEAD
is" and the latter is "specifically just the master
branch". This change, prior to landing, was known to cause breakage. After landing rust-lang/cargo#8468 has also been reported with breakage we did not expect. Specifically the following scenarios break:
- If you previously did not mention
branch
, then if the git repository you're depending on has both amaster
branch and a default non-master
branch, then this will break. - Due to other changes in how Cargo fetches git commits if you check out a repository with a lock file then
cargo build
will fail if the default branch is not actually calledmaster
. (Cargo only fetches theHEAD
reference now, notrefs/heads/master
) - From rust-lang/cargo#8468, if you use
branch = "master"
in yourCargo.toml
then the lock file is no longer compatible across Cargo before and after this change.
We're a bit unsure in the Cargo team about how best to handle this change. This is something we'd like to land eventually no matter what. It is possible for us to land this without the third point of breakage around lock files, but that would take quite a long time to deploy since it requires changing the lock file format in one way or another.
This is where we're asking for your help! Have you been broken recently by this change? Is this something you were easily able to work around? Are there other forms of breakage that we're not aware of? We're hoping to get some feedback about the practical impact of this change to help us inform what we should be doing here. Any input is greatly appreciated!