Repository navigation
fix: clear the git index after a stash conflict - #13
Merged
askb merged 1 commit intoNov 4, 2026
Merged
Conversation
After `git stash pop` conflicted, the script ran `git checkout --theirs .` to keep the live files, but the conflict stayed in the index. Every later run then failed at `git stash` with "needs merge" / "could not write index", so no backup or upstream sync happened again until someone ran `git reset` by hand. Unstage everything right after keeping the live files, and heal a repo already stuck that way at the start of a run. The working tree is never touched. Self-check covers both cases (fails on 0.3.1). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: mmornati <[email protected]>
askb
force-pushed
the
upstream/clear-index-after-stash-conflict
branch
from
November 4, 2026 06:49
eaefcc5 to
5a918b1
Compare
Owner
|
Rebased onto main after #12 (kept both 0.3.1 changelog entries, no code conflict). Self-check 3a–3d and shellcheck pass locally. Merging once CI is green — thanks Marco. |
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
When
git stash popconflicts after the upstream sync (the live config and a merged PR changed the same file, typically a HACS update on the box), the script runs:checkout --theirsrewrites the files with the live version, which is correct, but the conflict stays in the index (UUentries ingit status). From then on, every run fails at the firstgit stash:No backup and no upstream sync happens again until someone SSHes in and runs
git resetby hand. On our instance it stayed stuck for more than a day after a browser_mod 3.4.0 → 3.4.1 HACS update, which also blocked merged config PRs from reaching the box.Fix
git reset -qunstages everything. The kept files become plain drift and go out through the normal backup PR.git ls-files -uis not empty (a repo already stuck because of an earlier version), log it and rungit reset -qso the repo heals by itself.Both only touch the index. The working tree, which is the live config, is never modified.
Tests
Two new cases in
tests/self_check.sh:Run in
alpine:3.21:OK: all self-checks passed. With the current script the new test fails (FAIL: unmerged index entries left after stash conflict).Version bumped to 0.3.1, with a CHANGELOG entry. This is independent of #12 (rollback after backup), but that bug is a common source of these stash conflicts. Both bump to 0.3.1, so whichever lands second needs its version bumped again; I'm happy to rebase.
🤖 Generated with Claude Code