Skip to content

fix(pull): survive stat-dirty staging files and surface merge failures - #31

Merged
PerryLink merged 1 commit into
mainfrom
fix/pull-stash-and-visibility-29
Nov 13, 2026
Merged

PerryLink merged 1 commit into
mainfrom
fix/pull-stash-and-visibility-29

Conversation

@PerryLink

Copy link
Copy Markdown
Owner

Reproduced the #29 mechanics from the report: a tracked DSH atomic-write staging file (.l2s.<payload>.<hash>.tmp<seq>.<seq>) keeps the work tree stat-dirty while its content is unchanged, so git merge takes the autostash path and aborts with fatal: stash failed.

The failure was then invisible: beginMerge read a non-zero merge exit without MERGE_HEAD as “already up to date”, so pull() returned ok: true, lastPullAt advanced, and lastError kept a days-old push error while the repo stayed divergent.

Fixes, each with a regression test:

  1. .l2s.* is now a host-private artifact — excluded from the mirror and from the delete set, so it never reaches another device.
  2. git update-index -q --refresh runs before every merge (whitelisted as refresh-only).
  3. A merge that never started now throws GIT_FAILED with the sanitized stderr tail instead of masquerading as a no-op.
  4. The next successful pull/push clears lastError.
  5. sync_status omits undefined keys (lastPullAt / lastPushAt / lastError, plus head / remoteHead / error on an empty repo), fixing the value is not lossless JSON rejection.

Fixes #29

A tracked DSH atomic-write staging file (`.l2s.<payload>.<hash>.tmp<seq>.<seq>`)
keeps the work tree stat-dirty while its content is unchanged, so `git merge`
takes the autostash path and aborts with `fatal: stash failed`. The failure was
then swallowed: a non-zero merge exit without MERGE_HEAD was read as "already up
to date", `pull()` returned ok, and `lastError` kept an old push error forever.

- exclude `.l2s.*` from the mirror and the delete set (host-private artifacts)
- refresh the stat cache before merging
- throw GIT_FAILED when a merge produced no MERGE_HEAD
- clear `lastError` on the next successful pull/push
- omit undefined keys from `sync_status` (lossless JSON)

Fixes #29
@PerryLink
PerryLink merged commit 47b71a4 into main Nov 13, 2026
9 checks passed
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.

[Bug] Pull deadlocks with "fatal: stash failed" when the mirror tracks host staging files; the failure is invisible (stale lastError, no log)

1 participant