Skip to content

Commit da2772a

Browse files
committed
git-synchronizer: make it work on MacOSX, too
MacOSX' sed does not understand \t... We cannot use "case ... $key) ... esac" if inside a "$(...)" clause because MacOSX' shell gets hopelessly confused by the closing parenthesis in the case block. Also, the 1970s called MacOSX that they want their uniq back that does not even understand the -D option (show all duplicate lines; useful if some fields are skipped when testing for uniqueness). As of time of writing, MacOSX has not responded yet. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent cee8c5b commit da2772a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

git-synchronizer.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ get_remote_branches () {
5353
name="$1"
5454

5555
git for-each-ref refs/remotes/$name/\* |
56-
sed "s|\trefs/remotes/$name/|\t|"
56+
sed "s| refs/remotes/$name/| |"
5757
}
5858

5959
fetch_from () {
@@ -148,7 +148,7 @@ do
148148
has_spaces $url && continue
149149
name=$(url2remotename $url)
150150
git for-each-ref refs/remotes/$name/\* |
151-
sed "s|^\(.*\)\trefs/remotes/\($name\)/|\2 \1 |"
151+
sed "s|^\(.*\) refs/remotes/\($name\)/|\2 \1 |"
152152
done)"
153153

154154
for ref in $(echo "$remote_branches" |
@@ -210,15 +210,24 @@ do
210210
uniq)"
211211
done
212212

213-
disagreeing="$(echo "$todo" |
214-
sort -k 3 |
215-
uniq -D -f 2)"
213+
disagreeing=$(echo "$todo" |
214+
cut -f 2 |
215+
sort |
216+
uniq -d)
216217

217218
if test -n "$disagreeing"
218219
then
219-
add_error "$(printf "Incompatible updates:\n%s\n\n" "$disagreeing")"
220+
message="$(for name in $disagreeing
221+
do
222+
echo "$todo" | grep " $name$"
223+
done)"
224+
add_error "$(printf "Incompatible updates:\n%s\n\n" "$message")"
220225
fi
221226

227+
# make it easier to test whether a name is in $disagreeing via:
228+
# test "$disagreeing" != "${disagreeing#* $name }"
229+
disagreeing=" $disagreeing "
230+
222231
# Push
223232

224233
test -z "$todo" ||
@@ -231,10 +240,7 @@ do
231240
while read sha1 type ref
232241
do
233242
test -z "$sha1" && continue
234-
if echo "$disagreeing" | grep " $ref$" > /dev/null 2>&1
235-
then
236-
continue
237-
fi
243+
test "$disagreeing" = "${disagreeing#* $name }" || continue
238244
remoteref=refs/remotes/$name/$ref
239245
if test $sha1 = $nullsha1
240246
then

0 commit comments

Comments
 (0)