-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
cargo thinks the following dependencies are different although they are exactly the same:
[dependencies]
a = {git = "https://github.com/aaa/bbb"}
a = {git = "https://github.com/aaa/bbb.git"}
a = {git = "https://github.com/aaa///bbb"}
a = {git = "https://github.com/aaa/bbb", rev ="0123456789abcdef"}
a = {git = "https://github.com/aaa/bbb", branch = "ccc"}
a = {git = "https://github.com/aaa/bbb", tag = "ddd"}
a = {git = "https://github.com/fff/bbb", tag = "ddd"}
assuming that branch ccc
HEAD as well as tag ddd
points to rev = "0123456789abcdef"
, being the HEAD of master
. Moreover, fff/bbb
being a fresh fork of repository bbb
by user fff
I would suggest that all these references are being treated as equal because they are.
The fact that cargo doesn't know that all these dependencies are equal causes a lot of trouble:
- two separate but identical versions of a crate in dependency tree rust#61725
- Patching dependencies does not work if it's for the same location but a different branch #5478
- having some sort of semver for git dependencies #6961
The great thing about git is that a commit hash is a unique fingerprint of a repository. It doesn't matter on which branch, tag or even in which organization the reference is located. The commit hash is the same, so is the code.
actually, just writing
[dependencies]
a = { git-rev = "0123456789abcdef" }
might not be practical, but it would be unique across the entirety of all git repositories in existence. The only problem being to retrieve the corresponding code if you don't know the url, so I'm not suggesting this syntax. I just want to make the point that - behind the scenes - cargo could very well use a git commit hash without any url, branch or tag as an identifier for a specific version of a crate.