sgit-loc 390 B

123456789101112131415
  1. #! /bin/bash
  2. [[ $# -ne 1 ]] && echo "Usage: $0 SHA1SUM
  3. Converts SHA1SUM into a git object location." && exit 1
  4. objdir="$PWD/.git/objects"
  5. sha=$1
  6. sha_dir="$objdir"/$(echo $sha | awk '{print substr($1,1,2)}')
  7. sha_file=$(echo $sha | awk '{print substr($1,3)}')
  8. [[ ! -f "$sha_dir"/"$sha_file" ]] && echo "Warning: no object is currently associated with $sha." 1>&2
  9. echo $sha_dir/$sha_file