Skip to content

Commit 6c82f31

Browse files
committed
reproduce #1598
1 parent 73a7d15 commit 6c82f31

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

gix-protocol/src/handshake/refs/shared.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use bstr::{BStr, BString, ByteSlice};
2-
31
use crate::handshake::{refs::parse::Error, Ref};
2+
use bstr::{BStr, BString, ByteSlice};
43

54
impl From<InternalRef> for Ref {
65
fn from(v: InternalRef) -> Self {
@@ -160,7 +159,13 @@ pub(in crate::handshake::refs) fn parse_v1(
160159
});
161160
}
162161
None => {
163-
let object = gix_hash::ObjectId::from_hex(hex_hash.as_bytes())?;
162+
let object = match gix_hash::ObjectId::from_hex(hex_hash.as_bytes()) {
163+
Ok(id) => id,
164+
Err(_) if hex_hash.as_bstr() == "shallow" => {
165+
todo!("shallow");
166+
}
167+
Err(err) => return Err(err.into()),
168+
};
164169
match out_refs
165170
.iter()
166171
.take(num_initial_out_refs)

gix-protocol/src/handshake/refs/tests.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,58 @@ dce0ea858eef7ff61ad345cc5cdac62203fb3c10 refs/tags/gix-commitgraph-v0.0.0
118118
);
119119
}
120120

121+
#[maybe_async::test(feature = "blocking-client", async(feature = "async-client", async_std::test))]
122+
async fn extract_references_from_v1_refs_with_shallow() {
123+
let input = &mut Fixture(
124+
"73a6868963993a3328e7d8fe94e5a6ac5078a944 HEAD
125+
21c9b7500cb144b3169a6537961ec2b9e865be81 MISSING_NAMESPACE_TARGET
126+
73a6868963993a3328e7d8fe94e5a6ac5078a944 refs/heads/main
127+
8e472f9ccc7d745927426cbb2d9d077de545aa4e refs/pull/13/head
128+
dce0ea858eef7ff61ad345cc5cdac62203fb3c10 refs/tags/gix-commitgraph-v0.0.0
129+
21c9b7500cb144b3169a6537961ec2b9e865be81 refs/tags/gix-commitgraph-v0.0.0^{}
130+
shallow 21c9b7500cb144b3169a6537961ec2b9e865be81
131+
shallow dce0ea858eef7ff61ad345cc5cdac62203fb3c10"
132+
.as_bytes(),
133+
);
134+
let out = refs::from_v1_refs_received_as_part_of_handshake_and_capabilities(
135+
input,
136+
Capabilities::from_bytes(b"\0symref=HEAD:refs/heads/main symref=MISSING_NAMESPACE_TARGET:(null)")
137+
.expect("valid capabilities")
138+
.0
139+
.iter(),
140+
)
141+
.await
142+
.expect("no failure from valid input");
143+
assert_eq!(
144+
out,
145+
vec![
146+
Ref::Symbolic {
147+
full_ref_name: "HEAD".into(),
148+
target: "refs/heads/main".into(),
149+
tag: None,
150+
object: oid("73a6868963993a3328e7d8fe94e5a6ac5078a944")
151+
},
152+
Ref::Direct {
153+
full_ref_name: "MISSING_NAMESPACE_TARGET".into(),
154+
object: oid("21c9b7500cb144b3169a6537961ec2b9e865be81")
155+
},
156+
Ref::Direct {
157+
full_ref_name: "refs/heads/main".into(),
158+
object: oid("73a6868963993a3328e7d8fe94e5a6ac5078a944")
159+
},
160+
Ref::Direct {
161+
full_ref_name: "refs/pull/13/head".into(),
162+
object: oid("8e472f9ccc7d745927426cbb2d9d077de545aa4e")
163+
},
164+
Ref::Peeled {
165+
full_ref_name: "refs/tags/gix-commitgraph-v0.0.0".into(),
166+
tag: oid("dce0ea858eef7ff61ad345cc5cdac62203fb3c10"),
167+
object: oid("21c9b7500cb144b3169a6537961ec2b9e865be81")
168+
},
169+
]
170+
);
171+
}
172+
121173
#[test]
122174
fn extract_symbolic_references_from_capabilities() -> Result<(), client::Error> {
123175
let caps = client::Capabilities::from_bytes(

0 commit comments

Comments
 (0)