From 1448ec37f9141d16da28151289e3d590c89fc739 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Thu, 29 Dec 2016 13:47:17 +0900 Subject: Set commit time to ZipArchiveEntry Archived zip files for a same commit have different MD5 hash because mdate and mdate in the header of zip entries are not specified. In this case, Commons Compress sets an archived time. In the original git implementation, it's set a commit time: https://github.com/git/git/blob/e2b2d6a172b76d44cb7b1ddb12ea5bfac9613a44/archive.c#L378 By this fix, archive command sets the commit time to ZipArchiveEntry when RevCommit is given as an archiving target. Change-Id: I30dd8710e910cdf42d57742f8709e9803930a123 Signed-off-by: Naoki Takezoe Signed-off-by: David Pursehouse Signed-off-by: Matthias Sohn --- .../tst/org/eclipse/jgit/api/ArchiveCommandTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'org.eclipse.jgit.test') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java index fc8df42e26..54d58eca46 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java @@ -57,6 +57,7 @@ import java.util.Map; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.lib.FileMode; +import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.util.StringUtils; @@ -203,12 +204,14 @@ public class ArchiveCommandTest extends RepositoryTestCase { private final List SUFFIXES = Collections .unmodifiableList(Arrays.asList(".mck")); + @Override public MockOutputStream createArchiveOutputStream(OutputStream s) throws IOException { return createArchiveOutputStream(s, Collections. emptyMap()); } + @Override public MockOutputStream createArchiveOutputStream(OutputStream s, Map o) throws IOException { for (Map.Entry p : o.entrySet()) { @@ -224,11 +227,18 @@ public class ArchiveCommandTest extends RepositoryTestCase { return new MockOutputStream(); } + @Override public void putEntry(MockOutputStream out, String path, FileMode mode, ObjectLoader loader) { + putEntry(out, null, path, mode, loader); + } + + @Override + public void putEntry(MockOutputStream out, ObjectId tree, String path, FileMode mode, ObjectLoader loader) { String content = mode != FileMode.TREE ? new String(loader.getBytes()) : null; entries.put(path, content); } + @Override public Iterable suffixes() { return SUFFIXES; } -- cgit v1.2.3