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.