From 21bafabb73e4dba07b1904a7137c1c9d6d16d305 Mon Sep 17 00:00:00 2001 From: Hermes Date: Thu, 23 Apr 2026 21:21:51 +0200 Subject: [PATCH] fix(install): resolve stash ref by SHA before git stash drop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 166d984fac..a2e81c15c5 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -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