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