fix(install): resolve stash ref by SHA before git stash drop

git rev-parse refs/stash returns a commit SHA, which git stash apply
accepts but git stash drop rejects with "is not a stash reference".
The autostash cleanup path therefore always failed with exit 1, even
though the user's local changes had already been re-applied — making
successful updates look broken and leaving orphaned stashes behind.

Look up the stash@{N} ref by SHA in git stash list before dropping,
keeping the SHA for apply (robust against intervening stashes).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Hermes 2026-04-23 21:21:51 +02:00
parent f5af6520d0
commit 21bafabb73

View file

@ -752,7 +752,11 @@ clone_repo() {
if [ "$restore_now" = "yes" ]; then
log_info "Restoring local changes..."
if git stash apply "$autostash_ref"; then
git stash drop "$autostash_ref" >/dev/null
local autostash_drop_ref
autostash_drop_ref="$(git stash list --format='%gd %H' | awk -v sha="$autostash_ref" '$2 == sha {print $1; exit}')"
if [ -n "$autostash_drop_ref" ]; then
git stash drop "$autostash_drop_ref" >/dev/null
fi
log_warn "Local changes were restored on top of the updated codebase."
log_warn "Review git diff / git status if Hermes behaves unexpectedly."
else