git_prole/git/
commitish.rs

1use std::fmt::Display;
2
3use super::commit_hash::CommitHash;
4use super::Ref;
5
6/// A resolved `<commit-ish>`, which can either be a commit hash or a ref name.
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum ResolvedCommitish {
9    /// A commit hash.
10    Commit(CommitHash),
11    /// A ref name.
12    Ref(Ref),
13}
14
15impl Display for ResolvedCommitish {
16    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17        match self {
18            ResolvedCommitish::Commit(commit) => Display::fmt(commit, f),
19            ResolvedCommitish::Ref(ref_name) => Display::fmt(ref_name, f),
20        }
21    }
22}