]> source.dussan.org Git - jgit.git/commitdiff
Fix server side NPE during push to empty repository 52/252/1
authorShawn O. Pearce <spearce@spearce.org>
Mon, 1 Feb 2010 08:51:28 +0000 (00:51 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 1 Feb 2010 08:52:23 +0000 (00:52 -0800)
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>
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

index 15bdf9618f982c3bc6805b9b0fcd67309c19f3b6..35c52bdfe20c79437d68943b7861f933d798346b 100644 (file)
@@ -592,7 +592,7 @@ public class ReceivePack {
                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())