Git - show untracked files in folders when viewing a stash by spokodev · Pull Request #343202 · microsoft/vscode · GitHub
Skip to content

Git - show untracked files in folders when viewing a stash - #343202

Open
Spoko Dev (spokodev) wants to merge 1 commit into
microsoft:mainfrom
spokodev:fix/git-view-stash-untracked-folders
Open

Spoko Dev (spokodev) wants to merge 1 commit into
microsoft:mainfrom
spokodev:fix/git-view-stash-untracked-folders

Conversation

@spokodev

Copy link
Copy Markdown
Contributor

Fixes #343201

Repository.getObjectFiles lists the stash's untracked-files commit with git ls-tree without -r, so _viewStash only recognises untracked files at the repository root. Files in folders are diffed against the stash commit, where they don't exist, and drop out of the View Stash editor. This passes { recursive: true } to lstree; getObjectFiles has no other caller.

Added a test in extensions/git/src/test/git.test.ts that stashes file.txt and folder/file.txt with --include-untracked and checks that getObjectFiles('stash@{0}^3') returns both. It fails without the change (folder is returned instead of folder/file.txt).

How to test: follow the steps in #343201. With VS Code 1.143.0, View Stash shows top.txt and the tracked file only; with this change applied to the built git extension it also shows src/feature/new.ts.

With many untracked files in a stash, _viewStash now compares every change against a longer list (stashUntrackedFiles.find(...) with pathEquals). I left that lookup as it is to keep this change small and keep the pathEquals semantics.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 11:07
@vs-code-engineering

Copy link
Copy Markdown
Contributor

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Fixes viewing stashed untracked files in subfolders by making Repository.getObjectFiles list tree entries recursively, and adds a regression test for the stash untracked-files commit case.

Changes:

  • Update Repository.getObjectFiles to call lstree with { recursive: true }.
  • Add an integration-style test that stashes untracked files at root and in a folder and validates getObjectFiles('stash@{0}^3').
File Description
extensions/​git/​src/​repository.ts Ensures getObjectFiles returns all files in a tree (including nested paths), fixing stash view behavior.
extensions/​git/​src/​test/​git.test.ts Adds coverage to prevent regressions when stashes contain untracked files in subfolders.

Review effort: Lite

Comment thread extensions/git/src/test/git.test.ts
Comment thread extensions/git/src/test/git.test.ts

This branch has not been deployed

No deployments
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.

Git - View Stash does not show untracked files in folders

3 participants