Repository navigation
fix: keep the live config when returning to the base branch after a backup - #12
Merged
Merged
Conversation
…ackup cleanup_branch ran `git checkout <base>` after committing the drift on the backup branch. The base branch does not have that drift yet, so the checkout rewrote /config to the pre-backup state: backed-up changes left the disk until the next run pulled the merged PR, edits made in between hit stale files (stash_conflict / pull_rebase_failed), and drift from a PR that was never merged was lost. Move HEAD with symbolic-ref + mixed reset instead, so the working tree is untouched and the drift is reconciled by the next stash/pull/pop. The self-check now asserts the live files survive a backup and that the run after the PR merges syncs cleanly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: mmornati <139323+mmornati@users.noreply.github.com>
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Marco
Problem
After a run commits the drift on
auto-backup/<timestamp>and pushes it, the EXIT trapcleanup_branchreturns to the base branch withgit checkout -q "$BASE_BRANCH".The base branch doesn't have that drift yet (the PR isn't merged), so the checkout rewrites
/configto the pre-backup state:warning:stash_conflictorerror:pull_rebase_failedon the next run.We hit this on a production instance: integration versions on disk kept bouncing between the old and new versions after every backup run.
Fix
Point
HEADback at the base branch without touching the working tree:The drift stays as uncommitted changes, and the next run's existing stash → pull → pop reconciles it with the merged PR.
Tests
tests/self_check.shnow asserts that:Run in
alpine:3.21:OK: all self-checks passed. With the currentgit checkoutthe new step 3 assertion fails.Version bumped to 0.3.1, with a CHANGELOG entry. I'm also opening a separate PR for a related stash-conflict bug. Both bump to 0.3.1, so whichever lands second needs its version bumped again; I'm happy to rebase.
🤖 Generated with Claude Code