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 | pub mod state { | 30 | pub mod state { |
| 31 | use bstr::{BStr, BString}; | ||
| 31 | use std::path::Path; | 32 | use std::path::Path; |
| 32 | 33 | ||
| 33 | type AttributeMatchGroup = git_attributes::MatchGroup<git_attributes::Attributes>; | 34 | type AttributeMatchGroup = git_attributes::MatchGroup<git_attributes::Attributes>; |
| @@ -54,14 +55,26 @@ pub mod state { · 20 unmodified lines | |||
| 54 | pub stack: IgnoreMatchGroup, | 55 | pub stack: IgnoreMatchGroup, |
| 55 | /// Ignore patterns which aren't tied to the repository root, hence are global. They are consulted last. | 56 | /// Ignore patterns which aren't tied to the repository root, hence are global. They are consulted last. |
| 56 | pub globals: IgnoreMatchGroup, | 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 | impl Ignore { | 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 | Ignore { | 71 | Ignore { |
| 62 | overrides, | 72 | overrides, |
| 63 | globals, | 73 | globals, |
| 64 | stack: Default::default(), | 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 | git_worktree::fs::cache::state::Ignore::new( | 149 | git_worktree::fs::cache::state::Ignore::new( |
| 150 | git_attributes::MatchGroup::from_overrides(vec!["!force-include"]), | 150 | git_attributes::MatchGroup::from_overrides(vec!["!force-include"]), |
| 151 | git_attributes::MatchGroup::from_git_dir(&git_dir, Some(user_exclude_path), &mut buf).unwrap(), | 151 | git_attributes::MatchGroup::from_git_dir(&git_dir, Some(user_exclude_path), &mut buf).unwrap(), |
| 152 | None, | ||
| 152 | ), | 153 | ), |
| 153 | ), | 154 | ), |
| 154 | Default::default(), | 155 | Default::default(), |