mirror of
https://github.com/oasislinux/oasis.git
synced 2025-12-25 12:14:00 +01:00
25 lines
448 B
Bash
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
|