lördag 11 juli 2009 22:19:20 skrev "Shawn O. Pearce" <spearce@xxxxxxxxxxx>: > The HEAD ref cannot be pushed to by a client, if it is a detached HEAD > the client shouldn't be permitted to change it, if it is a symref to > another ref then the client should update the destination ref and not > the symref. Instead offer the HEAD ref as a ".have" line, which is an > invalid ref that the client can't update but still lets the client know > we have its target object reachable. > > Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> > --- > .../org/spearce/jgit/transport/ReceivePack.java | 5 ++++- > .../org/spearce/jgit/transport/RefAdvertiser.java | 15 +++++++++++++++ > 2 files changed, 19 insertions(+), 1 deletions(-) > > diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java > index fd8aa86..1c490af 100644 > --- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java > +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java > @@ -509,8 +509,11 @@ private void sendAdvertisedRefs() throws IOException { > adv.advertiseCapability(CAPABILITY_REPORT_STATUS); > if (allowOfsDelta) > adv.advertiseCapability(CAPABILITY_OFS_DELTA); > - refs = db.getAllRefs(); > + refs = new HashMap<String, Ref>(db.getAllRefs()); > + final Ref head = refs.remove(Constants.HEAD); > adv.send(refs.values()); > + if (head != null && head.getName() == head.getOrigName()) > + adv.advertiseHave(head.getObjectId()); This relies on an implicit guarantee that == works here. Would equals cost too much? Or perhaps we should document this guarantee as part of the interface. -- robin -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html