Skip to content

Commit df81076

Browse files
committed
adapt to changes in gix-protocol
1 parent 0de7117 commit df81076

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

gitoxide-core/src/repository/fetch.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=3;
1818

1919
pub(crate) mod function {
2020
use anyhow::bail;
21+
use gix::remote::fetch::refs::update::TypeChange;
2122
use gix::{prelude::ObjectIdExt, refspec::match_group::validate::Fix, remote::fetch::Status};
2223
use layout::{
2324
backends::svg::SVGWriter,
@@ -261,11 +262,28 @@ pub(crate) mod function {
261262
crate::repository::remote::refs::print_ref(&mut out, r)?;
262263
}
263264
};
265+
let mode_and_type = update.type_change.map_or_else(
266+
|| format!("{}", update.mode),
267+
|type_change| {
268+
format!(
269+
"{} ({})",
270+
update.mode,
271+
match type_change {
272+
TypeChange::DirectToSymbolic => {
273+
"direct ref overwrites symbolic"
274+
}
275+
TypeChange::SymbolicToDirect => {
276+
"symbolic ref overwrites direct"
277+
}
278+
}
279+
)
280+
},
281+
);
264282
match edit {
265283
Some(edit) => {
266-
writeln!(out, " -> {} [{}]", edit.name, update.mode)
284+
writeln!(out, " -> {} [{mode_and_type}]", edit.name)
267285
}
268-
None => writeln!(out, " [{}]", update.mode),
286+
None => writeln!(out, " [{mode_and_type}]"),
269287
}?;
270288
}
271289
consume_skipped_tags(&mut skipped_due_to_implicit_tag, &mut out)?;

gitoxide-core/src/repository/remote.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ mod refs_impl {
244244
},
245245
Symbolic {
246246
path: String,
247+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
248+
tag: Option<String>,
247249
target: String,
248250
object: String,
249251
},
@@ -265,10 +267,12 @@ mod refs_impl {
265267
},
266268
handshake::Ref::Symbolic {
267269
full_ref_name: path,
270+
tag,
268271
target,
269272
object,
270273
} => JsonRef::Symbolic {
271274
path: path.to_string(),
275+
tag: tag.map(|t| t.to_string()),
272276
target: target.to_string(),
273277
object: object.to_string(),
274278
},
@@ -298,9 +302,15 @@ mod refs_impl {
298302
} => write!(&mut out, "{tag} {path} object:{object}").map(|_| tag.as_ref()),
299303
handshake::Ref::Symbolic {
300304
full_ref_name: path,
305+
tag,
301306
target,
302307
object,
303-
} => write!(&mut out, "{object} {path} symref-target:{target}").map(|_| object.as_ref()),
308+
} => match tag {
309+
Some(tag) => {
310+
write!(&mut out, "{tag} {path} symref-target:{target} peeled:{object}").map(|_| tag.as_ref())
311+
}
312+
None => write!(&mut out, "{object} {path} symref-target:{target}").map(|_| object.as_ref()),
313+
},
304314
handshake::Ref::Unborn { full_ref_name, target } => {
305315
static NULL: gix::hash::ObjectId = gix::hash::ObjectId::null(gix::hash::Kind::Sha1);
306316
write!(&mut out, "unborn {full_ref_name} symref-target:{target}").map(|_| NULL.as_ref())

gix/src/clone/fetch/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub fn update_head(
7676
gix_protocol::handshake::Ref::Symbolic {
7777
full_ref_name,
7878
target,
79+
tag: _,
7980
object,
8081
} if full_ref_name == "HEAD" => (Some(object.as_ref()), Some(target)),
8182
gix_protocol::handshake::Ref::Direct { full_ref_name, object } if full_ref_name == "HEAD" => {

gix/src/remote/connection/fetch/update_refs/tests.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,14 @@ mod update {
582582
},
583583
TargetRef::Symbolic(name) => {
584584
let target = name.as_bstr().into();
585-
let id = r.peel_to_id_in_place().unwrap();
586-
gix_protocol::handshake::Ref::Symbolic {
587-
full_ref_name,
588-
target,
589-
object: id.detach(),
585+
match r.peel_to_id_in_place() {
586+
Ok(id) => gix_protocol::handshake::Ref::Symbolic {
587+
full_ref_name,
588+
target,
589+
tag: None,
590+
object: id.detach(),
591+
},
592+
Err(_) => gix_protocol::handshake::Ref::Unborn { full_ref_name, target },
590593
}
591594
}
592595
}

0 commit comments

Comments
 (0)