…maybe this is where we should see that mutating this just to use it in reflogs isn't the way.
Unified · Split
| @@ -35,11 +35,7 @@ impl<'s> Transaction<'s> { · 34 unmodified lines | ||
| 35 | 35 | assert!(!change.update.deref, "Deref mode is turned into splits and turned off"); |
| 36 | 36 | match &change.update.change { |
| 37 | 37 | // reflog first, then reference |
| 38 | − Change::Update { | |
| 39 | − log, | |
| 40 | − new, | |
| 41 | − expected: mode, | |
| 42 | − } => { | |
| 38 | + Change::Update { log, new, expected } => { | |
| 43 | 39 | let lock = change.lock.take().expect("each ref is locked"); |
| 44 | 40 | let (update_ref, update_reflog) = match log.mode { |
| 45 | 41 | RefLog::Only => (false, true), |
| @@ -49,7 +45,7 @@ impl<'s> Transaction<'s> { · 3 unmodified lines | ||
| 49 | 45 | match new { |
| 50 | 46 | Target::Symbolic(_) => {} // no reflog for symref changes |
| 51 | 47 | Target::Peeled(new_oid) => { |
| 52 | − let previous = mode.previous_oid().or(change.leaf_referent_previous_oid); | |
| 48 | + let previous = expected.previous_oid().or(change.leaf_referent_previous_oid); | |
| 53 | 49 | let do_update = previous.as_ref().map_or(true, |previous| previous != new_oid); |
| 54 | 50 | if do_update { |
| 55 | 51 | self.store.reflog_create_or_append( |
| @@ -58,8 +58,7 @@ pub enum PreviousValue { · 57 unmodified lines | ||
| 58 | 58 | impl PreviousValue { |
| 59 | 59 | pub(crate) fn previous_oid(&self) -> Option<ObjectId> { |
| 60 | 60 | match self { |
| 61 | − PreviousValue::MustExistAndMatch(Target::Peeled(oid)) | |
| 62 | − | PreviousValue::ExistingMustMatch(Target::Peeled(oid)) => Some(*oid), | |
| 61 | + PreviousValue::MustExistAndMatch(Target::Peeled(oid)) => Some(*oid), | |
| 63 | 62 | _ => None, |
| 64 | 63 | } |
| 65 | 64 | } |