handle clean/init cases better
authorShane Jaroch <chown_tee@proton.me>
Sat, 17 Jan 2026 01:50:21 +0000 (20:50 -0500)
committerShane Jaroch <chown_tee@proton.me>
Sat, 17 Jan 2026 01:50:21 +0000 (20:50 -0500)
git-remote-gcrypt

index f4aec67937729cd843f27bf4f393b6b9e41a516c..e9fce0aed7aa8f2be77d845abca504c599ba7a54 100755 (executable)
@@ -551,11 +551,11 @@ EOF
                xfeed "$2" rclone delete -v --include-from=/dev/stdin "${1#rclone://}/" >&2
        elif islocalrepo "$1"
        then
-               for fn_ in $2; do
+               echo "$2" | while IFS= read -r fn_; do
                        rm -f "$1"/"$fn_"
                done
        else
-               for fn_ in $2; do
+               echo "$2" | while IFS= read -r fn_; do
                        gitception_remove "${1#gitception://}" "$fn_"
                done
        fi
@@ -1462,9 +1462,15 @@ cmd_clean()
                if [ "${FORCE_INIT:-}" = "yes" ]; then
                        echo_info "WARNING: No gcrypt manifest found, but --init specified."
                        echo_info "WARNING: Proceeding to scan/clean potential unencrypted files."
+               elif isnull "$FORCE_CLEAN"; then
+                       echo_info "WARNING: No gcrypt manifest found."
+                       echo_info "WARNING: Listing all files as potential garbage (dry-run)."
                else
-                       echo_die "Error: No gcrypt manifest found on remote '$URL'." \
-                               "Aborting clean to prevent accidental data loss."
+                       echo_info "Error: No gcrypt manifest found on remote '$URL'."
+                       echo_info "Aborting clean to prevent accidental data loss."
+                       echo_info "To force initiation of the repository as git-crypt (and delete all old objects):"
+                       echo_info "  git-remote-gcrypt clean --init --force $URL"
+                       exit 1
                fi
        fi
 
@@ -1511,7 +1517,11 @@ cmd_clean()
        if isnull "$FORCE_CLEAN"; then
                echo_info "NOTE: This is a scan of unencrypted files on the remote."
                echo_info "To actually delete these files, use:"
-               echo_info "   git-remote-gcrypt clean $URL --force"
+               if [ "$Did_find_repo" != "yes" ]; then
+                       echo_info "   git-remote-gcrypt clean --init --force $URL"
+               else
+                       echo_info "   git-remote-gcrypt clean --force $URL"
+               fi
                CLEAN_FINAL "$URL"
                git remote remove "$NAME" 2>/dev/null || true
                exit 0