Skip to content

Commit 52142b4

Browse files
committed
adapt to changes in gix-ref.
1 parent f538559 commit 52142b4

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

gix-negotiate/tests/baseline/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn run() -> crate::Result {
7171
// }
7272
for tip in lookup_names(&["HEAD"]).into_iter().chain(
7373
refs.iter()?
74-
.prefixed(b"refs/heads".as_bstr())?
74+
.prefixed(b"refs/heads")?
7575
.filter_map(Result::ok)
7676
.map(|r| r.target.into_id()),
7777
) {

gix/src/open/repository.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#![allow(clippy::result_large_err)]
2-
use gix_features::threading::OwnShared;
3-
use std::ffi::OsStr;
4-
use std::{borrow::Cow, path::PathBuf};
5-
62
use super::{Error, Options};
73
use crate::{
4+
bstr,
85
bstr::BString,
96
config,
107
config::{
@@ -14,6 +11,9 @@ use crate::{
1411
open::Permissions,
1512
ThreadSafeRepository,
1613
};
14+
use gix_features::threading::OwnShared;
15+
use std::ffi::OsStr;
16+
use std::{borrow::Cow, path::PathBuf};
1717

1818
#[derive(Default, Clone)]
1919
pub(crate) struct EnvironmentOverrides {
@@ -347,9 +347,10 @@ impl ThreadSafeRepository {
347347
refs.namespace.clone_from(&config.refs_namespace);
348348
let replacements = replacement_objects_refs_prefix(&config.resolved, lenient_config, filter_config_section)?
349349
.and_then(|prefix| {
350+
use bstr::ByteSlice;
350351
let _span = gix_trace::detail!("find replacement objects");
351352
let platform = refs.iter().ok()?;
352-
let iter = platform.prefixed(prefix.clone()).ok()?;
353+
let iter = platform.prefixed(prefix.as_bstr()).ok()?;
353354
let replacements = iter
354355
.filter_map(Result::ok)
355356
.filter_map(|r: gix_ref::Reference| {

gix/src/reference/iter.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
#![allow(clippy::empty_docs)]
33
use std::borrow::Cow;
44

5-
use gix_ref::{
6-
bstr::{BStr, ByteSlice},
7-
file::ReferenceExt,
8-
};
5+
use gix_ref::{bstr::BStr, file::ReferenceExt};
96

107
/// A platform to create iterators over references.
118
#[must_use = "Iterators should be obtained from this iterator platform"]
@@ -49,34 +46,31 @@ impl Platform<'_> {
4946
// TODO: Create a custom `Path` type that enforces the requirements of git naturally, this type is surprising possibly on windows
5047
// and when not using a trailing '/' to signal directories.
5148
pub fn prefixed<'a>(&self, prefix: impl Into<Cow<'a, BStr>>) -> Result<Iter<'_>, init::Error> {
52-
Ok(Iter::new(self.repo, self.platform.prefixed(prefix.into())?))
49+
Ok(Iter::new(self.repo, self.platform.prefixed(prefix.into().as_ref())?))
5350
}
5451

5552
// TODO: tests
5653
/// Return an iterator over all references that are tags.
5754
///
5855
/// They are all prefixed with `refs/tags`.
5956
pub fn tags(&self) -> Result<Iter<'_>, init::Error> {
60-
Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/tags/".as_bstr())?))
57+
Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/tags/")?))
6158
}
6259

6360
// TODO: tests
6461
/// Return an iterator over all local branches.
6562
///
6663
/// They are all prefixed with `refs/heads`.
6764
pub fn local_branches(&self) -> Result<Iter<'_>, init::Error> {
68-
Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/heads/".as_bstr())?))
65+
Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/heads/")?))
6966
}
7067

7168
// TODO: tests
7269
/// Return an iterator over all remote branches.
7370
///
7471
/// They are all prefixed with `refs/remotes`.
7572
pub fn remote_branches(&self) -> Result<Iter<'_>, init::Error> {
76-
Ok(Iter::new(
77-
self.repo,
78-
self.platform.prefixed(b"refs/remotes/".as_bstr())?,
79-
))
73+
Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/remotes/")?))
8074
}
8175
}
8276

@@ -123,7 +117,7 @@ impl<'r> Iterator for Iter<'r> {
123117

124118
///
125119
pub mod init {
126-
/// The error returned by [`Platform::all()`][super::Platform::all()] or [`Platform::prefixed()`][super::Platform::prefixed()].
120+
/// The error returned by [`Platform::all()`](super::Platform::all()) or [`Platform::prefixed()`](super::Platform::prefixed()).
127121
#[derive(Debug, thiserror::Error)]
128122
#[allow(missing_docs)]
129123
pub enum Error {

0 commit comments

Comments
 (0)