History

[clone] When unpacking peeled refs, use the object that refers to the tag…

…and not the one that refers to the (usually) commit the tags points to. When declaring wants, it really wants to see tips first, it appears. Quite tricky

Sebastian Thiel committed 6 years ago

Commit fe8bb391 parent 7c8ecb73 files · +6 −4Browse files

Unified · Split

3 files
  1. git-protocol/src/fetch/refs.rs +4 −2
  2. git-protocol/tests/fetch/mod.rs +1 −1
  3. gitoxide-core/src/pack/receive.rs +1 −1
git-protocol/src/fetch/refs.rs+4−2
@@ -54,10 +54,12 @@ pub enum Ref { · 53 unmodified lines
5454 }
5555
5656 impl Ref {
57− pub fn unpack_common(&self) -> (&BString, &owned::Id) {
57+ /// Provide shared fields referring to the ref itself. In case of peeled refs, the tag object itself is returned as it is what
58+ /// the path refers to.
59+ pub fn unpack(&self) -> (&BString, &owned::Id) {
5860 match self {
5961 Ref::Direct { path, object, .. }
60− | Ref::Peeled { path, object, .. }
62+ | Ref::Peeled { path, tag: object, .. } // the tag acts as reference
6163 | Ref::Symbolic { path, object, .. } => (path, object),
6264 }
6365 }
git-protocol/tests/fetch/mod.rs+1−1
@@ -16,7 +16,7 @@ struct CloneDelegate { · 15 unmodified lines
1616 impl fetch::Delegate for CloneDelegate {
1717 fn negotiate(&mut self, refs: &[Ref], arguments: &mut Arguments, _previous_result: Option<&Response>) -> Action {
1818 for r in refs {
19− arguments.want(r.unpack_common().1.to_borrowed());
19+ arguments.want(r.unpack().1.to_borrowed());
2020 }
2121 Action::Close
2222 }
gitoxide-core/src/pack/receive.rs+1−1
@@ -20,7 +20,7 @@ struct CloneDelegate<W: io::Write> { · 19 unmodified lines
2020 impl<W: io::Write> git_protocol::fetch::Delegate for CloneDelegate<W> {
2121 fn negotiate(&mut self, refs: &[Ref], arguments: &mut Arguments, _previous: Option<&Response>) -> Action {
2222 for r in refs {
23− arguments.want(r.unpack_common().1.to_borrowed());
23+ arguments.want(r.unpack().1.to_borrowed());
2424 }
2525 Action::Close
2626 }