]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgo/merge.sh
print-rtl: Change return type of two print functions from int to void
[thirdparty/gcc.git] / libgo / merge.sh
CommitLineData
7a938933
ILT
1#!/bin/sh
2
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.
6
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.
10
af146490 11# The file MERGE should hold the Git revision number of the last
7a938933
ILT
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.
15
16set -e
17
18TMPDIR=${TMPDIR:-/tmp}
19
20OLDDIR=${TMPDIR}/libgo-merge-old
21NEWDIR=${TMPDIR}/libgo-merge-new
22
23if ! test -f MERGE; then
24 echo 1>&2 "merge.sh: must be run in libgo source directory"
25 exit 1
26fi
27
bfa9b580
ILT
28rev=weekly
29case $# in
301) ;;
312) rev=$2 ;;
32*)
af146490 33 echo 1>&2 "merge.sh: Usage: merge.sh git-repository [revision]"
7a938933 34 exit 1
bfa9b580
ILT
35 ;;
36esac
7a938933
ILT
37
38repository=$1
39
adb0401d 40old_rev=`sed 1q MERGE`
7a938933
ILT
41
42rm -rf ${OLDDIR}
c271e224
ILT
43git clone ${repository} ${OLDDIR}
44(cd ${OLDDIR} && git checkout ${old_rev})
7a938933
ILT
45
46rm -rf ${NEWDIR}
c271e224
ILT
47git clone ${repository} ${NEWDIR}
48(cd ${NEWDIR} && git checkout ${rev})
7a938933 49
c271e224 50new_rev=`cd ${NEWDIR} && git log | sed 1q | sed -e 's/commit //'`
7a938933
ILT
51
52merge() {
53 name=$1
54 old=$2
55 new=$3
56 libgo=$4
cfcbb422
ILT
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"
61 fi
62 fi
63 elif ! test -f ${new}; then
7a938933
ILT
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
68 fi
69 if ! test -f ${libgo}; then
70 # File removed in new version and libgo.
71 :;
72 else
73 echo "merge.sh: ${name}: REMOVED"
74 rm -f ${libgo}
7a938933
ILT
75 fi
76 elif test -f ${old}; then
77 # The file exists in the old version.
78 if ! test -f ${libgo}; then
42f20102
ILT
79 if ! cmp -s ${old} ${new}; then
80 echo "merge.sh: $name: skipping: exists in old and new git, but not in libgo"
81 fi
1a2f01ef 82 return
7a938933
ILT
83 fi
84 if cmp -s ${old} ${libgo}; then
85 # The libgo file is unchanged from the old version.
86 if cmp -s ${new} ${libgo}; then
87 # File is unchanged from old to new version.
1a2f01ef 88 return
7a938933
ILT
89 fi
90 # Update file in libgo.
91 echo "merge.sh: $name: updating"
92 cp ${new} ${libgo}
93 else
94 # The libgo file has local changes.
95 set +e
96 diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
97 status=$?
98 set -e
99 case $status in
100 0)
101 echo "merge.sh: $name: updating"
102 mv ${libgo}.tmp ${libgo}
103 ;;
104 1)
105 echo "merge.sh: $name: CONFLICTS"
106 mv ${libgo}.tmp ${libgo}
7a938933
ILT
107 ;;
108 *)
c2047754 109 echo 1>&2 "merge.sh: $name: DIFF3 FAILURE"
7a938933
ILT
110 ;;
111 esac
112 fi
113 else
114 # The file does not exist in the old version.
115 if test -f ${libgo}; then
116 if ! cmp -s ${new} ${libgo}; then
117 echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
118 fi
119 else
120 echo "merge.sh: $name: NEW"
121 dir=`dirname ${libgo}`
122 if ! test -d ${dir}; then
123 mkdir -p ${dir}
124 fi
125 cp ${new} ${libgo}
7a938933
ILT
126 fi
127 fi
128}
129
22b955cc 130echo ${rev} > VERSION
66320347 131
f8d9fa9e 132(cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
c2047754
ILT
133 skip=false
134 case "$f" in
8dc2499a 135 ./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/quoted/* | ./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 | ./cmd/vendor/golang.org/x/sync/semaphore)
c2047754
ILT
136 ;;
137 ./cmd/*)
138 skip=true
139 ;;
140 ./runtime/race/*)
141 skip=true
142 ;;
143 esac
144 if test "$skip" = "true"; then
145 continue
146 fi
147
f8d9fa9e
ILT
148 oldfile=${OLDDIR}/src/$f
149 newfile=${NEWDIR}/src/$f
4f4a855d 150 libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
7a938933
ILT
151 merge $f ${oldfile} ${newfile} ${libgofile}
152done
153
cfcbb422
ILT
154(cd ${NEWDIR}/src && find . -name 'go.mod' -print) | while read f; do
155 oldfile=${OLDDIR}/src/$f
156 newfile=${NEWDIR}/src/$f
157 libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
158 merge $f ${oldfile} ${newfile} ${libgofile}
159done
160
161(cd ${NEWDIR}/src && find . -name 'modules.txt' -print) | while read f; do
162 oldfile=${OLDDIR}/src/$f
163 newfile=${NEWDIR}/src/$f
726b7aa0 164 libgofile=go/$f
cfcbb422
ILT
165 merge $f ${oldfile} ${newfile} ${libgofile}
166done
167
f8d9fa9e 168(cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
c2047754 169 skip=false
c25edd44 170 case "$d" in
cfcbb422 171 ./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/*)
c2047754
ILT
172 ;;
173 ./cmd/*)
174 skip=true
175 ;;
1a2f01ef 176 ./runtime/race/* | ./runtime/cgo/*)
c2047754
ILT
177 skip=true
178 ;;
179 esac
180 if test "$skip" = "true"; then
181 continue
182 fi
183
f8d9fa9e
ILT
184 oldtd=${OLDDIR}/src/$d
185 newtd=${NEWDIR}/src/$d
5a8ea165 186 libgotd=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
7a938933 187 if ! test -d ${oldtd}; then
c2047754 188 echo "merge.sh: $d: NEWDIR"
7a938933
ILT
189 continue
190 fi
c271e224 191 (cd ${oldtd} && git ls-files .) | while read f; do
8dc2499a 192 if test "`basename -- $f`" = ".gitignore"; then
7a938933
ILT
193 continue
194 fi
7a938933
ILT
195 name=$d/$f
196 oldfile=${oldtd}/$f
197 newfile=${newtd}/$f
198 libgofile=${libgotd}/$f
199 merge ${name} ${oldfile} ${newfile} ${libgofile}
200 done
69921f4a 201 (cd ${newtd} && git ls-files .) | while read f; do
20a33efd
ILT
202 if test "`basename -- $f`" = ".gitignore"; then
203 continue
204 fi
205 oldfile=${oldtd}/$f
206 if ! test -f ${oldfile}; then
207 name=$d/$f
208 newfile=${newtd}/$f
209 libgofile=${libgotd}/$f
210 merge ${name} ${oldfile} ${newfile} ${libgofile}
211 fi
212 done
7a938933
ILT
213done
214
93661575
ILT
215(cd ${NEWDIR}/misc/cgo && find . -type f -print) | while read f; do
216 oldfile=${OLDDIR}/misc/cgo/$f
217 newfile=${NEWDIR}/misc/cgo/$f
218 libgofile=misc/cgo/$f
219 merge $f ${oldfile} ${newfile} ${libgofile}
220done
221
f8d9fa9e
ILT
222(cd ${OLDDIR}/src && find . -name '*.go' -print) | while read f; do
223 oldfile=${OLDDIR}/src/$f
224 newfile=${NEWDIR}/src/$f
7a938933
ILT
225 libgofile=go/$f
226 if test -f ${newfile}; then
227 continue
228 fi
229 if ! test -f ${libgofile}; then
230 continue
231 fi
232 echo "merge.sh: ${libgofile}: REMOVED"
233 rm -f ${libgofile}
7a938933
ILT
234done
235
93661575
ILT
236(cd ${OLDDIR}/misc/cgo && find . -type f -print) | while read f; do
237 oldfile=${OLDDIR}/misc/cgo/$f
238 newfile=${NEWDIR}/misc/cgo/$f
239 libgofile=misc/cgo/$f
240 if test -f ${newfile}; then
241 continue
242 fi
243 if ! test -f ${libgofile}; then
244 continue
245 fi
246 echo "merge.sh: ${libgofile}: REMOVED"
247 rm -f ${libgofile}
93661575
ILT
248done
249
7a938933
ILT
250(echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
251mv MERGE.tmp MERGE