mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Only fetch single object in shallow mode for compatibility
This commit is contained in:
parent
99316c8e43
commit
2aaebcbcaa
@ -900,10 +900,15 @@ pub fn fetch(
|
|||||||
refspecs.push(format!("+{0}:{0}", rev));
|
refspecs.push(format!("+{0}:{0}", rev));
|
||||||
} else if let Some(oid_to_fetch) = oid_to_fetch {
|
} else if let Some(oid_to_fetch) = oid_to_fetch {
|
||||||
refspecs.push(format!("+{0}:refs/commit/{0}", oid_to_fetch));
|
refspecs.push(format!("+{0}:refs/commit/{0}", oid_to_fetch));
|
||||||
} else if rev.parse::<Oid>().is_ok() {
|
} else if !matches!(shallow, gix::remote::fetch::Shallow::NoChange)
|
||||||
// There is a specific commit to fetch and we will just do so in shallow-mode only
|
&& rev.parse::<Oid>().is_ok()
|
||||||
// to not disturb the previous logic. Note that with typical settings for shallowing,
|
{
|
||||||
// we will just fetch a single `rev` as single commit.
|
// There is a specific commit to fetch and we will do so in shallow-mode only
|
||||||
|
// to not disturb the previous logic.
|
||||||
|
// Note that with typical settings for shallowing, we will just fetch a single `rev`
|
||||||
|
// as single commit.
|
||||||
|
// The reason we write to `refs/remotes/origin/HEAD` is that it's of special significance
|
||||||
|
// when during `GitReference::resolve()`, but otherwise it shouldn't matter.
|
||||||
refspecs.push(format!("+{0}:refs/remotes/origin/HEAD", rev));
|
refspecs.push(format!("+{0}:refs/remotes/origin/HEAD", rev));
|
||||||
} else {
|
} else {
|
||||||
// We don't know what the rev will point to. To handle this
|
// We don't know what the rev will point to. To handle this
|
||||||
|
@ -948,13 +948,6 @@ fn dep_with_bad_submodule() {
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
std::fs::remove_file(
|
|
||||||
repo.path()
|
|
||||||
.join("objects")
|
|
||||||
.join(&commit.id().to_string()[..2])
|
|
||||||
.join(&commit.id().to_string()[2..]),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let p = project
|
let p = project
|
||||||
.file(
|
.file(
|
||||||
@ -979,8 +972,8 @@ fn dep_with_bad_submodule() {
|
|||||||
"extern crate dep1; pub fn foo() { dep1::dep() }",
|
"extern crate dep1; pub fn foo() { dep1::dep() }",
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
let expected = if cargo_uses_gitoxide() {
|
|
||||||
format!(
|
let expected = format!(
|
||||||
"\
|
"\
|
||||||
[UPDATING] git repository [..]
|
[UPDATING] git repository [..]
|
||||||
[UPDATING] git submodule `file://[..]/dep2`
|
[UPDATING] git submodule `file://[..]/dep2`
|
||||||
@ -996,41 +989,10 @@ Caused by:
|
|||||||
failed to update submodule `src`
|
failed to update submodule `src`
|
||||||
|
|
||||||
Caused by:
|
Caused by:
|
||||||
failed to fetch submodule `src` from [..]
|
object not found - no match for id [..]
|
||||||
|
|
||||||
Caused by:
|
|
||||||
Could not decode server reply
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
upload-pack: not our ref [..]
|
|
||||||
",
|
",
|
||||||
path2url(git_project.root())
|
path2url(git_project.root())
|
||||||
)
|
);
|
||||||
} else {
|
|
||||||
format!(
|
|
||||||
"\
|
|
||||||
[UPDATING] git repository [..]
|
|
||||||
[UPDATING] git submodule `file://[..]/dep2`
|
|
||||||
[ERROR] failed to get `dep1` as a dependency of package `foo v0.5.0 [..]`
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
failed to load source for dependency `dep1`
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
Unable to update {}
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
failed to update submodule `src`
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
failed to fetch submodule `src` from [..]
|
|
||||||
|
|
||||||
Caused by:
|
|
||||||
target OID for the reference doesn't exist on the repository; class=Reference (4)
|
|
||||||
",
|
|
||||||
path2url(git_project.root())
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
p.cargo("check")
|
p.cargo("check")
|
||||||
.with_stderr(expected)
|
.with_stderr(expected)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user