Unified · Split
| @@ -98,6 +98,13 @@ impl State { · 97 unmodified lines | ||
| 98 | 98 | .map(|idx| &self.entries[idx]) |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | + /// Like [`entry_index_by_path_and_stage()`][State::entry_index_by_path_and_stage()], | |
| 102 | + /// but returns the mutable entry instead of the index. | |
| 103 | + pub fn entry_mut_by_path_and_stage(&mut self, path: &BStr, stage: entry::Stage) -> Option<&mut Entry> { | |
| 104 | + self.entry_index_by_path_and_stage(path, stage) | |
| 105 | + .map(|idx| &mut self.entries[idx]) | |
| 106 | + } | |
| 107 | + | |
| 101 | 108 | /// Return the entry at `idx` or _panic_ if the index is out of bounds. |
| 102 | 109 | /// |
| 103 | 110 | /// The `idx` is typically returned by [entry_by_path_and_stage()][State::entry_by_path_and_stage()]. |
| @@ -146,7 +146,7 @@ fn remove_flag_is_respected() -> crate::Result { · 145 unmodified lines | ||
| 146 | 146 | assert_eq!(index.entries().len(), total_entries); |
| 147 | 147 | let entries_to_remove = 4; |
| 148 | 148 | for entry in &mut index.entries_mut()[..entries_to_remove] { |
| 149 | − entry.flags.toggle(git_index::entry::Flags::REMOVE); | |
| 149 | + entry.flags.toggle(entry::Flags::REMOVE); | |
| 150 | 150 | } |
| 151 | 151 | let mut buf = Vec::<u8>::new(); |
| 152 | 152 | index.write_to(&mut buf, Default::default())?; |