summaryrefslogtreecommitdiffstats
path: root/extra/git2/src/revspec.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:35 +0000
commit7e5d7eea9c580ef4b41a765bde624af431942b96 (patch)
tree2c0d9ca12878fc4525650aa4e54d77a81a07cc09 /extra/git2/src/revspec.rs
parentAdding debian version 1.70.0+dfsg1-9. (diff)
downloadrustc-7e5d7eea9c580ef4b41a765bde624af431942b96.tar.xz
rustc-7e5d7eea9c580ef4b41a765bde624af431942b96.zip
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extra/git2/src/revspec.rs')
-rw-r--r--extra/git2/src/revspec.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/extra/git2/src/revspec.rs b/extra/git2/src/revspec.rs
new file mode 100644
index 000000000..d2e08670a
--- /dev/null
+++ b/extra/git2/src/revspec.rs
@@ -0,0 +1,34 @@
+use crate::{Object, RevparseMode};
+
+/// A revspec represents a range of revisions within a repository.
+pub struct Revspec<'repo> {
+ from: Option<Object<'repo>>,
+ to: Option<Object<'repo>>,
+ mode: RevparseMode,
+}
+
+impl<'repo> Revspec<'repo> {
+ /// Assembles a new revspec from the from/to components.
+ pub fn from_objects(
+ from: Option<Object<'repo>>,
+ to: Option<Object<'repo>>,
+ mode: RevparseMode,
+ ) -> Revspec<'repo> {
+ Revspec { from, to, mode }
+ }
+
+ /// Access the `from` range of this revspec.
+ pub fn from(&self) -> Option<&Object<'repo>> {
+ self.from.as_ref()
+ }
+
+ /// Access the `to` range of this revspec.
+ pub fn to(&self) -> Option<&Object<'repo>> {
+ self.to.as_ref()
+ }
+
+ /// Returns the intent of the revspec.
+ pub fn mode(&self) -> RevparseMode {
+ self.mode
+ }
+}