Skip to content

Git - handle autostash conflicts when pulling and show autostash entries in the stash list - #325762

Open
tieo wants to merge 1 commit into
microsoft:mainfrom
tieo:git-autostash-conflict
Open

Git - handle autostash conflicts when pulling and show autostash entries in the stash list#325762
tieo wants to merge 1 commit into
microsoft:mainfrom
tieo:git-autostash-conflict

Conversation

@tieo

@tieo tieo commented Jul 14, 2026

Copy link
Copy Markdown

Fixes #262360

With git.autoStash enabled, a pull whose autostash fails to re-apply gives no indication of it: no notification, and the autostash entry git leaves behind is not listed under the stash actions.

Two causes, both in git.ts:

  • git pull --autostash exits with 0 when re-applying the autostash fails and only reports it on stderr, so pull() never sets GitErrorCodes.StashConflict and the existing handler never runs. The manual stash apply notifies because git stash pop exits non-zero.
  • The reflog subject of a stash is (WIP )on <branch>: <message>, which git writes even for a user provided message. The autostash entry carries no branch, so it never matches stashRegex and is dropped by parseGitStashes.

To test:

  1. Set "git.autoStash": true.
  2. Commit a change upstream so the branch is behind, then modify the same lines locally.
  3. Run Git: Pull.
  4. Observe the merge conflict warning, and the autostash entry in the stash list. Before, the pull appeared to succeed, the file was left conflicted, and the stash was invisible.

Adds parseGitStashes tests for a WIP on <branch> stash, a stash the user named autostash, and the branchless autostash entry.

Written with the assistance of an LLM and verified manually against a real repository.

Copilot AI review requested due to automatic review settings July 14, 2026 10:03
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/git.ts
  • extensions/git/src/test/git.test.ts

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.

Pull request overview

Handles failed Git pull autostash restoration and makes branchless autostashes visible.

Changes:

  • Detects autostash conflicts reported through successful pull stderr.
  • Parses branchless autostash entries.
  • Adds stash parsing tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
extensions/git/src/git.ts Handles autostash conflicts and branchless stashes.
extensions/git/src/test/git.test.ts Tests stash parsing variants.

Comment thread extensions/git/src/git.ts
@tieo

tieo commented Jul 20, 2026

Copy link
Copy Markdown
Author

Hello? Is somebody there? 🫠

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.

Invisible autostash

3 participants