forked from mirrors/jj
cli: add WorkspaceCommandHelper::parse_file_path() for convenience
WorkspaceCommandHelper knows the context where user file pattern should be resolved.
This commit is contained in:
parent
71ef8e74aa
commit
d635d02f06
2 changed files with 7 additions and 1 deletions
|
@ -501,6 +501,12 @@ impl WorkspaceCommandHelper {
|
|||
.to_owned()
|
||||
}
|
||||
|
||||
/// Parses a path relative to cwd into a RepoPath, which is relative to the
|
||||
/// workspace root.
|
||||
pub fn parse_file_path(&self, input: &str) -> Result<RepoPath, FsPathParseError> {
|
||||
RepoPath::parse_fs_path(&self.cwd, self.workspace_root(), input)
|
||||
}
|
||||
|
||||
pub fn git_config(&self) -> Result<git2::Config, git2::Error> {
|
||||
if let Some(git_repo) = self.repo.store().git_repo() {
|
||||
git_repo.config()
|
||||
|
|
|
@ -1253,7 +1253,7 @@ fn cmd_files(ui: &mut Ui, command: &CommandHelper, args: &FilesArgs) -> Result<(
|
|||
fn cmd_print(ui: &mut Ui, command: &CommandHelper, args: &PrintArgs) -> Result<(), CommandError> {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let commit = workspace_command.resolve_single_rev(&args.revision)?;
|
||||
let path = RepoPath::parse_fs_path(ui.cwd(), workspace_command.workspace_root(), &args.path)?;
|
||||
let path = workspace_command.parse_file_path(&args.path)?;
|
||||
let repo = workspace_command.repo();
|
||||
match commit.tree().path_value(&path) {
|
||||
None => {
|
||||
|
|
Loading…
Reference in a new issue