Skip to content

Commit 7255a5f

Browse files
authored
Merge pull request #1898 from GitoxideLabs/improvements
various improvements
2 parents 85b060c + 9db196b commit 7255a5f

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

gix-diff/src/blob/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub struct Platform {
113113
pub attr_stack: gix_worktree::Stack,
114114

115115
/// The way we convert resources into diffable states.
116-
filter_mode: pipeline::Mode,
116+
pub filter_mode: pipeline::Mode,
117117
/// A continuously growing cache keeping ready-for-diff blobs by their path in the worktree,
118118
/// as that is what affects their final diff-able state.
119119
///

gix-status/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing with 'git status'-like fu
99
authors = ["Sebastian Thiel <[email protected]>", "Pascal Kuthe <[email protected]>"]
1010
edition = "2021"
1111
include = ["src/**/*", "LICENSE-*"]
12-
rust-version = "1.70"
12+
rust-version = "1.74"
1313
autotests = false
1414

1515
[lib]

gix-status/src/index_as_worktree_with_renames/types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ pub enum Entry<'index, ContentChange, SubmoduleStatus> {
129129
/// [CollapsedEntriesEmissionMode::OnStatusMismatch](gix_dir::walk::CollapsedEntriesEmissionMode::OnStatusMismatch).
130130
/// It will also be `Some(dir_status)` if that option was [CollapsedEntriesEmissionMode::All](gix_dir::walk::CollapsedEntriesEmissionMode::All).
131131
dirwalk_entry_collapsed_directory_status: Option<gix_dir::entry::Status>,
132-
/// The object id after the rename, specifically hashed in order to determine equality.
132+
/// The object id as it would appear if the entry was written to the object database, specifically hashed in order to determine equality.
133+
/// Note that it doesn't (necessarily) exist in the object database, and may be [null](gix_hash::ObjectId::null) if no hashing
134+
/// was performed.
133135
dirwalk_entry_id: gix_hash::ObjectId,
134136
/// It's `None` if the 'source.id' is equal to `dirwalk_entry_id`, as identity made an actual diff computation unnecessary.
135137
/// Otherwise, and if enabled, it's `Some(stats)` to indicate how similar both entries were.

gix-status/src/stack.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use std::path::{Path, PathBuf};
2-
1+
use bstr::BStr;
32
use gix_fs::Stack;
3+
use std::borrow::Cow;
4+
use std::path::{Path, PathBuf};
45

56
use crate::SymlinkCheck;
67

@@ -27,6 +28,22 @@ impl SymlinkCheck {
2728
self.inner.make_relative_path_current(relative_path, &mut Delegate)?;
2829
Ok(self.inner.current())
2930
}
31+
32+
/// Like [`Self::verified_path()`], but do not fail if there is no directory entry at `relative_path` or on the way
33+
/// to `relative_path`. Instead.
34+
/// For convenience, this incarnation is tuned to be easy to use with Git paths, i.e. slash-separated `BString` path.
35+
pub fn verified_path_allow_nonexisting(&mut self, relative_path: &BStr) -> std::io::Result<Cow<'_, Path>> {
36+
let rela_path = gix_path::try_from_bstr(relative_path).map_err(std::io::Error::other)?;
37+
if let Err(err) = self.verified_path(&rela_path) {
38+
if err.kind() == std::io::ErrorKind::NotFound {
39+
Ok(Cow::Owned(self.inner.root().join(rela_path)))
40+
} else {
41+
Err(err)
42+
}
43+
} else {
44+
Ok(Cow::Borrowed(self.inner.current()))
45+
}
46+
}
3047
}
3148

3249
struct Delegate;

gix/src/status/index_worktree.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ pub enum Item {
359359
/// [CollapsedEntriesEmissionMode::OnStatusMismatch](gix_dir::walk::CollapsedEntriesEmissionMode::OnStatusMismatch).
360360
/// It will also be `Some(dir_status)` if that option was [CollapsedEntriesEmissionMode::All](gix_dir::walk::CollapsedEntriesEmissionMode::All).
361361
dirwalk_entry_collapsed_directory_status: Option<gix_dir::entry::Status>,
362-
/// The object id after the rename, specifically hashed in order to determine equality.
362+
/// The object id as it would appear if the entry was written to the object database, specifically hashed in order to determine equality.
363+
/// Note that it doesn't (necessarily) exist in the object database, and may be [null](gix_hash::ObjectId::null) if no hashing
364+
/// was performed.
363365
dirwalk_entry_id: gix_hash::ObjectId,
364366
/// It's `None` if the 'source.id' is equal to `dirwalk_entry_id`, as identity made an actual diff computation unnecessary.
365367
/// Otherwise, and if enabled, it's `Some(stats)` to indicate how similar both entries were.

0 commit comments

Comments
 (0)