2 use crate::dirstate::status::IgnoreFnType; |
2 use crate::dirstate::status::IgnoreFnType; |
3 use crate::dirstate::status::StatusPath; |
3 use crate::dirstate::status::StatusPath; |
4 use crate::dirstate_tree::dirstate_map::BorrowedPath; |
4 use crate::dirstate_tree::dirstate_map::BorrowedPath; |
5 use crate::dirstate_tree::dirstate_map::ChildNodesRef; |
5 use crate::dirstate_tree::dirstate_map::ChildNodesRef; |
6 use crate::dirstate_tree::dirstate_map::DirstateMap; |
6 use crate::dirstate_tree::dirstate_map::DirstateMap; |
|
7 use crate::dirstate_tree::dirstate_map::DirstateVersion; |
7 use crate::dirstate_tree::dirstate_map::NodeRef; |
8 use crate::dirstate_tree::dirstate_map::NodeRef; |
8 use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
9 use crate::dirstate_tree::on_disk::DirstateV2ParseError; |
9 use crate::matchers::get_ignore_function; |
10 use crate::matchers::get_ignore_function; |
10 use crate::matchers::Matcher; |
11 use crate::matchers::Matcher; |
11 use crate::utils::files::get_bytes_from_os_string; |
12 use crate::utils::files::get_bytes_from_os_string; |
57 .build_global() |
58 .build_global() |
58 .ok(); |
59 .ok(); |
59 |
60 |
60 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = |
61 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = |
61 if options.list_ignored || options.list_unknown { |
62 if options.list_ignored || options.list_unknown { |
62 let mut hasher = Sha1::new(); |
63 let (ignore_fn, warnings, changed) = match dmap.dirstate_version { |
63 let (ignore_fn, warnings) = get_ignore_function( |
64 DirstateVersion::V1 => { |
64 ignore_files, |
65 let (ignore_fn, warnings) = get_ignore_function( |
65 &root_dir, |
66 ignore_files, |
66 &mut |pattern_bytes| hasher.update(pattern_bytes), |
67 &root_dir, |
67 )?; |
68 &mut |_pattern_bytes| {}, |
68 let new_hash = *hasher.finalize().as_ref(); |
69 )?; |
69 let changed = new_hash != dmap.ignore_patterns_hash; |
70 (ignore_fn, warnings, None) |
70 dmap.ignore_patterns_hash = new_hash; |
71 } |
71 (ignore_fn, warnings, Some(changed)) |
72 DirstateVersion::V2 => { |
|
73 let mut hasher = Sha1::new(); |
|
74 let (ignore_fn, warnings) = get_ignore_function( |
|
75 ignore_files, |
|
76 &root_dir, |
|
77 &mut |pattern_bytes| hasher.update(pattern_bytes), |
|
78 )?; |
|
79 let new_hash = *hasher.finalize().as_ref(); |
|
80 let changed = new_hash != dmap.ignore_patterns_hash; |
|
81 dmap.ignore_patterns_hash = new_hash; |
|
82 (ignore_fn, warnings, Some(changed)) |
|
83 } |
|
84 }; |
|
85 (ignore_fn, warnings, changed) |
72 } else { |
86 } else { |
73 (Box::new(|&_| true), vec![], None) |
87 (Box::new(|&_| true), vec![], None) |
74 }; |
88 }; |
75 |
89 |
76 let filesystem_time_at_status_start = |
90 let filesystem_time_at_status_start = |
131 let new_cachable = common.new_cachable_directories.into_inner().unwrap(); |
145 let new_cachable = common.new_cachable_directories.into_inner().unwrap(); |
132 let outdated = common.outated_cached_directories.into_inner().unwrap(); |
146 let outdated = common.outated_cached_directories.into_inner().unwrap(); |
133 |
147 |
134 outcome.dirty = common.ignore_patterns_have_changed == Some(true) |
148 outcome.dirty = common.ignore_patterns_have_changed == Some(true) |
135 || !outdated.is_empty() |
149 || !outdated.is_empty() |
136 || !new_cachable.is_empty(); |
150 || (!new_cachable.is_empty() |
|
151 && dmap.dirstate_version == DirstateVersion::V2); |
137 |
152 |
138 // Remove outdated mtimes before adding new mtimes, in case a given |
153 // Remove outdated mtimes before adding new mtimes, in case a given |
139 // directory is both |
154 // directory is both |
140 for path in &outdated { |
155 for path in &outdated { |
141 dmap.clear_cached_mtime(path)?; |
156 dmap.clear_cached_mtime(path)?; |