Download scripts/unpack-git-objects.sh from dn-scribe/attstore: direct link, hf CLI and curl.
- Browser
- Download file 2.55 kB
-
https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/scripts/unpack-git-objects.sh
- Command line
-
hf download hf://spaces/dn-scribe/attstore/scripts/unpack-git-objects.sh
-
curl -L -o unpack-git-objects.sh https://huggingface.co/spaces/dn-scribe/attstore/resolve/main/scripts/unpack-git-objects.sh
2.55 kB
| # Unpack git objects from pack files for dumb HTTP serving | |
| set -e # Exit on error | |
| REPO_DIR="repos/sample-policies.git" | |
| # Change to repo directory | |
| cd "$REPO_DIR" || exit 1 | |
| # Check if pack files exist | |
| if ls objects/pack/*.pack 1> /dev/null 2>&1; then | |
| echo "Unpacking objects from pack files..." | |
| # Move pack files temporarily | |
| mkdir -p /tmp/git-packs-$$ | |
| mv objects/pack/*.pack objects/pack/*.idx /tmp/git-packs-$$/ | |
| # Unpack each pack file | |
| for pack in /tmp/git-packs-$$/*.pack; do | |
| if [ -f "$pack" ]; then | |
| echo "Processing $(basename $pack)..." | |
| cat "$pack" | git unpack-objects | |
| fi | |
| done | |
| # Clean up temp directory | |
| rm -rf /tmp/git-packs-$$ | |
| echo "Pack files successfully unpacked and removed." | |
| else | |
| echo "No pack files found. Checking if objects are already unpacked..." | |
| OBJECT_COUNT=$(find objects -type f -path 'objects/[0-9a-f][0-9a-f]/*' 2>/dev/null | wc -l | tr -d ' ') | |
| if [ "$OBJECT_COUNT" -eq 0 ]; then | |
| echo "ERROR: No pack files and no loose objects found!" | |
| echo "Repository may be corrupted. Please re-clone." | |
| exit 1 | |
| else | |
| echo "Found $OBJECT_COUNT loose objects already." | |
| fi | |
| fi | |
| echo "Creating info directory if needed..." | |
| mkdir -p info objects/info | |
| echo "Fixing refs if needed..." | |
| # Ensure packed-refs are unpacked | |
| if [ -f packed-refs ]; then | |
| echo "Found packed-refs, ensuring they are accessible..." | |
| fi | |
| echo "Updating server info..." | |
| if ! git update-server-info 2>/dev/null; then | |
| echo "Warning: git update-server-info failed. Creating info/refs manually..." | |
| # Create a basic refs file | |
| { | |
| git for-each-ref --format='%(objectname)%09%(refname)' refs/heads refs/tags 2>/dev/null || \ | |
| cat packed-refs | grep -v '^#' | awk '{print $1 "\t" $2}' | |
| } > info/refs | |
| fi | |
| echo "Creating objects/info/packs..." | |
| # Create empty packs file since we removed all packs | |
| echo "# no packs" > objects/info/packs | |
| echo "Done! Repository is ready for dumb HTTP serving." | |
| echo "" | |
| echo "Statistics:" | |
| echo " Loose objects: $(find objects -type f -path 'objects/[0-9a-f][0-9a-f]/*' 2>/dev/null | wc -l | tr -d ' ')" | |
| echo " Object dirs: $(find objects -type d -name '[0-9a-f][0-9a-f]' 2>/dev/null | wc -l | tr -d ' ')" | |
| echo " Pack files: $(ls objects/pack/*.pack 2>/dev/null | wc -l | tr -d ' ')" | |
| echo "" | |
| echo "Refs file:" | |
| ls -lh info/refs 2>/dev/null || echo "info/refs not found" | |
| echo "" | |
| echo "Sample object directories:" | |
| ls objects/ | grep -E '^[0-9a-f]{2}$' | head -5 | |