Skip to content

Commit 7dff447

Browse files
committed
Merge branch 'improvements'
2 parents b0668fb + 70d835b commit 7dff447

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

gix-ref/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ pub(crate) struct Store {
121121
inner: store::State,
122122
}
123123

124-
/// A validated complete and fully qualified referenced reference name, safe to use for all operations.
124+
/// A validated complete and fully qualified reference name, safe to use for all operations.
125125
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
126126
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
127127
pub struct FullName(pub(crate) BString);
128128

129-
/// A validated complete and fully qualified referenced reference name, safe to use for all operations.
129+
/// A validated complete and fully qualified reference name, safe to use for all operations.
130130
#[derive(Hash, Debug, PartialEq, Eq, Ord, PartialOrd)]
131131
#[repr(transparent)]
132132
pub struct FullNameRef(BStr);
@@ -138,10 +138,12 @@ pub struct PartialNameRef(BStr);
138138

139139
/// A validated and potentially partial reference name, safe to use for common operations.
140140
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
141+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
141142
pub struct PartialName(BString);
142143

143144
/// A _validated_ prefix for references to act as a namespace.
144145
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
146+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
145147
pub struct Namespace(BString);
146148

147149
/// Denotes the kind of reference.
@@ -160,6 +162,7 @@ pub enum Kind {
160162
///
161163
/// This translates into a prefix containing all references of a given category.
162164
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
165+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
163166
pub enum Category<'a> {
164167
/// A tag in `refs/tags`
165168
Tag,
@@ -179,6 +182,7 @@ pub enum Category<'a> {
179182
/// A `PseudoRef` in another _linked_ worktree, never in the main one, like `worktrees/<id>/HEAD`.
180183
LinkedPseudoRef {
181184
/// The name of the worktree.
185+
#[cfg_attr(feature = "serde", serde(borrow))]
182186
name: &'a BStr,
183187
},
184188
/// Any reference that is prefixed with `worktrees/<id>/refs/`.

gix/src/remote/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl Direction {
2323

2424
/// The name of a remote, either interpreted as symbol like `origin` or as url as returned by [`Remote::name()`][crate::Remote::name()].
2525
#[derive(Debug, PartialEq, Eq, Clone, Ord, PartialOrd, Hash)]
26+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2627
pub enum Name<'repo> {
2728
/// A symbolic name, like `origin`.
2829
/// Note that it has not necessarily been validated yet.

gix/src/remote/name.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ impl Name<'_> {
5050
Name::Symbol(_) => None,
5151
}
5252
}
53+
54+
/// Return a fully-owned copy of this instance.
55+
pub fn to_owned(&self) -> Name<'static> {
56+
match self {
57+
Name::Symbol(s) => Name::Symbol(s.clone().into_owned().into()),
58+
Name::Url(s) => Name::Url(s.clone().into_owned().into()),
59+
}
60+
}
5361
}
5462

5563
impl<'a> TryFrom<Cow<'a, BStr>> for Name<'a> {

0 commit comments

Comments
 (0)