Top Description Fields Constructors Methods
org.eclipse.jgit.api

public Class CleanCommand

extends GitCommand<Set<String>>
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.DOT_GIT

Remove untracked files from the working tree
See Also
Git documentation about Clean

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private boolean
private Set<String>
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
CleanCommand(Repository repo)

Constructor for CleanCommand

Method Summary

Modifier and TypeMethod and Description
public Set<String>
call()

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private Set<String>

Returns:

a set of strings with the cleaned path added to it
cleanPath
(String
The path to be cleaned
path
,
Set<String>
A set of strings representing the files that have been cleaned already, the path to be cleaned will be added to this set before being returned.
inFiles
)

When dryRun is false, deletes the specified path from disk.

private Set<String>
filterFolders(Set<String> untracked, Set<String> untrackedFolders)

private Set<String>
filterIgnorePaths(Set<String> inputPaths, Set<String> ignoredNotInIndex, boolean exact)

public CleanCommand

Returns:

this
setCleanDirectories
(boolean
whether to clean directories too, or only files.
dirs
)

If dirs is set, in addition to files, also clean directories.

public CleanCommand

Returns:

this
setDryRun
(boolean
whether to do a dry run or not
dryRun
)

If dryRun is set, the paths in question will not actually be deleted.

public CleanCommand

Returns:

this
setForce
(boolean
whether or not to delete git repositories
force
)

If force is set, directories that are git repositories will also be deleted.

public CleanCommand

Returns:

this
setIgnore
(boolean
whether to respect .gitignore or not.
ignore
)

If ignore is set, don't report/clean files/directories that are ignored by a .gitignore.

public CleanCommand

Returns:

this
setPaths
(Set<String>
the paths to set (with / as separator)
paths
)

If paths are set, only these paths are affected by the cleaning.

Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

directoriesback to summary
private boolean directories
dryRunback to summary
private boolean dryRun
forceback to summary
private boolean force
ignoreback to summary
private boolean ignore
pathsback to summary
private Set<String> paths

Constructor Detail

CleanCommandback to summary
protected CleanCommand(Repository repo)

Constructor for CleanCommand

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

callback to summary
public Set<String> call() throws NoWorkTreeException, GitAPIException

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Doc from org.eclipse.jgit.api.GitCommand.call.

Computes a result, or throws an exception if unable to do so.

Execute the command

Executes the clean command with all the options and parameters collected by the setter methods of this class. Each instance of this class should only be used for one invocation of the command (means: one call to call())

Returns:Set<String>

Doc from java.util.concurrent.Callable.call.

computed result

Annotations
@Override
cleanPathback to summary
private Set<String> cleanPath(String path, Set<String> inFiles) throws IOException

When dryRun is false, deletes the specified path from disk. If dryRun is true, no paths are actually deleted. In both cases, the paths that would have been deleted are added to inFiles and returned. Paths that are directories are recursively deleted when directories is true. Paths that are git repositories are recursively deleted when directories and force are both true.

Parameters
path:String

The path to be cleaned

inFiles:Set<String>

A set of strings representing the files that have been cleaned already, the path to be cleaned will be added to this set before being returned.

Returns:Set<String>

a set of strings with the cleaned path added to it

Exceptions
IOException:
if an IO error occurred
filterFoldersback to summary
private Set<String> filterFolders(Set<String> untracked, Set<String> untrackedFolders)
filterIgnorePathsback to summary
private Set<String> filterIgnorePaths(Set<String> inputPaths, Set<String> ignoredNotInIndex, boolean exact)
setCleanDirectoriesback to summary
public CleanCommand setCleanDirectories(boolean dirs)

If dirs is set, in addition to files, also clean directories.

Parameters
dirs:boolean

whether to clean directories too, or only files.

Returns:CleanCommand

this

setDryRunback to summary
public CleanCommand setDryRun(boolean dryRun)

If dryRun is set, the paths in question will not actually be deleted.

Parameters
dryRun:boolean

whether to do a dry run or not

Returns:CleanCommand

this

setForceback to summary
public CleanCommand setForce(boolean force)

If force is set, directories that are git repositories will also be deleted.

Parameters
force:boolean

whether or not to delete git repositories

Returns:CleanCommand

this

Since
4.5
setIgnoreback to summary
public CleanCommand setIgnore(boolean ignore)

If ignore is set, don't report/clean files/directories that are ignored by a .gitignore. otherwise do handle them.

Parameters
ignore:boolean

whether to respect .gitignore or not.

Returns:CleanCommand

this

setPathsback to summary
public CleanCommand setPaths(Set<String> paths)

If paths are set, only these paths are affected by the cleaning.

Parameters
paths:Set<String>

the paths to set (with / as separator)

Returns:CleanCommand

this