Skip to content

Commit e33efa2

Browse files
yujaByron
authored andcommitted
fix: don't ignore packed ref deletion in non-default transaction mode
Before, Change::Delete edits weren't propagated to packed refs if the mode was DeletionsAndNonSymbolicUpdates/RemoveLooseSourceReference.
1 parent 68fd5b3 commit e33efa2

File tree

2 files changed

+37
-1
lines changed
  • gix-ref
    • src/store/file/transaction
    • tests/file/transaction/prepare_and_commit/create_or_update

2 files changed

+37
-1
lines changed

gix-ref/src/store/file/transaction/prepare.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ impl<'s, 'p> Transaction<'s, 'p> {
287287
..edit.update.clone()
288288
});
289289
*num_updates += 1;
290+
continue;
290291
}
291-
continue;
292292
}
293293
match edit.update.change {
294294
Change::Update {

gix-ref/tests/file/transaction/prepare_and_commit/create_or_update/mod.rs

+36
Original file line numberDiff line numberDiff line change
@@ -813,3 +813,39 @@ fn packed_refs_creation_with_packed_refs_mode_leave_keeps_original_loose_refs()
813813
);
814814
Ok(())
815815
}
816+
817+
#[test]
818+
fn packed_refs_deletion_in_deletions_and_updates_mode() -> crate::Result {
819+
let (_keep, store) = store_writable("make_packed_ref_repository.sh")?;
820+
assert!(
821+
store.try_find_loose("refs/heads/d1")?.is_none(),
822+
"no loose d1 available, it's packed"
823+
);
824+
let odb = gix_odb::at(store.git_dir().join("objects"))?;
825+
let old_id = hex_to_id("134385f6d781b7e97062102c6a483440bfda2a03");
826+
let edits = store
827+
.transaction()
828+
.packed_refs(PackedRefs::DeletionsAndNonSymbolicUpdates(Box::new(odb)))
829+
.prepare(
830+
Some(RefEdit {
831+
change: Change::Delete {
832+
expected: PreviousValue::MustExistAndMatch(Target::Peeled(old_id)),
833+
log: RefLog::AndReference,
834+
},
835+
name: "refs/heads/d1".try_into()?,
836+
deref: false,
837+
}),
838+
Fail::Immediately,
839+
Fail::Immediately,
840+
)?
841+
.commit(committer().to_ref())?;
842+
843+
assert_eq!(edits.len(), 1, "only one edit was performed in the packed refs store");
844+
845+
let packed = store.open_packed_buffer().unwrap().expect("packed refs is available");
846+
assert!(
847+
packed.try_find("refs/heads/d1")?.is_none(),
848+
"d1 should be removed from packed refs"
849+
);
850+
Ok(())
851+
}

0 commit comments

Comments
 (0)