@@ -315,6 +315,7 @@ 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 } ;
318
319
319
320
pub ( super ) enum ApplyChange {
320
321
SetSizeToZero ,
@@ -505,6 +506,41 @@ pub mod iter {
505
506
} ,
506
507
}
507
508
509
+ impl Item {
510
+ /// Return a simplified summary of the item as digest of its status, or `None` if this item is
511
+ /// created from the directory walk and is *not untracked*, or if it is merely to communicate
512
+ /// a needed update to the index entry.
513
+ pub fn summary ( & self ) -> Option < gix_status:: index_as_worktree_with_renames:: Summary > {
514
+ use gix_status:: index_as_worktree_with_renames:: Summary :: * ;
515
+ Some ( match self {
516
+ Item :: Modification { status, .. } => match status {
517
+ EntryStatus :: Conflict ( _) => Conflict ,
518
+ EntryStatus :: Change ( change) => match change {
519
+ Change :: Removed => Removed ,
520
+ Change :: Type => TypeChange ,
521
+ Change :: Modification { .. } | Change :: SubmoduleModification ( _) => Modified ,
522
+ } ,
523
+ EntryStatus :: NeedsUpdate ( _) => return None ,
524
+ EntryStatus :: IntentToAdd => IntentToAdd ,
525
+ } ,
526
+ Item :: DirectoryContents { entry, .. } => {
527
+ if matches ! ( entry. status, gix_dir:: entry:: Status :: Untracked ) {
528
+ Added
529
+ } else {
530
+ return None ;
531
+ }
532
+ }
533
+ Item :: Rewrite { copy, .. } => {
534
+ if * copy {
535
+ Copied
536
+ } else {
537
+ Renamed
538
+ }
539
+ }
540
+ } )
541
+ }
542
+ }
543
+
508
544
impl < ' index > From < gix_status:: index_as_worktree_with_renames:: Entry < ' index , ( ) , SubmoduleStatus > > for Item {
509
545
fn from ( value : gix_status:: index_as_worktree_with_renames:: Entry < ' index , ( ) , SubmoduleStatus > ) -> Self {
510
546
match value {
@@ -675,7 +711,7 @@ pub mod iter {
675
711
}
676
712
677
713
impl Iterator for super :: Iter {
678
- type Item = Result < Item , crate :: status :: index_worktree:: Error > ;
714
+ type Item = Result < Item , index_worktree:: Error > ;
679
715
680
716
fn next ( & mut self ) -> Option < Self :: Item > {
681
717
#[ cfg( feature = "parallel" ) ]
0 commit comments