Fix endian bug in rust demangler
[official-gcc.git] / libgo / merge.sh
blob5bec1b935520d1bdab1e26c46f3a289d4543b32c
1 #!/bin/sh
3 # Copyright 2009 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
7 # This script merges changes from the master copy of the Go library
8 # into the libgo library. This does the easy stuff; the hard stuff is
9 # left to the user.
11 # The file MERGE should hold the Git revision number of the last
12 # revision which was merged into these sources. Given that, and given
13 # the current sources, we can run the usual diff3 algorithm to merge
14 # all changes into our sources.
16 set -e
18 TMPDIR=${TMPDIR:-/tmp}
20 OLDDIR=${TMPDIR}/libgo-merge-old
21 NEWDIR=${TMPDIR}/libgo-merge-new
23 if ! test -f MERGE; then
24 echo 1>&2 "merge.sh: must be run in libgo source directory"
25 exit 1
28 rev=weekly
29 case $# in
30 1) ;;
31 2) rev=$2 ;;
33 echo 1>&2 "merge.sh: Usage: merge.sh git-repository [revision]"
34 exit 1
36 esac
38 repository=$1
40 old_rev=`sed 1q MERGE`
42 rm -rf ${OLDDIR}
43 git clone ${repository} ${OLDDIR}
44 (cd ${OLDDIR} && git checkout ${old_rev})
46 rm -rf ${NEWDIR}
47 git clone ${repository} ${NEWDIR}
48 (cd ${NEWDIR} && git checkout ${rev})
50 new_rev=`cd ${NEWDIR} && git log | sed 1q | sed -e 's/commit //'`
52 merge() {
53 name=$1
54 old=$2
55 new=$3
56 libgo=$4
57 if test -d ${new}; then
58 if ! test -d ${old}; then
59 if test -f ${old}; then
60 echo 1>&2 "merge.sh: ${name}: FILE BECAME DIRECTORY"
63 elif ! test -f ${new}; then
64 # The file does not exist in the new version.
65 if ! test -f ${old}; then
66 echo 1>&2 "merge.sh internal error no files $old $new"
67 exit 1
69 if ! test -f ${libgo}; then
70 # File removed in new version and libgo.
72 else
73 echo "merge.sh: ${name}: REMOVED"
74 rm -f ${libgo}
75 git rm ${libgo}
77 elif test -f ${old}; then
78 # The file exists in the old version.
79 if ! test -f ${libgo}; then
80 if ! cmp -s ${old} ${new}; then
81 echo "merge.sh: $name: skipping: exists in old and new git, but not in libgo"
83 return
85 if cmp -s ${old} ${libgo}; then
86 # The libgo file is unchanged from the old version.
87 if cmp -s ${new} ${libgo}; then
88 # File is unchanged from old to new version.
89 return
91 # Update file in libgo.
92 echo "merge.sh: $name: updating"
93 cp ${new} ${libgo}
94 else
95 # The libgo file has local changes.
96 set +e
97 diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
98 status=$?
99 set -e
100 case $status in
102 echo "merge.sh: $name: updating"
103 mv ${libgo}.tmp ${libgo}
106 echo "merge.sh: $name: CONFLICTS"
107 mv ${libgo}.tmp ${libgo}
110 echo 1>&2 "merge.sh: $name: DIFF3 FAILURE"
112 esac
114 else
115 # The file does not exist in the old version.
116 if test -f ${libgo}; then
117 if ! cmp -s ${new} ${libgo}; then
118 echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
120 else
121 echo "merge.sh: $name: NEW"
122 dir=`dirname ${libgo}`
123 if ! test -d ${dir}; then
124 mkdir -p ${dir}
126 cp ${new} ${libgo}
127 git add ${libgo}
132 echo ${rev} > VERSION
134 (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
135 skip=false
136 case "$f" in
137 ./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)
139 ./cmd/*)
140 skip=true
142 ./runtime/race/*)
143 skip=true
145 esac
146 if test "$skip" = "true"; then
147 continue
150 oldfile=${OLDDIR}/src/$f
151 newfile=${NEWDIR}/src/$f
152 libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
153 merge $f ${oldfile} ${newfile} ${libgofile}
154 done
156 (cd ${NEWDIR}/src && find . -name 'go.mod' -print) | while read f; do
157 oldfile=${OLDDIR}/src/$f
158 newfile=${NEWDIR}/src/$f
159 libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
160 merge $f ${oldfile} ${newfile} ${libgofile}
161 done
163 (cd ${NEWDIR}/src && find . -name 'modules.txt' -print) | while read f; do
164 oldfile=${OLDDIR}/src/$f
165 newfile=${NEWDIR}/src/$f
166 libgofile=go/$f
167 merge $f ${oldfile} ${newfile} ${libgofile}
168 done
170 (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
171 skip=false
172 case "$d" in
173 ./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/*)
175 ./cmd/*)
176 skip=true
178 ./runtime/race/* | ./runtime/cgo/*)
179 skip=true
181 esac
182 if test "$skip" = "true"; then
183 continue
186 oldtd=${OLDDIR}/src/$d
187 newtd=${NEWDIR}/src/$d
188 libgotd=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
189 if ! test -d ${oldtd}; then
190 echo "merge.sh: $d: NEWDIR"
191 continue
193 (cd ${oldtd} && git ls-files .) | while read f; do
194 if test "`basename $f`" = ".gitignore"; then
195 continue
197 name=$d/$f
198 oldfile=${oldtd}/$f
199 newfile=${newtd}/$f
200 libgofile=${libgotd}/$f
201 merge ${name} ${oldfile} ${newfile} ${libgofile}
202 done
203 done
205 (cd ${NEWDIR}/misc/cgo && find . -type f -print) | while read f; do
206 oldfile=${OLDDIR}/misc/cgo/$f
207 newfile=${NEWDIR}/misc/cgo/$f
208 libgofile=misc/cgo/$f
209 merge $f ${oldfile} ${newfile} ${libgofile}
210 done
212 (cd ${OLDDIR}/src && find . -name '*.go' -print) | while read f; do
213 oldfile=${OLDDIR}/src/$f
214 newfile=${NEWDIR}/src/$f
215 libgofile=go/$f
216 if test -f ${newfile}; then
217 continue
219 if ! test -f ${libgofile}; then
220 continue
222 echo "merge.sh: ${libgofile}: REMOVED"
223 rm -f ${libgofile}
224 git rm ${libgofile}
225 done
227 (cd ${OLDDIR}/misc/cgo && find . -type f -print) | while read f; do
228 oldfile=${OLDDIR}/misc/cgo/$f
229 newfile=${NEWDIR}/misc/cgo/$f
230 libgofile=misc/cgo/$f
231 if test -f ${newfile}; then
232 continue
234 if ! test -f ${libgofile}; then
235 continue
237 echo "merge.sh: ${libgofile}: REMOVED"
238 rm -f ${libgofile}
239 git rm ${libgofile}
240 done
242 (echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
243 mv MERGE.tmp MERGE