@@ -315,6 +315,7 @@ pub mod iter {
315315 use crate :: status:: index_worktree:: { iter, BuiltinSubmoduleStatus } ;
316316 use crate :: status:: { index_worktree, Platform } ;
317317 use crate :: worktree:: IndexPersistedOrInMemory ;
318+ use gix_status:: index_as_worktree:: { Change , EntryStatus } ;
318319
319320 pub ( super ) enum ApplyChange {
320321 SetSizeToZero ,
@@ -505,6 +506,41 @@ pub mod iter {
505506 } ,
506507 }
507508
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+
508544 impl < ' index > From < gix_status:: index_as_worktree_with_renames:: Entry < ' index , ( ) , SubmoduleStatus > > for Item {
509545 fn from ( value : gix_status:: index_as_worktree_with_renames:: Entry < ' index , ( ) , SubmoduleStatus > ) -> Self {
510546 match value {
@@ -675,7 +711,7 @@ pub mod iter {
675711 }
676712
677713 impl Iterator for super :: Iter {
678- type Item = Result < Item , crate :: status :: index_worktree:: Error > ;
714+ type Item = Result < Item , index_worktree:: Error > ;
679715
680716 fn next ( & mut self ) -> Option < Self :: Item > {
681717 #[ cfg( feature = "parallel" ) ]
0 commit comments