pub enum SourceRef<'a> {
    FullName(&'a BStr),
    ObjectId(ObjectId),
}
Expand description

The source (or left-hand) side of a mapping, which references its name.

Variants§

§

FullName(&'a BStr)

A full reference name, which is expected to be valid.

Validity, however, is not enforced here.

§

ObjectId(ObjectId)

The name of an object that is expected to exist on the remote side. Note that it might not be advertised by the remote but part of the object graph, and thus gets sent in the pack. The server is expected to fail unless the desired object is present but at some time it is merely a request by the user.

Implementations§

Create a fully owned instance from this one.

Examples found in repository?
src/match_group/validate.rs (line 114)
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
    pub fn validated(mut self) -> Result<(Self, Vec<Fix>), Error> {
        let mut sources_by_destinations = BTreeMap::new();
        for (dst, (spec_index, src)) in self
            .mappings
            .iter()
            .filter_map(|m| m.rhs.as_ref().map(|dst| (dst.as_ref(), (m.spec_index, &m.lhs))))
        {
            let sources = sources_by_destinations.entry(dst).or_insert_with(Vec::new);
            if !sources.iter().any(|(_, lhs)| lhs == &src) {
                sources.push((spec_index, src))
            }
        }
        let mut issues = Vec::new();
        for (dst, conflicting_sources) in sources_by_destinations.into_iter().filter(|(_, v)| v.len() > 1) {
            issues.push(Issue::Conflict {
                destination_full_ref_name: dst.to_owned(),
                specs: conflicting_sources
                    .iter()
                    .map(|(spec_idx, _)| self.group.specs[*spec_idx].to_bstring())
                    .collect(),
                sources: conflicting_sources.into_iter().map(|(_, src)| src.to_owned()).collect(),
            })
        }
        if !issues.is_empty() {
            Err(Error { issues })
        } else {
            let mut fixed = Vec::new();
            let group = &self.group;
            self.mappings.retain(|m| match m.rhs.as_ref() {
                Some(dst) => {
                    if dst.starts_with(b"refs/") || dst.as_ref() == "HEAD" {
                        true
                    } else {
                        fixed.push(Fix::MappingWithPartialDestinationRemoved {
                            name: dst.as_ref().to_owned(),
                            spec: group.specs[m.spec_index].to_owned(),
                        });
                        false
                    }
                }
                None => true,
            });
            Ok((self, fixed))
        }
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Checks if this value is equivalent to the given key. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.