|
| 1 | +use git::revision::spec::parse::{delegate, Delegate}; |
1 | 2 | use git_repository as git;
|
| 3 | +use git_repository::bstr::BStr; |
| 4 | +use git_repository::hash::Prefix; |
| 5 | +use git_repository::revision::spec::parse::delegate::{PeelTo, ReflogLookup, SiblingBranch, Traversal}; |
| 6 | +use git_repository::revision::spec::Kind; |
2 | 7 | use std::ffi::OsString;
|
3 | 8 |
|
4 |
| -pub fn explain( |
5 |
| - _repo: git::Repository, |
6 |
| - _spec: OsString, |
7 |
| - mut _out: impl std::io::Write, |
8 |
| - mut _err: impl std::io::Write, |
9 |
| -) -> anyhow::Result<()> { |
10 |
| - Ok(()) |
| 9 | +struct Explain<'a> { |
| 10 | + out: &'a mut dyn std::io::Write, |
| 11 | +} |
| 12 | + |
| 13 | +impl<'a> delegate::Revision for Explain<'a> { |
| 14 | + fn find_ref(&mut self, name: &BStr) -> Option<()> { |
| 15 | + todo!() |
| 16 | + } |
| 17 | + |
| 18 | + fn disambiguate_prefix(&mut self, prefix: Prefix) -> Option<()> { |
| 19 | + todo!() |
| 20 | + } |
| 21 | + |
| 22 | + fn reflog(&mut self, query: ReflogLookup) -> Option<()> { |
| 23 | + todo!() |
| 24 | + } |
| 25 | + |
| 26 | + fn nth_checked_out_branch(&mut self, branch_no: usize) -> Option<()> { |
| 27 | + todo!() |
| 28 | + } |
| 29 | + |
| 30 | + fn sibling_branch(&mut self, kind: SiblingBranch) -> Option<()> { |
| 31 | + todo!() |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +impl<'a> delegate::Navigate for Explain<'a> { |
| 36 | + fn traverse(&mut self, kind: Traversal) -> Option<()> { |
| 37 | + todo!() |
| 38 | + } |
| 39 | + |
| 40 | + fn peel_until(&mut self, kind: PeelTo<'_>) -> Option<()> { |
| 41 | + todo!() |
| 42 | + } |
| 43 | + |
| 44 | + fn find(&mut self, regex: &BStr, negated: bool) -> Option<()> { |
| 45 | + todo!() |
| 46 | + } |
| 47 | + |
| 48 | + fn index_lookup(&mut self, path: &BStr, stage: u8) -> Option<()> { |
| 49 | + todo!() |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +impl<'a> delegate::Kind for Explain<'a> { |
| 54 | + fn kind(&mut self, kind: Kind) -> Option<()> { |
| 55 | + todo!() |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +impl<'a> Delegate for Explain<'a> { |
| 60 | + fn done(&mut self) { |
| 61 | + todo!() |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +pub fn explain(_repo: git::Repository, spec: OsString, mut out: impl std::io::Write) -> anyhow::Result<()> { |
| 66 | + let mut explain = Explain { out: &mut out }; |
| 67 | + let spec = git::path::os_str_into_bstr(&spec)?; |
| 68 | + git::revision::spec::parse(spec, &mut explain).map_err(anyhow::Error::from) |
11 | 69 | }
|
0 commit comments