pub struct ResolvedPathspecs {
pub specs: Vec<String>,
pub sources: Vec<String>,
pub scoped: bool,
}Expand description
Pathspec argv fragments resolved against a repository work tree.
Fields§
§specs: Vec<String>Work-tree-relative pathspec strings for matching.
sources: Vec<String>User-facing spellings aligned with specs (argv or file lines).
scoped: boolTrue when the caller supplied argv paths and/or a from-file (not “whole tree”).
Implementations§
Source§impl ResolvedPathspecs
impl ResolvedPathspecs
Sourcepub fn resolve(
repo: &Repository,
cwd: &Path,
raw: &[String],
from_file: Option<PathspecInput>,
) -> Result<Self, PathspecResolveError>
pub fn resolve( repo: &Repository, cwd: &Path, raw: &[String], from_file: Option<PathspecInput>, ) -> Result<Self, PathspecResolveError>
Resolve raw argv pathspecs and optional --pathspec-from-file bytes against repo.
cwd is the process working directory used for relative pathspec prefixes (never read
from the environment inside the library).
§Examples
use grit_lib::worktree::pathspec::{PathspecInput, ResolvedPathspecs};
use grit_lib::repo::{InitOptions, Repository};
use std::fs;
let dir = tempfile::tempdir()?;
let repo = Repository::init(dir.path(), &InitOptions::default())?;
fs::write(dir.path().join("a.txt"), b"x")?;
let resolved = ResolvedPathspecs::resolve(
&repo,
dir.path(),
&["a.txt".to_string()],
None,
)?;
assert_eq!(resolved.specs, ["a.txt"]);
let from_file = PathspecInput::new(b"a.txt\n".to_vec(), false);
let from_file = ResolvedPathspecs::resolve(&repo, dir.path(), &[], Some(from_file))?;
assert_eq!(from_file.specs, ["a.txt"]);Sourcepub fn is_entire_tree(&self) -> bool
pub fn is_entire_tree(&self) -> bool
Whether the invocation targets the entire work tree (no path arguments or from-file).
Sourcepub fn into_pathspec_lists(self) -> (Vec<String>, Vec<String>)
pub fn into_pathspec_lists(self) -> (Vec<String>, Vec<String>)
Consume self and return resolved specs and user-facing sources.
When Self::is_entire_tree is true, both vectors are empty (match legacy
“stage/remove/clean the whole tree” call sites).
Sourcepub fn into_specs(self) -> Vec<String>
pub fn into_specs(self) -> Vec<String>
Resolved pathspec strings only; empty when the invocation is unscoped.
Trait Implementations§
Source§impl Clone for ResolvedPathspecs
impl Clone for ResolvedPathspecs
Source§impl Debug for ResolvedPathspecs
impl Debug for ResolvedPathspecs
Source§impl Default for ResolvedPathspecs
impl Default for ResolvedPathspecs
impl Eq for ResolvedPathspecs
Source§impl PartialEq for ResolvedPathspecs
impl PartialEq for ResolvedPathspecs
impl StructuralPartialEq for ResolvedPathspecs
Auto Trait Implementations§
impl Freeze for ResolvedPathspecs
impl RefUnwindSafe for ResolvedPathspecs
impl Send for ResolvedPathspecs
impl Sync for ResolvedPathspecs
impl Unpin for ResolvedPathspecs
impl UnsafeUnpin for ResolvedPathspecs
impl UnwindSafe for ResolvedPathspecs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.