Skip to content

Status() reports a wholly untracked directory as a plain file path, so callers can't tell "newdir/" from a file named "newdir" #150

Description

@matt-edmondson

What's wrong

The default untracked mode is GitUntrackedFilesMode.Normal. In that mode, git collapses a directory with no tracked files to a single record, ? newdir/, with a trailing slash. The collapse itself is documented on the enum.

However, Parsing/GitStatusParser.cs (ReadPathOnlyEntry, around lines 76 and 220) converts the path with GitParseValues.ToRelativeFilePath, which loses the trailing /. GitStatusEntry has no directory flag either. The entry is typed as a RelativeFilePath, and nothing indicates that it is a directory. Ignored (!) records have the same problem.

Failure scenario

Commit a.txt, then create newdir/x.txt. Status() returns a single entry: Path='newdir', Untracked. That is exactly what an untracked file named newdir would produce.

  • A "discard untracked files" feature that calls File.Delete(entry.Path) throws or does nothing.
  • A UI can't show a folder or offer to expand it.

An untracked nested repository or submodule checkout shows up the same way.

This was reproduced with a scratch integration test through the public Status() API, which printed STATUS 'newdir' Untracked.

Suggested fix / acceptance criteria

  • Detect the trailing / on ? and ! records and surface it, for example with bool IsDirectory on GitStatusEntry, or with a directory-path type.
  • Tests:
    • in default mode, Status() over an untracked directory reports an entry marked as a directory;
    • an untracked file with the same name is not marked as a directory.

Activity

  1. matt-edmondson commented on Sep 28, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Notes: An additive bool IsDirectory on GitStatusEntry keeps the change non-breaking. Apply it to both ? and ! records, and cover an untracked nested repository in the tests too.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions