pub struct Context<'a> {
pub should_interrupt: Option<&'a AtomicBool>,
pub git_dir_realpath: &'a Path,
pub current_dir: &'a Path,
pub index: &'a State,
pub ignore_case_index_lookup: Option<&'a AccelerateLookup<'a>>,
pub pathspec: &'a mut Search,
pub pathspec_attributes: &'a mut dyn FnMut(&BStr, Case, bool, &mut Outcome) -> bool,
pub excludes: Option<&'a mut Stack>,
pub objects: &'a dyn Find,
pub explicit_traversal_root: Option<&'a Path>,
}
Expand description
All information that is required to perform a dirwalk, and classify paths properly.
Fields§
§should_interrupt: Option<&'a AtomicBool>
If not None
, it will be checked before entering any directory to trigger early interruption.
If this flag is true
at any point in the iteration, it will abort with an error.
git_dir_realpath: &'a Path
The git_dir
of the parent repository, after a call to gix_path::realpath()
.
It’s used to help us differentiate our own .git
directory from nested unrelated repositories,
which is needed if core.worktree
is used to nest the .git
directory deeper within.
current_dir: &'a Path
The current working directory as returned by gix_fs::current_dir()
to assure it respects core.precomposeUnicode
.
It’s used to produce the realpath of the git-dir of a repository candidate to assure it’s not our own repository.
It is also used to assure that when the walk is for deletion, that the current working dir will not be collapsed.
index: &'a State
The index to quickly understand if a file or directory is tracked or not.
§Important
The index must have been validated so that each entry that is considered up-to-date will have the gix_index::entry::Flags::UPTODATE flag set. Otherwise the index entry is not considered and a disk-access may occur which is costly.
ignore_case_index_lookup: Option<&'a AccelerateLookup<'a>>
A utility to lookup index entries faster, and deal with ignore-case handling.
Must be set if ignore_case
is true
, or else some entries won’t be found if their case is different.
§Deviation
Git uses a name-based hash (for looking up entries, not directories) even when operating
in case-sensitive mode. It does, however, skip the directory hash creation (for looking
up directories) unless core.ignoreCase
is enabled.
We only use the hashmap when available and when ignore_case
is enabled in the options.
pathspec: &'a mut Search
A pathspec to use as filter - we only traverse into directories if it matches.
Note that the ignore_case
setting it uses should match our Options::ignore_case.
If no such filtering is desired, pass an empty pathspec
which will match everything.
pathspec_attributes: &'a mut dyn FnMut(&BStr, Case, bool, &mut Outcome) -> bool
The attributes
callback for use in gix_pathspec::Search::pattern_matching_relative_path(), which happens when
pathspecs use attributes for filtering.
If pathspec
isn’t empty, this function may be called if pathspecs perform attribute lookups.
excludes: Option<&'a mut Stack>
A way to query the .gitignore
files to see if a directory or file is ignored.
Set to None
to not perform any work on checking for ignored, which turns previously ignored files into untracked ones, a useful
operation when trying to add ignored files to a repository.
objects: &'a dyn Find
Access to the object database for use with excludes
- it’s possible to access .gitignore
files in the index if configured.
explicit_traversal_root: Option<&'a Path>
If not None
, override the traversal root that is computed and use this one instead.
This can be useful if the traversal root may be a file, in which case the traversal will still be returning possibly matching root entries.
§Panics
If the traversal_root
is not in the worktree_root
passed to walk().