This is the only override that is allowed, .gitattributes isn't allowed for instance. Don't know what it is used for, but `git ls-files` can set this with a flag.
Unified · Split
| @@ -28,6 +28,7 @@ pub enum State { · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | /// |
| 30 | 30 | pub mod state { |
| 31 | + use bstr::{BStr, BString}; | |
| 31 | 32 | use std::path::Path; |
| 32 | 33 | |
| 33 | 34 | type AttributeMatchGroup = git_attributes::MatchGroup<git_attributes::Attributes>; |
| @@ -54,14 +55,26 @@ pub mod state { · 20 unmodified lines | ||
| 54 | 55 | pub stack: IgnoreMatchGroup, |
| 55 | 56 | /// Ignore patterns which aren't tied to the repository root, hence are global. They are consulted last. |
| 56 | 57 | pub globals: IgnoreMatchGroup, |
| 58 | + /// The name of the file to look for in directories. | |
| 59 | + pub exclude_file_name_for_directories: BString, | |
| 57 | 60 | } |
| 58 | 61 | |
| 59 | 62 | impl Ignore { |
| 60 | − pub fn new(overrides: IgnoreMatchGroup, globals: IgnoreMatchGroup) -> Self { | |
| 63 | + /// The `exclude_file_name_for_directories` is an optional override for the filename to use when checking per-directory | |
| 64 | + /// ignore files within the repository, defaults to`.gitignore`. | |
| 65 | + // TODO: more docs | |
| 66 | + pub fn new( | |
| 67 | + overrides: IgnoreMatchGroup, | |
| 68 | + globals: IgnoreMatchGroup, | |
| 69 | + exclude_file_name_for_directories: Option<&BStr>, | |
| 70 | + ) -> Self { | |
| 61 | 71 | Ignore { |
| 62 | 72 | overrides, |
| 63 | 73 | globals, |
| 64 | 74 | stack: Default::default(), |
| 75 | + exclude_file_name_for_directories: exclude_file_name_for_directories | |
| 76 | + .map(ToOwned::to_owned) | |
| 77 | + .unwrap_or(".gitignore".into()), | |
| 65 | 78 | } |
| 66 | 79 | } |
| 67 | 80 | |
| @@ -149,6 +149,7 @@ mod ignore_and_attributes { · 148 unmodified lines | ||
| 149 | 149 | git_worktree::fs::cache::state::Ignore::new( |
| 150 | 150 | git_attributes::MatchGroup::from_overrides(vec!["!force-include"]), |
| 151 | 151 | git_attributes::MatchGroup::from_git_dir(&git_dir, Some(user_exclude_path), &mut buf).unwrap(), |
| 152 | + None, | |
| 152 | 153 | ), |
| 153 | 154 | ), |
| 154 | 155 | Default::default(), |