[RS6000] Don't expand strcmp and strncmp inline when -Os
[official-gcc.git] / libgo / merge.sh
blob8a92a2ecd4d0dd6b323fedc37d4f0b7f08304f07
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 -f ${new}; then
58 # The file does not exist in the new version.
59 if ! test -f ${old}; then
60 echo 1>&2 "merge.sh internal error no files $old $new"
61 exit 1
63 if ! test -f ${libgo}; then
64 # File removed in new version and libgo.
66 else
67 echo "merge.sh: ${name}: REMOVED"
68 rm -f ${libgo}
69 git rm ${libgo}
71 elif test -f ${old}; then
72 # The file exists in the old version.
73 if ! test -f ${libgo}; then
74 echo "merge.sh: $name: skipping: exists in old and new git, but not in libgo"
75 continue
77 if cmp -s ${old} ${libgo}; then
78 # The libgo file is unchanged from the old version.
79 if cmp -s ${new} ${libgo}; then
80 # File is unchanged from old to new version.
81 continue
83 # Update file in libgo.
84 echo "merge.sh: $name: updating"
85 cp ${new} ${libgo}
86 else
87 # The libgo file has local changes.
88 set +e
89 diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
90 status=$?
91 set -e
92 case $status in
94 echo "merge.sh: $name: updating"
95 mv ${libgo}.tmp ${libgo}
98 echo "merge.sh: $name: CONFLICTS"
99 mv ${libgo}.tmp ${libgo}
102 echo 1>&2 "merge.sh: $name: DIFF3 FAILURE"
104 esac
106 else
107 # The file does not exist in the old version.
108 if test -f ${libgo}; then
109 if ! cmp -s ${new} ${libgo}; then
110 echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
112 else
113 echo "merge.sh: $name: NEW"
114 dir=`dirname ${libgo}`
115 if ! test -d ${dir}; then
116 mkdir -p ${dir}
118 cp ${new} ${libgo}
119 git add ${libgo}
124 echo ${rev} > VERSION
126 (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
127 skip=false
128 case "$f" in
129 ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/internal/browser/*)
131 ./cmd/*)
132 skip=true
134 ./runtime/race/*)
135 skip=true
137 esac
138 if test "$skip" = "true"; then
139 continue
142 oldfile=${OLDDIR}/src/$f
143 newfile=${NEWDIR}/src/$f
144 libgofile=go/`echo $f | sed -e 's|/vendor/|/|'`
145 merge $f ${oldfile} ${newfile} ${libgofile}
146 done
148 (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
149 skip=false
150 case "$f" in
151 ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/internal/browser/*)
153 ./cmd/*)
154 skip=true
156 ./runtime/race/*)
157 skip=true
159 esac
160 if test "$skip" = "true"; then
161 continue
164 oldtd=${OLDDIR}/src/$d
165 newtd=${NEWDIR}/src/$d
166 libgotd=go/$d
167 if ! test -d ${oldtd}; then
168 echo "merge.sh: $d: NEWDIR"
169 continue
171 (cd ${oldtd} && git ls-files .) | while read f; do
172 if test "`basename $f`" = ".gitignore"; then
173 continue
175 name=$d/$f
176 oldfile=${oldtd}/$f
177 newfile=${newtd}/$f
178 libgofile=${libgotd}/$f
179 merge ${name} ${oldfile} ${newfile} ${libgofile}
180 done
181 done
183 (cd ${OLDDIR}/src && find . -name '*.go' -print) | while read f; do
184 oldfile=${OLDDIR}/src/$f
185 newfile=${NEWDIR}/src/$f
186 libgofile=go/$f
187 if test -f ${newfile}; then
188 continue
190 if ! test -f ${libgofile}; then
191 continue
193 echo "merge.sh: ${libgofile}: REMOVED"
194 rm -f ${libgofile}
195 git rm ${libgofile}
196 done
198 (echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
199 mv MERGE.tmp MERGE