diff options
author | Nasser Grainawi <quic_nasserg@quicinc.com> | 2021-03-04 14:14:43 -0700 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-03-07 00:02:56 +0100 |
commit | 2a6b2eddcfac17ef5ff3b6b28dfaadd83e34956a (patch) | |
tree | f75b39459509e582a854ac79537ddac1d57df00d /org.eclipse.jgit.junit/src | |
parent | 093020864f06b75708f8ec225e5df9e0ad54f9c1 (diff) | |
download | jgit-2a6b2eddcfac17ef5ff3b6b28dfaadd83e34956a.tar.gz jgit-2a6b2eddcfac17ef5ff3b6b28dfaadd83e34956a.zip |
PackFile: Add id + ext based constructors
Add new constructors to PackFile to improve a common use case where
callers know the directory, id, and extension, but previously needed to
construct a valid file name (with prefix, '.', etc) to create a
PackFile. Most callers can use the variant that has id as an ObjectId,
but provide an id as String variant too.
Change-Id: I39e4466abe8c9509f5916d5bfe675066570b8585
Signed-off-by: Nasser Grainawi <quic_nasserg@quicinc.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java | 11 |
1 files changed, 2 insertions, 9 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 24f7741f16..0232156a49 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 @@ -915,9 +915,8 @@ public class TestRepository<R extends Repository> implements AutoCloseable { all.add(r.getObjectId()); pw.preparePack(m, all, PackWriter.NONE); - final ObjectId name = pw.computeName(); - - pack = nameFor(odb, name, ".pack"); + pack = new PackFile(odb.getPackDirectory(), pw.computeName(), + PackExt.PACK); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(pack))) { pw.writePack(m, m, out); @@ -962,12 +961,6 @@ public class TestRepository<R extends Repository> implements AutoCloseable { } } - private static PackFile nameFor(ObjectDirectory odb, ObjectId name, - String t) { - File packdir = odb.getPackDirectory(); - return new PackFile(packdir, "pack-" + name.name() + t); - } - private void writeFile(File p, byte[] bin) throws IOException, ObjectWritingException { final LockFile lck = new LockFile(p); |