aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit
diff options
context:
space:
mode:
authorSasa Zivkov <sasa.zivkov@sap.com>2012-09-16 23:57:18 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2012-09-16 23:57:18 +0200
commita551493240d5513a101415e55742c689562d6f51 (patch)
tree7a5e1fdd36b33d4e77446a349105c4065855297f /org.eclipse.jgit.junit
parentfdf1f413b61f17921cbbb3a8b969022facf9f3eb (diff)
downloadjgit-a551493240d5513a101415e55742c689562d6f51.tar.gz
jgit-a551493240d5513a101415e55742c689562d6f51.zip
Additional unit tests for the GC
Change-Id: Id5b578f7040c6c896ab9386a6b5ed62b0f495ed5 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index b36b5c761f..cc4852a2bd 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -550,6 +550,23 @@ public class TestRepository<R extends Repository> {
}
/**
+ * Tag an object using a lightweight tag.
+ *
+ * @param name
+ * the tag name. The /refs/tags/ prefix will be added if the name
+ * doesn't start with it
+ * @param obj
+ * the object to tag
+ * @return the tagged object
+ * @throws Exception
+ */
+ public ObjectId lightweightTag(String name, ObjectId obj) throws Exception {
+ if (!name.startsWith(Constants.R_TAGS))
+ name = Constants.R_TAGS + name;
+ return update(name, obj);
+ }
+
+ /**
* Run consistency checks against the object database.
* <p>
* This method completes silently if the checks pass. A temporary revision
@@ -733,6 +750,8 @@ public class TestRepository<R extends Repository> {
private final DirCache tree = DirCache.newInCore();
+ private ObjectId topLevelTree;
+
private final List<RevCommit> parents = new ArrayList<RevCommit>(2);
private int tick = 1;
@@ -787,6 +806,11 @@ public class TestRepository<R extends Repository> {
return this;
}
+ public CommitBuilder setTopLevelTree(ObjectId treeId) {
+ topLevelTree = treeId;
+ return this;
+ }
+
public CommitBuilder add(String path, String content) throws Exception {
return add(path, blob(content));
}
@@ -840,7 +864,10 @@ public class TestRepository<R extends Repository> {
ObjectId commitId;
try {
- c.setTreeId(tree.writeTree(inserter));
+ if (topLevelTree != null)
+ c.setTreeId(topLevelTree);
+ else
+ c.setTreeId(tree.writeTree(inserter));
commitId = inserter.insert(c);
inserter.flush();
} finally {