From: Shane Date: Mon, 26 Jan 2026 06:31:22 +0000 (+0000) Subject: add logging X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=2453f52f5b5c54ee6e22bff523d873c5d046237e;p=gamesguru%2Fgit-remote-gcrypt.git add logging --- diff --git a/git-remote-gcrypt b/git-remote-gcrypt index c403d17..5ea56f0 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -1527,14 +1527,18 @@ get_remote_file_list() # to avoid D/F conflicts with the directory we are about to use. git update-ref -d "refs/gcrypt/list-files" 2>/dev/null || : - if git fetch --quiet "$URL" "refs/heads/*:refs/gcrypt/list-files/*" 2>/dev/null; then + echo_info "Debug: Fetching refs/heads/* from $URL to list files..." + if git fetch --verbose "$URL" "refs/heads/*:refs/gcrypt/list-files/*" >&2; then + echo_info "Debug: Fetch successful." # List files from ALL fetched branches # We iterate refs manually to detect which one has files local refs all_files="" ref_files="" # distinct refs Global_Dirty_Refs="" refs=$(git for-each-ref --format='%(refname)' "refs/gcrypt/list-files/") + echo_info "Debug: Found refs: $refs" for ref in $refs; do + echo_info "Debug: Checking ref $ref" ref_files=$(git -c core.quotePath=false ls-tree -r --name-only "$ref") if isnonnull "$ref_files"; then # Map refs/gcrypt/list-files/BRANCH -> refs/heads/BRANCH diff --git a/tests/test-clean-ref-conflict.sh b/tests/test-clean-ref-conflict.sh deleted file mode 100644 index 27350ba..0000000 --- a/tests/test-clean-ref-conflict.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# Test: clean command fails if refs/gcrypt/list-files exists as a file (D/F conflict) -set -e -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' -print_info() { echo -e "${GREEN}$*${NC}"; } -print_err() { echo -e "${RED}✗ $*${NC}"; } - -SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)" -export PATH="$SCRIPT_DIR:$PATH" -tempdir=$(mktemp -d) -trap 'rm -rf "$tempdir"' EXIT - -export GNUPGHOME="${tempdir}/gpg" -mkdir -p "${GNUPGHOME}" -chmod 700 "${GNUPGHOME}" -cat <<'EOF' >"${GNUPGHOME}/gpg" -#!/usr/bin/env bash -exec /usr/bin/gpg --no-tty "$@" -EOF -chmod +x "${GNUPGHOME}/gpg" - -GIT="git -c advice.defaultBranchName=false -c commit.gpgSign=false" -gpg --batch --passphrase "" --quick-generate-key "Test " - -mkdir "$tempdir/remote" && cd "$tempdir/remote" -$GIT init --bare - -mkdir "$tempdir/seeder" && cd "$tempdir/seeder" -$GIT init -b main -$GIT remote add origin "$tempdir/remote" -echo "DATA" >file.txt -$GIT add file.txt -$GIT commit -m "init" -$GIT push origin main - -print_info "Attempting clean with poisoned environment..." -cd "$tempdir" -git init -# Create a commit so we have something to point the ref to -touch foo -git add foo -git commit -m "init" - -# POISON: Create a ref that conflicts with the directory we want to use -# The old code used refs/gcrypt/list-files as a file. -# The new code uses refs/gcrypt/list-files/BRANCH. -# If we have the old ref, git fetch might fail. -git update-ref refs/gcrypt/list-files HEAD - -if "$SCRIPT_DIR/git-remote-gcrypt" clean --init --force "gcrypt::$tempdir/remote"; then - print_info "Clean command finished." -else - print_err "Clean command returned error code." -fi - -# Check if file still exists (it should be gone if clean worked) -cd "$tempdir/remote" -files=$($GIT ls-tree -r main | grep "file.txt" || :) -if [ -n "$files" ]; then - print_err "FAILURE: file.txt still exists on main! (Clean likely failed silently)" - exit 1 -else - print_info "SUCCESS: file.txt was removed." -fi