mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-09-28 21:29:02 +00:00
Fix deducing git ignored state for files too, not only directories
This commit is contained in:
parent
6403336028
commit
bd4f144884
@ -242,21 +242,30 @@ impl Git {
|
|||||||
else { self.file_status(index) }
|
else { self.file_status(index) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the status for the file at the given path.
|
/// Get the user-facing status of a file.
|
||||||
|
/// We check the statuses directly applying to a file, and for the ignored
|
||||||
|
/// status we check if any of its parents directories is ignored by git.
|
||||||
fn file_status(&self, file: &Path) -> f::Git {
|
fn file_status(&self, file: &Path) -> f::Git {
|
||||||
let path = reorient(file);
|
let path = reorient(file);
|
||||||
|
|
||||||
self.statuses.iter()
|
let s = self.statuses.iter()
|
||||||
.find(|p| p.0.as_path() == path)
|
.filter(|p| if p.1 == git2::Status::IGNORED {
|
||||||
.map(|&(_, s)| f::Git { staged: index_status(s), unstaged: working_tree_status(s) })
|
path.starts_with(&p.0)
|
||||||
.unwrap_or_default()
|
} else {
|
||||||
|
p.0 == path
|
||||||
|
})
|
||||||
|
.fold(git2::Status::empty(), |a, b| a | b.1);
|
||||||
|
|
||||||
|
let staged = index_status(s);
|
||||||
|
let unstaged = working_tree_status(s);
|
||||||
|
f::Git { staged, unstaged }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the combined, user-facing status of a file or directory.
|
/// Get the combined, user-facing status of a directory.
|
||||||
/// Statuses are aggregating (for example, a directory is considered
|
/// Statuses are aggregating (for example, a directory is considered
|
||||||
/// modified if any file under it has the status modified), except
|
/// modified if any file under it has the status modified), except for
|
||||||
/// for ignored which applies to files under (for example, a file is
|
/// ignored status which applies to files under (for example, a directory
|
||||||
/// considered ignored if one of its parent directories is ignored)
|
/// is considered ignored if one of its parent directories is ignored).
|
||||||
fn dir_status(&self, dir: &Path) -> f::Git {
|
fn dir_status(&self, dir: &Path) -> f::Git {
|
||||||
let path = reorient(dir);
|
let path = reorient(dir);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user