Introduce a setFilename() method for ArchiveCommand so callers can
specify the intended filename of the produced archive. If the
filename ends with .tar, the format will default to tar; if .zip, zip;
if .tar.gz, gzip-compressed tar; and so on.
This doesn't affect "jgit archive" because it doesn't support the
--output=<file> option yet. A later patch might do that.
Change-Id: Ic0236a70f7aa7f2271c3ef11083b21ee986b4df5
Attempts to write entries with too-long filenames currently error out:
$ jgit.pgm/target/jgit archive HEAD >test.tar
java.lang.RuntimeException: file name 'org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java' is too long ( > 100 bytes)
at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.putArchiveEntry(TarArchiveOutputStream.java:288)
at org.eclipse.jgit.archive.TarFormat.putEntry(TarFormat.java:92)
at org.eclipse.jgit.archive.TarFormat.putEntry(TarFormat.java:62)
at org.eclipse.jgit.api.ArchiveCommand.writeArchive(ArchiveCommand.java:293)
at org.eclipse.jgit.api.ArchiveCommand.call(ArchiveCommand.java:322)
at org.eclipse.jgit.pgm.Archive.run(Archive.java:97)
at org.eclipse.jgit.pgm.TextBuiltin.execute(TextBuiltin.java:174)
at org.eclipse.jgit.pgm.Main.execute(Main.java:213)
at org.eclipse.jgit.pgm.Main.run(Main.java:121)
at org.eclipse.jgit.pgm.Main.main(Main.java:95)
That's because the default longFileMode is LONGFILE_ERROR, which
throws an exception for filenames longer than 100 characters. Switch
to LONGFILE_POSIX. While at it, handle large files and filenames with
strange encodings, too.
This requires commons compress 1.4, which introduced support for large
files and POSIX long filenames.
Change-Id: I04d5427eec0968b129f55d7a4c6021039a494828
OSGi 4.01 comes with package org.osgi.framework version 1.3 [1] which
has the BundleActivator interface needed by org.eclipse.jgit.archive.
OSGi 5.0 matches package org.osgi.framework version 1.7 [2].
[1] http://www.osgi.org/javadoc/r4v401/
[2] http://www.osgi.org/javadoc/r5/core/
Change-Id: I10f78e5eb02b5d03395f23d2f0ad039caf565269
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Document archive formats, the archive format interface, and the
parameters of the GitAPIException constructors. Noticed by eclipse.
Reported-by: Dani Megert <Daniel_Megert@ch.ibm.com>
Change-Id: I22b5f9d4c0358bbe867c1906feec7c279e214273
This makes the functionality of registering all formats from the
org.eclipse.jgit.archive package available in contexts where
FormatActivator cannot be built because the OSGi core framework is not
readily available to build against.
Change-Id: If8e3487e933783a7e12f8e1838cbfe0b5862ce80
Add a static start() method to FormatActivator to allow outside
classes such as the Archive subcommand of the jgit program to use it
without a BundleContext. This way, the list of formats only has to be
maintained in one place.
While at it, build a list of registered formats at start() time, so
stop() doesn't have to repeat the same list of formats.
Suggested-by: Shawn Pearce <spearce@spearce.org>
Change-Id: I55cb3095043568740880cc9e4f7cde05f49c363c
Allow use of ArchiveCommand without depending on the jgit command-line
tools.
To avoid complicating the process of installing and upgrading JGit,
this does not add a dependency by the org.eclipse.jgit bundle on
commons-compress. Instead, the caller is responsible for registering
any formats they want to use by calling ArchiveCommand.registerFormat.
This patch puts functionality that requires an archiver into a
separate org.eclipse.jgit.archive bundle for people who want it. One
can use it by calling ArchiveCommand.registerFormat directly to
register its formats or by relying on OSGi class loading to load
org.eclipse.jgit.archive.FormatActivator, which takes care of
registration automatically.
Once the appropriate formats are registered, you can make a tar or zip
from a git tree object as follows:
ArchiveCommand cmd = git.archive();
try {
cmd.setTree(tree).setFormat(fmt).setOutputStream(out).call();
} finally {
cmd.release();
}
Change-Id: I418e7e7d76422dc6f010d0b3b624d7bec3b20c6e