…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 | assert!(!change.update.deref, "Deref mode is turned into splits and turned off"); | 35 | assert!(!change.update.deref, "Deref mode is turned into splits and turned off"); |
| 36 | match &change.update.change { | 36 | match &change.update.change { |
| 37 | // reflog first, then reference | 37 | // reflog first, then reference |
| 38 | Change::Update { | 38 | Change::Update { log, new, expected } => { |
| 39 | log, | ||
| 40 | new, | ||
| 41 | expected: mode, | ||
| 42 | } => { | ||
| 43 | let lock = change.lock.take().expect("each ref is locked"); | 39 | let lock = change.lock.take().expect("each ref is locked"); |
| 44 | let (update_ref, update_reflog) = match log.mode { | 40 | let (update_ref, update_reflog) = match log.mode { |
| 45 | RefLog::Only => (false, true), | 41 | RefLog::Only => (false, true), |
| @@ -49,7 +45,7 @@ impl<'s> Transaction<'s> { · 3 unmodified lines | |||
| 49 | match new { | 45 | match new { |
| 50 | Target::Symbolic(_) => {} // no reflog for symref changes | 46 | Target::Symbolic(_) => {} // no reflog for symref changes |
| 51 | Target::Peeled(new_oid) => { | 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 | let do_update = previous.as_ref().map_or(true, |previous| previous != new_oid); | 49 | let do_update = previous.as_ref().map_or(true, |previous| previous != new_oid); |
| 54 | if do_update { | 50 | if do_update { |
| 55 | self.store.reflog_create_or_append( | 51 | self.store.reflog_create_or_append( |
| @@ -58,8 +58,7 @@ pub enum PreviousValue { · 57 unmodified lines | |||
| 58 | impl PreviousValue { | 58 | impl PreviousValue { |
| 59 | pub(crate) fn previous_oid(&self) -> Option<ObjectId> { | 59 | pub(crate) fn previous_oid(&self) -> Option<ObjectId> { |
| 60 | match self { | 60 | match self { |
| 61 | PreviousValue::MustExistAndMatch(Target::Peeled(oid)) | 61 | PreviousValue::MustExistAndMatch(Target::Peeled(oid)) => Some(*oid), |
| 62 | | PreviousValue::ExistingMustMatch(Target::Peeled(oid)) => Some(*oid), | ||
| 63 | _ => None, | 62 | _ => None, |
| 64 | } | 63 | } |
| 65 | } | 64 | } |