From 6aa02040d7554300894a2cf27888f9ec1cce2fd1 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 21 Feb 2026 13:15:28 -0600 Subject: fix(Makefile): detect and prompt on restow conflicts Dry-run stow before restowing to catch real files blocking symlinks. Shows conflicting files and prompts to overwrite or abort. --- Makefile | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e0e9237..31c258e 100644 --- a/Makefile +++ b/Makefile @@ -90,9 +90,29 @@ stow: check-de # Restow - refresh symlinks (unlink + relink) restow: check-de @echo "Restowing common + $(DE)..." - @cd $(DOTFILES) && $(STOW) --restow common - @cd $(DOTFILES) && $(STOW) --restow $(DE) - @echo "Done." + @output=$$(cd $(DOTFILES) && $(STOW) -n --restow common 2>&1; cd $(DOTFILES) && $(STOW) -n --restow $(DE) 2>&1); \ + conflicts=$$(echo "$$output" | grep "existing target" | sed 's/.*existing target //; s/ since.*//'); \ + if [ -n "$$conflicts" ]; then \ + echo ""; \ + echo "Conflicts found (real files blocking symlinks):"; \ + echo "$$conflicts" | while read -r f; do echo " ~/$$f"; done; \ + echo ""; \ + printf "Overwrite with repo versions? [y/N] "; \ + read -r ans; \ + if [ "$$ans" = "y" ] || [ "$$ans" = "Y" ]; then \ + echo "$$conflicts" | while read -r f; do rm -f "$(HOME)/$$f"; done; \ + cd $(DOTFILES) && $(STOW) --restow common && \ + cd $(DOTFILES) && $(STOW) --restow $(DE); \ + echo "Done."; \ + else \ + echo "Aborted. Resolve manually or use 'make reset $(DE)'."; \ + exit 1; \ + fi; \ + else \ + cd $(DOTFILES) && $(STOW) --restow common && \ + cd $(DOTFILES) && $(STOW) --restow $(DE); \ + echo "Done."; \ + fi # Reset - resolve conflicts by adopting then reverting to repo version reset: check-de -- cgit v1.2.3