public class ArchiveCommand extends GitCommand<OutputStream>
Examples (git is a Git instance):
Create a tarball from HEAD:
cmd = new ArchiveCommand(git.getRepository());
try {
cmd.setTree(db.resolve("HEAD"))
.setOutputStream(out).call();
} finally {
cmd.release();
}
Create a ZIP file from master:
try {
cmd.setTree(db.resolve("master"))
.setFormat(ArchiveCommand.Format.ZIP)
.setOutputStream(out).call();
} finally {
cmd.release();
}
| Modifier and Type | Class and Description |
|---|---|
static class |
ArchiveCommand.Format
Available archival formats (corresponding to values for
the --format= option)
|
repo| Constructor and Description |
|---|
ArchiveCommand(Repository repo) |
| Modifier and Type | Method and Description |
|---|---|
OutputStream |
call() |
void |
release()
Release any resources used by the internal ObjectReader.
|
ArchiveCommand |
setFormat(ArchiveCommand.Format fmt) |
ArchiveCommand |
setOutputStream(OutputStream out) |
ArchiveCommand |
setTree(ObjectId tree) |
checkCallable, getRepository, setCallablepublic ArchiveCommand(Repository repo)
repo - public void release()
This does not close the output stream set with setOutputStream, which belongs to the caller.
public OutputStream call() throws GitAPIException
call in interface Callable<OutputStream>call in class GitCommand<OutputStream>GitAPIExceptionpublic ArchiveCommand setTree(ObjectId tree) throws IOException
tree - the tag, commit, or tree object to produce an archive forIOExceptionpublic ArchiveCommand setOutputStream(OutputStream out)
out - the stream to which to write the archivepublic ArchiveCommand setFormat(ArchiveCommand.Format fmt)
fmt - archive format (e.g., Format.TAR)Copyright © 2013. All rights reserved.