@@ -434,6 +434,34 @@ impl<'a> ChangeRef<'a> {
434
434
}
435
435
}
436
436
437
+ /// Return the current mode of this instance, along with its object id.
438
+ pub fn entry_mode_and_id ( & self ) -> ( gix_object:: tree:: EntryMode , & gix_hash:: oid ) {
439
+ match self {
440
+ ChangeRef :: Addition { entry_mode, id, .. }
441
+ | ChangeRef :: Deletion { entry_mode, id, .. }
442
+ | ChangeRef :: Modification { entry_mode, id, .. }
443
+ | ChangeRef :: Rewrite { entry_mode, id, .. } => ( * entry_mode, id) ,
444
+ }
445
+ }
446
+
447
+ /// Return the *previous* mode and id of the resource where possible, i.e. the source of a rename or copy, or a modification.
448
+ pub fn source_entry_mode_and_id ( & self ) -> ( gix_object:: tree:: EntryMode , & gix_hash:: oid ) {
449
+ match self {
450
+ ChangeRef :: Addition { entry_mode, id, .. }
451
+ | ChangeRef :: Deletion { entry_mode, id, .. }
452
+ | ChangeRef :: Modification {
453
+ previous_entry_mode : entry_mode,
454
+ previous_id : id,
455
+ ..
456
+ }
457
+ | ChangeRef :: Rewrite {
458
+ source_entry_mode : entry_mode,
459
+ source_id : id,
460
+ ..
461
+ } => ( * entry_mode, id) ,
462
+ }
463
+ }
464
+
437
465
/// Return the *current* location of the resource, i.e. the destination of a rename or copy, or the
438
466
/// location at which an addition, deletion or modification took place.
439
467
pub fn location ( & self ) -> & ' a BStr {
@@ -478,6 +506,34 @@ impl Change {
478
506
}
479
507
}
480
508
509
+ /// Return the current mode of this instance, along with its object id.
510
+ pub fn entry_mode_and_id ( & self ) -> ( gix_object:: tree:: EntryMode , & gix_hash:: oid ) {
511
+ match self {
512
+ Change :: Addition { entry_mode, id, .. }
513
+ | Change :: Deletion { entry_mode, id, .. }
514
+ | Change :: Modification { entry_mode, id, .. }
515
+ | Change :: Rewrite { entry_mode, id, .. } => ( * entry_mode, id) ,
516
+ }
517
+ }
518
+
519
+ /// Return the *previous* mode and id of the resource where possible, i.e. the source of a rename or copy, or a modification.
520
+ pub fn source_entry_mode_and_id ( & self ) -> ( gix_object:: tree:: EntryMode , & gix_hash:: oid ) {
521
+ match self {
522
+ Change :: Addition { entry_mode, id, .. }
523
+ | Change :: Deletion { entry_mode, id, .. }
524
+ | Change :: Modification {
525
+ previous_entry_mode : entry_mode,
526
+ previous_id : id,
527
+ ..
528
+ }
529
+ | Change :: Rewrite {
530
+ source_entry_mode : entry_mode,
531
+ source_id : id,
532
+ ..
533
+ } => ( * entry_mode, id) ,
534
+ }
535
+ }
536
+
481
537
/// Return the *current* location of the resource, i.e. the destination of a rename or copy, or the
482
538
/// location at which an addition, deletion or modification took place.
483
539
pub fn location ( & self ) -> & BStr {
0 commit comments