Skip to content

Treat exact-file Git operations as literal pathspecs - #23123

Merged
tidy-dev merged 2 commits into
developmentfrom
tidy-dev-literal-filename-behavior
Nov 4, 2026
Merged

tidy-dev merged 2 commits into
developmentfrom
tidy-dev-literal-filename-behavior

Conversation

@tidy-dev

@tidy-dev tidy-dev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

No linked public issue. A search of the issue tracker did not identify a matching report.

Description

Treat filenames such as :(glob)*.txt and file*.txt as 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.

  • Use command-scoped --literal-pathspecs for 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.
  • Prefix relative filenames in the shared single-file diff helper with :(literal). Preserve the existing :(top,literal) handling for absolute-looking paths and the separate untracked --no-index flow.
  • Add regression coverage for unrelated staging/commits, deletion, unstaging, overwritten edits, partial rename selections, working-directory and historical diffs, and submodule discard. Include a reset test with Windows-compatible filenames for its stdin branch.

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 4038b57019c1c0b215a7bbba16df05a99720d806 on macOS, with Node.js 24.15.0.

Command Observed result
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.ts Passed: 119 passed, one existing skipped test.
yarn 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.ts 127 passed, one existing skipped test, one failure in the previously observed uninitialized-submodule branch-checkout case. All new regression cases passed.
yarn test 3,548 passed, eight failures, two skipped (3,558 total). All eight failures also reproduce on unmodified development; the suite is not fully green.
yarn lint:fix Passed; no tracked formatting changes.
yarn lint Passed.
yarn -s tsc --noEmit -p tsconfig.json Passed.
NODE_ENV=production RELEASE_CHANNEL=development DESKTOP_SKIP_PACKAGE=1 yarn build:prod Passed; produced a self-contained development-identity build.

Before/after evidence: In an isolated snapshot of unmodified development at 4f843bc0d89a2060c1f93a1803fef257d5c529b7, running the new tests against the old application code produced 18 failures and one pass. The identical command on this PR produced 19 passes:

yarn 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.ts '--test-name-pattern=pathspec magic|literal filenames|partially commits a rename from|loads only|discards only the literal submodule|Windows-compatible names'

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 development snapshot with yarn 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):

yarn test app/test/unit/stores/assisted-commit-push-boundary-test.ts app/test/unit/stores/assisted-commit-push-test.ts '--test-name-pattern=stages publication into the real owned config despite a shadow introduced after native push|uses native upstream configuration instead of a GIT_CONFIG-only shadow file'

Platform gap: Windows execution has not been verified locally. The reset case uses Windows-compatible names and exercises reset --stdin -z when 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.txt disappears.

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.txt remains 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 .txt files; 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.

Before and after: the selected magic filename's working-directory diff excludes unrelated matching file content in the patched build

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)*-module in beta removes the added line from the matching unrelated submodule too. Repeating the operation in the local build preserves Unrelated Change in unintended-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

tidy-dev and others added 2 commits November 4, 2026 08:00
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]>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 13:17
@tidy-dev tidy-dev added the needs-deep-review Requires in-depth human code review of affected paths; agent review is not sufficient. label Nov 4, 2026

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.

🔵 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

@tidy-dev
tidy-dev marked this pull request as ready for review November 4, 2026 13:26
@tidy-dev
tidy-dev requested a review from a team as a code owner November 4, 2026 13:26
@tidy-dev
tidy-dev merged commit 52bc751 into development Nov 4, 2026
45 checks passed
@tidy-dev
tidy-dev deleted the tidy-dev-literal-filename-behavior branch November 4, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-deep-review Requires in-depth human code review of affected paths; agent review is not sufficient.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants