Skip to content

Commit d2c772e

Browse files
committed
change!: fetch::Ref::unpack() now returns the peeled object as well. (#450)
1 parent bab5860 commit d2c772e

File tree

1 file changed

+10
-11
lines changed
  • git-protocol/src/fetch/refs

1 file changed

+10
-11
lines changed

git-protocol/src/fetch/refs/mod.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,20 @@ pub enum Ref {
7878
}
7979

8080
impl Ref {
81-
/// Provide shared fields referring to the ref itself, namely `(name, target)`.
82-
/// In case of peeled refs, the tag object itself is returned as it is what the ref directly refers to.
83-
pub fn unpack(&self) -> (&BString, &git_hash::oid) {
81+
/// Provide shared fields referring to the ref itself, namely `(name, target, [peeled])`.
82+
/// In case of peeled refs, the tag object itself is returned as it is what the ref directly refers to, and target of the tag is returned
83+
/// as `peeled`.
84+
pub fn unpack(&self) -> (&BString, &git_hash::oid, Option<&git_hash::oid>) {
8485
match self {
85-
Ref::Direct {
86+
Ref::Direct { full_ref_name, object }
87+
| Ref::Symbolic {
8688
full_ref_name, object, ..
87-
}
88-
| Ref::Peeled {
89+
} => (full_ref_name, object, None),
90+
Ref::Peeled {
8991
full_ref_name,
9092
tag: object,
91-
..
92-
}
93-
| Ref::Symbolic {
94-
full_ref_name, object, ..
95-
} => (full_ref_name, object),
93+
object: peeled,
94+
} => (full_ref_name, object, Some(peeled)),
9695
}
9796
}
9897
}

0 commit comments

Comments
 (0)