diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 175ddbcba..5133f5cde 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -670,18 +670,29 @@ public class UploadPack { pw.setThin(options.contains(OPTION_THIN_PACK)); pw.preparePack(pm, want, commonBase); if (options.contains(OPTION_INCLUDE_TAG)) { - for (final Ref r : refs.values()) { - final RevObject o; - try { - o = walk.parseAny(r.getObjectId()); - } catch (IOException e) { - continue; + for (Ref ref : refs.values()) { + ObjectId objectId = ref.getObjectId(); + + // If the object was already requested, skip it. + if (wantAll.isEmpty()) { + if (wantIds.contains(objectId)) + continue; + } else { + RevObject obj = walk.lookupOrNull(objectId); + if (obj != null && obj.has(WANT)) + continue; } - if (o.has(WANT) || !(o instanceof RevTag)) + + if (!ref.isPeeled()) + ref = db.peel(ref); + + ObjectId peeledId = ref.getPeeledObjectId(); + if (peeledId == null) continue; - final RevTag t = (RevTag) o; - if (!pw.willInclude(t) && pw.willInclude(t.getObject())) - pw.addObject(t); + + objectId = ref.getObjectId(); + if (pw.willInclude(peeledId) && !pw.willInclude(objectId)) + pw.addObject(walk.parseAny(objectId)); } }