History

[ref #190] don't claim there was a previous oid unnecessarily…

…maybe this is where we should see that mutating this just to use it in reflogs isn't the way.

Sebastian Thiel committed 5 years ago

Commit 68f7fc21 parent 07126d62 files · +3 −8Browse files

Unified · Split

2 files
  1. git-ref/src/store/file/transaction/commit.rs +2 −6
  2. git-ref/src/transaction/mod.rs +1 −2
git-ref/src/store/file/transaction/commit.rs+2−6
@@ -35,11 +35,7 @@ impl<'s> Transaction<'s> { · 34 unmodified lines
3535 assert!(!change.update.deref, "Deref mode is turned into splits and turned off");
3636 match &change.update.change {
3737 // reflog first, then reference
38− Change::Update {
39− log,
40− new,
41− expected: mode,
42− } => {
38+ Change::Update { log, new, expected } => {
4339 let lock = change.lock.take().expect("each ref is locked");
4440 let (update_ref, update_reflog) = match log.mode {
4541 RefLog::Only => (false, true),
@@ -49,7 +45,7 @@ impl<'s> Transaction<'s> { · 3 unmodified lines
4945 match new {
5046 Target::Symbolic(_) => {} // no reflog for symref changes
5147 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);
5349 let do_update = previous.as_ref().map_or(true, |previous| previous != new_oid);
5450 if do_update {
5551 self.store.reflog_create_or_append(
git-ref/src/transaction/mod.rs+1−2
@@ -58,8 +58,7 @@ pub enum PreviousValue { · 57 unmodified lines
5858 impl PreviousValue {
5959 pub(crate) fn previous_oid(&self) -> Option<ObjectId> {
6060 match self {
61− PreviousValue::MustExistAndMatch(Target::Peeled(oid))
62− | PreviousValue::ExistingMustMatch(Target::Peeled(oid)) => Some(*oid),
61+ PreviousValue::MustExistAndMatch(Target::Peeled(oid)) => Some(*oid),
6362 _ => None,
6463 }
6564 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t