update.sh: pre-compute list of changed refs before nc_openbsd
For some repositories with many refs (some might consider that many
refs an abuse of Git -- I'm looking at YOU Gerrit), the process of
joining the before refs and after refs files and reading all the
results (even though many lines may show no ref change) can actually
take several seconds to complete.
With the recent change to send the refs to taskd.pl all in one go
using one "ref-changes" message instead of individual "ref-change"
messages, it's possible for the join + read delay to exceed the
timeout given to nc_openbsd resulting in a prematurely closed
connection and failure to send out those ref updates.
Instead of arbitrarily increasing the timeout delay (which will only
stave off the problem until an even more abusive repository comes
along), pre-compute the change list before opening the connection
to the socket.
Additionally, use sed to filter out the unchanged refs (which it can
do substantially faster than the shell script) to further decrease
the processing time.
Also switch the refs files delimiter from tab to space to make the
files easier to deal with since a literal tab is awkward and not
obvious in the quoted strings used with git and sed.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>