sgit-stage 513 B

12345678910111213141516
  1. #! /bin/bash
  2. [[ $# -ne 1 ]] && echo "Usage: $0 FILE
  3. Stages FILE into index." && exit 1
  4. [[ ! -f "$1" ]] && echo "File $1 doesn't exist." && exit 1
  5. source_file="$1"
  6. sha=$(sgit-sha "$source_file")
  7. sha_dir="$PWD"/.git/objects/$(echo $sha | awk '{print substr($1,1,2)}')
  8. sha_file=$(echo $sha | awk '{print substr($1,3)}')
  9. [[ ! -f "$sha_dir/$sha_file" ]] && echo "You must first convert $source_file into a git blob using, say, sgit-mkblob." && exit 1
  10. git update-index --add --cacheinfo 100644 $sha "$source_file"