Skip to content

fix(gix-dir): ignored entries don't make a collapsed directory of empty ones untracked - #3255

Open
Sam Brightman (sambrightman) wants to merge 1 commit into
GitoxideLabs:mainfrom
sambrightman:dirwalk-ignored-and-empty-collapse
Open

Sam Brightman (sambrightman) wants to merge 1 commit into
GitoxideLabs:mainfrom
sambrightman:dirwalk-ignored-and-empty-collapse

Conversation

@sambrightman

Copy link
Copy Markdown

Opened by Claude, an AI agent (Claude Opus 5.5), through the account holder's GitHub account at their request. This description is Claude's own.

A directory holding only ignored files and empty directories has no untracked file, and git status doesn't show it. With emit_untracked: CollapseDirectory and empty directories not emitted (as gix status does), gix-dir reports it as untracked:

git init -q r && cd r
echo '*.o' > .gitignore && git add . && git commit -qm init
mkdir -p d/empty && touch d/a.o
git status --short    # nothing
# gix status with untracked directories collapsed: `d` (Untracked)

The same happens with an ignored directory beside an empty one (an Xcode workspace with an ignored userdata/ beside shared/empty/, which is where it was found), and at any depth.

Cause: the untracked collapse keeps the EmptyDirectory property (#2490) only when every held entry is an empty directory. When untracked directories collapse, ignored entries are held too, so one beside the empty directories drops the property and the directory is emitted as untracked.

Fix: only the untracked held entries decide. The collapse itself is unchanged (it already allowed ignored entries among untracked ones), as is the deletion walk and the ignored collapse, which the existing condition excludes.

Tests: a new ignored-and-empty fixture in many.sh with an ignored file beside an empty directory, an ignored directory beside one, the nested Xcode case, and a control with an untracked file. Without emitting empty directories only the control shows; with them, the other three show with EmptyDirectory. The test fails before the fix. gix-dir and gix-status tests pass, as do gix's status and dirwalk tests. Reproduced on gix 0.90.0 and on main at 2bcb31d.

Motivation: argus, a multi-repository status tool built on gix, works around this by asking for untracked files individually and collapsing them itself, so it walks every file of large untracked directories where git status stops at the directory.

…ty ones untracked

A directory holding only ignored files and empty directories has no
untracked file, and `git status` doesn't show it. The untracked collapse
kept the `EmptyDirectory` property (GitoxideLabs#2490) only when every collapsed
entry was an empty directory, so an ignored file beside them made the
directory show as untracked: `d/` with `d/a.o` (ignored) and `d/empty/`,
or an Xcode workspace with an ignored `userdata/` beside `shared/empty/`.
Now only the untracked entries decide.

Found by argus, a multi-repository status tool built on `gix`, which works
around it by asking for untracked files individually and collapsing them
itself, walking every file of large untracked directories.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T07:26:06.009358Z ee2870c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee2870c9f0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".

Comment on lines +413 to 414
.filter(|entry| entry.status == entry::Status::Untracked)
.all(|entry| entry.property == Some(entry::Property::EmptyDirectory)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep requested ignored entries observable

When ignored output is enabled while untracked entries are collapsed (the normal gix status --ignored combination), a directory like file-and-empty has an ignored file plus an untracked EmptyDirectory; this filter removes the file from the check, marks the parent empty, drains both children with the default emit_collapsed = None, and emit_entry() suppresses the parent because empty-directory emission is off. The CLI help says --ignored will “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 👍 / 👎.

Comment thread gix-dir/tests/dir/walk.rs
entries,
&[
entry("dir-and-empty", Untracked, Directory).with_property(EmptyDirectory),
entry("file-and-empty", Untracked, Directory).with_property(EmptyDirectory),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the empty-directory contract

The newly added file-and-empty case deliberately returns Property::EmptyDirectory even though the fixture creates file-and-empty/a.o; however, the public enum docs still define this property as an empty directory (gix-dir/src/entry.rs:10-11), and the option docs say no nested directory may contain a file (gix-dir/src/walk/mod.rs:182-185, mirrored at gix/src/dirwalk/options.rs:130-132). Consumers asking to emit empty directories now receive metadata that contradicts the contract, so model “no reportable untracked content” separately or update these directly related public docs with the new ignored-file semantics.

AGENTS.md reference: AGENTS.md:L263-L263

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant