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>
This commit is contained in:
Shawn O. Pearce 2011-02-07 16:46:06 -08:00 committed by Chris Aniszczyk
parent f9c9fe5226
commit 3271bcee2b
1 changed files with 21 additions and 10 deletions

View File

@ -670,18 +670,29 @@ private void sendPack() throws IOException {
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));
}
}