]> source.dussan.org Git - gitblit.git/commitdiff
GitNotes. Unit testing. More correct refs.
authorJames Moger <james.moger@gitblit.com>
Fri, 3 Jun 2011 21:44:19 +0000 (17:44 -0400)
committerJames Moger <james.moger@gitblit.com>
Fri, 3 Jun 2011 21:44:19 +0000 (17:44 -0400)
23 files changed:
src/com/gitblit/models/RefModel.java
src/com/gitblit/utils/JGitUtils.java
src/com/gitblit/utils/MetricUtils.java
src/com/gitblit/utils/TicgitUtils.java
src/com/gitblit/wicket/GitBlitWebApp.properties
src/com/gitblit/wicket/pages/BlobPage.java
src/com/gitblit/wicket/pages/CommitPage.html
src/com/gitblit/wicket/pages/CommitPage.java
src/com/gitblit/wicket/pages/MarkdownPage.java
src/com/gitblit/wicket/pages/RawPage.java
src/com/gitblit/wicket/pages/SummaryPage.java
src/com/gitblit/wicket/pages/TagPage.html
src/com/gitblit/wicket/pages/TagPage.java
src/com/gitblit/wicket/panels/CommitHeaderPanel.java
src/com/gitblit/wicket/panels/HistoryPanel.java
src/com/gitblit/wicket/panels/LogPanel.java
src/com/gitblit/wicket/panels/RefsPanel.java
src/com/gitblit/wicket/panels/SearchPanel.java
src/com/gitblit/wicket/panels/TagsPanel.html
src/com/gitblit/wicket/panels/TagsPanel.java
src/com/gitblit/wicket/resources/gitblit.css
tests/com/gitblit/tests/GitBlitSuite.java
tests/com/gitblit/tests/JGitUtilsTest.java

index b33c8ba76501d908a350660586265d397e44b928..39bf19c94faf74cd8cb82529acd381755e69609b 100644 (file)
@@ -19,50 +19,99 @@ import java.io.Serializable;
 import java.util.Date;\r
 \r
 import org.eclipse.jgit.lib.ObjectId;\r
+import org.eclipse.jgit.lib.PersonIdent;\r
 import org.eclipse.jgit.lib.Ref;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
+import org.eclipse.jgit.revwalk.RevObject;\r
+import org.eclipse.jgit.revwalk.RevTag;\r
 \r
 public class RefModel implements Serializable, Comparable<RefModel> {\r
 \r
        private static final long serialVersionUID = 1L;\r
        public final String displayName;\r
-       public final RevCommit commit;\r
-       public transient Ref ref;\r
+       public final RevObject referencedObject;\r
+       public transient Ref reference;\r
 \r
-       public RefModel(String displayName, Ref ref, RevCommit commit) {\r
+       public RefModel(String displayName, Ref ref, RevObject refObject) {\r
                this.displayName = displayName;\r
-               this.ref = ref;\r
-               this.commit = commit;\r
+               this.reference = ref;\r
+               this.referencedObject = refObject;\r
        }\r
 \r
        public Date getDate() {\r
-               return new Date(commit.getCommitTime() * 1000L);\r
+               Date date = new Date(0);\r
+               if (referencedObject != null) {\r
+                       if (referencedObject instanceof RevTag) {\r
+                               date = ((RevTag) referencedObject).getTaggerIdent().getWhen();\r
+                       } else if (referencedObject instanceof RevCommit) {\r
+                               date = ((RevCommit) referencedObject).getCommitterIdent().getWhen();\r
+                       }\r
+               }\r
+               return date;\r
        }\r
 \r
        public String getName() {\r
-               return ref.getName();\r
+               return reference.getName();\r
        }\r
 \r
-       public ObjectId getCommitId() {\r
-               return commit.getId();\r
+       public int getReferencedObjectType() {\r
+               int type = referencedObject.getType();\r
+               if (referencedObject instanceof RevTag) {\r
+                       type = ((RevTag) referencedObject).getObject().getType();\r
+               }\r
+               return type;\r
        }\r
 \r
-       public String getShortLog() {\r
-               return commit.getShortMessage();\r
+       public ObjectId getReferencedObjectId() {\r
+               if (referencedObject instanceof RevTag) {\r
+                       return ((RevTag) referencedObject).getObject().getId();\r
+               }\r
+               return referencedObject.getId();\r
+       }\r
+\r
+       public String getShortMessage() {\r
+               String message = "";\r
+               if (referencedObject instanceof RevTag) {\r
+                       message = ((RevTag) referencedObject).getShortMessage();\r
+               } else if (referencedObject instanceof RevCommit) {\r
+                       message = ((RevCommit) referencedObject).getShortMessage();\r
+               }\r
+               return message;\r
+       }\r
+\r
+       public String getFullMessage() {\r
+               String message = "";\r
+               if (referencedObject instanceof RevTag) {\r
+                       message = ((RevTag) referencedObject).getFullMessage();\r
+               } else if (referencedObject instanceof RevCommit) {\r
+                       message = ((RevCommit) referencedObject).getFullMessage();\r
+               }\r
+               return message;\r
+       }\r
+\r
+       public PersonIdent getAuthorIdent() {\r
+               if (referencedObject instanceof RevTag) {\r
+                       return ((RevTag) referencedObject).getTaggerIdent();\r
+               } else if (referencedObject instanceof RevCommit) {\r
+                       return ((RevCommit) referencedObject).getAuthorIdent();\r
+               }\r
+               return null;\r
        }\r
 \r
        public ObjectId getObjectId() {\r
-               return ref.getObjectId();\r
+               return reference.getObjectId();\r
        }\r
 \r
        public boolean isAnnotatedTag() {\r
-               // ref.isPeeled() ??\r
-               return !getCommitId().equals(getObjectId());\r
+               if (referencedObject instanceof RevTag) {\r
+                       return !getReferencedObjectId().equals(getObjectId());\r
+               }\r
+               return reference.getPeeledObjectId() != null;\r
        }\r
 \r
        @Override\r
        public int hashCode() {\r
-               return getCommitId().hashCode() + getName().hashCode();\r
+               return getReferencedObjectId().hashCode() + getName().hashCode();\r
        }\r
 \r
        @Override\r
index fd2eaf36bb4247d2f0c8a536ee241b1cb21ce051..2590a30005c5390263473a7e3c209425977f073c 100644 (file)
@@ -29,7 +29,6 @@ import java.util.HashMap;
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.Map.Entry;\r
-import java.util.Set;\r
 import java.util.zip.ZipEntry;\r
 import java.util.zip.ZipOutputStream;\r
 \r
@@ -42,7 +41,6 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;\r
 import org.eclipse.jgit.errors.MissingObjectException;\r
 import org.eclipse.jgit.errors.StopWalkException;\r
-import org.eclipse.jgit.lib.AnyObjectId;\r
 import org.eclipse.jgit.lib.Constants;\r
 import org.eclipse.jgit.lib.FileMode;\r
 import org.eclipse.jgit.lib.ObjectId;\r
@@ -212,41 +210,31 @@ public class JGitUtils {
                return commit;\r
        }\r
 \r
-       public static Map<ObjectId, List<String>> getAllRefs(Repository r) {\r
-               Map<ObjectId, List<String>> refs = new HashMap<ObjectId, List<String>>();\r
-               Map<AnyObjectId, Set<Ref>> allRefs = r.getAllRefsByPeeledObjectId();\r
-               for (Entry<AnyObjectId, Set<Ref>> setRefs : allRefs.entrySet()) {\r
-                       List<String> list = new ArrayList<String>();\r
-                       for (Ref setRef : setRefs.getValue()) {\r
-                               String name = setRef.getName();\r
-                               list.add(name);\r
+       public static Map<ObjectId, List<RefModel>> getAllRefs(Repository r) {\r
+               List<RefModel> list = getRefs(r, org.eclipse.jgit.lib.RefDatabase.ALL, -1);\r
+               Map<ObjectId, List<RefModel>> refs = new HashMap<ObjectId, List<RefModel>>();\r
+               for (RefModel ref : list) {\r
+                       ObjectId objectid = ref.getReferencedObjectId();\r
+                       if (!refs.containsKey(objectid)) {\r
+                               refs.put(objectid, new ArrayList<RefModel>());\r
                        }\r
-                       refs.put(setRefs.getKey().toObjectId(), list);\r
-               }\r
+                       refs.get(objectid).add(ref);\r
+               }               \r
                return refs;\r
        }\r
 \r
-       /**\r
-        * Lookup an entry stored in a tree, failing if not present.\r
-        * \r
-        * @param tree\r
-        *            the tree to search.\r
-        * @param path\r
-        *            the path to find the entry of.\r
-        * @return the parsed object entry at this path\r
-        * @throws Exception\r
-        */\r
-       public static byte[] getRawContent(Repository r, RevCommit commit, final String path) {\r
+       public static byte[] getByteContent(Repository r, RevTree tree, final String path) {\r
                RevWalk rw = new RevWalk(r);\r
                TreeWalk tw = new TreeWalk(r);\r
                tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));\r
                byte[] content = null;\r
                try {\r
-                       if (commit == null) {\r
+                       if (tree == null) {\r
                                ObjectId object = r.resolve(Constants.HEAD);\r
-                               commit = rw.parseCommit(object);\r
+                               RevCommit commit = rw.parseCommit(object);\r
+                               tree = commit.getTree();\r
                        }\r
-                       tw.reset(commit.getTree());\r
+                       tw.reset(tree);\r
                        while (tw.next()) {\r
                                if (tw.isSubtree() && !path.equals(tw.getPathString())) {\r
                                        tw.enterSubtree();\r
@@ -268,7 +256,7 @@ public class JGitUtils {
                                content = os.toByteArray();\r
                        }\r
                } catch (Throwable t) {\r
-                       LOGGER.error("Can't find " + path + " in tree " + commit.getTree().name(), t);\r
+                       LOGGER.error("Can't find " + path + " in tree " + tree.name(), t);\r
                } finally {\r
                        rw.dispose();\r
                        tw.release();\r
@@ -276,8 +264,40 @@ public class JGitUtils {
                return content;\r
        }\r
 \r
-       public static String getRawContentAsString(Repository r, RevCommit commit, String blobPath) {\r
-               byte[] content = getRawContent(r, commit, blobPath);\r
+       public static String getStringContent(Repository r, RevTree tree, String blobPath) {\r
+               byte[] content = getByteContent(r, tree, blobPath);\r
+               if (content == null) {\r
+                       return null;\r
+               }\r
+               return new String(content, Charset.forName(Constants.CHARACTER_ENCODING));\r
+       }\r
+\r
+       public static byte[] getByteContent(Repository r, String objectId) {\r
+               RevWalk rw = new RevWalk(r);\r
+               byte[] content = null;\r
+               try {\r
+                       RevBlob blob = rw.lookupBlob(ObjectId.fromString(objectId));\r
+                       rw.parseBody(blob);\r
+                       ByteArrayOutputStream os = new ByteArrayOutputStream();\r
+                       ObjectLoader ldr = r.open(blob.getId(), Constants.OBJ_BLOB);\r
+                       byte[] tmp = new byte[4096];\r
+                       InputStream in = ldr.openStream();\r
+                       int n;\r
+                       while ((n = in.read(tmp)) > 0) {\r
+                               os.write(tmp, 0, n);\r
+                       }\r
+                       in.close();\r
+                       content = os.toByteArray();\r
+               } catch (Throwable t) {\r
+                       LOGGER.error("Can't find blob " + objectId, t);\r
+               } finally {\r
+                       rw.dispose();\r
+               }\r
+               return content;\r
+       }\r
+\r
+       public static String getStringContent(Repository r, String objectId) {\r
+               byte[] content = getByteContent(r, objectId);\r
                if (content == null) {\r
                        return null;\r
                }\r
@@ -605,7 +625,7 @@ public class JGitUtils {
                return getRefs(r, Constants.R_REMOTES, maxCount);\r
        }\r
 \r
-       public static List<RefModel> getNotes(Repository r, int maxCount) {\r
+       public static List<RefModel> getNotesRefs(Repository r, int maxCount) {\r
                return getRefs(r, Constants.R_NOTES, maxCount);\r
        }\r
 \r
@@ -613,11 +633,13 @@ public class JGitUtils {
                List<RefModel> list = new ArrayList<RefModel>();\r
                try {\r
                        Map<String, Ref> map = r.getRefDatabase().getRefs(refs);\r
+                       RevWalk rw = new RevWalk(r);\r
                        for (Entry<String, Ref> entry : map.entrySet()) {\r
                                Ref ref = entry.getValue();\r
-                               RevCommit commit = getCommit(r, ref.getObjectId().getName());\r
-                               list.add(new RefModel(entry.getKey(), ref, commit));\r
+                               RevObject object = rw.parseAny(ref.getObjectId());\r
+                               list.add(new RefModel(entry.getKey(), ref, object));\r
                        }\r
+                       rw.dispose();\r
                        Collections.sort(list);\r
                        Collections.reverse(list);\r
                        if (maxCount > 0 && list.size() > maxCount) {\r
@@ -631,14 +653,18 @@ public class JGitUtils {
 \r
        public static List<GitNote> getNotesOnCommit(Repository repository, RevCommit commit) {\r
                List<GitNote> list = new ArrayList<GitNote>();\r
-               List<RefModel> notesRefs = getNotes(repository, -1);\r
+               List<RefModel> notesRefs = getNotesRefs(repository, -1);\r
                for (RefModel notesRef : notesRefs) {\r
-                       RevCommit notes = JGitUtils.getCommit(repository, notesRef.getName());\r
+                       RevTree notesTree = JGitUtils.getCommit(repository, notesRef.getName()).getTree();\r
                        StringBuilder sb = new StringBuilder(commit.getName());\r
                        sb.insert(2, '/');\r
-                       String text = getRawContentAsString(repository, notes, sb.toString());\r
+                       String notePath = sb.toString();\r
+                       String text = getStringContent(repository, notesTree, notePath);\r
                        if (!StringUtils.isEmpty(text)) {\r
-                               GitNote gitNote = new GitNote(notesRef, text);\r
+                               List<RevCommit> history = getRevLog(repository, notesRef.getName(), notePath, 0, -1);\r
+                               RefModel noteRef = new RefModel(notesRef.displayName, null, history.get(history\r
+                                               .size() - 1));\r
+                               GitNote gitNote = new GitNote(noteRef, text);\r
                                list.add(gitNote);\r
                        }\r
                }\r
index 4ca9f36a0ad46025d22fa25429852cf8e96783f2..d963bf58fe577fedc8edc8fd7ad0c53e4765bccb 100644 (file)
@@ -47,7 +47,7 @@ public class MetricUtils {
                        final List<RefModel> tags = JGitUtils.getTags(r, -1);\r
                        final Map<ObjectId, RefModel> tagMap = new HashMap<ObjectId, RefModel>();\r
                        for (RefModel tag : tags) {\r
-                               tagMap.put(tag.getCommitId(), tag);\r
+                               tagMap.put(tag.getReferencedObjectId(), tag);\r
                        }\r
                        try {\r
                                RevWalk walk = new RevWalk(r);\r
index 576de3496ae45d8a54413b2fbb30f21ce26388a1..8224d1cb4518cd4516d33cd0ff1d90b9c7f5a7c4 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Collections;
 import java.util.List;\r
 \r
 import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.revwalk.RevCommit;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -64,7 +65,8 @@ public class TicgitUtils {
                if (ticgitBranch == null) {\r
                        return null;\r
                }\r
-               List<PathModel> paths = JGitUtils.getFilesInPath(r, null, ticgitBranch.commit);\r
+               RevCommit commit = (RevCommit) ticgitBranch.referencedObject;\r
+               List<PathModel> paths = JGitUtils.getFilesInPath(r, null, commit);\r
                List<TicketModel> tickets = new ArrayList<TicketModel>();\r
                for (PathModel ticketFolder : paths) {\r
                        if (ticketFolder.isTree()) {\r
@@ -97,11 +99,10 @@ public class TicgitUtils {
        }\r
 \r
        private static void readTicketContents(Repository r, RefModel ticketsBranch, TicketModel ticket) {\r
-               List<PathModel> ticketFiles = JGitUtils\r
-                               .getFilesInPath(r, ticket.name, ticketsBranch.commit);\r
+               RevCommit commit = (RevCommit) ticketsBranch.referencedObject;\r
+               List<PathModel> ticketFiles = JGitUtils.getFilesInPath(r, ticket.name, commit);\r
                for (PathModel file : ticketFiles) {\r
-                       String content = JGitUtils.getRawContentAsString(r, ticketsBranch.commit, file.path)\r
-                                       .trim();\r
+                       String content = JGitUtils.getStringContent(r, commit.getTree(), file.path).trim();\r
                        if (file.name.equals("TICKET_ID")) {\r
                                ticket.id = content;\r
                        } else if (file.name.equals("TITLE")) {\r
index 2ba03e6ec8274683aa57d119746883234edaa54d..f64f1e56cc60e49ddfb2ff40fdf8cebd0bab174a 100644 (file)
@@ -93,4 +93,5 @@ gb.zip = zip
 gb.showReadme = show readme\r
 gb.showReadmeDescription = show a \"readme\" markdown file on the summary page\r
 gb.nameDescription = use '/' to group repositories.  e.g. libraries/mycoollib.git\r
-gb.ownerDescription = the owner may edit repository settings
\ No newline at end of file
+gb.ownerDescription = the owner may edit repository settings\r
+gb.blob = blob
\ No newline at end of file
index 4601ac7b85a1415e256a8cad847a6e2f84471825..3c5c8e04ecde5a4c96b90ea0d7b44b4a97237848 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.CommitHeaderPanel;\r
 import com.gitblit.wicket.panels.PathBreadcrumbsPanel;\r
@@ -38,82 +39,100 @@ public class BlobPage extends RepositoryPage {
        public BlobPage(PageParameters params) {\r
                super(params);\r
 \r
+               Repository r = getRepository();\r
                final String blobPath = WicketUtils.getPath(params);\r
 \r
-               String extension = null;\r
-               if (blobPath.lastIndexOf('.') > -1) {\r
-                       extension = blobPath.substring(blobPath.lastIndexOf('.') + 1).toLowerCase();\r
-               }\r
+               if (StringUtils.isEmpty(blobPath)) {\r
+                       // blob by objectid\r
 \r
-               // see if we should redirect to the markdown page\r
-               for (String ext : GitBlit.getStrings(Keys.web.markdownExtensions)) {\r
-                       if (ext.equals(extension)) {\r
-                               setResponsePage(MarkdownPage.class, params);\r
-                               return;\r
+                       add(new Label("blameLink", getString("gb.blame")).setEnabled(false));\r
+                       add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class).setEnabled(false));\r
+                       add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,\r
+                                       WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));\r
+                       add(new BookmarkablePageLink<Void>("headLink", BlobPage.class).setEnabled(false));\r
+                       add(new CommitHeaderPanel("commitHeader", objectId));\r
+                       add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));\r
+                       Component c = new Label("blobText", JGitUtils.getStringContent(r, objectId));\r
+                       WicketUtils.setCssClass(c, "plainprint");\r
+                       add(c);\r
+               } else {\r
+                       // standard blob view\r
+                       String extension = null;\r
+                       if (blobPath.lastIndexOf('.') > -1) {\r
+                               extension = blobPath.substring(blobPath.lastIndexOf('.') + 1).toLowerCase();\r
                        }\r
-               }\r
 \r
-               // standard blob view\r
-               Repository r = getRepository();\r
-               RevCommit commit = getCommit();\r
+                       // see if we should redirect to the markdown page\r
+                       for (String ext : GitBlit.getStrings(Keys.web.markdownExtensions)) {\r
+                               if (ext.equals(extension)) {\r
+                                       setResponsePage(MarkdownPage.class, params);\r
+                                       return;\r
+                               }\r
+                       }\r
 \r
-               // blob page links\r
-               add(new Label("blameLink", getString("gb.blame")));\r
-               add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,\r
-                               WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));\r
-               add(new BookmarkablePageLink<Void>("rawLink", RawPage.class, WicketUtils.newPathParameter(\r
-                               repositoryName, objectId, blobPath)));\r
-               add(new BookmarkablePageLink<Void>("headLink", BlobPage.class,\r
-                               WicketUtils.newPathParameter(repositoryName, Constants.HEAD, blobPath)));\r
+                       // manually get commit because it can be null\r
+                       RevCommit commit = JGitUtils.getCommit(r, objectId);\r
 \r
-               add(new CommitHeaderPanel("commitHeader", repositoryName, commit));\r
+                       // blob page links\r
+                       add(new Label("blameLink", getString("gb.blame")));\r
+                       add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,\r
+                                       WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));\r
+                       add(new BookmarkablePageLink<Void>("rawLink", RawPage.class,\r
+                                       WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));\r
+                       add(new BookmarkablePageLink<Void>("headLink", BlobPage.class,\r
+                                       WicketUtils.newPathParameter(repositoryName, Constants.HEAD, blobPath)));\r
 \r
-               add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));\r
+                       add(new CommitHeaderPanel("commitHeader", repositoryName, commit));\r
 \r
-               // Map the extensions to types\r
-               Map<String, Integer> map = new HashMap<String, Integer>();\r
-               for (String ext : GitBlit.getStrings(Keys.web.prettyPrintExtensions)) {\r
-                       map.put(ext.toLowerCase(), 1);\r
-               }\r
-               for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {\r
-                       map.put(ext.toLowerCase(), 2);\r
-               }\r
-               for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {\r
-                       map.put(ext.toLowerCase(), 3);\r
-               }\r
+                       add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));\r
 \r
-               if (extension != null) {\r
-                       int type = 0;\r
-                       if (map.containsKey(extension)) {\r
-                               type = map.get(extension);\r
+                       // Map the extensions to types\r
+                       Map<String, Integer> map = new HashMap<String, Integer>();\r
+                       for (String ext : GitBlit.getStrings(Keys.web.prettyPrintExtensions)) {\r
+                               map.put(ext.toLowerCase(), 1);\r
+                       }\r
+                       for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {\r
+                               map.put(ext.toLowerCase(), 2);\r
+                       }\r
+                       for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {\r
+                               map.put(ext.toLowerCase(), 3);\r
                        }\r
-                       Component c = null;\r
-                       switch (type) {\r
-                       case 1:\r
-                               // PrettyPrint blob text\r
-                               c = new Label("blobText", JGitUtils.getRawContentAsString(r, commit, blobPath));\r
-                               WicketUtils.setCssClass(c, "prettyprint linenums");\r
-                               break;\r
-                       case 2:\r
-                               // TODO image blobs\r
-                               c = new Label("blobText", "Image File");\r
-                               break;\r
-                       case 3:\r
-                               // TODO binary blobs\r
-                               c = new Label("blobText", "Binary File");\r
-                               break;\r
-                       default:\r
+\r
+                       if (extension != null) {\r
+                               int type = 0;\r
+                               if (map.containsKey(extension)) {\r
+                                       type = map.get(extension);\r
+                               }\r
+                               Component c = null;\r
+                               switch (type) {\r
+                               case 1:\r
+                                       // PrettyPrint blob text\r
+                                       c = new Label("blobText", JGitUtils.getStringContent(r, commit.getTree(),\r
+                                                       blobPath));\r
+                                       WicketUtils.setCssClass(c, "prettyprint linenums");\r
+                                       break;\r
+                               case 2:\r
+                                       // TODO image blobs\r
+                                       c = new Label("blobText", "Image File");\r
+                                       break;\r
+                               case 3:\r
+                                       // TODO binary blobs\r
+                                       c = new Label("blobText", "Binary File");\r
+                                       break;\r
+                               default:\r
+                                       // plain text\r
+                                       c = new Label("blobText", JGitUtils.getStringContent(r, commit.getTree(),\r
+                                                       blobPath));\r
+                                       WicketUtils.setCssClass(c, "plainprint");\r
+                               }\r
+                               add(c);\r
+                       } else {\r
                                // plain text\r
-                               c = new Label("blobText", JGitUtils.getRawContentAsString(r, commit, blobPath));\r
-                               WicketUtils.setCssClass(c, "plainprint");\r
+                               Label blobLabel = new Label("blobText", JGitUtils.getStringContent(r,\r
+                                               commit.getTree(), blobPath));\r
+                               WicketUtils.setCssClass(blobLabel, "plainprint");\r
+                               add(blobLabel);\r
                        }\r
-                       add(c);\r
-               } else {\r
-                       // plain text\r
-                       Label blobLabel = new Label("blobText", JGitUtils.getRawContentAsString(r, commit,\r
-                                       blobPath));\r
-                       WicketUtils.setCssClass(blobLabel, "plainprint");\r
-                       add(blobLabel);\r
                }\r
        }\r
 \r
index bd317b7aad333770b57985bc92fc201a7d1eed53..f2d328e059d95de5534b7d9e761de89dfee0e9ce 100644 (file)
        <div class="commit_message" wicket:id="fullMessage">[commit message]</div>\r
 \r
        <!--  git notes -->\r
-       <table style="padding-bottom:5px;">\r
+       <table class="gitnotes">\r
                <tr wicket:id="notes">\r
-                       <td style="vertical-align:top;"><span class="headRef" wicket:id="refName"></span><br/><span wicket:id="authorName"></span><br/><span wicket:id="authorDate"></span></td>\r
-                       <td><span wicket:id="noteContent"></span></td>\r
+                       <td class="info">\r
+                               <table>\r
+                                       <tr><td><span wicket:id="refName"></span></td></tr>\r
+                                       <tr><td><span class="sha1" wicket:id="authorName"></span></td></tr>\r
+                                       <tr><td><span class="sha1" wicket:id="authorDate"></span></td></tr>\r
+                               </table>\r
+                       </td>\r
+                       <td class="message"><span class="sha1" wicket:id="noteContent"></span></td>\r
                </tr>\r
        </table>\r
        \r
index 3af9cf1d9f228c7658a4b706630595eaffe716ca..7b5fdbe07d6da89521afebabb25e44c05df38252 100644 (file)
@@ -16,9 +16,9 @@
 package com.gitblit.wicket.pages;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.List;\r
 \r
-import org.apache.wicket.Component;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;\r
@@ -37,12 +37,13 @@ import com.gitblit.Keys;
 import com.gitblit.models.GitNote;\r
 import com.gitblit.models.PathModel.PathChangeModel;\r
 import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.StringUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.CommitHeaderPanel;\r
 import com.gitblit.wicket.panels.CommitLegendPanel;\r
 import com.gitblit.wicket.panels.LinkPanel;\r
+import com.gitblit.wicket.panels.RefsPanel;\r
 \r
 public class CommitPage extends RepositoryPage {\r
 \r
@@ -123,13 +124,10 @@ public class CommitPage extends RepositoryPage {
 \r
                        public void populateItem(final Item<GitNote> item) {\r
                                GitNote entry = item.getModelObject();\r
-                               Component c = new LinkPanel("refName", null, entry.notesRef.displayName,\r
-                                               CommitPage.class, newCommitParameter(entry.notesRef.commit.getName()));\r
-                               WicketUtils.setCssClass(c, "headRef");\r
-                               item.add(c);\r
-                               item.add(createPersonPanel("authorName", entry.notesRef.commit.getAuthorIdent(), SearchType.AUTHOR));\r
+                               item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));\r
+                               item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), SearchType.AUTHOR));\r
                                item.add(WicketUtils.createTimestampLabel("authorDate",\r
-                                               entry.notesRef.commit.getAuthorIdent().getWhen(), getTimeZone()));\r
+                                               entry.notesRef.getAuthorIdent().getWhen(), getTimeZone()));\r
                                item.add(new Label("noteContent", StringUtils.breakLinesForHtml(entry.content)).setEscapeModelStrings(false));\r
                        }\r
                };\r
index fc8b7cbc17aa1b76c2b026cefe18adb9f2a5a189..9202fb880f4dcd310b8b21bbc6e8e6a1c04d3828 100644 (file)
@@ -48,7 +48,7 @@ public class MarkdownPage extends RepositoryPage {
                                WicketUtils.newPathParameter(repositoryName, Constants.HEAD, markdownPath)));\r
 \r
                // Read raw markdown content and transform it to html\r
-               String markdownText = JGitUtils.getRawContentAsString(r, commit, markdownPath);\r
+               String markdownText = JGitUtils.getStringContent(r, commit.getTree(), markdownPath);\r
                String htmlText;\r
                try {\r
                        htmlText = MarkdownUtils.transformMarkdown(markdownText);\r
index acda03afd9a42dd761f5f845ed73a82ec5932aba..c1ebea5ceef1dc4f7c2fa67c06c10d6f38b0413a 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
 import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
 \r
 public class RawPage extends WebPage {\r
@@ -50,49 +51,58 @@ public class RawPage extends WebPage {
                        return;\r
                }\r
 \r
-               RevCommit commit = JGitUtils.getCommit(r, objectId);\r
-\r
-               String extension = null;\r
-               if (blobPath.lastIndexOf('.') > -1) {\r
-                       extension = blobPath.substring(blobPath.lastIndexOf('.') + 1);\r
-               }\r
+               if (StringUtils.isEmpty(blobPath)) {\r
+                       // objectid referenced raw view\r
+                       Label blobLabel = new Label("rawText", JGitUtils.getStringContent(r, objectId));\r
+                       WicketUtils.setCssClass(blobLabel, "plainprint");\r
+                       add(blobLabel);\r
+               } else {\r
+                       // standard raw blob view\r
+                       RevCommit commit = JGitUtils.getCommit(r, objectId);\r
 \r
-               // Map the extensions to types\r
-               Map<String, Integer> map = new HashMap<String, Integer>();\r
-               for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {\r
-                       map.put(ext.toLowerCase(), 2);\r
-               }\r
-               for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {\r
-                       map.put(ext.toLowerCase(), 3);\r
-               }\r
+                       String extension = null;\r
+                       if (blobPath.lastIndexOf('.') > -1) {\r
+                               extension = blobPath.substring(blobPath.lastIndexOf('.') + 1);\r
+                       }\r
 \r
-               if (extension != null) {\r
-                       int type = 0;\r
-                       if (map.containsKey(extension)) {\r
-                               type = map.get(extension);\r
+                       // Map the extensions to types\r
+                       Map<String, Integer> map = new HashMap<String, Integer>();\r
+                       for (String ext : GitBlit.getStrings(Keys.web.imageExtensions)) {\r
+                               map.put(ext.toLowerCase(), 2);\r
+                       }\r
+                       for (String ext : GitBlit.getStrings(Keys.web.binaryExtensions)) {\r
+                               map.put(ext.toLowerCase(), 3);\r
                        }\r
-                       Component c = null;\r
-                       switch (type) {\r
-                       case 2:\r
-                               // TODO image blobs\r
-                               c = new Label("rawText", "Image File");\r
-                               break;\r
-                       case 3:\r
-                               // TODO binary blobs\r
-                               c = new Label("rawText", "Binary File");\r
-                               break;\r
-                       default:\r
+\r
+                       if (extension != null) {\r
+                               int type = 0;\r
+                               if (map.containsKey(extension)) {\r
+                                       type = map.get(extension);\r
+                               }\r
+                               Component c = null;\r
+                               switch (type) {\r
+                               case 2:\r
+                                       // TODO image blobs\r
+                                       c = new Label("rawText", "Image File");\r
+                                       break;\r
+                               case 3:\r
+                                       // TODO binary blobs\r
+                                       c = new Label("rawText", "Binary File");\r
+                                       break;\r
+                               default:\r
+                                       // plain text\r
+                                       c = new Label("rawText", JGitUtils.getStringContent(r, commit.getTree(),\r
+                                                       blobPath));\r
+                                       WicketUtils.setCssClass(c, "plainprint");\r
+                               }\r
+                               add(c);\r
+                       } else {\r
                                // plain text\r
-                               c = new Label("rawText", JGitUtils.getRawContentAsString(r, commit, blobPath));\r
-                               WicketUtils.setCssClass(c, "plainprint");\r
+                               Label blobLabel = new Label("rawText", JGitUtils.getStringContent(r,\r
+                                               commit.getTree(), blobPath));\r
+                               WicketUtils.setCssClass(blobLabel, "plainprint");\r
+                               add(blobLabel);\r
                        }\r
-                       add(c);\r
-               } else {\r
-                       // plain text\r
-                       Label blobLabel = new Label("rawText", JGitUtils.getRawContentAsString(r, commit,\r
-                                       blobPath));\r
-                       WicketUtils.setCssClass(blobLabel, "plainprint");\r
-                       add(blobLabel);\r
                }\r
                r.close();\r
        }\r
index a2d36d2e2da120f21725e2cd2cbdac022d07882f..fd21ed64c0c4b2b33aaa34dd88610c263e249238 100644 (file)
@@ -167,7 +167,7 @@ public class SummaryPage extends RepositoryPage {
                                        }\r
                                }\r
                                if (!StringUtils.isEmpty(readme)) {\r
-                                       String markdownText = JGitUtils.getRawContentAsString(r, head, readme);\r
+                                       String markdownText = JGitUtils.getStringContent(r, head.getTree(), readme);\r
                                        htmlText = MarkdownUtils.transformMarkdown(markdownText);\r
                                }\r
                        } catch (ParseException p) {\r
index 839375bce0dc8e8baec74f5d080d2ddf3122153f..f1a42c1abd86882a0e27e4c7dac379c4b4c5deaf 100644 (file)
        \r
        <!-- commit info -->\r
        <table class="plain">\r
-               <tr><th><wicket:message key="gb.object">[object]</wicket:message></th><td><span class="sha1" wicket:id="tagId">[tag id]</span></td></tr>\r
-               <tr><th><wicket:message key="gb.tagger">[tagger]</wicket:message></th><td><span class="sha1" wicket:id="tagAuthor">[tag author]</span></td></tr>\r
+               <tr><th><wicket:message key="gb.name">[name]</wicket:message></th><td><span class="tagRef" wicket:id="tagName">[tag name]</span></td></tr>\r
+               <tr><th><wicket:message key="gb.tag">[tag]</wicket:message></th><td><span class="sha1" wicket:id="tagId">[tag id]</span></td></tr>\r
+               <tr><th><wicket:message key="gb.object">[object]</wicket:message></th><td><span class="sha1" wicket:id="taggedObject">[tagged object]</span> <span class="link" wicket:id="taggedObjectType"></span></td></tr>\r
+               <tr><th><wicket:message key="gb.tagger">[tagger]</wicket:message></th><td><span class="sha1" wicket:id="tagger">[tagger]</span></td></tr>\r
                <tr><th></th><td><span class="sha1" wicket:id="tagDate">[tag date]</span></td></tr>\r
        </table>\r
        \r
index 7945231d373142b33e52628c45ad7526ca49cb4d..71a86452cf7755191e49c66d7e3b4f6aedec8efa 100644 (file)
  */\r
 package com.gitblit.wicket.pages;\r
 \r
+import java.text.MessageFormat;\r
+import java.util.Arrays;\r
 import java.util.List;\r
 \r
 import org.apache.wicket.PageParameters;\r
+import org.apache.wicket.markup.html.basic.Label;\r
+import org.eclipse.jgit.lib.Constants;\r
 import org.eclipse.jgit.lib.Repository;\r
-import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.panels.LinkPanel;\r
+import com.gitblit.wicket.panels.RefsPanel;\r
 \r
 public class TagPage extends RepositoryPage {\r
 \r
@@ -33,11 +37,10 @@ public class TagPage extends RepositoryPage {
                super(params);\r
 \r
                Repository r = getRepository();\r
-               RevCommit c = getCommit();\r
-               List<RefModel> tags = JGitUtils.getTags(r, -1);\r
 \r
+               // Find tag in repository\r
+               List<RefModel> tags = JGitUtils.getTags(r, -1);\r
                RefModel tagRef = null;\r
-               // determine tag\r
                for (RefModel tag : tags) {\r
                        if (tag.getName().equals(objectId) || tag.getObjectId().getName().equals(objectId)) {\r
                                tagRef = tag;\r
@@ -45,25 +48,42 @@ public class TagPage extends RepositoryPage {
                        }\r
                }\r
 \r
+               // Failed to find tag!\r
                if (tagRef == null) {\r
-                       // point to commit\r
-                       add(new LinkPanel("commit", "title", c.getShortMessage(), CommitPage.class,\r
-                                       newCommitParameter()));\r
-                       add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class,\r
-                                       newCommitParameter(c.getName())));\r
-               } else {\r
-                       // TODO commit or tree or blob?\r
-                       add(new LinkPanel("commit", "title", tagRef.displayName, CommitPage.class,\r
-                                       newCommitParameter()));\r
-                       add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class,\r
-                                       newCommitParameter(c.getName())));\r
+                       error(MessageFormat.format("Could not find tag {0}", objectId), true);\r
+               }\r
+\r
+               // Display tag.\r
+               Class<? extends RepositoryPage> linkClass;\r
+               PageParameters linkParameters = newCommitParameter(tagRef.getReferencedObjectId().getName());\r
+               String typeKey;\r
+               switch (tagRef.getReferencedObjectType()) {\r
+               case Constants.OBJ_BLOB:\r
+                       typeKey = "gb.blob";\r
+                       linkClass = BlobPage.class;\r
+                       break;\r
+               case Constants.OBJ_TREE:\r
+                       typeKey = "gb.tree";\r
+                       linkClass = TreePage.class;\r
+                       break;\r
+               case Constants.OBJ_COMMIT:\r
+               default:\r
+                       typeKey = "gb.commit";\r
+                       linkClass = CommitPage.class;\r
+                       break;\r
                }\r
+               add(new LinkPanel("commit", "title", tagRef.displayName, linkClass, linkParameters));\r
+               add(new RefsPanel("tagName", repositoryName, Arrays.asList(tagRef)));\r
+               add(new Label("tagId", tagRef.getObjectId().getName()));\r
+               add(new LinkPanel("taggedObject", "list", tagRef.getReferencedObjectId().getName(),\r
+                               linkClass, linkParameters));\r
+               add(new Label("taggedObjectType", getString(typeKey)));\r
 \r
-               add(createPersonPanel("tagAuthor", c.getAuthorIdent(), SearchType.AUTHOR));\r
-               add(WicketUtils\r
-                               .createTimestampLabel("tagDate", c.getAuthorIdent().getWhen(), getTimeZone()));\r
+               add(createPersonPanel("tagger", tagRef.getAuthorIdent(), SearchType.AUTHOR));\r
+               add(WicketUtils.createTimestampLabel("tagDate", tagRef.getAuthorIdent().getWhen(),\r
+                               getTimeZone()));\r
 \r
-               addFullText("fullMessage", c.getFullMessage(), true);\r
+               addFullText("fullMessage", tagRef.getFullMessage(), true);\r
        }\r
 \r
        @Override\r
index 1a6580d6a5849b14a8833d2087ecd0ff866ca528..7d0ad0f0bc44fc41be1655d4a8de12cdc714ef49 100644 (file)
@@ -25,6 +25,14 @@ public class CommitHeaderPanel extends BasePanel {
 \r
        private static final long serialVersionUID = 1L;\r
 \r
+       public CommitHeaderPanel(String id, String title) {\r
+               super(id);\r
+               add(new Label("shortmessage", title));\r
+               add(new Label("commitid"));\r
+               add(new Label("author"));\r
+               add(new Label("date"));\r
+       }\r
+       \r
        public CommitHeaderPanel(String id, String repositoryName, RevCommit c) {\r
                super(id);\r
                add(new LinkPanel("shortmessage", "title", c.getShortMessage(), CommitPage.class,\r
index 180a248a2315a4df37f8b206c374103008277e2c..9ad407ca8b692d1076144da769b3507fd761e38a 100644 (file)
@@ -34,6 +34,7 @@ import com.gitblit.GitBlit;
 import com.gitblit.Keys;\r
 import com.gitblit.models.PathModel;\r
 import com.gitblit.models.PathModel.PathChangeModel;\r
+import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
 import com.gitblit.utils.StringUtils;\r
@@ -73,7 +74,7 @@ public class HistoryPanel extends BasePanel {
                }\r
                final boolean isTree = matchingPath == null ? true : matchingPath.isTree();\r
 \r
-               final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
+               final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r);\r
                List<RevCommit> commits;\r
                if (pageResults) {\r
                        // Paging result set\r
index 436c24f73d2a4c3fe1dd18a6dae8545adf07f146..873d7d9b6a0ed88eac6a4927b4e2f75cbe6dc47f 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
 import com.gitblit.utils.StringUtils;\r
@@ -57,7 +58,7 @@ public class LogPanel extends BasePanel {
                        itemsPerPage = 50;\r
                }\r
 \r
-               final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
+               final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r);\r
                List<RevCommit> commits;\r
                if (pageResults) {\r
                        // Paging result set\r
index 33b1884f923343d2b0b1240c02a06da0cd0ae475..266a49b73a649d46605f87116baccfcc50c5cc96 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.ObjectId;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 \r
+import com.gitblit.models.RefModel;\r
 import com.gitblit.wicket.WicketUtils;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
@@ -39,45 +40,55 @@ public class RefsPanel extends Panel {
        private static final long serialVersionUID = 1L;\r
 \r
        public RefsPanel(String id, final String repositoryName, RevCommit c,\r
-                       Map<ObjectId, List<String>> refs) {\r
+                       Map<ObjectId, List<RefModel>> refs) {\r
+               this(id, repositoryName, refs.get(c.getId()));\r
+       }\r
+\r
+       public RefsPanel(String id, final String repositoryName, List<RefModel> refs) {\r
                super(id);\r
-               List<String> refNames = refs.get(c.getId());\r
-               if (refNames == null) {\r
-                       refNames = new ArrayList<String>();\r
+               if (refs == null) {\r
+                       refs = new ArrayList<RefModel>();\r
                }\r
-               Collections.sort(refNames);\r
+               Collections.sort(refs);\r
                // refNames.remove(Constants.HEAD);\r
 \r
-               ListDataProvider<String> refsDp = new ListDataProvider<String>(refNames);\r
-               DataView<String> refsView = new DataView<String>("ref", refsDp) {\r
+               ListDataProvider<RefModel> refsDp = new ListDataProvider<RefModel>(refs);\r
+               DataView<RefModel> refsView = new DataView<RefModel>("ref", refsDp) {\r
                        private static final long serialVersionUID = 1L;\r
 \r
-                       public void populateItem(final Item<String> item) {\r
-                               String entry = item.getModelObject();\r
+                       public void populateItem(final Item<RefModel> item) {\r
+                               RefModel entry = item.getModelObject();\r
+                               String name = entry.displayName;\r
+                               String objectid = entry.getReferencedObjectId().getName();\r
                                Component c = null;\r
-                               if (entry.startsWith(Constants.R_HEADS)) {\r
+                               if (name.startsWith(Constants.R_HEADS)) {\r
+                                       // local head\r
+                                       c = new LinkPanel("refName", null, name.substring(Constants.R_HEADS.length()),\r
+                                                       LogPage.class, WicketUtils.newObjectParameter(repositoryName, objectid));\r
+                                       WicketUtils.setCssClass(c, "headRef");\r
+                               } else if (name.equals(Constants.HEAD)) {\r
                                        // local head\r
-                                       c = new LinkPanel("refName", null, entry.substring(Constants.R_HEADS.length()),\r
-                                                       LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry));\r
+                                       c = new LinkPanel("refName", null, name, LogPage.class,\r
+                                                       WicketUtils.newObjectParameter(repositoryName, objectid));\r
                                        WicketUtils.setCssClass(c, "headRef");\r
-                               } else if (entry.startsWith(Constants.R_REMOTES)) {\r
+                               } else if (name.startsWith(Constants.R_REMOTES)) {\r
                                        // remote head\r
                                        c = new LinkPanel("refName", null,\r
-                                                       entry.substring(Constants.R_REMOTES.length()), LogPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, entry));\r
+                                                       name.substring(Constants.R_REMOTES.length()), LogPage.class,\r
+                                                       WicketUtils.newObjectParameter(repositoryName, objectid));\r
                                        WicketUtils.setCssClass(c, "remoteRef");\r
-                               } else if (entry.startsWith(Constants.R_TAGS)) {\r
+                               } else if (name.startsWith(Constants.R_TAGS)) {\r
                                        // tag\r
-                                       c = new LinkPanel("refName", null, entry.substring(Constants.R_TAGS.length()),\r
-                                                       TagPage.class, WicketUtils.newObjectParameter(repositoryName, entry));\r
+                                       c = new LinkPanel("refName", null, name.substring(Constants.R_TAGS.length()),\r
+                                                       TagPage.class, WicketUtils.newObjectParameter(repositoryName, objectid));\r
                                        WicketUtils.setCssClass(c, "tagRef");\r
                                } else {\r
                                        // other\r
-                                       c = new LinkPanel("refName", null, entry, CommitPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, entry));\r
+                                       c = new LinkPanel("refName", null, name, CommitPage.class,\r
+                                                       WicketUtils.newObjectParameter(repositoryName, objectid));\r
                                        WicketUtils.setCssClass(c, "otherRef");\r
                                }\r
-                               WicketUtils.setHtmlTooltip(c, entry);\r
+                               WicketUtils.setHtmlTooltip(c, name);\r
                                item.add(c);\r
                        }\r
                };\r
index f91e0e8ae7b679e07613157f983212187fb1b933..5f82a4286851d49439a431539e255d26cae873c6 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
 import com.gitblit.utils.StringUtils;\r
@@ -55,7 +56,7 @@ public class SearchPanel extends BasePanel {
 \r
                RevCommit commit = JGitUtils.getCommit(r, objectId);\r
 \r
-               final Map<ObjectId, List<String>> allRefs = JGitUtils.getAllRefs(r);\r
+               final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r);\r
                List<RevCommit> commits;\r
                if (pageResults) {\r
                        // Paging result set\r
index 9f98504dfff5791df426aa88e60ad30528f5111f..481d8e812c3603d3b12c972429a9cead66e1967b 100644 (file)
@@ -28,7 +28,7 @@
        <!--  annotated tag links -->\r
        <wicket:fragment wicket:id="annotatedLinks">\r
                <span class="link">\r
-                       <a wicket:id="view"><wicket:message key="gb.view"></wicket:message></a> | <a wicket:id="commit"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a>\r
+                       <a wicket:id="tag"><wicket:message key="gb.tag"></wicket:message></a> | <a wicket:id="commit"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a>\r
                </span>\r
        </wicket:fragment>\r
        \r
                        <a wicket:id="commit"><wicket:message key="gb.commit"></wicket:message></a> | <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a>\r
                </span>\r
        </wicket:fragment>\r
+\r
+       <!-- blob tag links -->\r
+       <wicket:fragment wicket:id="blobLinks">\r
+               <span class="link">\r
+                       <a wicket:id="tag"><wicket:message key="gb.tag"></wicket:message></a> | <a wicket:id="blob"><wicket:message key="gb.blob"></wicket:message></a> | <a wicket:id="raw"><wicket:message key="gb.raw"></wicket:message></a>\r
+               </span>\r
+       </wicket:fragment>\r
        \r
 </wicket:panel>\r
 </body>\r
index de8112a468855c256ac04ee0e7832a135e925a69..259af312da0baa208a25eb72599f9e0903abc790 100644 (file)
@@ -24,17 +24,22 @@ import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;\r
 import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
 import org.apache.wicket.model.StringResourceModel;\r
+import org.eclipse.jgit.lib.Constants;\r
 import org.eclipse.jgit.lib.Repository;\r
 \r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.WicketUtils;\r
+import com.gitblit.wicket.pages.BlobPage;\r
 import com.gitblit.wicket.pages.CommitPage;\r
 import com.gitblit.wicket.pages.LogPage;\r
+import com.gitblit.wicket.pages.RawPage;\r
+import com.gitblit.wicket.pages.RepositoryPage;\r
 import com.gitblit.wicket.pages.SummaryPage;\r
 import com.gitblit.wicket.pages.TagPage;\r
 import com.gitblit.wicket.pages.TagsPage;\r
+import com.gitblit.wicket.pages.TreePage;\r
 \r
 public class TagsPanel extends BasePanel {\r
 \r
@@ -67,47 +72,83 @@ public class TagsPanel extends BasePanel {
 \r
                                item.add(WicketUtils.createDateLabel("tagDate", entry.getDate(), getTimeZone()));\r
 \r
-                               // tag icon\r
-                               if (entry.isAnnotatedTag()) {\r
-                                       item.add(WicketUtils.newImage("tagIcon", "tag_16x16.png"));\r
-                               } else {\r
-                                       item.add(WicketUtils.newBlankImage("tagIcon"));\r
+                               Class<? extends RepositoryPage> linkClass;\r
+                               switch (entry.getReferencedObjectType()) {\r
+                               case Constants.OBJ_BLOB:\r
+                                       linkClass = BlobPage.class;\r
+                                       break;\r
+                               case Constants.OBJ_TREE:\r
+                                       linkClass = TreePage.class;\r
+                                       break;\r
+                               case Constants.OBJ_COMMIT:\r
+                               default:\r
+                                       linkClass = CommitPage.class;\r
+                                       break;\r
                                }\r
-\r
-                               item.add(new LinkPanel("tagName", "list name", entry.displayName, CommitPage.class,\r
-                                               WicketUtils.newObjectParameter(repositoryName, entry.getCommitId()\r
-                                                               .getName())));\r
+                               item.add(new LinkPanel("tagName", "list name", entry.displayName, linkClass,\r
+                                               WicketUtils.newObjectParameter(repositoryName, entry\r
+                                                               .getReferencedObjectId().getName())));\r
                                String message;\r
                                if (maxCount > 0) {\r
-                                       message = StringUtils.trimString(entry.getShortLog(), 40);\r
+                                       message = StringUtils.trimString(entry.getShortMessage(), 40);\r
                                } else {\r
-                                       message = entry.getShortLog();\r
+                                       // workaround for RevTag returning a lengthy shortlog. :(\r
+                                       message = StringUtils.trimShortLog(entry.getShortMessage());\r
                                }\r
-                               if (entry.isAnnotatedTag()) {\r
+                               if (linkClass.equals(BlobPage.class)) {\r
+                                       // Blob Tag Object\r
+                                       item.add(WicketUtils.newImage("tagIcon", "file_16x16.png"));\r
                                        item.add(new LinkPanel("tagDescription", "list", message, TagPage.class,\r
                                                        WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()\r
                                                                        .getName())));\r
-                                       Fragment fragment = new Fragment("tagLinks", "annotatedLinks", this);\r
-                                       fragment.add(new BookmarkablePageLink<Void>("view", TagPage.class, WicketUtils\r
+\r
+                                       Fragment fragment = new Fragment("tagLinks", "blobLinks", this);\r
+                                       fragment.add(new BookmarkablePageLink<Void>("tag", TagPage.class, WicketUtils\r
                                                        .newObjectParameter(repositoryName, entry.getObjectId().getName()))\r
                                                        .setEnabled(entry.isAnnotatedTag()));\r
-                                       fragment.add(new BookmarkablePageLink<Void>("commit", CommitPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, entry.getCommitId()\r
-                                                                       .getName())));\r
-                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
-                                                       .newObjectParameter(repositoryName, entry.getName())));\r
-                                       item.add(fragment);\r
-                               } else {\r
-                                       item.add(new LinkPanel("tagDescription", "list", message, CommitPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()\r
+\r
+                                       fragment.add(new BookmarkablePageLink<Void>("blob", linkClass, WicketUtils\r
+                                                       .newObjectParameter(repositoryName, entry.getReferencedObjectId()\r
                                                                        .getName())));\r
-                                       Fragment fragment = new Fragment("tagLinks", "lightweightLinks", this);\r
-                                       fragment.add(new BookmarkablePageLink<Void>("commit", CommitPage.class,\r
-                                                       WicketUtils.newObjectParameter(repositoryName, entry.getCommitId()\r
+\r
+                                       fragment.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils\r
+                                                       .newObjectParameter(repositoryName, entry.getReferencedObjectId()\r
                                                                        .getName())));\r
-                                       fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils\r
-                                                       .newObjectParameter(repositoryName, entry.getName())));\r
                                        item.add(fragment);\r
+                               } else {\r
+                                       // TODO Tree Tag Object\r
+                                       // Standard Tag Object\r
+                                       if (entry.isAnnotatedTag()) {\r
+                                               item.add(WicketUtils.newImage("tagIcon", "tag_16x16.png"));\r
+                                               item.add(new LinkPanel("tagDescription", "list", message, TagPage.class,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()\r
+                                                                               .getName())));\r
+\r
+                                               Fragment fragment = new Fragment("tagLinks", "annotatedLinks", this);\r
+                                               fragment.add(new BookmarkablePageLink<Void>("tag", TagPage.class,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()\r
+                                                                               .getName())).setEnabled(entry.isAnnotatedTag()));\r
+\r
+                                               fragment.add(new BookmarkablePageLink<Void>("commit", linkClass,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry\r
+                                                                               .getReferencedObjectId().getName())));\r
+\r
+                                               fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                                               item.add(fragment);\r
+                                       } else {\r
+                                               item.add(WicketUtils.newBlankImage("tagIcon"));\r
+                                               item.add(new LinkPanel("tagDescription", "list", message, CommitPage.class,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry.getObjectId()\r
+                                                                               .getName())));\r
+                                               Fragment fragment = new Fragment("tagLinks", "lightweightLinks", this);\r
+                                               fragment.add(new BookmarkablePageLink<Void>("commit", CommitPage.class,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry\r
+                                                                               .getReferencedObjectId().getName())));\r
+                                               fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class,\r
+                                                               WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+                                               item.add(fragment);\r
+                                       }\r
                                }\r
 \r
                                WicketUtils.setAlternatingBackground(item, counter);\r
index c9356c3d5ca6ebe96b57d2ebd4efb5179f017fe5..5dd0f160b14d0e14f40d8aab427e3c2447107433 100644 (file)
@@ -243,6 +243,7 @@ div.page_path {
 }\r
 \r
 div.commit_message {\r
+       font-family: monospace;\r
        padding: 8px;\r
        border: solid #bbb;\r
        border-width: 1px 0px 0px;\r
@@ -508,7 +509,7 @@ table.pretty, table.comments {
        border-right: 1px solid #bbb;   \r
 }\r
 \r
-table.pretty, table.comments, table.repositories {\r
+table.pretty, table.comments, table.repositories, table.gitnotes {\r
        width:100%;\r
 }\r
 \r
@@ -608,7 +609,29 @@ table.palette td.header {
 }\r
 table.palette td.pane {\r
        padding: 0px;   \r
-} \r
+}\r
+\r
+table.gitnotes {       \r
+       padding-bottom: 5px;\r
+}\r
+table.gitnotes td {\r
+       border-top: 1px solid #ccc;\r
+       padding-top: 3px;\r
+       vertical-align:top;\r
+}\r
+\r
+table.gitnotes td table td {\r
+       border: none;\r
+       padding-top: 0px;\r
+}\r
+\r
+table.gitnotes td.info {\r
+}\r
+\r
+table.gitnotes td.message {\r
+       width: 65%;\r
+       border-left: 1px solid #ccc;\r
+}\r
 \r
 tr th a { padding-right: 15px; background-position: right; background-repeat:no-repeat; }\r
 tr th.wicket_orderDown a {background-image: url(arrow_down.png); }\r
index 97e46c9c415b335e767bbde49986ccb5ac6cce2d..fe201b8b06d9c115aeff224fead6f46a5743e91c 100644 (file)
 package com.gitblit.tests;\r
 \r
 import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
 \r
 import junit.extensions.TestSetup;\r
 import junit.framework.Test;\r
 import junit.framework.TestSuite;\r
 \r
 import org.eclipse.jgit.api.CloneCommand;\r
+import org.eclipse.jgit.api.FetchCommand;\r
 import org.eclipse.jgit.api.Git;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.storage.file.FileRepository;\r
+import org.eclipse.jgit.transport.RefSpec;\r
 \r
 import com.gitblit.FileSettings;\r
 import com.gitblit.GitBlit;\r
@@ -61,6 +65,14 @@ public class GitBlitSuite extends TestSetup {
                return new FileRepository(new File(REPOSITORIES, "ticgit.git"));\r
        }\r
 \r
+       public static Repository getJGitRepository() throws Exception {\r
+               return new FileRepository(new File(REPOSITORIES, "nested/jgit.git"));\r
+       }\r
+\r
+       public static Repository getBluezGnomeRepository() throws Exception {\r
+               return new FileRepository(new File(REPOSITORIES, "nested/bluez-gnome.git"));\r
+       }\r
+\r
        @Override\r
        protected void setUp() throws Exception {\r
                FileSettings settings = new FileSettings("distrib/gitblit.properties");\r
@@ -71,12 +83,15 @@ public class GitBlitSuite extends TestSetup {
 \r
                if (REPOSITORIES.exists() || REPOSITORIES.mkdirs()) {\r
                        cloneOrFetch("helloworld.git", "https://github.com/git/hello-world.git", true);\r
-                       cloneOrFetch("nested/helloworld.git", "https://github.com/git/hello-world.git", true);\r
                        cloneOrFetch("ticgit.git", "https://github.com/jeffWelling/ticgit.git", true);\r
+                       cloneOrFetch("nested/bluez-gnome.git", "https://git.kernel.org/pub/scm/bluetooth/bluez-gnome.git", true);\r
+                       cloneOrFetch("nested/jgit.git", "https://github.com/eclipse/jgit.git", true);\r
+                       cloneOrFetch("nested/helloworld.git", "https://github.com/git/hello-world.git", true);\r
 \r
                        enableTickets("ticgit.git");\r
                        enableDocs("ticgit.git");\r
                        showRemoteBranches("ticgit.git");\r
+                       showRemoteBranches("nested/jgit.git");\r
                }\r
        }\r
 \r
@@ -84,22 +99,35 @@ public class GitBlitSuite extends TestSetup {
                File folder = new File(REPOSITORIES, toFolder + (bare ? "" : "/.git"));\r
                if (folder.exists()) {\r
                        System.out.print("Updating " + (bare ? "bare " : " ") + toFolder + "... ");\r
-                       FileRepository repository = new FileRepository(new File(REPOSITORIES, toFolder));\r
-                       Git git = new Git(repository);\r
-                       git.fetch().call();\r
-                       repository.close();\r
+                       fetch(toFolder);\r
                        System.out.println("done.");\r
                } else {\r
                        System.out.println("Cloning " + (bare ? "bare " : " ") + toFolder + "... ");\r
                        CloneCommand clone = new CloneCommand();\r
                        clone.setBare(bare);\r
-                       clone.setCloneAllBranches(true);\r
+                       clone.setCloneAllBranches(true);                        \r
                        clone.setURI(fromUrl);\r
                        clone.setDirectory(folder);\r
                        clone.call();\r
+                       // Now we have to fetch because CloneCommand doesn't fetch\r
+                       // Notes nor does it allow manual RefSpec.\r
+                       fetch(toFolder);\r
                        System.out.println("done.");\r
                }\r
        }\r
+       \r
+       private void fetch(String toFolder) throws Exception {\r
+               FileRepository repository = new FileRepository(new File(REPOSITORIES, toFolder));\r
+               Git git = new Git(repository);\r
+               FetchCommand fetch = git.fetch();\r
+               List<RefSpec> specs = new ArrayList<RefSpec>();\r
+               specs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));\r
+               specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));\r
+               specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));\r
+               fetch.setRefSpecs(specs);\r
+               fetch.call();\r
+               repository.close();\r
+       }\r
 \r
        private void enableTickets(String repositoryName) {\r
                try {\r
index 6afa38b2bf0766a30ddf9d1852f15238637702d4..7196afdf1131621ae12b72dee156d4e13d5c5717 100644 (file)
@@ -34,11 +34,13 @@ import org.eclipse.jgit.revwalk.RevCommit;
 \r
 import com.gitblit.GitBlit;\r
 import com.gitblit.Keys;\r
+import com.gitblit.models.GitNote;\r
 import com.gitblit.models.PathModel;\r
 import com.gitblit.models.PathModel.PathChangeModel;\r
 import com.gitblit.models.RefModel;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.SearchType;\r
+import com.gitblit.utils.StringUtils;\r
 \r
 public class JGitUtilsTest extends TestCase {\r
 \r
@@ -115,10 +117,24 @@ public class JGitUtilsTest extends TestCase {
        }\r
 \r
        public void testRefs() throws Exception {\r
-               Repository repository = GitBlitSuite.getTicgitRepository();\r
-               Map<ObjectId, List<String>> map = JGitUtils.getAllRefs(repository);\r
+               Repository repository = GitBlitSuite.getJGitRepository();\r
+               Map<ObjectId, List<RefModel>> map = JGitUtils.getAllRefs(repository);\r
                repository.close();\r
                assertTrue(map.size() > 0);\r
+               for (Map.Entry<ObjectId, List<RefModel>> entry : map.entrySet()) {\r
+                       List<RefModel> list = entry.getValue();\r
+                       for (RefModel ref : list) {\r
+                               if (ref.displayName.equals("refs/tags/spearce-gpg-pub")) {\r
+                                       assertTrue(ref.getObjectId().getName().equals("8bbde7aacf771a9afb6992434f1ae413e010c6d8"));\r
+                                       assertTrue(ref.getAuthorIdent().getEmailAddress().equals("spearce@spearce.org"));\r
+                                       assertTrue(ref.getShortMessage().startsWith("GPG key"));\r
+                                       assertTrue(ref.getFullMessage().startsWith("GPG key"));                                 \r
+                                       assertTrue(ref.getReferencedObjectType() == Constants.OBJ_BLOB);\r
+                               } else if (ref.displayName.equals("refs/tags/v0.12.1")) {\r
+                                       assertTrue(ref.isAnnotatedTag());\r
+                               }\r
+                       }\r
+               }\r
        }\r
 \r
        public void testBranches() throws Exception {\r
@@ -127,17 +143,17 @@ public class JGitUtilsTest extends TestCase {
                        assertTrue(model.getName().startsWith(Constants.R_HEADS));\r
                        assertTrue(model.equals(model));\r
                        assertFalse(model.equals(""));\r
-                       assertTrue(model.hashCode() == model.getCommitId().hashCode()\r
+                       assertTrue(model.hashCode() == model.getReferencedObjectId().hashCode()\r
                                        + model.getName().hashCode());\r
-                       assertTrue(model.getShortLog().equals(model.commit.getShortMessage()));\r
+                       assertTrue(model.getShortMessage().equals(model.getShortMessage()));\r
                }\r
                for (RefModel model : JGitUtils.getRemoteBranches(repository, -1)) {\r
                        assertTrue(model.getName().startsWith(Constants.R_REMOTES));\r
                        assertTrue(model.equals(model));\r
                        assertFalse(model.equals(""));\r
-                       assertTrue(model.hashCode() == model.getCommitId().hashCode()\r
+                       assertTrue(model.hashCode() == model.getReferencedObjectId().hashCode()\r
                                        + model.getName().hashCode());\r
-                       assertTrue(model.getShortLog().equals(model.commit.getShortMessage()));\r
+                       assertTrue(model.getShortMessage().equals(model.getShortMessage()));\r
                }\r
                assertTrue(JGitUtils.getRemoteBranches(repository, 10).size() == 10);\r
                repository.close();\r
@@ -152,33 +168,52 @@ public class JGitUtilsTest extends TestCase {
                        assertTrue(model.getName().startsWith(Constants.R_TAGS));\r
                        assertTrue(model.equals(model));\r
                        assertFalse(model.equals(""));\r
-                       assertTrue(model.hashCode() == model.getCommitId().hashCode()\r
+                       assertTrue(model.hashCode() == model.getReferencedObjectId().hashCode()\r
                                        + model.getName().hashCode());\r
-                       assertTrue(model.getShortLog().equals(model.commit.getShortMessage()));\r
+               }\r
+               repository.close();\r
+               \r
+               repository = GitBlitSuite.getBluezGnomeRepository();\r
+               for (RefModel model : JGitUtils.getTags(repository, -1)) {\r
+                       if (model.getObjectId().getName().equals("728643ec0c438c77e182898c2f2967dbfdc231c8")) {\r
+                               assertFalse(model.isAnnotatedTag());\r
+                               assertTrue(model.getAuthorIdent().getEmailAddress().equals("marcel@holtmann.org"));\r
+                               assertTrue(model.getFullMessage().equals("Update changelog and bump version number\n"));\r
+                       }\r
                }\r
                repository.close();\r
        }\r
 \r
        public void testCommitNotes() throws Exception {\r
-//             Repository repository = new FileRepository(new File("c:/projects/git/jgit.git/.git"));\r
-//             RevCommit commit = JGitUtils.getCommit(repository,\r
-//                             "ada903085d1b4ef8c79e3e2d91f49fee7e188f53");\r
-//             List<GitNote> list = JGitUtils.getNotesOnCommit(repository, commit);\r
-//             repository.close();\r
-//             assertTrue(list.size() > 0);\r
+               Repository repository = GitBlitSuite.getJGitRepository();\r
+               RevCommit commit = JGitUtils.getCommit(repository,\r
+                               "690c268c793bfc218982130fbfc25870f292295e");\r
+               List<GitNote> list = JGitUtils.getNotesOnCommit(repository, commit);\r
+               repository.close();\r
+               assertTrue(list.size() > 0);\r
+               assertTrue(list.get(0).notesRef.getReferencedObjectId().getName()\r
+                               .equals("183474d554e6f68478a02d9d7888b67a9338cdff"));\r
        }\r
 \r
        public void testStringContent() throws Exception {\r
                Repository repository = GitBlitSuite.getHelloworldRepository();\r
-               String contentA = JGitUtils.getRawContentAsString(repository, null, "java.java");\r
+               String contentA = JGitUtils.getStringContent(repository, null, "java.java");\r
                RevCommit commit = JGitUtils.getCommit(repository, Constants.HEAD);\r
-               String contentB = JGitUtils.getRawContentAsString(repository, commit, "java.java");\r
-               String contentC = JGitUtils.getRawContentAsString(repository, commit, "missing.txt");\r
+               String contentB = JGitUtils.getStringContent(repository, commit.getTree(), "java.java");\r
+               String contentC = JGitUtils.getStringContent(repository, commit.getTree(), "missing.txt");\r
+\r
+               // manually construct a blob, calculate the hash, lookup the hash in git\r
+               StringBuilder sb = new StringBuilder();\r
+               sb.append("blob ").append(contentA.length()).append('\0');\r
+               sb.append(contentA);\r
+               String sha1 = StringUtils.getSHA1(sb.toString());\r
+               String contentD = JGitUtils.getStringContent(repository, sha1);\r
                repository.close();\r
                assertTrue("ContentA is null!", contentA != null && contentA.length() > 0);\r
                assertTrue("ContentB is null!", contentB != null && contentB.length() > 0);\r
                assertTrue(contentA.equals(contentB));\r
                assertTrue(contentC == null);\r
+               assertTrue(contentA.equals(contentD));\r
        }\r
 \r
        public void testFilesInCommit() throws Exception {\r