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

public Class GarbageCollectCommand

extends GitCommand<Properties>
Class Inheritance
Imports
java.io.IOException, java.text.MessageFormat, .ParseException, java.time.Instant, java.util.Date, .Properties, java.util.concurrent.ExecutionException, org.eclipse.jgit.api.errors.GitAPIException, .JGitInternalException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.internal.storage.dfs.DfsGarbageCollector, .DfsRepository, org.eclipse.jgit.internal.storage.file.FileRepository, .GC, .GC.RepoStatistics, org.eclipse.jgit.lib.ConfigConstants, .ProgressMonitor, .Repository, .StoredConfig, org.eclipse.jgit.storage.pack.PackConfig

A class used to execute a gc command. It has setters for all supported options and arguments of this command and a call() method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call to call())
Since
2.2
See Also
Git documentation about gc

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_GC_AGGRESSIVE_DEPTH

Default value of maximum delta chain depth during aggressive garbage collection:

public static final int
DEFAULT_GC_AGGRESSIVE_WINDOW

Default window size during packing during aggressive garbage collection: *

private Instant
private ProgressMonitor
private Boolean
private PackConfig
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
GarbageCollectCommand(Repository repo)

Constructor for GarbageCollectCommand.

Method Summary

Modifier and TypeMethod and Description
public Properties
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.

public Properties

Returns:

the repository statistics
getStatistics
()

Computes and returns the repository statistics.

public GarbageCollectCommand

Returns:

this instance
setAggressive
(boolean
whether to turn on or off aggressive mode
aggressive
)

Whether to use aggressive mode or not.

public GarbageCollectCommand

Returns:

this instance
setExpire
(Date
minimal age of objects to be pruned.
expire
)
Deprecated since 7.2. use setExpire(Instant) instead

During gc() or prune() each unreferenced, loose object which has been created or modified after expire will not be pruned.

public GarbageCollectCommand

Returns:

this instance
setExpire
(Instant
minimal age of objects to be pruned.
expire
)

During gc() or prune() each unreferenced, loose object which has been created or modified after expire will not be pruned.

public GarbageCollectCommand

Returns:

this instance
setPackKeptObjects
(boolean
whether to include objects in `.keep` files when repacking.
packKeptObjects
)

Whether to include objects in `.keep` packs when repacking.

public GarbageCollectCommand

Returns:

this instance
setPreserveOldPacks
(boolean
whether to preserve old pack files
preserveOldPacks
)

Whether to preserve old pack files instead of deleting them.

public GarbageCollectCommand

Returns:

this instance
setProgressMonitor
(ProgressMonitor
a progress monitor
monitor
)

Set progress monitor

public GarbageCollectCommand

Returns:

this instance
setPrunePreserved
(boolean
whether to prune preserved pack files
prunePreserved
)

Whether to prune preserved pack files in the preserved directory.

private static Properties
Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

DEFAULT_GC_AGGRESSIVE_DEPTHback to summary
public static final int DEFAULT_GC_AGGRESSIVE_DEPTH

Default value of maximum delta chain depth during aggressive garbage collection:

Since
3.6
DEFAULT_GC_AGGRESSIVE_WINDOWback to summary
public static final int DEFAULT_GC_AGGRESSIVE_WINDOW

Default window size during packing during aggressive garbage collection: *

Since
3.6
expireback to summary
private Instant expire
monitorback to summary
private ProgressMonitor monitor
packKeptObjectsback to summary
private Boolean packKeptObjects
pconfigback to summary
private PackConfig pconfig

Constructor Detail

GarbageCollectCommandback to summary
protected GarbageCollectCommand(Repository repo)

Constructor for GarbageCollectCommand.

Parameters
repo:Repository

a org.eclipse.jgit.lib.Repository object.

Method Detail

callback to summary
public Properties call() throws 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

Returns:Properties

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

computed result

Annotations
@Override
getStatisticsback to summary
public Properties getStatistics() throws GitAPIException

Computes and returns the repository statistics.

Returns:Properties

the repository statistics

Exceptions
GitAPIException:
thrown if the repository statistics cannot be computed
Since
3.0
setAggressiveback to summary
public GarbageCollectCommand setAggressive(boolean aggressive)

Whether to use aggressive mode or not. If set to true JGit behaves more similar to native git's "git gc --aggressive". If set to true compressed objects found in old packs are not reused but every object is compressed again. Configuration variables pack.window and pack.depth are set to 250 for this GC.

Parameters
aggressive:boolean

whether to turn on or off aggressive mode

Returns:GarbageCollectCommand

this instance

Since
3.6
setExpireback to summary
public GarbageCollectCommand setExpire(Date expire)

Deprecated

since 7.2.

use setExpire(Instant) instead

During gc() or prune() each unreferenced, loose object which has been created or modified after expire will not be pruned. Only older objects may be pruned. If set to null then every object is a candidate for pruning. Use org.eclipse.jgit.util.GitDateParser to parse time formats used by git gc.

Parameters
expire:Date

minimal age of objects to be pruned.

Returns:GarbageCollectCommand

this instance

Annotations
@Deprecated
since:7.2
setExpireback to summary
public GarbageCollectCommand setExpire(Instant expire)

During gc() or prune() each unreferenced, loose object which has been created or modified after expire will not be pruned. Only older objects may be pruned. If set to null then every object is a candidate for pruning. Use org.eclipse.jgit.util.GitTimeParser to parse time formats used by git gc.

Parameters
expire:Instant

minimal age of objects to be pruned.

Returns:GarbageCollectCommand

this instance

Since
7.2
setPackKeptObjectsback to summary
public GarbageCollectCommand setPackKeptObjects(boolean packKeptObjects)

Whether to include objects in `.keep` packs when repacking.

Parameters
packKeptObjects:boolean

whether to include objects in `.keep` files when repacking.

Returns:GarbageCollectCommand

this instance

Since
5.13.3
setPreserveOldPacksback to summary
public GarbageCollectCommand setPreserveOldPacks(boolean preserveOldPacks)

Whether to preserve old pack files instead of deleting them.

Parameters
preserveOldPacks:boolean

whether to preserve old pack files

Returns:GarbageCollectCommand

this instance

Since
4.7
setProgressMonitorback to summary
public GarbageCollectCommand setProgressMonitor(ProgressMonitor monitor)

Set progress monitor

Parameters
monitor:ProgressMonitor

a progress monitor

Returns:GarbageCollectCommand

this instance

setPrunePreservedback to summary
public GarbageCollectCommand setPrunePreserved(boolean prunePreserved)

Whether to prune preserved pack files in the preserved directory.

Parameters
prunePreserved:boolean

whether to prune preserved pack files

Returns:GarbageCollectCommand

this instance

Since
4.7
toPropertiesback to summary
private static Properties toProperties(GC.RepoStatistics stats)
Annotations
@SuppressWarnings:boxing