Skip to content

Commit ea95284

Browse files
committed
feat: Add blob::pipeline::WorktreeRoots::is_unset()
That way it's easy to determine if a worktree root has any root set.
1 parent 1d3d258 commit ea95284

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

gix-diff/src/blob/pipeline.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct WorktreeRoots {
2222
pub new_root: Option<PathBuf>,
2323
}
2424

25+
/// Access
2526
impl WorktreeRoots {
2627
/// Return the root path for the given `kind`
2728
pub fn by_kind(&self, kind: ResourceKind) -> Option<&Path> {
@@ -30,6 +31,11 @@ impl WorktreeRoots {
3031
ResourceKind::NewOrDestination => self.new_root.as_deref(),
3132
}
3233
}
34+
35+
/// Return `true` if all worktree roots are unset.
36+
pub fn is_unset(&self) -> bool {
37+
self.new_root.is_none() && self.old_root.is_none()
38+
}
3339
}
3440

3541
/// Data as part of an [Outcome].
@@ -184,6 +190,8 @@ impl Pipeline {
184190
/// Access
185191
impl Pipeline {
186192
/// Return all drivers that this instance was initialized with.
193+
///
194+
/// They are sorted by [`name`](Driver::name) to support binary searches.
187195
pub fn drivers(&self) -> &[super::Driver] {
188196
&self.drivers
189197
}
@@ -445,7 +453,7 @@ impl Pipeline {
445453
}
446454
}
447455
.map_err(|err| {
448-
convert_to_diffable::Error::CreateTempfile {
456+
convert_to_diffable::Error::StreamCopy {
449457
source: err,
450458
rela_path: rela_path.to_owned(),
451459
}
@@ -533,6 +541,8 @@ impl Driver {
533541
pub fn prepare_binary_to_text_cmd(&self, path: &Path) -> Option<std::process::Command> {
534542
let command: &BStr = self.binary_to_text_command.as_ref()?.as_ref();
535543
let cmd = gix_command::prepare(gix_path::from_bstr(command).into_owned())
544+
// TODO: Add support for an actual Context, validate it *can* match Git
545+
.with_context(Default::default())
536546
.with_shell()
537547
.stdin(Stdio::null())
538548
.stdout(Stdio::piped())

gix-diff/src/blob/platform.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub mod prepare_diff {
184184

185185
use crate::blob::platform::Resource;
186186

187-
/// The kind of operation that was performed during the [`diff`](super::Platform::prepare_diff()) operation.
187+
/// The kind of operation that should be performed based on the configuration of the resources involved in the diff.
188188
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
189189
pub enum Operation<'a> {
190190
/// The [internal diff algorithm](imara_diff::diff) should be called with the provided arguments.

0 commit comments

Comments
 (0)