Fix server side NPE during push to empty repository

If the repository is empty, we have no HEAD branch, which means we
can't test to see if the HEAD is detached and should be advertised
as a .have line.

Change-Id: I6e85f836e7db057cede812d0d6c1aecbd6cbe6c5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-02-01 00:51:28 -08:00
parent 8c2d0455d1
commit efa8b52df5
1 changed files with 1 additions and 1 deletions

View File

@ -592,7 +592,7 @@ public void sendAdvertisedRefs(final RefAdvertiser adv) throws IOException {
refs = db.getAllRefs();
final Ref head = refs.remove(Constants.HEAD);
adv.send(refs);
if (!head.isSymbolic())
if (head != null && !head.isSymbolic())
adv.advertiseHave(head.getObjectId());
adv.includeAdditionalHaves();
if (adv.isEmpty())