@@ -315,6 +315,9 @@ pub mod iter {
315
315
use crate :: status:: index_worktree:: { iter, BuiltinSubmoduleStatus } ;
316
316
use crate :: status:: { index_worktree, Platform } ;
317
317
use crate :: worktree:: IndexPersistedOrInMemory ;
318
+ use gix_status:: index_as_worktree:: { Change , EntryStatus } ;
319
+
320
+ pub use gix_status:: index_as_worktree_with_renames:: Summary ;
318
321
319
322
pub ( super ) enum ApplyChange {
320
323
SetSizeToZero ,
@@ -377,7 +380,7 @@ pub mod iter {
377
380
/// This can also happen for copies.
378
381
RewriteFromIndex {
379
382
/// The entry that is the source of the rewrite, which means it was removed on disk,
380
- /// equivalent to [Change::Removed](gix_status::index_as_worktree::Change::Removed) .
383
+ /// equivalent to [Change::Removed].
381
384
///
382
385
/// Note that the [entry-id](gix_index::Entry::id) is the content-id of the source of the rewrite.
383
386
source_entry : gix_index:: Entry ,
@@ -505,6 +508,41 @@ pub mod iter {
505
508
} ,
506
509
}
507
510
511
+ impl Item {
512
+ /// Return a simplified summary of the item as digest of its status, or `None` if this item is
513
+ /// created from the directory walk and is *not untracked*, or if it is merely to communicate
514
+ /// a needed update to the index entry.
515
+ pub fn summary ( & self ) -> Option < Summary > {
516
+ use gix_status:: index_as_worktree_with_renames:: Summary :: * ;
517
+ Some ( match self {
518
+ Item :: Modification { status, .. } => match status {
519
+ EntryStatus :: Conflict ( _) => Conflict ,
520
+ EntryStatus :: Change ( change) => match change {
521
+ Change :: Removed => Removed ,
522
+ Change :: Type => TypeChange ,
523
+ Change :: Modification { .. } | Change :: SubmoduleModification ( _) => Modified ,
524
+ } ,
525
+ EntryStatus :: NeedsUpdate ( _) => return None ,
526
+ EntryStatus :: IntentToAdd => IntentToAdd ,
527
+ } ,
528
+ Item :: DirectoryContents { entry, .. } => {
529
+ if matches ! ( entry. status, gix_dir:: entry:: Status :: Untracked ) {
530
+ Added
531
+ } else {
532
+ return None ;
533
+ }
534
+ }
535
+ Item :: Rewrite { copy, .. } => {
536
+ if * copy {
537
+ Copied
538
+ } else {
539
+ Renamed
540
+ }
541
+ }
542
+ } )
543
+ }
544
+ }
545
+
508
546
impl < ' index > From < gix_status:: index_as_worktree_with_renames:: Entry < ' index , ( ) , SubmoduleStatus > > for Item {
509
547
fn from ( value : gix_status:: index_as_worktree_with_renames:: Entry < ' index , ( ) , SubmoduleStatus > ) -> Self {
510
548
match value {
@@ -675,7 +713,7 @@ pub mod iter {
675
713
}
676
714
677
715
impl Iterator for super :: Iter {
678
- type Item = Result < Item , crate :: status :: index_worktree:: Error > ;
716
+ type Item = Result < Item , index_worktree:: Error > ;
679
717
680
718
fn next ( & mut self ) -> Option < Self :: Item > {
681
719
#[ cfg( feature = "parallel" ) ]
0 commit comments