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
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 reference37 // 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 changes46 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(
git-ref/src/transaction/mod.rs+1−2
@@ -58,8 +58,7 @@ pub enum PreviousValue { · 57 unmodified lines
58impl PreviousValue {58impl 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 }

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