From a78b79cc30eb94800cc4dc8d26fa1fe32d8d0415 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 4 Mar 2011 07:14:50 -0800 Subject: [PATCH] Don't auto follow non-annotated tags in fetch When fetch TagOpt is AUTO_FOLLOW do not follow refs/tags/ names that point directly to commits which are on unreleated side branches. Change-Id: Iea6eee5a05ae7402a7f256fd9c1e3d3b5ccb58dd Reported-by: Slawomir Ginter Signed-off-by: Shawn O. Pearce --- .../eclipse/jgit/transport/FetchProcess.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java index db08b0608..17c2d5f86 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java @@ -164,8 +164,10 @@ else if (tagopt == TagOpt.FETCH_TAGS) have.addAll(askFor.keySet()); askFor.clear(); for (final Ref r : additionalTags) { - final ObjectId id = r.getPeeledObjectId(); - if (id == null || transport.local.hasObject(id)) + ObjectId id = r.getPeeledObjectId(); + if (id == null) + id = r.getObjectId(); + if (transport.local.hasObject(id)) wantTag(r); } @@ -347,14 +349,22 @@ private Collection expandAutoFollowTags() throws TransportException { for (final Ref r : conn.getRefs()) { if (!isTag(r)) continue; + + Ref local = haveRefs.get(r.getName()); + ObjectId obj = r.getObjectId(); + if (r.getPeeledObjectId() == null) { - additionalTags.add(r); + if (local != null && obj.equals(local.getObjectId())) + continue; + if (askFor.containsKey(obj) || transport.local.hasObject(obj)) + wantTag(r); + else + additionalTags.add(r); continue; } - final Ref local = haveRefs.get(r.getName()); if (local != null) { - if (!r.getObjectId().equals(local.getObjectId())) + if (!obj.equals(local.getObjectId())) wantTag(r); } else if (askFor.containsKey(r.getPeeledObjectId()) || transport.local.hasObject(r.getPeeledObjectId()))