Skip to content

Commit 91d1a3a

Browse files
committed
adapt to changes in git-refspec (#450)
1 parent e819fc6 commit 91d1a3a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

git-repository/src/remote/connection/ref_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum Error {
1919
MappingValidation(#[from] git_refspec::match_group::validate::Error),
2020
}
2121

22-
impl<'a, 'repo, T, P> Connection<'a, 'repo, T, P>
22+
impl<'remote, 'repo, T, P> Connection<'remote, 'repo, T, P>
2323
where
2424
T: Transport,
2525
P: Progress,
@@ -32,14 +32,14 @@ where
3232
///
3333
/// Note that this doesn't fetch the objects mentioned in the tips nor does it make any change to underlying repository.
3434
#[git_protocol::maybe_async::maybe_async]
35-
pub async fn ref_map(mut self) -> Result<fetch::RefMap, Error> {
35+
pub async fn ref_map(mut self) -> Result<fetch::RefMap<'remote>, Error> {
3636
let res = self.ref_map_inner().await;
3737
git_protocol::fetch::indicate_end_of_interaction(&mut self.transport).await?;
3838
res
3939
}
4040

4141
#[git_protocol::maybe_async::maybe_async]
42-
async fn ref_map_inner(&mut self) -> Result<fetch::RefMap, Error> {
42+
async fn ref_map_inner(&mut self) -> Result<fetch::RefMap<'remote>, Error> {
4343
let remote = self.fetch_refs().await?;
4444
let group = git_refspec::MatchGroup::from_fetch_specs(self.remote.fetch_specs.iter().map(|s| s.to_ref()));
4545
let (res, fixes) = group

git-repository/src/remote/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ pub mod fetch {
3232

3333
/// Information about the relationship between our refspecs, and remote references with their local counterparts.
3434
#[derive(Debug, Clone)]
35-
pub struct RefMap {
35+
pub struct RefMap<'spec> {
3636
/// A mapping between a remote reference and a local tracking branch.
3737
pub mappings: Vec<Mapping>,
3838
/// Information about the fixes applied to the `mapping` due to validation and sanitization.
39-
pub fixes: Vec<git_refspec::match_group::validate::Fix>,
39+
pub fixes: Vec<git_refspec::match_group::validate::Fix<'spec>>,
4040
/// All refs advertised by the remote.
4141
pub remote_refs: Vec<git_protocol::fetch::Ref>,
4242
/// Additional information provided by the server as part of the handshake.

gitoxide-core/src/repository/remote.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod refs_impl {
33
use anyhow::bail;
44
use git_repository as git;
55
use git_repository::protocol::fetch;
6+
use git_repository::refspec::RefSpec;
67

78
use crate::OutputFormat;
89

@@ -65,7 +66,9 @@ mod refs_impl {
6566
.await?;
6667

6768
match kind {
68-
refs::Kind::Tracking { .. } => print_refmap(&repo, remote, map, out, err),
69+
refs::Kind::Tracking { .. } => {
70+
print_refmap(&repo, remote.refspecs(git::remote::Direction::Fetch), map, out, err)
71+
}
6972
refs::Kind::Remote => {
7073
match format {
7174
OutputFormat::Human => drop(print(out, &map.remote_refs)),
@@ -82,8 +85,8 @@ mod refs_impl {
8285

8386
fn print_refmap(
8487
repo: &git::Repository,
85-
remote: git::Remote<'_>,
86-
mut map: git::remote::fetch::RefMap,
88+
refspecs: &[RefSpec],
89+
mut map: git::remote::fetch::RefMap<'_>,
8790
mut out: impl std::io::Write,
8891
mut err: impl std::io::Write,
8992
) -> anyhow::Result<()> {
@@ -92,7 +95,7 @@ mod refs_impl {
9295
for mapping in &map.mappings {
9396
if mapping.spec_index != last_spec_index {
9497
last_spec_index = mapping.spec_index;
95-
let spec = &remote.refspecs(git::remote::Direction::Fetch)[mapping.spec_index];
98+
let spec = &refspecs[mapping.spec_index];
9699
spec.to_ref().write_to(&mut out)?;
97100
writeln!(out)?;
98101
}

0 commit comments

Comments
 (0)