Skip to content

Reset stale local mirror cache when remote is empty - #8

Open
matt8s wants to merge 2 commits into
redstreet:mainfrom
matt8s:fix/reset-stale-cache-empty-remote
Open

matt8s wants to merge 2 commits into
redstreet:mainfrom
matt8s:fix/reset-stale-cache-empty-remote

Conversation

@matt8s

@matt8s matt8s commented Oct 6, 2026

Copy link
Copy Markdown

This fixes a push failure when the rclone remote has no repository archive/refs but the helper still has an old local mirror under .git/rclone/<remote>/repo.

In that state, a push of unrelated history can fail in git fast-import with a non-fast-forward warning because the stale mirror constrains the new branch even though the actual remote is empty.

The change:

  • treats a remote with no repo archive and no refs as genuinely empty;
  • clears the helper's local mirror/marks cache before exporting to it;
  • preserves the existing recovery behavior when the archive disappears but refs still remain;
  • adds a regression test that creates a remote, pushes once, deletes the remote contents, replaces the local branch with unrelated history, and pushes again.

I encountered this on RHEL 9 after reusing a local repository whose helper cache contained history from an earlier remote state. Moving .git/rclone/origin aside allowed the push to succeed, which led to this fix.

This is intentionally separate from #7 and is based directly on current main, so the two PRs can be reviewed and merged independently.

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