123456789101112131415 |
- #! /bin/bash
- [[ $# -ne 1 ]] && echo "Usage: sgit-cat SHA1SUM
- Outputs contents of git object associated with SHA1SUM."
- objdir="$PWD/.git/objects"
- sha=$1
- sha_dir="$objdir"/$(echo $sha | awk '{print substr($1,1,2)}')
- sha_file=$(echo $sha | awk '{print substr($1,3)}')
- [[ ! -f "$sha_dir"/"$sha_file" ]] && echo "No object associated with $sha." && exit 1
- openssl zlib -d < "$sha_dir"/"$sha_file" | tr '\000' '\n'
|