summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.archive
diff options
context:
space:
mode:
authorNaoki Takezoe <takezoe@gmail.com>2016-12-29 13:47:17 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2017-02-18 10:47:27 +0100
commit1448ec37f9141d16da28151289e3d590c89fc739 (patch)
treefa9e8078b2e8bc9fc536e32c7fc0db5c303322f7 /org.eclipse.jgit.archive
parentd3962fef6b9736c416c14dbb12b54c0a4a269763 (diff)
downloadjgit-1448ec37f9141d16da28151289e3d590c89fc739.tar.gz
jgit-1448ec37f9141d16da28151289e3d590c89fc739.zip
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 <takezoe@gmail.com> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.archive')
-rw-r--r--org.eclipse.jgit.archive/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java13
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java15
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java15
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java15
-rw-r--r--org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java20
6 files changed, 76 insertions, 3 deletions
diff --git a/org.eclipse.jgit.archive/META-INF/MANIFEST.MF b/org.eclipse.jgit.archive/META-INF/MANIFEST.MF
index b477de5f07..53c9b595c2 100644
--- a/org.eclipse.jgit.archive/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.archive/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Import-Package: org.apache.commons.compress.archivers;version="[1.4,2.0)",
org.eclipse.jgit.api;version="[4.7.0,4.8.0)",
org.eclipse.jgit.lib;version="[4.7.0,4.8.0)",
org.eclipse.jgit.nls;version="[4.7.0,4.8.0)",
+ org.eclipse.jgit.revwalk;version="[4.7.0,4.8.0)",
org.eclipse.jgit.util;version="[4.7.0,4.8.0)",
org.osgi.framework;version="[1.3.0,2.0.0)"
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
index d56cb35d9d..900f024bfc 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
@@ -57,6 +57,7 @@ import org.apache.commons.compress.archivers.tar.TarConstants;
import org.eclipse.jgit.api.ArchiveCommand;
import org.eclipse.jgit.archive.internal.ArchiveText;
import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
/**
@@ -84,9 +85,21 @@ public final class TarFormat extends BaseFormat implements
return applyFormatOptions(out, o);
}
+ @Deprecated
+ @Override
public void putEntry(ArchiveOutputStream out,
String path, FileMode mode, ObjectLoader loader)
throws IOException {
+ putEntry(out, null, path, mode,loader);
+ }
+
+ /**
+ * @since 4.7
+ */
+ @Override
+ public void putEntry(ArchiveOutputStream out,
+ ObjectId tree, String path, FileMode mode, ObjectLoader loader)
+ throws IOException {
if (mode == FileMode.SYMLINK) {
final TarArchiveEntry entry = new TarArchiveEntry(
path, TarConstants.LF_SYMLINK);
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java
index f3ab4da43a..bba0293637 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java
@@ -53,6 +53,7 @@ import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
import org.eclipse.jgit.api.ArchiveCommand;
import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
/**
@@ -80,10 +81,22 @@ public final class Tbz2Format extends BaseFormat implements
return tarFormat.createArchiveOutputStream(out, o);
}
+ @Deprecated
+ @Override
public void putEntry(ArchiveOutputStream out,
String path, FileMode mode, ObjectLoader loader)
throws IOException {
- tarFormat.putEntry(out, path, mode, loader);
+ putEntry(out, null, path, mode,loader);
+ }
+
+ /**
+ * @since 4.7
+ */
+ @Override
+ public void putEntry(ArchiveOutputStream out,
+ ObjectId tree, String path, FileMode mode, ObjectLoader loader)
+ throws IOException {
+ tarFormat.putEntry(out, tree, path, mode, loader);
}
public Iterable<String> suffixes() {
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java
index 06f09a4887..b6bf3ff665 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java
@@ -53,6 +53,7 @@ import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.eclipse.jgit.api.ArchiveCommand;
import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
/**
@@ -80,10 +81,22 @@ public final class TgzFormat extends BaseFormat implements
return tarFormat.createArchiveOutputStream(out, o);
}
+ @Deprecated
+ @Override
public void putEntry(ArchiveOutputStream out,
String path, FileMode mode, ObjectLoader loader)
throws IOException {
- tarFormat.putEntry(out, path, mode, loader);
+ putEntry(out, null, path, mode,loader);
+ }
+
+ /**
+ * @since 4.7
+ */
+ @Override
+ public void putEntry(ArchiveOutputStream out,
+ ObjectId tree, String path, FileMode mode, ObjectLoader loader)
+ throws IOException {
+ tarFormat.putEntry(out, tree, path, mode, loader);
}
public Iterable<String> suffixes() {
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java
index 14839353d4..76d934f21c 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java
@@ -53,6 +53,7 @@ import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
import org.eclipse.jgit.api.ArchiveCommand;
import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
/**
@@ -80,10 +81,22 @@ public final class TxzFormat extends BaseFormat implements
return tarFormat.createArchiveOutputStream(out, o);
}
+ @Deprecated
+ @Override
public void putEntry(ArchiveOutputStream out,
String path, FileMode mode, ObjectLoader loader)
throws IOException {
- tarFormat.putEntry(out, path, mode, loader);
+ putEntry(out, null, path, mode,loader);
+ }
+
+ /**
+ * @since 4.7
+ */
+ @Override
+ public void putEntry(ArchiveOutputStream out,
+ ObjectId tree, String path, FileMode mode, ObjectLoader loader)
+ throws IOException {
+ tarFormat.putEntry(out, tree, path, mode, loader);
}
public Iterable<String> suffixes() {
diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
index 0e1b2536f2..dfbf2ee62d 100644
--- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
+++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java
@@ -56,7 +56,9 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.eclipse.jgit.api.ArchiveCommand;
import org.eclipse.jgit.archive.internal.ArchiveText;
import org.eclipse.jgit.lib.FileMode;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
+import org.eclipse.jgit.revwalk.RevCommit;
/**
* PKWARE's ZIP format.
@@ -80,9 +82,21 @@ public final class ZipFormat extends BaseFormat implements
return applyFormatOptions(new ZipArchiveOutputStream(s), o);
}
+ @Deprecated
+ @Override
public void putEntry(ArchiveOutputStream out,
String path, FileMode mode, ObjectLoader loader)
throws IOException {
+ putEntry(out, null, path, mode,loader);
+ }
+
+ /**
+ * @since 4.7
+ */
+ @Override
+ public void putEntry(ArchiveOutputStream out,
+ ObjectId tree, String path, FileMode mode, ObjectLoader loader)
+ throws IOException {
// ZipArchiveEntry detects directories by checking
// for '/' at the end of the filename.
if (path.endsWith("/") && mode != FileMode.TREE) //$NON-NLS-1$
@@ -92,6 +106,12 @@ public final class ZipFormat extends BaseFormat implements
path = path + "/"; //$NON-NLS-1$
final ZipArchiveEntry entry = new ZipArchiveEntry(path);
+
+ if(tree instanceof RevCommit){
+ long commitTime = ((RevCommit) tree).getCommitTime();
+ entry.setTime(commitTime);
+ }
+
if (mode == FileMode.TREE) {
out.putArchiveEntry(entry);
out.closeArchiveEntry();