From e8303d595fc3e01157ea3c0c8b57f802af5061b5 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 7 Mar 2026 16:04:18 +0100 Subject: [PATCH] fix: handle more cases in android repair --- scripts/android-repair-git | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/android-repair-git b/scripts/android-repair-git index 17e270275a36b3ee8b5d0a884119e0bccfb6084c..fdff6a4eac10667a6f8bb615883a1aa1f066a81b 100644 --- a/scripts/android-repair-git +++ b/scripts/android-repair-git @@ -8,13 +8,25 @@ checkout() { + # The lock is left there even when nothing uses it... + # Of course in general this is dangerous, nothing else + # should be accessing the repo. + rm -rf .git/index.lock + + if [[ ! -f $repo/.git/HEAD ]]; then + cd - + rm -rf $repo + fi + if git show-ref --verify --quiet refs/remotes/origin/main; then - git checkout -b main origin/main + git checkout main elif git show-ref --verify --quiet refs/remotes/origin/master; then - git checkout -b master origin/master + git checkout master else echo "ERROR: No main or master branch found in $repo" >&2 fi + + git reset --hard HEAD } for repo in ~/.emacs.d/stateful/elpaca/repos/*; do