Package org.eclipse.jgit.lfs
Class CleanFilter
- java.lang.Object
-
- org.eclipse.jgit.attributes.FilterCommand
-
- org.eclipse.jgit.lfs.CleanFilter
-
public class CleanFilter extends FilterCommand
Built-in LFS clean filter When new content is about to be added to the git repository and this filter is configured for that content, then this filter will replace the original content with content of a so-called LFS pointer file. The pointer file content will then be added to the git repository. Additionally this filter writes the original content in a so-called 'media file' to '.git/lfs/objects/ <first-two-characters-of-contentid>/<rest-of-contentid>'- Since:
- 4.6
- See Also:
- Git LFS Specification
-
-
Field Summary
Fields Modifier and Type Field Description private AtomicObjectOutputStreamaOutstatic FilterCommandFactoryFACTORYThe factory is responsible for creating instances ofCleanFilterprivate LfslfsUtilprivate longsizeprivate java.nio.file.PathtmpFile-
Fields inherited from class org.eclipse.jgit.attributes.FilterCommand
in, out
-
-
Constructor Summary
Constructors Constructor Description CleanFilter(Repository db, java.io.InputStream in, java.io.OutputStream out)Constructor for CleanFilter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static voidregister()Registers this filter by callingFilterCommandRegistry.register(String, FilterCommandFactory)intrun()Execute the command.
-
-
-
Field Detail
-
FACTORY
public static final FilterCommandFactory FACTORY
The factory is responsible for creating instances ofCleanFilter
-
aOut
private AtomicObjectOutputStream aOut
-
lfsUtil
private Lfs lfsUtil
-
size
private long size
-
tmpFile
private java.nio.file.Path tmpFile
-
-
Constructor Detail
-
CleanFilter
public CleanFilter(Repository db, java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
Constructor for CleanFilter.- Parameters:
db- the repositoryin- anInputStreamproviding the original contentout- theOutputStreaminto which the content of the pointer file should be written. That's the content which will be added to the git repository- Throws:
java.io.IOException- when the creation of the temporary file fails or when noOutputStreamfor this file can be created
-
-
Method Detail
-
register
static void register()
Registers this filter by callingFilterCommandRegistry.register(String, FilterCommandFactory)
-
run
public int run() throws java.io.IOExceptionExecute the command. The command is supposed to read data fromFilterCommand.inand to write the result toFilterCommand.out. It returns the number of bytes it read fromFilterCommand.in. It should be called in a loop until it returns -1 signaling that theInputStreamis completely processed.On successful completion (return -1) or on Exception, the streams
FilterCommand.inandFilterCommand.outare closed by the implementation.- Specified by:
runin classFilterCommand- Returns:
- the number of bytes read from the
InputStreamor -1. -1 means that theInputStreamis completely processed. - Throws:
java.io.IOException- whenIOExceptionoccurred while reading fromFilterCommand.inor writing toFilterCommand.out
-
-