working_copy: rename sub_path to path

The `sub_path` is created by joining `dir` to a basename. I think
calling it just `path` is clear, especially since its the main path
involved in each iteration of the loop.
This commit is contained in:
Martin von Zweigbergk 2023-07-31 23:04:04 -07:00 committed by Martin von Zweigbergk
parent 02f2325fae
commit bcba1c6682

View file

@ -672,8 +672,8 @@ impl TreeState {
if name == ".jj" || name == ".git" {
continue;
}
let sub_path = dir.join(&RepoPathComponent::from(name));
if let Some(file_state) = self.file_states.get(&sub_path) {
let path = dir.join(&RepoPathComponent::from(name));
if let Some(file_state) = self.file_states.get(&path) {
if file_state.file_type == FileType::GitSubmodule {
continue;
}
@ -682,24 +682,24 @@ impl TreeState {
if file_type.is_dir() {
// If the whole directory is ignored, skip it unless we're already tracking
// some file in it.
if git_ignore.matches_all_files_in(&sub_path.to_internal_dir_string())
&& current_tree.path_value(&sub_path).is_none()
if git_ignore.matches_all_files_in(&path.to_internal_dir_string())
&& current_tree.path_value(&path).is_none()
{
continue;
}
work.push(WorkItem {
dir: sub_path,
dir: path,
disk_dir: entry.path(),
git_ignore: git_ignore.clone(),
});
} else if matcher.matches(&sub_path) {
} else if matcher.matches(&path) {
if let Some(progress) = progress {
progress(&sub_path);
progress(&path);
}
let maybe_current_file_state = self.file_states.get(&sub_path);
let maybe_current_file_state = self.file_states.get(&path);
if maybe_current_file_state.is_none()
&& git_ignore.matches_file(&sub_path.to_internal_file_string())
&& git_ignore.matches_file(&path.to_internal_file_string())
{
// If it wasn't already tracked and it matches
// the ignored paths, then
@ -714,18 +714,18 @@ impl TreeState {
err,
})?;
if let Some(new_file_state) = file_state(&metadata) {
deleted_files.remove(&sub_path);
deleted_files.remove(&path);
let update = self.get_updated_tree_value(
&sub_path,
&path,
entry.path(),
maybe_current_file_state,
&current_tree,
&new_file_state,
)?;
if let Some(tree_value) = update {
tree_builder.set(sub_path.clone(), tree_value);
tree_builder.set(path.clone(), tree_value);
}
self.file_states.insert(sub_path, new_file_state);
self.file_states.insert(path, new_file_state);
}
}
}