Files
oasis-linux-mirror/scripts/commit.sh
Michael Forney f4720910b9 Update ninja requirement to 1.8.0 and don't bother with atomic outputs
Since ninja 1.8.0[0] and samurai 0.2[1], output mtime is always
recorded after a job succeeds, and outputs are considered dirty if
the recorded mtime is older than any input. This means that even
if a command partially writes its output then fails (for example,
if run with stdout redirected to a file), it will still get re-run
during the next build.

This means that outputs no longer have to be written atomically
(i.e. renamed into place) in order to ensure a correct build, and
we can drop the idiom `command >$out.tmp && mv $out.tmp $out`.

[0] 04d886b110
[1] 799bc5a471
2019-11-17 15:24:25 -08:00

25 lines
576 B
Bash

set -e
repo=$1
branch=$2
tag=$3
out=$4
if commit=$(git -C "$repo" show-ref -s --verify "refs/heads/$branch" 2>/dev/null) ; then
oldtree=$(git -C "$repo" rev-parse --verify "$branch^{tree}")
newtree=$(git -C "$repo" rev-parse --verify "$tag^{tree}")
if [ "$oldtree" != "$newtree" ] ; then
set -- -p "$branch"
unset commit
fi
else
set --
unset commit
fi
if [ -z "${commit+set}" ] ; then
commit=$(git -C "$repo" commit-tree -m "oasis $(git rev-parse --short=10 HEAD)" "$@" "$tag")
git -C "$repo" update-ref "refs/heads/$branch" "$commit"
fi
echo "$commit" >"$out"