diff --git a/org.eclipse.jgit.archive/META-INF/MANIFEST.MF b/org.eclipse.jgit.archive/META-INF/MANIFEST.MF index 48027d712..fa8cb50d1 100644 --- a/org.eclipse.jgit.archive/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.archive/META-INF/MANIFEST.MF @@ -6,12 +6,12 @@ Bundle-Version: 3.0.0.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Import-Package: org.apache.commons.compress.archivers;version="[1.3,2.0)", - org.apache.commons.compress.archivers.tar;version="[1.3,2.0)", - org.apache.commons.compress.archivers.zip;version="[1.3,2.0)", - org.apache.commons.compress.compressors.bzip2;version="[1.3,2.0)", - org.apache.commons.compress.compressors.gzip;version="[1.3,2.0)", - org.apache.commons.compress.compressors.xz;version="[1.3,2.0)", +Import-Package: org.apache.commons.compress.archivers;version="[1.4,2.0)", + org.apache.commons.compress.archivers.tar;version="[1.4,2.0)", + org.apache.commons.compress.archivers.zip;version="[1.4,2.0)", + org.apache.commons.compress.compressors.bzip2;version="[1.4,2.0)", + org.apache.commons.compress.compressors.gzip;version="[1.4,2.0)", + org.apache.commons.compress.compressors.xz;version="[1.4,2.0)", org.eclipse.jgit.api;version="[3.0.0,3.1.0)", org.eclipse.jgit.lib;version="[3.0.0,3.1.0)", org.osgi.framework;version="[1.3.0,2.0.0)" 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 3b27489e2..228de7c37 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 @@ -54,11 +54,14 @@ import org.eclipse.jgit.lib.ObjectLoader; /** - * Unix TAR format (ustar + old GNU long filename extension). + * Unix TAR format (ustar + some PAX extensions). */ public class TarFormat implements ArchiveCommand.Format { public ArchiveOutputStream createArchiveOutputStream(OutputStream s) { - return new TarArchiveOutputStream(s); + TarArchiveOutputStream out = new TarArchiveOutputStream(s, "UTF-8"); //$NON-NLS-1$ + out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX); + out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX); + return out; } public void putEntry(ArchiveOutputStream out, diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java index cb2a7258a..a2a5044a5 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java @@ -228,6 +228,36 @@ public void testTarPreservesMode() throws Exception { assertTarContainsEntry("with-modes.tar", "l", "symlink -> plain"); } + @Test + public void testArchiveWithLongFilename() throws Exception { + String filename = "1234567890"; + for (int i = 0; i < 20; i++) + filename = filename + "/1234567890"; + writeTrashFile(filename, "file with long path"); + git.add().addFilepattern("1234567890").call(); + git.commit().setMessage("file with long name").call(); + + final byte[] result = CLIGitCommand.rawExecute( // + "git archive HEAD", db); + assertArrayEquals(new String[] { filename }, + listZipEntries(result)); + } + + @Test + public void testTarWithLongFilename() throws Exception { + String filename = "1234567890"; + for (int i = 0; i < 20; i++) + filename = filename + "/1234567890"; + writeTrashFile(filename, "file with long path"); + git.add().addFilepattern("1234567890").call(); + git.commit().setMessage("file with long name").call(); + + final byte[] result = CLIGitCommand.rawExecute( // + "git archive --format=tar HEAD", db); + assertArrayEquals(new String[] { filename }, + listTarEntries(result)); + } + @Test public void testArchivePreservesContent() throws Exception { final String payload = "“The quick brown fox jumps over the lazy dog!”";