2 ### automerge - merge the Emacs release branch to master
4 ## Copyright (C) 2018 Free Software Foundation, Inc.
6 ## Author: Glenn Morris <rgm@gnu.org>
8 ## This file is part of GNU Emacs.
10 ## GNU Emacs is free software: you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
15 ## GNU Emacs is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
25 ## Automatically merge the Emacs release branch to master.
28 die
() # write error to stderr and exit
30 [ $# -gt 0 ] && echo "$PN: $@" >&2
34 PN
=${0##*/} # basename of script
37 [ "$PD" = "$0" ] && PD
=.
# if PATH includes PWD
39 ## This should be the admin directory.
42 [ -d admin
] || die
"Could not locate admin directory"
44 [ -e .git
] || die
"No .git"
49 Usage: ${PN} [-b] [-e emacs] [-n nmin] [-p] [-t] [-- make-flags]
50 Merge the Emacs release branch to master.
51 Passes any non-option args to make (eg -- -j2).
53 -e: Emacs executable to use for the initial merge (default $emacs)
54 -n: Minimum number of commits to try merging (default $nmin)
55 -b: try to build after merging
56 -t: try to check after building
57 -p: if merge, build, check all succeed, push when finished (caution!)
72 while getopts ":hbe:n:pqt" option
; do
88 (\?) die
"Bad option -$OPTARG" ;;
90 (:) die
"Option -$OPTARG requires an argument" ;;
92 (*) die
"getopts error" ;;
99 ## Does not work 100% because a lot of Emacs batch output comes on
101 [ "$quiet" ] && exec 1> /dev
/null
104 [ "$push" ] && test=1
105 [ "$test" ] && build
=1
110 trap "rm -f $tempfile 2> /dev/null" EXIT
113 [ -e Makefile
] && [ "$build" ] && {
115 make maintainer-clean
>& /dev
/null
121 if $emacs --batch -Q -l .
/admin
/gitmerge.el \
122 --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \
123 >|
$tempfile 2>&1; then
127 grep -qE "Nothing to merge|Number of missing commits" $tempfile && {
128 echo "Fewer than $nmin commits to merge"
138 [ "$build" ] ||
exit 0
141 echo "Running autoreconf..."
143 autoreconf
-i -I m4 2>|
$tempfile
147 ## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
148 if [ "$quiet" ]; then
149 grep -v 'installing `\.' $tempfile 1>&2
154 [ $retval -ne 0 ] && die
"autoreconf error"
157 echo "Running ./configure..."
159 ## Minimize required packages.
160 .
/configure
--without-x || die
"configure error"
165 make "$@" || die
"make error"
167 echo "Build finished ok"
170 [ "$test" ] ||
exit 0
175 make "$@" check || die
"check error"
177 echo "Tests finished ok"
180 [ "$push" ] ||
exit 0
183 ## In case someone else pushed while we were working.
184 echo "Checking for remote changes..."
185 git fetch || die
"fetch error"
186 ## git >= 1.8.5 has "pull --rebase=preserve"
187 git rebase
--preserve-merges || die
"rebase error"
191 git push || die
"push error"
196 ### automerge ends here