Skip to content

Commit 21420da

Browse files
committed
fix match_group::Item to make it uniform with how we typically name refs (#450)
1 parent 6d1c372 commit 21420da

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

git-refspec/src/match_group/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a> MatchGroup<'a> {
8888
.matches_lhs(Item {
8989
full_ref_name: name,
9090
target: &null_id,
91-
tag: None,
91+
object: None,
9292
})
9393
.0
9494
}

git-refspec/src/match_group/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ pub struct Outcome<'spec, 'item> {
2525
pub struct Item<'a> {
2626
/// The full name of the references, like `refs/heads/main`
2727
pub full_ref_name: &'a BStr,
28-
/// The peeled id it points to that we should match against.
28+
/// The id that `full_ref_name` points to, which typically is a commit, but can also be a tag object (or anything else).
2929
pub target: &'a oid,
30-
/// The tag object's id if this is a tag
31-
pub tag: Option<&'a oid>,
30+
/// The object an annotated tag is pointing to, if `target` is an annotated tag.
31+
pub object: Option<&'a oid>,
3232
}
3333

3434
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

git-refspec/src/match_group/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ impl<'a> Needle<'a> {
111111
if *id == item.target {
112112
return Match::Normal;
113113
}
114-
match item.tag {
115-
Some(tag) if tag == *id => Match::Normal,
114+
match item.object {
115+
Some(object) if object == *id => Match::Normal,
116116
_ => Match::None,
117117
}
118118
}

git-refspec/tests/matching/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ pub mod baseline {
1818
pub struct Ref {
1919
pub name: BString,
2020
pub target: ObjectId,
21-
/// Set if this is a tag, pointing to the tag object itself
22-
pub tag: Option<ObjectId>,
21+
/// Set if `target` is an annotated tag, this being the object it points to.
22+
pub object: Option<ObjectId>,
2323
}
2424

2525
impl Ref {
2626
pub fn to_item(&self) -> git_refspec::match_group::Item<'_> {
2727
git_refspec::match_group::Item {
2828
full_ref_name: self.name.borrow(),
2929
target: &self.target,
30-
tag: self.tag.as_deref(),
30+
object: self.object.as_deref(),
3131
}
3232
}
3333
}
@@ -216,13 +216,10 @@ pub mod baseline {
216216
out.push(Ref {
217217
name: name.into(),
218218
target,
219-
tag: None,
219+
object: None,
220220
})
221221
} else {
222-
let last = out.last_mut().unwrap();
223-
let tag = last.target;
224-
last.target = target;
225-
last.tag = Some(tag);
222+
out.last_mut().unwrap().object = Some(target);
226223
}
227224
}
228225
Ok(out)

0 commit comments

Comments
 (0)