shlib.sh: transform has_forks into has_forks_with_alternates
commitd2e1d778af3196f1037575c7f5ffc392c7603d07
authorKyle J. McKay <mackyle@gmail.com>
Wed, 13 Dec 2017 08:14:01 +0000 (13 00:14 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Wed, 13 Dec 2017 08:14:01 +0000 (13 00:14 -0800)
tree580f715830afbf71bc057ce36db69bfcd71e99a1
parent6429b1b152586fff32fd812fb756fbc10b891327
shlib.sh: transform has_forks into has_forks_with_alternates

When using the shlib.sh has_forks function to check and see if a
project "has_forks", the end purpose involves deciding whether or
not to do extra work to make sure any forks referring to the project
via an alternates file are not corrupted,

There's no absolute requirement for forks to have a reference to
their parent's objects in their alternates file.  And forks that
do not have a reference need no special handling or consideration
when operating on the "parent" project.

Therefore replace the "has_forks" function with a different but
similar "has_forks_with_alternates" function instead and update
client code to use it.

The new function only returns true (a 0 return status) when at least
one of the immediate child forks has a non-zero length alternates
file.

This is a better result for the purposes of avoiding unnecessary
work.  It could do better by actually examining the alternates file
contents to see if there's an entry pointing to the project in
question.  That seems like overkill and a lot of work and then we
would need a new function name something like:

  has_forks_with_alternates_pointing_to_us

In the normal case, has_forks_with_alternates will end up doing
only one additional check on the first fork's alternates file (which
will normally be non-empty) and then returning an answer.

That would seem to make it worthwhile since it will help to avoid
extra work for projects with only "logical" forks (forks that are
logically related but the administrator has created with no alternates
or since removed the alternates file).  That extra work costs far
more to do than simply the one additional check.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/gc.sh
shlib.sh
toolbox/perform-pre-gc-linking.sh