Skip to content

Commit

Permalink
Auto merge of #8984 - ehuss:reject-ambiguous-git, r=Eh2406
Browse files Browse the repository at this point in the history
Reject ambiguous git dependency declaration.

This rejects a git dependency that specifies more than one of `branch`, `tag`, or `rev`. Cargo does not handle this case very well, and this warning has been in place for 4 years (since #2940).

Fixes #7841
  • Loading branch information
bors committed Dec 16, 2020
2 parents 4f0adae + d65a714 commit fde8ee3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1692,13 +1692,11 @@ impl DetailedTomlDependency {
.count();

if n_details > 1 {
let msg = format!(
bail!(
"dependency ({}) specification is ambiguous. \
Only one of `branch`, `tag` or `rev` is allowed. \
This will be considered an error in future versions",
Only one of `branch`, `tag` or `rev` is allowed.",
name_in_toml
);
cx.warnings.push(msg)
}

let reference = self
Expand Down
9 changes: 5 additions & 4 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,11 +851,12 @@ fn ambiguous_git_reference() {

p.cargo("build -v")
.with_status(101)
.with_stderr_contains(
.with_stderr(
"\
[WARNING] dependency (bar) specification is ambiguous. \
Only one of `branch`, `tag` or `rev` is allowed. \
This will be considered an error in future versions
[ERROR] failed to parse manifest at `[..]`
Caused by:
dependency (bar) specification is ambiguous. Only one of `branch`, `tag` or `rev` is allowed.
",
)
.run();
Expand Down

0 comments on commit fde8ee3

Please sign in to comment.