-
-
Notifications
You must be signed in to change notification settings - Fork 21
fix: files can be forced added even if gitignored #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,6 +208,9 @@ fn select_files_with_git( | |
| let mut excludes = worktree | ||
| .excludes(None) | ||
| .or_raise(|| Error::new("cannot create gix exclude stack"))?; | ||
| let index = repo | ||
| .index_or_empty() | ||
| .or_raise(|| Error::new("cannot open gix index"))?; | ||
|
|
||
| while let Some(entry) = it.next() { | ||
| let entry = entry.or_raise(|| Error::new("cannot traverse directory"))?; | ||
|
|
@@ -232,9 +235,14 @@ fn select_files_with_git( | |
|
|
||
| if file_type.is_dir() { | ||
| if platform.is_excluded() { | ||
| log::debug!(path:?, rela_path:?; "skip git ignored directory"); | ||
| it.skip_current_dir(); | ||
| continue; | ||
| let rela = gix::path::try_into_bstr(rela_path) | ||
| .or_raise(|| Error::new("cannot convert path to git path"))?; | ||
|
|
||
| if !index.path_is_directory(rela.as_ref()) { | ||
| log::debug!(path:?, rela_path:?; "skip git ignored directory"); | ||
| it.skip_current_dir(); | ||
| continue; | ||
| } | ||
| } | ||
| if matcher.matched(rela_path, file_type.is_dir()).is_ignore() { | ||
| log::debug!(path:?, rela_path:?; "skip glob ignored directory"); | ||
|
|
@@ -243,8 +251,13 @@ fn select_files_with_git( | |
| } | ||
| } else if file_type.is_file() { | ||
| if platform.is_excluded() { | ||
| log::debug!(path:?, rela_path:?; "skip git ignored file"); | ||
| continue; | ||
| let rela = gix::path::try_into_bstr(rela_path) | ||
| .or_raise(|| Error::new("cannot convert path to git path"))?; | ||
|
|
||
| if index.entry_by_path(rela.as_ref()).is_none() { | ||
| log::debug!(path:?, rela_path:?; "skip git ignored file"); | ||
| continue; | ||
| } | ||
|
Comment on lines
237
to
+260
|
||
| } | ||
| if !matcher | ||
| .matched(rela_path, file_type.is_dir()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conversion
gix::path::try_into_bstr(rela_path)(and its error handling) is repeated for both directories and files. Consider factoring this into a small helper/closure or converting once inside theplatform.is_excluded()block to reduce duplication and keep the ignore/index logic consistent across branches.