more fixes
authorShane Jaroch <chown_tee@proton.me>
Thu, 15 Jan 2026 06:24:12 +0000 (01:24 -0500)
committerShane Jaroch <chown_tee@proton.me>
Thu, 15 Jan 2026 06:24:12 +0000 (01:24 -0500)
Makefile
README.rst
completions/bash/git-remote-gcrypt
completions/templates/README.rst.in
completions/templates/bash.in
completions/templates/zsh.in
completions/zsh/_git-remote-gcrypt
git-remote-gcrypt
install.sh
tests/test-install-logic.sh
utils/gen_docs.sh

index f060776a147e0eba1204917a601027afd5d31ffc..af7a8d19e421fa0d571a53fa6d6bfbf6e30d0e44 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -133,7 +133,7 @@ test/system:        ##H Run logic tests (with bash & coverage)
        @rm -rf $(COV_SYSTEM)
        @mkdir -p $(COV_SYSTEM)
        @export GPG_TTY=$$(tty); \
-        [ -n "$(DEBUG)$(V)" ] && export GCRYPT_DEBUG=1 && printf "\033[1;33mDebug mode enabled\033[0m\n"; \
+        [ -n "$(DEBUG)$(V)" ] && export GCRYPT_DEBUG=1 && $(call print_warn,Debug mode enabled); \
         export GIT_CONFIG_PARAMETERS="'gcrypt.gpg-args=--pinentry-mode loopback --no-tty'"; \
         sed -i 's|^#!/bin/sh|#!/bin/bash|' git-remote-gcrypt; \
         trap "sed -i 's|^#!/bin/bash|#!/bin/sh|' git-remote-gcrypt" EXIT; \
index 4f798e363a3c060c7ac339e1c761f907f7e92250..ca4fed99fe1fbc614f7e8e5bc3f3011a3335a521 100644 (file)
@@ -72,8 +72,6 @@ Command Reference
     Environment Variables:
       GCRYPT_DEBUG=1        Enable verbose debug logging to stderr
       GCRYPT_TRACE=1        Enable shell tracing (set -x) for rsync/curl commands
-      GCRYPT_FULL_REPACK=1  Force full repack when pushing
-
 
 Configuration
 =============
@@ -289,7 +287,7 @@ To detect if a git url is a gcrypt repo, use::
 
 (Legacy syntax ``--check`` is also supported).
 
-Exit status is 0
+Exit status is 0 if the repository exists and uses gcrypt, 1 if it
 uses gcrypt but could not be decrypted, and 100 if the repo is not
 encrypted with gcrypt (or could not be accessed).
 
index baf07157aef4412a4fe2a23c7bc73826cc94a92a..3479aa508b62fcb893a097df0f736ab4c46d7301 100644 (file)
@@ -21,13 +21,13 @@ _git_remote_gcrypt() {
        # 2. Handle subcommands
        case "${COMP_WORDS[1]}" in
                clean)
-                       local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :)
-                       COMPREPLY=($(compgen -W " $remotes" -- "$cur"))
+                       local remotes=$( git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || : )
+                       COMPREPLY=( $( compgen -W " $remotes" -- "$cur" ) )
                        return 0
                        ;;
                check)
-                       local remotes=$(git remote 2>/dev/null || :)
-                       COMPREPLY=($(compgen -W "$remotes" -- "$cur"))
+                       local remotes=$( git remote 2>/dev/null || : )
+                       COMPREPLY=( $( compgen -W "$remotes" -- "$cur" ) )
                        return 0
                        ;;
                capabilities|fetch|list|push)
index a31a7fb9c31cd9321dc12493c410df5f744f2bdf..67b6ef8fe9f75dab644f94043f1438b3b7ecd93c 100644 (file)
@@ -271,7 +271,7 @@ To detect if a git url is a gcrypt repo, use::
 
 (Legacy syntax ``--check`` is also supported).
 
-Exit status is 0
+Exit status is 0 if the repository exists and uses gcrypt, 1 if it
 uses gcrypt but could not be decrypted, and 100 if the repo is not
 encrypted with gcrypt (or could not be accessed).
 
index 32956add259c1da1905b6c951dd9b9ded4ceb4a6..dcfe0cbee0087273938e5d24d8d7bb2c8079cf7c 100644 (file)
@@ -21,13 +21,13 @@ _git_remote_gcrypt() {
        # 2. Handle subcommands
        case "${COMP_WORDS[1]}" in
                clean)
-                       local remotes=$(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || :)
-                       COMPREPLY=($(compgen -W "{clean_flags_bash} $remotes" -- "$cur"))
+                       local remotes=$( git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print $1}' | sort -u || : )
+                       COMPREPLY=( $( compgen -W "{clean_flags_bash} $remotes" -- "$cur" ) )
                        return 0
                        ;;
                check)
-                       local remotes=$(git remote 2>/dev/null || :)
-                       COMPREPLY=($(compgen -W "$remotes" -- "$cur"))
+                       local remotes=$( git remote 2>/dev/null || : )
+                       COMPREPLY=( $( compgen -W "$remotes" -- "$cur" ) )
                        return 0
                        ;;
                capabilities|fetch|list|push)
index 329bdb134c9454ae3544544a93ea70037f59914b..60641e34fbb785cedaa94aca9aa28180f29b390b 100644 (file)
@@ -14,7 +14,7 @@ _git_remote_gcrypt() {
 
        case $line[1] in
        clean)
-               _arguments \
+               _arguments {clean_flags_zsh} \
                        '*:gcrypt URL: _alternative "remotes:gcrypt remote:($(git remote -v 2>/dev/null | grep "gcrypt::" | awk "{print \$1}" | sort -u))" "files:file:_files"'
                ;;
        check)
index ceb5ae59511ef12eac8557dd2cdd1131e1855e95..14a84003ec6aa27276d85ce6633515fb4ad77e56 100644 (file)
@@ -14,7 +14,7 @@ _git_remote_gcrypt() {
 
        case $line[1] in
        clean)
-               _arguments \
+               _arguments  \
                        '*:gcrypt URL: _alternative "remotes:gcrypt remote:($(git remote -v 2>/dev/null | grep "gcrypt::" | awk "{print \$1}" | sort -u))" "files:file:_files"'
                ;;
        check)
index 4a9213c46c0d4f0adf06647aa23b503482ddd5f3..c33dbec897124b1357cd2d2d0a4e73d17046b2f2 100755 (executable)
@@ -1419,10 +1419,10 @@ get_remote_file_list()
                                return 1
                        }
                        git update-ref -d "refs/gcrypt/list-files"
-               else
                        # Could not fetch, or remote is empty.
                        # If checking, this might be fine, but for clean it's an issue if we expected files.
                        # Returning 1 is safer.
+                       git update-ref -d "refs/gcrypt/list-files" 2>/dev/null || true
                        return 1
                fi
        fi
index ef42ede89bd54c2b15defcccdb9f66c9007b76e0..1eb0c5822eea3e6edcfe7c349fb537c914edd3e4 100755 (executable)
@@ -4,12 +4,19 @@ set -e
 : "${prefix:=/usr/local}"
 : "${DESTDIR:=}"
 
+log() { printf "\033[1;36m[INSTALL] %s\033[0m\n" "$1"; }
 verbose() { echo "$@" >&2 && "$@"; }
 
 install_v() {
        # Install $1 into $2/ with mode $3
-       verbose install -d "$2" \
-               && verbose install -m "$3" "$1" "$2"
+       if ! verbose install -d "$2"; then
+               echo "Error: Failed to create directory $2" >&2
+               exit 1
+       fi
+       if ! verbose install -m "$3" "$1" "$2"; then
+               echo "Error: Failed to install $1 into $2" >&2
+               exit 1
+       fi
 }
 
 # --- VERSION DETECTION ---
index 1b843f85771c94025cb5364189804898d7772997..c160ae1923d608ee4a9071bfd6af8c32584a8296 100755 (executable)
@@ -37,11 +37,13 @@ assert_version() {
        export prefix="$PREFIX"
        unset DESTDIR
 
-       # Run the installer
-       "bash" "$INSTALLER" >/dev/null 2>&1 || {
-               echo "Installer failed unexpectedly"
-               return 1
+       # Run the installer and capture output
+       cat </dev/null | "bash" "$INSTALLER" >.install_log 2>&1 || {
+               print_err "Installer failed unexpectedly. Output:"
+               cat .install_log
+               exit 1
        }
+       rm -f .install_log
 
        INSTALLED_BIN="$PREFIX/bin/git-remote-gcrypt"
        chmod +x "$INSTALLED_BIN"
@@ -89,11 +91,29 @@ EXPECTED_TAG="5.5.5-1 ($OS_IDENTIFIER)"
 
 assert_version "$EXPECTED_TAG"
 
-# --- TEST 3: DESTDIR Support ---
-echo "--- Test 3: DESTDIR Support ---"
+# --- TEST 3: Prefix Support (Mac-idiomatic) ---
+echo "--- Test 3: Prefix Support ---"
 rm -rf "${SANDBOX:?}/usr"
-export DESTDIR="$SANDBOX/pkg_root"
+export prefix="$SANDBOX/usr"
+unset DESTDIR
+
+"bash" "$INSTALLER" >/dev/null 2>&1 || {
+       print_err "Installer FAILED"
+       exit 1
+}
+
+if [ -f "$SANDBOX/usr/bin/git-remote-gcrypt" ]; then
+       printf "  ✓ %s\n" "Prefix honored"
+else
+       print_err "FAILED: Binary not found in expected prefix location"
+       exit 1
+fi
+
+# --- TEST 4: DESTDIR Support (Linux-idiomatic) ---
+echo "--- Test 4: DESTDIR Support ---"
+rm -rf "${SANDBOX:?}/pkg_root"
 export prefix="/usr"
+export DESTDIR="$SANDBOX/pkg_root"
 
 "bash" "$INSTALLER" >/dev/null 2>&1 || {
        print_err "Installer FAILED"
index b95bbafaf5bfec71a47fadb91edeb484c11b4c5d..b0545107280e2f49e2ffd3ac1cd5b95b8aa0bff1 100755 (executable)
@@ -29,7 +29,7 @@ RAW_HELP=$(sed -n "/^$SCRIPT_KEY=\"/,/\"$/p" "$SRC" | sed "s/^$SCRIPT_KEY=\"//;s
 
 # 1. Prepare {commands_help} for README (Indented for RST)
 # We want the Options and Git Protocol Commands sections
-COMMANDS_HELP=$(echo "$RAW_HELP" | sed -n '/^Options:/,$p' | sed 's/^/    /')
+COMMANDS_HELP=$(echo "$RAW_HELP" | sed -n '/^Options:/,$p' | sed 's/^/    /' | sed '$d')
 
 # 2. Parse Commands and Flags for Completions
 # Extract command names (first word after 2 spaces)
@@ -71,34 +71,38 @@ for line in $CLEAN_FLAGS_RAW; do
 done
 unset IFS
 
+# Helper for template substitution using awk
+# Usage: replace_template "TEMPLATE_FILE" "OUT_FILE" "KEY1=VALUE1" "KEY2=VALUE2" ...
+replace_template() {
+       _tmpl="$1"
+       _out="$2"
+       shift 2
+       _awk_script=""
+       for _kv in "$@"; do
+               _key="${_kv%%=*}"
+               _val="${_kv#*=}"
+               # Export the value so awk can access it via ENVIRON
+               export "REPLACE_$_key"="$_val"
+               _awk_script="${_awk_script} gsub(/\{${_key}\}/, ENVIRON[\"REPLACE_$_key\"]);"
+       done
+       awk "{ $_awk_script print }" "$_tmpl" >"$_out"
+}
+
 # 3. Generate README
 echo "Generating $README_OUT..."
-sed "s/{commands_help}/$(echo "$COMMANDS_HELP" | sed 's/[\/&]/\\&/g' | awk 'NR>1{printf "\\n"} {printf "%s", $0}')/" "$README_TMPL" >"$README_OUT"
+replace_template "$README_TMPL" "$README_OUT" "commands_help=$COMMANDS_HELP"
 
 # 4. Generate Bash
 echo "Generating Bash completions..."
-sed "s/{commands}/$COMMANDS_LIST/; s/{clean_flags_bash}/$CLEAN_FLAGS_BASH/" "$BASH_TMPL" >"$BASH_OUT"
+replace_template "$BASH_TMPL" "$BASH_OUT" "commands=$COMMANDS_LIST" "clean_flags_bash=$CLEAN_FLAGS_BASH"
 
 # 5. Generate Zsh
 echo "Generating Zsh completions..."
-# Zsh substitution is tricky with the complex string.
-# We'll stick to replacing {commands} and {clean_flags_zsh}
-# Need to escape special chars for sed
-# safe_cmds removed as unused
-# For clean_flags_zsh, since it contains quotes and braces, we need care.
-# We'll read the template line by line? No, sed is standard.
-# We use a temp file for the replacement string to avoid sed escaping hell for large blocks?
-# Or just keep it simple.
-sed "s/{commands}/$COMMANDS_LIST/" "$ZSH_TMPL" \
-       | sed "s|{clean_flags_zsh}|$CLEAN_FLAGS_ZSH|" >"$ZSH_OUT"
+replace_template "$ZSH_TMPL" "$ZSH_OUT" "commands=$COMMANDS_LIST" "clean_flags_zsh=$CLEAN_FLAGS_ZSH"
 
 # 6. Generate Fish
 echo "Generating Fish completions..."
 # Fish needs {not_sc_list} which matches {commands} (space separated)
-sed "s/{not_sc_list}/$COMMANDS_LIST/g" "$FISH_TMPL" \
-       |
-       # Multi-line replacement in sed is hard. Use awk?
-       # Or just injecting the string with escaped newlines.
-       sed "s|{clean_flags_fish}|$CLEAN_FLAGS_FISH|" >"$FISH_OUT"
+replace_template "$FISH_TMPL" "$FISH_OUT" "not_sc_list=$COMMANDS_LIST" "clean_flags_fish=$CLEAN_FLAGS_FISH"
 
 echo "Done."