@@ -114,6 +114,46 @@ impl ChangeRef<'_, '_> {
114114 } => ( location. as_ref ( ) , * index, * entry_mode, id) ,
115115 }
116116 }
117+
118+ /// Return the `location`, in the case of rewrites referring to the current change.
119+ pub fn location ( & self ) -> & BStr {
120+ match self {
121+ ChangeRef :: Addition { location, .. }
122+ | ChangeRef :: Deletion { location, .. }
123+ | ChangeRef :: Modification { location, .. }
124+ | ChangeRef :: Rewrite { location, .. } => location. as_ref ( ) ,
125+ }
126+ }
127+
128+ /// Return the `index`, in the case of rewrites referring to the current change.
129+ pub fn index ( & self ) -> usize {
130+ match self {
131+ ChangeRef :: Addition { index, .. }
132+ | ChangeRef :: Deletion { index, .. }
133+ | ChangeRef :: Modification { index, .. }
134+ | ChangeRef :: Rewrite { index, .. } => * index,
135+ }
136+ }
137+
138+ /// Return the `entry_mode`, in the case of rewrites referring to the current change.
139+ pub fn entry_mode ( & self ) -> gix_index:: entry:: Mode {
140+ match self {
141+ ChangeRef :: Addition { entry_mode, .. }
142+ | ChangeRef :: Deletion { entry_mode, .. }
143+ | ChangeRef :: Modification { entry_mode, .. }
144+ | ChangeRef :: Rewrite { entry_mode, .. } => * entry_mode,
145+ }
146+ }
147+
148+ /// Return the `id`, in the case of rewrites referring to the current change.
149+ pub fn id ( & self ) -> & gix_hash:: oid {
150+ match self {
151+ ChangeRef :: Addition { id, .. }
152+ | ChangeRef :: Deletion { id, .. }
153+ | ChangeRef :: Modification { id, .. }
154+ | ChangeRef :: Rewrite { id, .. } => id,
155+ }
156+ }
117157}
118158
119159impl rewrites:: tracker:: Change for ChangeRef < ' _ , ' _ > {
0 commit comments