2010-12-03 05:34:57 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# This script merges changes from the master copy of the Go library
|
|
|
|
# into the libgo library. This does the easy stuff; the hard stuff is
|
|
|
|
# left to the user.
|
|
|
|
|
2015-10-31 01:59:47 +01:00
|
|
|
# The file MERGE should hold the Git revision number of the last
|
2010-12-03 05:34:57 +01:00
|
|
|
# revision which was merged into these sources. Given that, and given
|
|
|
|
# the current sources, we can run the usual diff3 algorithm to merge
|
|
|
|
# all changes into our sources.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TMPDIR=${TMPDIR:-/tmp}
|
|
|
|
|
|
|
|
OLDDIR=${TMPDIR}/libgo-merge-old
|
|
|
|
NEWDIR=${TMPDIR}/libgo-merge-new
|
|
|
|
|
|
|
|
if ! test -f MERGE; then
|
|
|
|
echo 1>&2 "merge.sh: must be run in libgo source directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-12-02 20:27:25 +01:00
|
|
|
rev=weekly
|
|
|
|
case $# in
|
|
|
|
1) ;;
|
|
|
|
2) rev=$2 ;;
|
|
|
|
*)
|
2015-10-31 01:59:47 +01:00
|
|
|
echo 1>&2 "merge.sh: Usage: merge.sh git-repository [revision]"
|
2010-12-03 05:34:57 +01:00
|
|
|
exit 1
|
2011-12-02 20:27:25 +01:00
|
|
|
;;
|
|
|
|
esac
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
repository=$1
|
|
|
|
|
2011-09-16 17:47:21 +02:00
|
|
|
old_rev=`sed 1q MERGE`
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
rm -rf ${OLDDIR}
|
2015-03-06 17:19:05 +01:00
|
|
|
git clone ${repository} ${OLDDIR}
|
|
|
|
(cd ${OLDDIR} && git checkout ${old_rev})
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
rm -rf ${NEWDIR}
|
2015-03-06 17:19:05 +01:00
|
|
|
git clone ${repository} ${NEWDIR}
|
|
|
|
(cd ${NEWDIR} && git checkout ${rev})
|
2010-12-03 05:34:57 +01:00
|
|
|
|
2015-03-06 17:19:05 +01:00
|
|
|
new_rev=`cd ${NEWDIR} && git log | sed 1q | sed -e 's/commit //'`
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
merge() {
|
|
|
|
name=$1
|
|
|
|
old=$2
|
|
|
|
new=$3
|
|
|
|
libgo=$4
|
2020-12-23 18:57:37 +01:00
|
|
|
if test -d ${new}; then
|
|
|
|
if ! test -d ${old}; then
|
|
|
|
if test -f ${old}; then
|
|
|
|
echo 1>&2 "merge.sh: ${name}: FILE BECAME DIRECTORY"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
elif ! test -f ${new}; then
|
2010-12-03 05:34:57 +01:00
|
|
|
# The file does not exist in the new version.
|
|
|
|
if ! test -f ${old}; then
|
|
|
|
echo 1>&2 "merge.sh internal error no files $old $new"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! test -f ${libgo}; then
|
|
|
|
# File removed in new version and libgo.
|
|
|
|
:;
|
|
|
|
else
|
|
|
|
echo "merge.sh: ${name}: REMOVED"
|
|
|
|
rm -f ${libgo}
|
2015-10-31 01:59:47 +01:00
|
|
|
git rm ${libgo}
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
elif test -f ${old}; then
|
|
|
|
# The file exists in the old version.
|
|
|
|
if ! test -f ${libgo}; then
|
2017-01-27 16:01:57 +01:00
|
|
|
if ! cmp -s ${old} ${new}; then
|
|
|
|
echo "merge.sh: $name: skipping: exists in old and new git, but not in libgo"
|
|
|
|
fi
|
2018-01-09 02:23:08 +01:00
|
|
|
return
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
if cmp -s ${old} ${libgo}; then
|
|
|
|
# The libgo file is unchanged from the old version.
|
|
|
|
if cmp -s ${new} ${libgo}; then
|
|
|
|
# File is unchanged from old to new version.
|
2018-01-09 02:23:08 +01:00
|
|
|
return
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
# Update file in libgo.
|
|
|
|
echo "merge.sh: $name: updating"
|
|
|
|
cp ${new} ${libgo}
|
|
|
|
else
|
|
|
|
# The libgo file has local changes.
|
|
|
|
set +e
|
|
|
|
diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
|
|
|
|
status=$?
|
|
|
|
set -e
|
|
|
|
case $status in
|
|
|
|
0)
|
|
|
|
echo "merge.sh: $name: updating"
|
|
|
|
mv ${libgo}.tmp ${libgo}
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
echo "merge.sh: $name: CONFLICTS"
|
|
|
|
mv ${libgo}.tmp ${libgo}
|
|
|
|
;;
|
|
|
|
*)
|
2017-01-14 01:05:42 +01:00
|
|
|
echo 1>&2 "merge.sh: $name: DIFF3 FAILURE"
|
2010-12-03 05:34:57 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# The file does not exist in the old version.
|
|
|
|
if test -f ${libgo}; then
|
|
|
|
if ! cmp -s ${new} ${libgo}; then
|
|
|
|
echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "merge.sh: $name: NEW"
|
|
|
|
dir=`dirname ${libgo}`
|
|
|
|
if ! test -d ${dir}; then
|
|
|
|
mkdir -p ${dir}
|
|
|
|
fi
|
|
|
|
cp ${new} ${libgo}
|
2015-10-31 01:59:47 +01:00
|
|
|
git add ${libgo}
|
2010-12-03 05:34:57 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-07-22 20:15:38 +02:00
|
|
|
echo ${rev} > VERSION
|
2015-01-22 00:03:41 +01:00
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
(cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
|
2017-01-14 01:05:42 +01:00
|
|
|
skip=false
|
|
|
|
case "$f" in
|
2020-12-23 18:57:37 +01:00
|
|
|
./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./cmd/internal/traceviewer/* | ./cmd/vendor/golang.org/x/tools/* | ./cmd/vendor/golang.org/x/mod/* | ./cmd/vendor/golang.org/x/xerrors/* | ./cmd/vendor/golang.org/x/crypto/ed25519)
|
2017-01-14 01:05:42 +01:00
|
|
|
;;
|
|
|
|
./cmd/*)
|
|
|
|
skip=true
|
|
|
|
;;
|
|
|
|
./runtime/race/*)
|
|
|
|
skip=true
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test "$skip" = "true"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
oldfile=${OLDDIR}/src/$f
|
|
|
|
newfile=${NEWDIR}/src/$f
|
2019-01-18 20:04:36 +01:00
|
|
|
libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
|
2010-12-03 05:34:57 +01:00
|
|
|
merge $f ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
|
2020-12-23 18:57:37 +01:00
|
|
|
(cd ${NEWDIR}/src && find . -name 'go.mod' -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/src/$f
|
|
|
|
newfile=${NEWDIR}/src/$f
|
|
|
|
libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
|
|
|
|
merge $f ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
|
|
|
|
(cd ${NEWDIR}/src && find . -name 'modules.txt' -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/src/$f
|
|
|
|
newfile=${NEWDIR}/src/$f
|
|
|
|
libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
|
|
|
|
merge $f ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
(cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
|
2017-01-14 01:05:42 +01:00
|
|
|
skip=false
|
2017-01-23 23:18:42 +01:00
|
|
|
case "$d" in
|
2020-12-23 18:57:37 +01:00
|
|
|
./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/diff/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./cmd/internal/traceviewer/* | ./cmd/vendor/golang.org/x/tools/*)
|
2017-01-14 01:05:42 +01:00
|
|
|
;;
|
|
|
|
./cmd/*)
|
|
|
|
skip=true
|
|
|
|
;;
|
2018-01-09 02:23:08 +01:00
|
|
|
./runtime/race/* | ./runtime/cgo/*)
|
2017-01-14 01:05:42 +01:00
|
|
|
skip=true
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test "$skip" = "true"; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
oldtd=${OLDDIR}/src/$d
|
|
|
|
newtd=${NEWDIR}/src/$d
|
2020-01-03 00:05:27 +01:00
|
|
|
libgotd=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
|
2010-12-03 05:34:57 +01:00
|
|
|
if ! test -d ${oldtd}; then
|
2017-01-14 01:05:42 +01:00
|
|
|
echo "merge.sh: $d: NEWDIR"
|
2010-12-03 05:34:57 +01:00
|
|
|
continue
|
|
|
|
fi
|
2015-03-06 17:19:05 +01:00
|
|
|
(cd ${oldtd} && git ls-files .) | while read f; do
|
|
|
|
if test "`basename $f`" = ".gitignore"; then
|
2010-12-03 05:34:57 +01:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
name=$d/$f
|
|
|
|
oldfile=${oldtd}/$f
|
|
|
|
newfile=${newtd}/$f
|
|
|
|
libgofile=${libgotd}/$f
|
|
|
|
merge ${name} ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2017-06-27 06:21:40 +02:00
|
|
|
(cd ${NEWDIR}/misc/cgo && find . -type f -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/misc/cgo/$f
|
|
|
|
newfile=${NEWDIR}/misc/cgo/$f
|
|
|
|
libgofile=misc/cgo/$f
|
|
|
|
merge $f ${oldfile} ${newfile} ${libgofile}
|
|
|
|
done
|
|
|
|
|
2015-01-15 01:27:56 +01:00
|
|
|
(cd ${OLDDIR}/src && find . -name '*.go' -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/src/$f
|
|
|
|
newfile=${NEWDIR}/src/$f
|
2010-12-03 05:34:57 +01:00
|
|
|
libgofile=go/$f
|
|
|
|
if test -f ${newfile}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if ! test -f ${libgofile}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "merge.sh: ${libgofile}: REMOVED"
|
|
|
|
rm -f ${libgofile}
|
2015-10-31 01:59:47 +01:00
|
|
|
git rm ${libgofile}
|
2010-12-03 05:34:57 +01:00
|
|
|
done
|
|
|
|
|
2017-06-27 06:21:40 +02:00
|
|
|
(cd ${OLDDIR}/misc/cgo && find . -type f -print) | while read f; do
|
|
|
|
oldfile=${OLDDIR}/misc/cgo/$f
|
|
|
|
newfile=${NEWDIR}/misc/cgo/$f
|
|
|
|
libgofile=misc/cgo/$f
|
|
|
|
if test -f ${newfile}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if ! test -f ${libgofile}; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "merge.sh: ${libgofile}: REMOVED"
|
|
|
|
rm -f ${libgofile}
|
|
|
|
git rm ${libgofile}
|
|
|
|
done
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
(echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
|
|
|
|
mv MERGE.tmp MERGE
|