Browse Source

UploadPack: Rely on peeled ref data for include-tag

The peeled reference information for tags is more efficient to
work with than parsing the tag objects, as usually its coming from
the packed-refs file, which stores the peeled information for us.
Rely on the peeled information to decide if the tag should be
included or not, instead of using our RevWalk to parse the object.

Change-Id: I6714a8560a1c04b5578e9c5b469ea3c77188dff3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.12
Shawn O. Pearce 14 years ago committed by Chris Aniszczyk
parent
commit
3271bcee2b
  1. 31
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

31
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.setThin(options.contains(OPTION_THIN_PACK));
pw.preparePack(pm, want, commonBase); pw.preparePack(pm, want, commonBase);
if (options.contains(OPTION_INCLUDE_TAG)) { if (options.contains(OPTION_INCLUDE_TAG)) {
for (final Ref r : refs.values()) { for (Ref ref : refs.values()) {
final RevObject o; ObjectId objectId = ref.getObjectId();
try {
o = walk.parseAny(r.getObjectId()); // If the object was already requested, skip it.
} catch (IOException e) { if (wantAll.isEmpty()) {
continue; 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; continue;
final RevTag t = (RevTag) o;
if (!pw.willInclude(t) && pw.willInclude(t.getObject())) objectId = ref.getObjectId();
pw.addObject(t); if (pw.willInclude(peeledId) && !pw.willInclude(objectId))
pw.addObject(walk.parseAny(objectId));
} }
} }

Loading…
Cancel
Save