diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-07 19:11:48 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-07 19:11:48 -0500 |
| commit | 437678d7f728666733bcd91c0b21c1a45f665648 (patch) | |
| tree | 694bd02e1640d693ce15b5d4e836d98c464dfc16 | |
| parent | 64257ff711145b22812ae54df31d8b631c01e18e (diff) | |
| download | archsetup-437678d7f728666733bcd91c0b21c1a45f665648.tar.gz archsetup-437678d7f728666733bcd91c0b21c1a45f665648.zip | |
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.
| -rwxr-xr-x | archsetup | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 |
