feat: add Git and Jujutsu gutter indicators
This commit is contained in:
+21
-16
@@ -229,7 +229,7 @@ fn git_command(store: &Path) -> Command {
|
||||
.env("GIT_TERMINAL_PROMPT", "0");
|
||||
cmd
|
||||
}
|
||||
fn jj_command(root: &Path) -> Command {
|
||||
pub(crate) fn jj_command(root: &Path) -> Command {
|
||||
let mut cmd = Command::new("jj");
|
||||
cmd.arg("--repository")
|
||||
.arg(root)
|
||||
@@ -255,7 +255,7 @@ fn path_bytes(bytes: &[u8]) -> Result<PathBuf, String> {
|
||||
))
|
||||
}
|
||||
}
|
||||
fn safe_path(path: &Path) -> Result<(), String> {
|
||||
pub(crate) fn safe_path(path: &Path) -> Result<(), String> {
|
||||
if path.as_os_str().is_empty()
|
||||
|| path
|
||||
.components()
|
||||
@@ -274,7 +274,7 @@ fn safe_path(path: &Path) -> Result<(), String> {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn store_for_jj(root: &Path) -> Result<PathBuf, String> {
|
||||
pub(crate) fn store_for_jj(root: &Path) -> Result<PathBuf, String> {
|
||||
let mut repo = root.join(".jj/repo");
|
||||
if repo.is_file() {
|
||||
let pointer = fs::read(&repo).map_err(|e| e.to_string())?;
|
||||
@@ -289,6 +289,23 @@ fn store_for_jj(root: &Path) -> Result<PathBuf, String> {
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn jj_file_pattern(path: &str) -> String {
|
||||
let mut pattern = String::from("root-file:\"");
|
||||
for ch in path.chars() {
|
||||
match ch {
|
||||
'\\' => pattern.push_str("\\\\"),
|
||||
'"' => pattern.push_str("\\\""),
|
||||
'\0'..='\u{1f}' | '\u{7f}' => {
|
||||
use std::fmt::Write as _;
|
||||
write!(&mut pattern, "\\x{:02x}", ch as u32).unwrap();
|
||||
}
|
||||
_ => pattern.push(ch),
|
||||
}
|
||||
}
|
||||
pattern.push('"');
|
||||
pattern
|
||||
}
|
||||
|
||||
struct Remote {
|
||||
name: String,
|
||||
url: String,
|
||||
@@ -872,19 +889,7 @@ impl Repository {
|
||||
};
|
||||
let bytes = if matches!(kind.as_str(), "file" | "symlink" | "conflict") {
|
||||
// Use an exact fileset and jj's own conflict materialization.
|
||||
let mut pattern = String::from("root-file:\"");
|
||||
for ch in path.chars() {
|
||||
match ch {
|
||||
'\\' => pattern.push_str("\\\\"),
|
||||
'"' => pattern.push_str("\\\""),
|
||||
'\0'..='\u{1f}' | '\u{7f}' => {
|
||||
use std::fmt::Write as _;
|
||||
write!(&mut pattern, "\\x{:02x}", ch as u32).unwrap();
|
||||
}
|
||||
_ => pattern.push(ch),
|
||||
}
|
||||
}
|
||||
pattern.push('"');
|
||||
let pattern = jj_file_pattern(&path);
|
||||
self.jj(
|
||||
root,
|
||||
&["file", "show", "-r", &revset, "-T", "", "--", &pattern],
|
||||
|
||||
Reference in New Issue
Block a user