Skip to content

chore(release): 0.1.2 - no-op write returns success#13

Merged
vreshch merged 1 commit into
masterfrom
fix/noop-write
Jul 6, 2026
Merged

chore(release): 0.1.2 - no-op write returns success#13
vreshch merged 1 commit into
masterfrom
fix/noop-write

Conversation

@vreshch

@vreshch vreshch commented Jul 6, 2026

Copy link
Copy Markdown
Member

Bug

Writing byte-identical content to an existing doc failed. writeDoc runs git commit after staging, but with no staged diff git errors nothing to commit, working tree clean. That rejection surfaced to callers as an error (HTTP 400 / CLI exit 1) instead of success.

Per the write contract a no-op write MUST be a success: write overwrites the whole doc, so identical content means the doc is already in the desired state.

Found by an adversarial verifier running against the cli.

Fix

src/backends/local-backend.ts writeDoc: after git add, short-circuit when git status --porcelain -- <path> reports no pending change. Return the current HEAD rev + the path's last-commit time instead of creating an empty commit (cleaner than --allow-empty, which would spam empty commits).

Audit: edit / delete

  • edit routes through writeDoc, so it inherits the fix. Reachable no-op edits now succeed: str_replace with an identical result, and a frontmatter merge that changes nothing.
  • delete is unaffected: it is guarded by existsSync before committing, so it always has a real deletion diff and never hits the empty-commit path.

Tests

  • no-op write (byte-identical content) returns success, no new commit - asserts the rev is unchanged (short-circuited before an empty commit).
  • no-op edit (str_replace with identical result) returns success.
  • no-op edit (frontmatter merge changes nothing) returns success.

npm run verify green locally (type-check + lint + format + 52 tests + build).

Release

Version bump 0.1.1 -> 0.1.2. The chore(release): subject triggers the publish workflow on merge to master.

Writing byte-identical content to an existing doc failed: writeDoc ran
`git commit` with no staged diff, which errors "nothing to commit,
working tree clean" and surfaced as an error (HTTP 400 / CLI exit 1)
instead of success. A no-op write must succeed - write overwrites the
whole doc, so identical content means the doc is already in the desired
state.

Fix: after staging, short-circuit when `git status --porcelain` shows no
pending change; return the current HEAD rev + the path's last-commit time
instead of creating an empty commit. This also covers edit no-ops
(str_replace with identical result, frontmatter merge that changes
nothing) since edit routes through writeDoc. delete is unaffected - it is
guarded by existsSync, so it always has a real deletion diff.

Tests: no-op write returns success with the unchanged rev; edit no-op
(str_replace-identical, frontmatter-no-change) returns success.
@vreshch vreshch marked this pull request as ready for review July 6, 2026 06:54
@vreshch vreshch merged commit 1351200 into master Jul 6, 2026
1 check 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.

1 participant