From 437678d7f728666733bcd91c0b21c1a45f665648 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 7 May 2026 19:11:48 -0500 Subject: refactor(archsetup): break dotfile-restore chain into guarded steps The previous block ran three operations under one error_warn: `cd "$dotfiles_dir" && git config --global --add safe.directory ... && git restore .`. If any one of them failed, the operator saw a single "restoring dotfile versions" warning with no clue which step broke. The cd was unnecessary because git's `-C` flag does the same thing without changing the calling shell's working directory. I split the block into two guarded steps. The `safe.directory` config runs first with its own error_warn. If that step succeeds, the `git restore` runs next with its own error_warn. If `safe.directory` fails, the dotfile restore is skipped entirely. The original cause gets logged once instead of cascading into a second error from git's dubious-ownership check. I also dropped the `cd` and used `git -C "$dotfiles_dir"` instead. --- archsetup | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/archsetup b/archsetup index 6decbdd..9a1c277 100755 --- a/archsetup +++ b/archsetup @@ -893,9 +893,13 @@ user_customizations() { dconf write /org/gnome/desktop/interface/cursor-size 24 " >> "$logfile" 2>&1 ) || error_warn "$action" "$?" - action="restoring dotfile versions" && display "task" "$action" - (cd "$dotfiles_dir" && git config --global --add safe.directory "$user_archsetup_dir" && \ - git restore . >> "$logfile" 2>&1 ) || error_warn "$action" "$?" + action="marking dotfile dir as safe.directory" && display "task" "$action" + if git config --global --add safe.directory "$user_archsetup_dir" >> "$logfile" 2>&1; then + action="restoring dotfile versions" && display "task" "$action" + git -C "$dotfiles_dir" restore . >> "$logfile" 2>&1 || error_warn "$action" "$?" + else + error_warn "marking dotfile dir as safe.directory" "$?" + fi action="creating common directories" && display "task" "$action" # Create default directories and grant permissions -- cgit v1.2.3