Skip to content

Commit a7c4100

Browse files
committed
adapt to changes in gix-dir
1 parent 0d51771 commit a7c4100

File tree

2 files changed

+27
-7
lines changed
  • gitoxide-core/src/repository
  • gix-status/src/index_as_worktree_with_renames

2 files changed

+27
-7
lines changed

gitoxide-core/src/repository/clean.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,16 @@ pub(crate) mod function {
161161
if entry.disk_kind.is_none() {
162162
entry.disk_kind = workdir
163163
.join(gix::path::from_bstr(entry.rela_path.as_bstr()))
164-
.metadata()
164+
.symlink_metadata()
165165
.ok()
166-
.and_then(|e| gix::dir::entry::Kind::try_from_file_type(e.file_type()));
166+
.map(|e| e.file_type().into());
167167
}
168-
let mut disk_kind = entry.disk_kind.expect("present if not pruned");
168+
let Some(mut disk_kind) = entry.disk_kind else {
169+
if debug {
170+
writeln!(err, "DBG: ignoring unreadable entry at '{}' ", entry.rela_path).ok();
171+
}
172+
continue;
173+
};
169174
if !keep {
170175
if debug {
171176
writeln!(err, "DBG: prune '{}' as -x or -p is missing", entry.rela_path).ok();
@@ -183,6 +188,12 @@ pub(crate) mod function {
183188
}
184189

185190
match disk_kind {
191+
Kind::NonFile => {
192+
if debug {
193+
writeln!(err, "DBG: skipped non-file at '{}'", entry.rela_path).ok();
194+
}
195+
continue;
196+
}
186197
Kind::File | Kind::Symlink => {}
187198
Kind::Directory => {
188199
if !directories {
@@ -254,6 +265,7 @@ pub(crate) mod function {
254265
"WOULD remove"
255266
},
256267
suffix = match disk_kind {
268+
Kind::NonFile => unreachable!("always skipped earlier"),
257269
Kind::Directory if entry.property == Some(gix::dir::entry::Property::EmptyDirectory) => {
258270
" empty"
259271
}

gix-status/src/index_as_worktree_with_renames/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub(super) mod function {
158158

159159
let tracker = options
160160
.rewrites
161-
.map(gix_diff::rewrites::Tracker::<rewrite::ModificationOrDirwalkEntry<'index, T, U>>::new)
161+
.map(gix_diff::rewrites::Tracker::<ModificationOrDirwalkEntry<'index, T, U>>::new)
162162
.zip(filter);
163163
let rewrite_outcome = match tracker {
164164
Some((mut tracker, (mut filter, mut attrs))) => {
@@ -168,12 +168,12 @@ pub(super) mod function {
168168
let (change, location) = match event {
169169
Event::IndexEntry(record) => {
170170
let location = Cow::Borrowed(record.relative_path);
171-
(rewrite::ModificationOrDirwalkEntry::Modification(record), location)
171+
(ModificationOrDirwalkEntry::Modification(record), location)
172172
}
173173
Event::DirEntry(entry, collapsed_directory_status) => {
174174
let location = Cow::Owned(entry.rela_path.clone());
175175
(
176-
rewrite::ModificationOrDirwalkEntry::DirwalkEntry {
176+
ModificationOrDirwalkEntry::DirwalkEntry {
177177
id: rewrite::calculate_worktree_id(
178178
options.object_hash,
179179
worktree,
@@ -222,7 +222,7 @@ pub(super) mod function {
222222
}
223223
}
224224
Some(src) => {
225-
let rewrite::ModificationOrDirwalkEntry::DirwalkEntry {
225+
let ModificationOrDirwalkEntry::DirwalkEntry {
226226
id,
227227
entry,
228228
collapsed_directory_status,
@@ -466,6 +466,10 @@ pub(super) mod function {
466466
ModificationOrDirwalkEntry::Modification(c) => c.entry.mode.to_tree_entry_mode(),
467467
ModificationOrDirwalkEntry::DirwalkEntry { entry, .. } => entry.disk_kind.map(|kind| {
468468
match kind {
469+
Kind::NonFile => {
470+
// Trees are never tracked for rewrites, so we 'pretend'.
471+
gix_object::tree::EntryKind::Tree
472+
}
469473
Kind::File => gix_object::tree::EntryKind::Blob,
470474
Kind::Symlink => gix_object::tree::EntryKind::Link,
471475
Kind::Repository | Kind::Directory => gix_object::tree::EntryKind::Tree,
@@ -500,6 +504,10 @@ pub(super) mod function {
500504
};
501505

502506
Ok(match kind {
507+
Kind::NonFile => {
508+
// Go along with unreadable files, they are passed along without rename tracking.
509+
return Ok(object_hash.null());
510+
}
503511
Kind::File => {
504512
let platform = attrs
505513
.at_entry(rela_path, None, objects)

0 commit comments

Comments
 (0)