Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ pub enum Error {
MissingMarker(PathBuf),
#[error("unsupported filesystem entry: {0}")]
UnsupportedEntry(PathBuf),
#[error(
"clone failed for {root}: {source}. Found {path}, {problem}, which blocks whole-tree \
cloning. Run `chmod {permission} {}`, or remove it if it is empty and untracked",
shell_quote(.path)
)]
BlockedEntry {
root: PathBuf,
path: PathBuf,
problem: &'static str,
permission: &'static str,
#[source]
source: std::io::Error,
},
#[error("unsafe Git source: {0}")]
UnsafeGit(String),
#[error("directory is not managed by rift: {0}")]
Expand Down Expand Up @@ -78,6 +91,19 @@ pub enum Error {
},
}

/// Quotes `path` for a POSIX shell, leaving plain paths unquoted.
fn shell_quote(path: &Path) -> String {
let path = path.to_string_lossy();
if !path.is_empty()
&& path
.bytes()
.all(|byte| byte.is_ascii_alphanumeric() || b"_@%+=:,./-".contains(&byte))
{
return path.into_owned();
}
format!("'{}'", path.replace('\'', "'\\''"))
}

pub struct Create {
pub from: PathBuf,
pub name: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl From<Error> for Failure {
}
Error::MissingMarker(path) => ("missing_marker", Some(path.clone())),
Error::UnsupportedEntry(path) => ("unsupported_entry", Some(path.clone())),
Error::BlockedEntry { path, .. } => ("blocked_entry", Some(path.clone())),
Error::UnsafeGit(_) => ("unsafe_git", None),
Error::NotManaged(path) => ("not_managed", Some(path.clone())),
Error::MarkerMismatch(path) => ("marker_mismatch", Some(path.clone())),
Expand Down
Loading
Loading