summaryrefslogtreecommitdiff
path: root/scripts/hash.sh
blob: 15861d27bc6e51c517a4137cb727dcb374028975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
set -e

repo=$1
mode=$2
name=$3
shift 3

case "$mode" in
12????)
	hash=$(printf %s "$1" | git -C "$repo" hash-object -w --stdin) ;;
10????)
	hash=$(git -C "$repo" hash-object -w --stdin <"$1") ;;
*)
	echo "invalid mode: $mode"
	exit 1
esac

printf '%s %s\t%s\n' "$mode" "$hash" "$name"