fix(installer): clear unmerged index before installer autostash - #45589
Merged
Conversation
When an existing install at $INSTALL_DIR has an unmerged index (files in a "needs merge" state left by a previously interrupted update), the update path ran `git stash` then `git checkout <branch>`. On a conflicted index `git stash` aborts with "could not write index" and `git checkout` then aborts with "you need to resolve your current index first" — surfacing to desktop/bootstrap users as `git checkout main failed (exit 1)` and failing the whole install at the repository stage. Mirror the `hermes update` Python path (#4735): detect unmerged entries with `git ls-files --unmerged` and clear the conflict state with `git reset` before stashing. Working-tree changes are still captured by the subsequent stash, so nothing is discarded; only the index-level conflict markers are dropped, which lets the checkout proceed. Fixed in both installers (install.sh and install.ps1) so the Windows GUI installer and the POSIX one share the same recovery behavior.
Functional bash test drives install.sh's autostash block against a throwaway repo with a real conflicted index and asserts the stash now succeeds and the unmerged entries are cleared (previously `git stash` failed with "could not write index"). Source-order assertions cover both scripts to ensure the `git reset` clear runs before `git stash push` (a no-op otherwise).
Contributor
🔎 Lint report:
|
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.
Summary
Installer update paths now recover when an existing managed checkout has an unmerged git index before autostashing.
Salvages #45515 by @xxxigm onto current
main, preserving contributor authorship. The bug is the same state already handled by the Pythonhermes updatepath: an interrupted update leaves index conflict markers, sogit stashfails withcould not write indexand the latergit checkout mainfails.Changes
scripts/install.sh: detectgit ls-files --unmerged, rungit reset -q, then stash normally.scripts/install.ps1: same unmerged-index clear before stash for the Windows installer path.tests/test_install_unmerged_index.py: regression test for the bash autostash block plus source-order checks for both installers.Validation
scripts/run_tests.sh tests/test_install_unmerged_index.pycould not write index; after reset: unmerged cleared, stash rc=0, changes preservedOriginal PR: #45515
Infographic