upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/how-to/migration-scripts/10-check-git-sync.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docs/how-to/migration-scripts/10-check-git-sync.sh')
-rwxr-xr-xdocs/how-to/migration-scripts/10-check-git-sync.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/docs/how-to/migration-scripts/10-check-git-sync.sh b/docs/how-to/migration-scripts/10-check-git-sync.sh
index 1f2ce04..b4536cb 100755
--- a/docs/how-to/migration-scripts/10-check-git-sync.sh
+++ b/docs/how-to/migration-scripts/10-check-git-sync.sh
@@ -118,6 +118,11 @@ usage() {
118check_prerequisites() { 118check_prerequisites() {
119 local missing=0 119 local missing=0
120 120
121 if ! command -v git &> /dev/null; then
122 log_error "git not found. Install with your package manager."
123 missing=1
124 fi
125
121 if ! command -v nak &> /dev/null; then 126 if ! command -v nak &> /dev/null; then
122 log_error "nak not found. Install from: https://github.com/fiatjaf/nak" 127 log_error "nak not found. Install from: https://github.com/fiatjaf/nak"
123 log_error "Or run: nix-shell -p nak jq --run \"$0 $*\"" 128 log_error "Or run: nix-shell -p nak jq --run \"$0 $*\""
@@ -161,13 +166,15 @@ count_git_refs() {
161 return 166 return
162 fi 167 fi
163 168
164 # Use git show-ref to handle both packed and loose refs 169 # Try git show-ref first (handles packed refs correctly)
165 # Fall back to counting loose refs if git show-ref fails 170 # Note: We capture output separately to avoid pipefail issues
166 if git --git-dir="$git_dir" show-ref --heads 2>/dev/null | wc -l | tr -d ' '; then 171 local count
172 if count=$(git --git-dir="$git_dir" show-ref --heads 2>/dev/null | wc -l); then
173 echo "$count" | tr -d ' '
167 return 174 return
168 fi 175 fi
169 176
170 # Fallback: count loose refs 177 # Fallback: count loose refs (when git is not available or fails)
171 if [[ -d "$git_dir/refs/heads" ]]; then 178 if [[ -d "$git_dir/refs/heads" ]]; then
172 find "$git_dir/refs/heads" -type f 2>/dev/null | wc -l | tr -d ' ' 179 find "$git_dir/refs/heads" -type f 2>/dev/null | wc -l | tr -d ' '
173 else 180 else