mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-22 15:45:28 +00:00
working_copy: stat path without traversing from root in one case
We can easily make the `DirEntry` available here, so we can call `.metadata()` on that instead of on the `Path`. I think that avoids walking the path. I'm sure this has no significant impact on performance, but it's also almost as readable.
This commit is contained in:
parent
f6a516ff6d
commit
c9ab0a20d3
@ -16,7 +16,7 @@ use std::cell::{RefCell, RefMut};
|
|||||||
use std::collections::{BTreeMap, HashSet};
|
use std::collections::{BTreeMap, HashSet};
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::{File, Metadata, OpenOptions};
|
use std::fs::{DirEntry, File, Metadata, OpenOptions};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::ops::Bound;
|
use std::ops::Bound;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
@ -435,7 +435,7 @@ impl TreeState {
|
|||||||
if sparse_matcher.matches(&sub_path) {
|
if sparse_matcher.matches(&sub_path) {
|
||||||
self.update_file_state(
|
self.update_file_state(
|
||||||
sub_path,
|
sub_path,
|
||||||
entry.path(),
|
&entry,
|
||||||
git_ignore.as_ref(),
|
git_ignore.as_ref(),
|
||||||
&mut tree_builder,
|
&mut tree_builder,
|
||||||
)?;
|
)?;
|
||||||
@ -474,7 +474,7 @@ impl TreeState {
|
|||||||
fn update_file_state(
|
fn update_file_state(
|
||||||
&mut self,
|
&mut self,
|
||||||
repo_path: RepoPath,
|
repo_path: RepoPath,
|
||||||
disk_path: PathBuf,
|
dir_entry: &DirEntry,
|
||||||
git_ignore: &GitIgnoreFile,
|
git_ignore: &GitIgnoreFile,
|
||||||
tree_builder: &mut TreeBuilder,
|
tree_builder: &mut TreeBuilder,
|
||||||
) -> Result<(), SnapshotError> {
|
) -> Result<(), SnapshotError> {
|
||||||
@ -486,12 +486,11 @@ impl TreeState {
|
|||||||
// ignore it.
|
// ignore it.
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let metadata = disk_path
|
let disk_path = dir_entry.path();
|
||||||
.symlink_metadata()
|
let metadata = dir_entry.metadata().map_err(|err| SnapshotError::IoError {
|
||||||
.map_err(|err| SnapshotError::IoError {
|
message: format!("Failed to stat file {}", disk_path.display()),
|
||||||
message: format!("Failed to stat file {}", disk_path.display()),
|
err,
|
||||||
err,
|
})?;
|
||||||
})?;
|
|
||||||
let mut new_file_state = file_state(&metadata);
|
let mut new_file_state = file_state(&metadata);
|
||||||
match maybe_current_file_state {
|
match maybe_current_file_state {
|
||||||
None => {
|
None => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user