Skip to content

Commit

Permalink
path_slash
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Jul 31, 2024
1 parent 7b97d96 commit 161f43e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jj-lib = { workspace = true }
maplit = { workspace = true }
minus = { workspace = true }
once_cell = { workspace = true }
path-slash = "0.2.1"
pest = { workspace = true }
pest_derive = { workspace = true }
pollster = { workspace = true }
Expand Down
9 changes: 6 additions & 3 deletions cli/src/commands/git/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use jj_lib::git::{self, GitFetchError, GitFetchStats};
use jj_lib::repo::Repo;
use jj_lib::str_util::StringPattern;
use jj_lib::workspace::Workspace;
use path_slash::PathBufExt;

use crate::cli_util::{CommandHelper, WorkspaceCommandHelper};
use crate::command_error::{cli_error, user_error, user_error_with_message, CommandError};
Expand Down Expand Up @@ -55,10 +56,12 @@ fn absolute_git_source(cwd: &Path, source: &str) -> String {
// drive letter.
if !source.contains(':') && Path::new(source).exists() {
// It's less likely that cwd isn't utf-8, so just fall back to original source.
// TODO: This won't work for Windows UNC path or (less importantly) if the
// original source is a non-UTF Windows path. For Windows UNC paths, we
// could use dunce, though see also https://gitlab.com/kornelski/dunce/-/issues/7
cwd.join(source)
.into_os_string()
.into_string()
.unwrap_or_else(|_| source.to_owned())
.to_slash()
.map_or_else(|| source.to_owned(), |s| s.to_string())
} else {
source.to_owned()
}
Expand Down

0 comments on commit 161f43e

Please sign in to comment.