[EGIT PATCH 2/6] Peel annotated tags when getting all refs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For packed refs we got this automatically from packed-refs,
but for loose tags we have to follow the tags and get the leaf
object in order to comply with the documentation.

Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/RefDatabase.java      |   24 ++++++++++++++++++-
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
index 5a1b85f..1ee70d9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java
@@ -271,7 +271,16 @@ private void readOneLooseRef(final Map<String, Ref> avail,
 					return;
 				}
 
-				ref = new Ref(Ref.Storage.LOOSE, origName, refName, id);
+				Object tt = db.mapObject(id, refName);
+				if (tt != null && tt instanceof Tag) {
+					Tag t = (Tag)tt;
+					while (t != null && t.getType().equals(Constants.TYPE_TAG))
+						t = db.mapTag(t.getTag(), t.getObjId());
+					if (t != null)
+						ref = new Ref(Ref.Storage.LOOSE, origName, refName, id, t.getObjId());
+				} else
+					ref = new Ref(Ref.Storage.LOOSE, origName, refName, id);
+
 				looseRefs.put(ref.getName(), ref);
 				looseRefsMTime.put(ref.getName(), ent.lastModified());
 				avail.put(ref.getName(), ref);
@@ -363,7 +372,18 @@ private Ref readRefBasic(final String origName, final String name, final int dep
 			throw new IOException("Not a ref: " + name + ": " + line);
 		}
 
-		ref = new Ref(Ref.Storage.LOOSE, origName, name, id);
+		Object tt = db.mapObject(id, origName);
+		if (tt != null && tt instanceof Tag) {
+			Tag t = (Tag)tt;
+			while (t != null && t.getType().equals(Constants.TYPE_TAG))
+				t = db.mapTag(t.getTag(), t.getObjId());
+			if (t != null)
+				ref = new Ref(Ref.Storage.LOOSE, origName, name, id, t.getObjId());
+		} else
+			ref = new Ref(Ref.Storage.LOOSE, origName, name, id);
+
+		looseRefs.put(origName, ref);
+		ref = new Ref(Ref.Storage.LOOSE, origName, id);
 		looseRefs.put(name, ref);
 		looseRefsMTime.put(name, mtime);
 		return ref;
-- 
1.6.0.1.310.gf789d0.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux