diff options
Diffstat (limited to 'admin/automerge')
-rwxr-xr-x | admin/automerge | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/admin/automerge b/admin/automerge index 61570587d6b..81082f7dc68 100755 --- a/admin/automerge +++ b/admin/automerge @@ -4,7 +4,7 @@ ## Copyright (C) 2018-2021 Free Software Foundation, Inc. ## Author: Glenn Morris <rgm@gnu.org> -## Maintainer: emacs-devel@gnu.org +## Maintainer: Stefan Kangas <stefan@marxist.se> ## This file is part of GNU Emacs. @@ -37,7 +37,7 @@ die () # write error to stderr and exit { - [ $# -gt 0 ] && echo "$PN: $@" >&2 + [ $# -gt 0 ] && echo "$PN: $*" >&2 exit 1 } @@ -108,7 +108,8 @@ OPTIND=1 [ "$nocd" ] || { - cd $PD # this should be the admin directory + # $PD should be the admin directory + cd $PD || die "Could not change directory to $PD" cd ../ } @@ -126,9 +127,13 @@ OPTIND=1 [ "$test" ] && build=1 -tempfile=/tmp/$PN.$$ +if [ -x "$(command -v mktemp)" ]; then + tempfile=$(mktemp "/tmp/$PN.XXXXXXXXXX") +else + tempfile=/tmp/$PN.$$ +fi -trap "rm -f $tempfile 2> /dev/null" EXIT +trap 'rm -f $tempfile 2> /dev/null' EXIT [ -e Makefile ] && [ "$build" ] && { @@ -148,7 +153,7 @@ trap "rm -f $tempfile 2> /dev/null" EXIT rev=$(git rev-parse HEAD) -[ $(git rev-parse @{u}) = $rev ] || die "Local state does not match origin" +[ "$(git rev-parse @{u})" = "$rev" ] || die "Local state does not match origin" merge () @@ -157,12 +162,12 @@ merge () if $emacs --batch -Q -l ./admin/gitmerge.el \ --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \ - >| $tempfile 2>&1; then + >| "$tempfile" 2>&1; then echo "merged ok" return 0 else - grep -E "Nothing to merge|Number of missing commits" $tempfile && \ + grep -E "Nothing to merge|Number of missing commits" "$tempfile" && \ exit 0 cat "$tempfile" 1>&2 @@ -186,13 +191,13 @@ git diff --stat --cached origin/master | grep -q "etc/NEWS " && \ echo "Running autoreconf..." -autoreconf -i -I m4 2>| $tempfile +autoreconf -i -I m4 2>| "$tempfile" retval=$? ## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr. if [ "$quiet" ]; then - grep -v 'installing `\.' $tempfile 1>&2 + grep -v 'installing `\.' "$tempfile" 1>&2 else cat "$tempfile" 1>&2 fi @@ -231,7 +236,7 @@ echo "Tests finished ok" echo "Checking for remote changes..." git fetch || die "fetch error" -[ $(git rev-parse @{u}) = $rev ] || { +[ "$(git rev-parse @{u})" = "$rev" ] || { echo "Upstream has changed" @@ -240,7 +245,7 @@ git fetch || die "fetch error" ## Ref eg https://lists.gnu.org/r/emacs-devel/2014-12/msg01435.html ## Instead, we throw away what we just did, and do the merge again. echo "Resetting..." - git reset --hard $rev + git reset --hard "$rev" echo "Pulling..." git pull --ff-only || die "pull error" |