gc.sh: avoid unlikely ref name repack duplication
commit0a460383bc4ee6894c000aba22ed5de1cef1ba9f
authorKyle J. McKay <mackyle@gmail.com>
Sat, 30 Dec 2017 14:12:26 +0000 (30 06:12 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Sat, 30 Dec 2017 14:12:26 +0000 (30 06:12 -0800)
tree1183e0ad6d94f495317de275cf0ab1daba8fd2a8
parentfcfa7f3b842802602ed884997fc3135267ec700d
gc.sh: avoid unlikely ref name repack duplication

When repacking during gc, a substitute packed-refs file gets created
to make sure that everything that needs to, ends up getting packed
properly.

However, in order to avoid breaking internal symbolic refs the
original heads, notes and remotes refs namespace gets duplicated
exactly in the substitute packed-refs file with one exception.

A special additional heads ref gets added just to make sure there's
always at least one "heads" ref present.

While it's very unlikely that the name used for the additional heads
ref would be used in practice, it could happen and that would result
in two lines for the same ref name but with different values for
the hash.  Git might perhaps object strongly to that.  Let's not
find out.

Instead suppress the duplicate (from the original ref space) just
in case such a scenario ever occurs.  The actual original ref value
appears elsewhere under a separate partition of the substitute
packed-refs refs namespace so there's no danger of losing any
objects.  As for it being the target of an internal symbolic ref,
only the presence of the target is important to avoid breakage, not
the actual value, which works out quite well in this case.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/gc.sh