]> source.dussan.org Git - jgit.git/commitdiff
UploadPack: Rely on peeled ref data for include-tag 49/2449/2
authorShawn O. Pearce <spearce@spearce.org>
Tue, 8 Feb 2011 00:46:06 +0000 (16:46 -0800)
committerChris Aniszczyk <caniszczyk@gmail.com>
Sun, 13 Feb 2011 21:32:23 +0000 (15:32 -0600)
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>
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 175ddbcba2884c49bf8ed84a20cda97672722f87..5133f5cde9a629240889c063cd02d8d25de59ebc 100644 (file)
@@ -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));
                                }
                        }