Refactor untracked file collection logic in collect_untracked_files function

- Updated the logic to skip processing directories that start with a dot (.) unless they are in the set of tracked directories. This change improves the efficiency of identifying untracked files by preventing unnecessary directory traversal.
- Ensured that the `walk_dir` function is called only for relevant directories, enhancing the overall performance of the file collection process.

These modifications aim to optimize the handling of untracked files within the git repository.
This commit is contained in:
Joe 2026-03-01 14:29:06 -06:00
parent 8b0665b9cd
commit 7b17d3d55e

View file

@ -354,9 +354,10 @@ fn collect_untracked_files(repo: &gix::Repository, untracked: &mut HashSet<PathB
if let Ok(meta) = entry.metadata() {
if meta.is_dir() {
if tracked_dirs.contains(rel_str.as_ref() as &str) {
walk_dir(base, &path, index, tracked_dirs, untracked);
if name.starts_with('.') && !tracked_dirs.contains(rel_str.as_ref() as &str) {
continue;
}
walk_dir(base, &path, index, tracked_dirs, untracked);
} else if meta.is_file() {
let path_as_bstr: &gix::bstr::BStr = rel_str.as_bytes().as_bstr();
let is_tracked = index.entry_by_path(path_as_bstr).is_some();