Skip to content

fix(pull): keep an unstaged edit that git status lists first - #113

Closed
dhruva-vapi wants to merge 1 commit into
mainfrom
fix/pull-first-status-record
Closed

dhruva-vapi wants to merge 1 commit into
mainfrom
fix/pull-first-status-record

Conversation

@dhruva-vapi

@dhruva-vapi dhruva-vapi commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Value

V.A.L.U.E. tier: micro. One line in the engine and one test file.

  • Problem: npm run pull could overwrite a local edit without saying so. It happened to the first file git lists as changed, when that change was not staged, on a machine with no baselines for the org (a new clone, a new laptop). The person lost the edit and apply then pushed nothing for that file.
  • Who it affects: anyone who clones a repository built from this one, edits a resource file and runs pull or apply before staging.

What's in it

  • The cause. Pull asks git which files were changed and reads each record of git status --porcelain -z as two status letters, a space and the path. The helper that runs git trimmed the output first. An unstaged change starts with a space, so the first record lost it and its path lost its first letter (esources/<org>/…). That path matched no resource file, and pull treated the file as untouched.
  • The fix. The helper returns git's output as git wrote it. Its other two callers only check that the command succeeds.
  • The test. tests/pull-first-status-record.test.ts runs pull in a fresh clone against a local server: two unstaged edits, and one unstaged edit beside a new untracked file, each with a control (staged edits, and an edit that is not first in git's list).

Verification

  • On main at c4929e6, the new test file fails 2 of 4 without the change (the two unstaged cases) and passes 4 of 4 with it. The two controls pass both ways.
  • npm run build (tsc) passes. Nine other pull and sandbox test files pass when run one at a time with the change.
  • The full suite was left to CI.

Things to know

  • A staged edit was always kept, and so was an unstaged edit when another changed file came before it in git's list. That is why this went unnoticed.
  • The interactive push and apply pickers read git status in a similar way to tag files as modified. That read only decides what is shown, and it is not changed here.

Part of PRISM-2765

Pull asks git which files were changed locally and reads each record of
`git status --porcelain -z` as "XY <path>". The helper trimmed git's output
first. An unstaged change is " M <path>", so when it was the first record
the trim removed its leading space and the path lost its first letter. Pull
then did not treat that file as edited, and in a clone with no baselines it
wrote the platform's copy over the edit without saying so. A staged edit, or
an unstaged edit that was not first in git's list, was read correctly.

gitCmd() now returns git's output as git wrote it. Its other two callers
only check that the command succeeds.

tests/pull-first-status-record.test.ts covers it: two unstaged edits, and
one unstaged edit beside a new untracked file, each with a control. Without
the change it fails 2 of 4; with it, 4 of 4.

Part of PRISM-2765

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dhruva-vapi

Copy link
Copy Markdown
Contributor Author

Replaced by #114 (same commit, opened as the Devin bot so it can be approved)

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.

1 participant