Skip to content

Commit

Permalink
merge: add as_normal(), taken from RefTarget
Browse files Browse the repository at this point in the history
The `RefTarget::as_normal()` function is not specific to `RefTarget`,
and I plan to use it from `local_working_copy`.
  • Loading branch information
martinvonz committed Feb 9, 2024
1 parent 5a898b1 commit b253a28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ impl<T> Merge<Option<T>> {
!self.is_absent()
}

/// Returns the value if this is present and non-conflicting.
pub fn as_normal(&self) -> Option<&T> {
self.as_resolved()?.as_ref()
}

/// Creates lists of `removes` and `adds` from a `Merge` by dropping
/// `None` values. Note that the conversion is lossy: the order of `None`
/// values is not preserved when converting back to a `Merge`.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/op_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl RefTarget {

/// Returns id if this target is non-conflicting and points to a commit.
pub fn as_normal(&self) -> Option<&CommitId> {
self.as_resolved()?.as_ref()
self.merge.as_normal()
}

/// Returns true if this target points to no commit.
Expand Down

0 comments on commit b253a28

Please sign in to comment.