git-storage: return previous targets

The Updated values only tell the updated value of the target. It can
be useful to also return the previous value, e.g. for reporting,
hooks, etc.

Add `Option<Oid>` to the Update::Direct and Update::Symbolic variants.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
Fintan Halpenny
2022-09-27 12:32:20 +01:00
parent e6f36318cd
commit 5898c0ffde
2 changed files with 28 additions and 10 deletions
+4 -1
View File
@@ -99,7 +99,6 @@ pub struct SymrefTarget<'a> {
pub target: Oid,
}
// TODO: include the previous values
/// The successful result of an [`Update`] applied to the refdb.
#[derive(Debug, Clone)]
pub enum Updated {
@@ -109,6 +108,8 @@ pub enum Updated {
name: RefString,
/// The new `target` of the reference that was updated.
target: Oid,
/// The previous target of the reference, if it existed.
previous: Option<Oid>,
},
/// The [`Update::Symbolic`] was succesful.
Symbolic {
@@ -116,6 +117,8 @@ pub enum Updated {
name: RefString,
/// The new `target` of the reference that was updated.
target: RefString,
/// The previous peeled target of the reference, if it existed.
previous: Option<Oid>,
},
/// The [`Update::Remove`] was succesful.
Removed {