Repository navigation
fix(gix-dir): ignored entries don't make a collapsed directory of empty ones untracked #3255
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -655,6 +655,53 @@ fn complex_empty() -> TestResult { | |
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn ignored_entries_dont_make_a_collapsed_directory_of_empty_ones_untracked() -> TestResult { | ||
| let root = fixture("ignored-and-empty"); | ||
| let (_, entries) = collect(&root, None, |keep, ctx| { | ||
| walk( | ||
| &root, | ||
| ctx, | ||
| walk::Options { | ||
| emit_empty_directories: false, | ||
| emit_untracked: CollapseDirectory, | ||
| ..options() | ||
| }, | ||
| keep, | ||
| ) | ||
| }); | ||
| assert_eq!( | ||
| entries, | ||
| &[entry("with-file", Untracked, Directory)], | ||
| "directories holding only ignored entries and empty directories have no untracked file, \ | ||
| and are skipped like a tree of only empty directories, as Git does" | ||
| ); | ||
|
|
||
| let (_, entries) = collect(&root, None, |keep, ctx| { | ||
| walk( | ||
| &root, | ||
| ctx, | ||
| walk::Options { | ||
| emit_empty_directories: true, | ||
| emit_untracked: CollapseDirectory, | ||
| ..options() | ||
| }, | ||
| keep, | ||
| ) | ||
| }); | ||
| assert_eq!( | ||
| entries, | ||
| &[ | ||
| entry("dir-and-empty", Untracked, Directory).with_property(EmptyDirectory), | ||
| entry("file-and-empty", Untracked, Directory).with_property(EmptyDirectory), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The newly added AGENTS.md reference: AGENTS.md:L263-L263 Useful? React with 👍 / 👎. |
||
| entry("nested", Untracked, Directory).with_property(EmptyDirectory), | ||
| entry("with-file", Untracked, Directory), | ||
| ], | ||
| "they collapse as empty directories, and the one with an untracked file as before" | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn ignored_with_prefix_pathspec_collapses_just_like_untracked() -> TestResult { | ||
| let root = fixture("untracked-and-ignored-for-collapse"); | ||
|
|
||
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.
When ignored output is enabled while untracked entries are collapsed (the normal
gix status --ignoredcombination), a directory likefile-and-emptyhas an ignored file plus an untrackedEmptyDirectory; this filter removes the file from the check, marks the parent empty, drains both children with the defaultemit_collapsed = None, andemit_entry()suppresses the parent because empty-directory emission is off. The CLI help says--ignoredwill “show ignored files and directories” (src/plumbing/options/mod.rs:593-595), but this case now yields no entry, so preserve the ignored side whenever it was requested.Useful? React with 👍 / 👎.