Repository navigation
Treat exact-file Git operations as literal pathspecs - #23123
Merged
Merged
Conversation
Co-authored-by: Copilot App <[email protected]>
Keep single-file diffs, partial rename staging, Copilot conflict staging, and selected submodule resets scoped to literal filenames. Expand historical diff and cross-platform reset regression coverage. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Destructive Git operations and commit staging require human review to confirm preservation of unrelated index/worktree state and validate the untested Windows-specific reset --stdin -z branch.
No open issues 🎉
What changed in this PR
This PR keeps GitHub Desktop operations on selected files scoped to their exact filenames, preventing wildcard or pathspec syntax from selecting unrelated files. Literal handling remains local to exact-file operations rather than changing the shared Git wrapper.
Changes:
- Apply command-scoped literal pathspec handling to conflict resolution, checkout/reset, partial rename staging, and submodule discard.
- Use literal filename prefixes for single-file diffs while preserving existing absolute-path and untracked-file handling.
- Add regression coverage for selected-file behavior and preservation of unrelated changes, including a Windows-compatible reset case.
| File | Description |
|---|---|
app/test/unit/stores/app-store-add-accounts-test.ts |
Tests literal staging of Copilot conflict resolutions. |
app/test/unit/git/submodule-test.ts |
Tests discard affects only the selected submodule. |
app/test/unit/git/reset-test.ts |
Tests selected-path reset, including Windows-compatible filenames. |
app/test/unit/git/diff-test.ts |
Tests literal filenames in working-directory and historical diffs. |
app/test/unit/git/commit-test.ts |
Tests partial rename commits preserve unrelated changes. |
app/test/unit/git/checkout-test.ts |
Tests literal checkout and conflict removal. |
app/test/unit/git/add-test.ts |
Tests conflict staging excludes unrelated files. |
app/test/helpers/repositories.ts |
Adds shared fixtures with pathspec-like filenames. |
app/src/lib/stores/app-store.ts |
Makes Copilot conflict staging literal. |
app/src/lib/git/submodule.ts |
Makes selected recursive submodule discard literal. |
app/src/lib/git/rm.ts |
Makes conflicted-file removal literal. |
app/src/lib/git/reset.ts |
Makes selected-path reset literal. |
app/src/lib/git/diff.ts |
Adds literal prefixes to relative single-file diff paths. |
app/src/lib/git/checkout.ts |
Makes selected-path and conflict checkout literal. |
app/src/lib/git/apply.ts |
Makes partial rename staging and old-blob lookup literal. |
app/src/lib/git/add.ts |
Makes conflicted-file staging literal. |
Review effort: Balanced
sergiou87
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No linked public issue. A search of the issue tracker did not identify a matching report.
Description
Treat filenames such as
:(glob)*.txtandfile*.txtas exact names when Desktop acts on a selected file. Previously, Git could interpret those names as pathspec patterns and unexpectedly select other matching files: conflict resolution could stage or remove unrelated files, discard/undo could overwrite or unstage unrelated changes, partial rename commits could include other changes, selected submodule discard could reset other submodules, and single-file diffs could show the wrong content.--literal-pathspecsfor conflict add/checkout/remove, selected-path checkout/reset, partial rename staging and old-blob lookup, Copilot-generated conflict staging, and selected recursive submodule discard. Keep the--filename boundary.:(literal). Preserve the existing:(top,literal)handling for absolute-looking paths and the separate untracked--no-indexflow.Literal handling is limited to exact-file operations, not enabled globally in the shared Git wrapper. Intentional pathspec consumers elsewhere remain unchanged.
Validation
Validation covers public branch commit
4038b57019c1c0b215a7bbba16df05a99720d806on macOS, with Node.js 24.15.0.yarn test app/test/unit/git/add-test.ts app/test/unit/git/reset-test.ts app/test/unit/git/diff-test.ts app/test/unit/git/commit-test.ts app/test/unit/git/submodule-test.ts app/test/unit/stores/app-store-add-accounts-test.tsyarn test app/test/unit/git/add-test.ts app/test/unit/git/checkout-test.ts app/test/unit/git/reset-test.ts app/test/unit/git/diff-test.ts app/test/unit/git/commit-test.ts app/test/unit/git/submodule-test.ts app/test/unit/stores/app-store-add-accounts-test.tsyarn testdevelopment; the suite is not fully green.yarn lint:fixyarn lintyarn -s tsc --noEmit -p tsconfig.jsonNODE_ENV=production RELEASE_CHANNEL=development DESKTOP_SKIP_PACKAGE=1 yarn build:prodBefore/after evidence: In an isolated snapshot of unmodified
developmentat4f843bc0d89a2060c1f93a1803fef257d5c529b7, running the new tests against the old application code produced 18 failures and one pass. The identical command on this PR produced 19 passes:The Windows-compatible reset case already passed on macOS before the fix; the other 18 cases reproduce the unexpected filename handling and now pass.
The six previously observed failures were independently reproduced against the same unmodified
developmentsnapshot withyarn test app/test/unit/git/checkout-test.ts app/test/unit/git/push-test.ts app/test/unit/git/rev-parse-test.ts app/test/unit/parse-files-to-be-overwritten-test.ts(32 passed, six failed): uninitialized-submodule branch checkout, three push cases, bare-repository detection, and pull-error parsing. They remain unresolved.Two additional failures in the current suite involve assisted-push shadow-configuration handling (
error: only one config file at a time). Both independently reproduce on that unmodified snapshot with the following command (zero passed, two failed):Platform gap: Windows execution has not been verified locally. The reset case uses Windows-compatible names and exercises
reset --stdin -zwhen run on Windows. Cases using characters forbidden in Windows filenames are skipped there.Team-authored review
Evidence: See Validation and Screenshots, including the explicit recording and platform limitations. Automated checks cover the public branch commit above; recordings illustrate earlier local builds during development.
Review path:
needs-deep-review.These Git operations can discard work or change which files enter a commit. In-depth human review should verify that conflict staging/removal, selected-path discard/reset, partial rename commits, and recursive submodule discard affect only the intended paths; that unrelated index/worktree state is preserved; and that literal single-file diff handling retains absolute-path and untracked-file behavior. Windows reset stdin behavior also needs platform verification. This requirement remains in addition to the author's own assessment.
Screenshots
Before: GitHub Desktop 3.6.11-beta1. After: patched local builds containing the relevant fix at recording time. These recordings illustrate individual fixes during development; they are not all recordings of the final commit or the current public branch. Original CleanShot timestamps below are from 2026-11-03.
Conflict resolution stages only the selected file
Choosing a version of a conflicted magic filename previously included a matching unrelated untracked file in the merge commit. The patched build leaves that file untracked. This exercises the chosen-version checkout and staging flow.
Before — 19.52.48: includes an ordinary-filename control before the magic-filename reproduction. After merging, editing the unrelated file produces a modification rather than a new file, showing it was included in the merge commit.
before-conflict-resolution-unintended-commit.mp4
After — 20.41.16: the unrelated file remains new in Changes after continuing the merge.
after-conflict-resolution-excludes-untracked-file.mp4
Undoing the initial commit preserves unrelated edits
Restoring a deleted magic filename while undoing the initial commit must not overwrite matching files' uncommitted changes.
Before — 20.18.27: the additional uncommitted line in
test.txtdisappears.before-undo-initial-commit-loses-unrelated-edit.mp4
After — 20.35.45: the final diff retains both the original content and the uncommitted addition.
after-undo-initial-commit-preserves-unrelated-edit.mp4
Discarding a staged file preserves unrelated staging
This concerns unintended unstaging, not deletion of the unrelated working-tree edit. Terminal cached-name checks make the staging result visible.
Before — 20.20.21: discarding the magic filename also unstages
test.txt.before-discard-staged-file-unstages-unrelated.mp4
After — 20.38.09:
test.txtremains staged after discarding the selected magic filename.after-discard-staged-file-preserves-unrelated-staging.mp4
Choosing deletion preserves unrelated tracked files
Resolving a modify/delete conflict by choosing deletion must remove only the selected filename. The before/after fixtures use different unrelated filenames.
Before — 20.26.41: choosing deletion also removes matching tracked
.txtfiles; the editor tree is left with only.gitattributes.before-conflict-choose-deletion-removes-unrelated-files.mp4
After — 20.49.18: the magic filename is removed while unrelated files remain in the editor tree.
after-conflict-choose-deletion-preserves-unrelated-files.mp4
Single-file diffs stay scoped to the requested filename
Working-directory comparison — 21.07.06: beta on the left shows unrelated matching diff content and a spinner; the patched local build on the right shows only the selected file's deletion.
Renamed-file history comparison — 21.25.14: both windows display the same existing commit,
1a1691b. Beta on the left shows unrelated content as the rename diff; the local build on the right correctly reports that the file was renamed but not changed. This demonstrates history rendering, not the partial-commit operation or a change to the commit itself.before-after-renamed-file-history-diff.mp4
Copilot conflict dialog comparison — differing resolution choices
Side-by-side — 21.29.43: beta on the left accepts Copilot's result and includes a matching unrelated untracked file. The local build on the right leaves that file new after merging.
Qualification: the local-build portion explicitly chooses Current, a manual override, before continuing. This is not a like-for-like demonstration of accepting Copilot-generated content unchanged and must not be used as sole evidence for the direct generated-content staging branch. The AppStore regression test covers that branch; no equivalent unchanged-result after recording is included here.
before-after-copilot-dialog-conflict-staging.mp4
Discarding a selected submodule preserves unrelated edits
Side-by-side — 21.43.46: discarding only
:(glob)*-modulein beta removes the added line from the matching unrelated submodule too. Repeating the operation in the local build preservesUnrelated Changeinunintended-module/example.txt, and that submodule remains modified.before-after-submodule-discard.mp4
Release notes
Notes: [Fixed] Keep operations on selected files scoped to their exact filenames when names contain wildcard or Git pathspec syntax