diff options
author | Nasser Grainawi <quic_nasserg@quicinc.com> | 2021-02-10 22:51:05 -0700 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-03-04 22:19:36 +0100 |
commit | 971dafd302ae4bb2d69345f9624774ff226feebd (patch) | |
tree | aa76d7b8bc91e39cf958b3a8d4ad0974634ecaa2 /org.eclipse.jgit.junit/src/org | |
parent | 40d6eda3f16f24db20776d33e586737efeddc725 (diff) | |
download | jgit-971dafd302ae4bb2d69345f9624774ff226feebd.tar.gz jgit-971dafd302ae4bb2d69345f9624774ff226feebd.zip |
Create a PackFile class for Pack filenames
The PackFile class is intended to be a central place to do all
common pack filename manipulation and parsing to help reduce repeated
code and bugs. Use the PackFile class in the Pack class and in many
tests to ensure it works well in a variety of situations. Later changes
will expand use of PackFiles to even more areas.
Change-Id: I921b30f865759162bae46ddd2c6d669de06add4a
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src/org')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java | 11 |
1 files changed, 7 insertions, 4 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 e3eb2c5367..24f7741f16 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 @@ -44,7 +44,9 @@ import org.eclipse.jgit.internal.storage.file.FileRepository; import org.eclipse.jgit.internal.storage.file.LockFile; import org.eclipse.jgit.internal.storage.file.ObjectDirectory; import org.eclipse.jgit.internal.storage.file.Pack; +import org.eclipse.jgit.internal.storage.file.PackFile; import org.eclipse.jgit.internal.storage.file.PackIndex.MutableEntry; +import org.eclipse.jgit.internal.storage.pack.PackExt; import org.eclipse.jgit.internal.storage.pack.PackWriter; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; @@ -906,7 +908,7 @@ public class TestRepository<R extends Repository> implements AutoCloseable { ObjectDirectory odb = (ObjectDirectory) db.getObjectDatabase(); NullProgressMonitor m = NullProgressMonitor.INSTANCE; - final File pack, idx; + final PackFile pack, idx; try (PackWriter pw = new PackWriter(db)) { Set<ObjectId> all = new HashSet<>(); for (Ref r : db.getRefDatabase().getRefs()) @@ -922,7 +924,7 @@ public class TestRepository<R extends Repository> implements AutoCloseable { } pack.setReadOnly(); - idx = nameFor(odb, name, ".idx"); + idx = pack.create(PackExt.INDEX); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(idx))) { pw.writeIndex(out); @@ -960,9 +962,10 @@ public class TestRepository<R extends Repository> implements AutoCloseable { } } - private static File nameFor(ObjectDirectory odb, ObjectId name, String t) { + private static PackFile nameFor(ObjectDirectory odb, ObjectId name, + String t) { File packdir = odb.getPackDirectory(); - return new File(packdir, "pack-" + name.name() + t); + return new PackFile(packdir, "pack-" + name.name() + t); } private void writeFile(File p, byte[] bin) throws IOException, |