Skip to content

Commit 552dca1

Browse files
committed
hopefully fix things on windows.
1 parent 3f34aab commit 552dca1

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/cargo/sources/git/utils.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
//! Utilities for handling git repositories, mainly around
22
//! authentication/cloning.
33
4-
use crate::core::GitReference;
5-
use crate::util::errors::CargoResult;
6-
use crate::util::{network, Config, IntoUrl, MetricsCounter, Progress};
4+
use std::env;
5+
use std::fmt;
6+
use std::fs::canonicalize;
7+
use std::path::{Path, PathBuf};
8+
use std::process::Command;
9+
use std::time::{Duration, Instant};
10+
711
use anyhow::{anyhow, Context as _};
812
use cargo_util::paths::normalize_path;
913
use cargo_util::{paths, ProcessBuilder};
@@ -12,13 +16,12 @@ use git2::{self, ErrorClass, ObjectType};
1216
use log::{debug, info};
1317
use serde::ser;
1418
use serde::Serialize;
15-
use std::env;
16-
use std::fmt;
17-
use std::path::{Path, PathBuf};
18-
use std::process::Command;
19-
use std::time::{Duration, Instant};
2019
use url::{ParseError, Url};
2120

21+
use crate::core::GitReference;
22+
use crate::util::errors::CargoResult;
23+
use crate::util::{network, Config, IntoUrl, MetricsCounter, Progress};
24+
2225
fn serialize_str<T, S>(t: &T, s: S) -> Result<S::Ok, S::Error>
2326
where
2427
T: fmt::Display,
@@ -395,12 +398,12 @@ impl<'a> GitCheckout<'a> {
395398
if Path::new(child_url.path()).is_relative() {
396399
let parent_remote_path = Path::new(parent_remote_url.path());
397400
let child_remote_path = Path::new(child_url.path());
398-
let normalized_path_buf =
399-
normalize_path(&parent_remote_path.join(child_remote_path));
400-
normalized_path_buf
401-
.to_str()
402-
.expect("We had a utf-8 url earlier, but now we don't?")
403-
.to_string()
401+
let canonical = canonicalize(normalize_path(
402+
&parent_remote_path.join(child_remote_path),
403+
))?;
404+
let mut final_path = parent_remote_url.clone();
405+
final_path.set_path(canonical.to_string_lossy().as_ref());
406+
final_path.to_string()
404407
} else {
405408
child_url.to_string()
406409
}
@@ -414,13 +417,15 @@ impl<'a> GitCheckout<'a> {
414417
Err(err) => Err(err)
415418
.with_context(|| format!("Failed to parse child submodule url"))?,
416419
};
420+
let final_path = canonicalize(Path::new(new_parent_remote_url.path()))?;
421+
new_parent_remote_url.set_path(final_path.to_string_lossy().as_ref());
417422
new_parent_remote_url.to_string()
418423
}
419424
Err(err) => {
420425
return Err(anyhow::format_err!(
421426
"Error parsing submodule url: {:?}?",
422427
err
423-
))
428+
));
424429
}
425430
};
426431

@@ -700,9 +705,9 @@ where
700705
msg.push_str("https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli");
701706
err = err.context(msg);
702707

703-
// Otherwise if we didn't even get to the authentication phase them we may
704-
// have failed to set up a connection, in these cases hint on the
705-
// `net.git-fetch-with-cli` configuration option.
708+
// Otherwise if we didn't even get to the authentication phase them we may
709+
// have failed to set up a connection, in these cases hint on the
710+
// `net.git-fetch-with-cli` configuration option.
706711
} else if let Some(e) = err.downcast_ref::<git2::Error>() {
707712
match e.class() {
708713
ErrorClass::Net

tests/testsuite/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ Caused by:
655655
invalid value: integer `123456789`, expected i8",
656656
);
657657

658+
#[allow(dead_code)]
658659
#[derive(Debug, Deserialize)]
659660
struct S {
660661
f1: i64,
@@ -1154,6 +1155,7 @@ fn table_merge_failure() {
11541155
",
11551156
);
11561157

1158+
#[allow(dead_code)]
11571159
#[derive(Debug, Deserialize)]
11581160
struct Table {
11591161
key: StringList,

0 commit comments

Comments
 (0)