mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +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));
|
||||
} else if let Some(oid_to_fetch) = oid_to_fetch {
|
||||
refspecs.push(format!("+{0}:refs/commit/{0}", oid_to_fetch));
|
||||
} else if rev.parse::<Oid>().is_ok() {
|
||||
// There is a specific commit to fetch and we will just 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.
|
||||
} else if !matches!(shallow, gix::remote::fetch::Shallow::NoChange)
|
||||
&& rev.parse::<Oid>().is_ok()
|
||||
{
|
||||
// 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));
|
||||
} else {
|
||||
// We don't know what the rev will point to. To handle this
|
||||
|
@ -948,13 +948,6 @@ fn dep_with_bad_submodule() {
|
||||
None,
|
||||
)
|
||||
.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
|
||||
.file(
|
||||
@ -979,9 +972,9 @@ fn dep_with_bad_submodule() {
|
||||
"extern crate dep1; pub fn foo() { dep1::dep() }",
|
||||
)
|
||||
.build();
|
||||
let expected = if cargo_uses_gitoxide() {
|
||||
format!(
|
||||
"\
|
||||
|
||||
let expected = format!(
|
||||
"\
|
||||
[UPDATING] git repository [..]
|
||||
[UPDATING] git submodule `file://[..]/dep2`
|
||||
[ERROR] failed to get `dep1` as a dependency of package `foo v0.5.0 [..]`
|
||||
@ -996,41 +989,10 @@ Caused by:
|
||||
failed to update submodule `src`
|
||||
|
||||
Caused by:
|
||||
failed to fetch submodule `src` from [..]
|
||||
|
||||
Caused by:
|
||||
Could not decode server reply
|
||||
|
||||
Caused by:
|
||||
upload-pack: not our ref [..]
|
||||
object not found - no match for id [..]
|
||||
",
|
||||
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())
|
||||
)
|
||||
};
|
||||
path2url(git_project.root())
|
||||
);
|
||||
|
||||
p.cargo("check")
|
||||
.with_stderr(expected)
|
||||
|
Loading…
x
Reference in New Issue
Block a user