projects: make sure HEAD is a valid symref
commita036cd633ba29d203d85c775a409987bb980aad2
authorKyle J. McKay <mackyle@gmail.com>
Wed, 31 Aug 2016 04:43:06 +0000 (30 21:43 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Wed, 31 Aug 2016 04:43:06 +0000 (30 21:43 -0700)
tree9f156f44b7f332f491a255483efcbdcac47b37fb
parent8bdd60191bf2c8e8f037c3c42eaf0031e614fc2e
projects: make sure HEAD is a valid symref

The web UI will only allow HEAD to be set to a symref to an existing
refs/heads/* ref (or, if there are none of those present,
refs/heads/master).

However, if any initial clone fails to set a HEAD symref (clone.sh tries
very hard to get it right, but if the source is empty or not from a git
source it might not initially succeed), we need to try again to set a
valid HEAD until we get one.

The same for a push project.  Initially they are empty with HEAD set to
refs/heads/master, but if the only content ever pushed is to other heads
and the web UI is never used to set a valid HEAD then we need to try to
set a valid HEAD ourselves.

Once a valid HEAD has been set we will stop trying to set one even if
that HEAD is later deleted.  At that point it's no longer our
responsibility to make sure HEAD is valid, the project owner should
handle it at that point.

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