Closed bug report

adom-wiki pr revert truncates modified files and leaves added files, and reports success

Colby Knox · ·closed by Colby Knox

adom-wiki 1.8.8 · reproduced 2026-11-02 on adom/kicad-bridge, a 714-file repo

adom-wiki pr revert damages the repo: it truncates modified files and leaves added files behind, and it still reports success.

What I did

Ran adom-wiki pr revert "adom/kicad-bridge#<n>" on a merged pull request that modified existing files and added new ones.

What I expected

The tree after the revert is byte-identical to the tree before the merge.

What happened

The command reported success and created a Revert PR commit, but the tree was wrong in two ways:

  1. Modified files were truncated. 25 files that the PR had modified were cut down to only the lines in the diff's context. Everything outside the hunks was gone.
  2. Added files were not removed. 4 files that the PR had added were still in the repo.

Nothing in the output pointed to either problem, and the wiki page still loaded normally.

The revert commit is f18a6d9727d29e16e8f1e3ebb8ec276600c57f80 on adom/kicad-bridge, and 4f3a0f422531961128ec3e7fbb11d1814225ee09 is the repair that restored the 25 files, so the diff between them shows the damage.

How I found it and repaired it

I had cloned the repo before the merge, and compared that clone with a fresh clone taken after the revert. That comparison showed the 25 truncated files and the 4 leftovers.

To repair it, I pushed the 25 files from the pre-merge clone with repo push --files and removed the 4 with repo rm. A fresh clone then matched the pre-merge clone byte for byte, across all 714 files.

Impact

Anyone who trusts this command ends up with a broken default branch, and has no sign of it until a build or a user hits it. Someone without a pre-merge copy has to rebuild the files from git history.

Suggested fix

A revert should restore each file's full blob from the merge's parent, and delete the files the PR added, rather than building the result from the diff's hunks. It should also compare the resulting tree with the parent's tree, and fail if they differ and no later commit explains the difference.

Workaround

Until this is fixed, don't use pr revert. Restore the files from a pre-merge clone with repo push --files and repo rm, then compare a fresh clone against it.

1 Reply

Colby Knox marked this in progress ·
Colby Knox ·

Fixed, and live on the wiki. pr revert is safe to use again, no CLI update needed.

Cause: the server rebuilt each old file from the PR's stored diff. That diff only holds the lines around each change, so everything outside the hunks was lost, and added files weren't recognized. Even a file-set PR didn't come back to its pre-merge tree.

Fix: a revert is now a real git revert of the merge commit, on the branch the PR merged into. Every file comes back byte for byte, including binaries, and added files are removed. Commits made after the merge are kept.

New refusals, none of which change anything:

  • REVERT_CONFLICT (409): a later commit changed the same lines. The reply lists the files in conflicts.
  • NOTHING_TO_REVERT (400): the changes are already undone.
  • REVERT_NOT_ON_BRANCH (409): the merge commit is no longer on that branch.
  • REVERT_NO_MERGE_COMMIT (409): the PR has no recorded merge commit.

Tested: a new test fails on the old code and passes on the fix, and the full suite passed. On staging, a branch PR with a 3,000-line file, a binary file and two added files came back to its pre-merge tree, with those files byte-identical and the added ones gone.

Other repos: the last 63 days of server logs show one revert, the adom/kicad-bridge one above, which is already repaired.

Colby Knox closed this ·

Log in to reply.