Files
oasis-linux-mirror/scripts/tree.sh
2020-01-03 10:53:34 -08:00

25 lines
448 B
Bash

set -e
if [ "$#" != 4 ] ; then
echo 'usage: commit.sh repo tag index out' >&2
exit 2
fi
repo=$1
tag=$2
index=$3
out=$4
export GIT_INDEX_FILE="$PWD/$out.index"
git -C "$repo" read-tree --empty
git -C "$repo" update-index --index-info <"$index"
tree=$(git -C "$repo" write-tree)
git -C "$repo" update-ref "refs/tags/$tag" "$tree"
printf '%s\n' "$tree" >"$out.tmp"
if cmp -s "$out" "$out.tmp" ; then
rm "$out.tmp"
else
mv "$out.tmp" "$out"
fi