feat: support comments in ordinary source buffers
This commit is contained in:
@@ -1093,6 +1093,24 @@ pub fn discover_root(path: &Path) -> Result<PathBuf, String> {
|
||||
discover_root_with_cancellation(path, &AtomicBool::new(false))
|
||||
}
|
||||
|
||||
/// Identify the exact source bytes without writing objects or snapshotting the checkout.
|
||||
pub(crate) fn source_snapshot_revision(root: &Path, content: &str) -> Result<String, String> {
|
||||
let mut command = if root.join(".jj").exists() {
|
||||
git_command(&store_for_jj(root)?)
|
||||
} else {
|
||||
let mut command = Command::new("git");
|
||||
command.arg("-C").arg(root);
|
||||
command
|
||||
};
|
||||
command.args(["hash-object", "--no-filters", "--stdin"]);
|
||||
let id = text(checked(run(
|
||||
command,
|
||||
content.as_bytes().to_vec(),
|
||||
&AtomicBool::new(false),
|
||||
)?)?)?;
|
||||
Ok(format!("working:{}", id.trim()))
|
||||
}
|
||||
|
||||
fn discover_root_with_cancellation(path: &Path, cancelled: &AtomicBool) -> Result<PathBuf, String> {
|
||||
let path = fs::canonicalize(path).map_err(|error| error.to_string())?;
|
||||
let root = path
|
||||
|
||||
Reference in New Issue
Block a user