mirror of
https://github.com/oasislinux/oasis.git
synced 2026-02-01 11:34:17 +01:00
24 lines
369 B
Bash
24 lines
369 B
Bash
set -e
|
|
|
|
if [ "$#" != 4 ] ; then
|
|
echo 'usage: hash.sh repo mode name file' >&2
|
|
exit 2
|
|
fi
|
|
|
|
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"
|