diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2024-12-25 23:05:42 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2024-12-28 20:04:07 +0100 |
commit | 300a53dd6f84a630c73754632de0b4a1651ff890 (patch) | |
tree | 6c98f0c813c5bf3cba87bf645810cc77ac5bb3ca /org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java | |
parent | 5a56be277dac6328c9aec8ada60ab89c9750b1da (diff) | |
download | jgit-300a53dd6f84a630c73754632de0b4a1651ff890.tar.gz jgit-300a53dd6f84a630c73754632de0b4a1651ff890.zip |
GarbageCollectCommand, GC: use java.time API
We are moving away from the old java.util.Date API to the
java.time API.
Add GitTimeParser#parseInstant to support this.
Change-Id: I3baeafeda5b65421dc94c1045b0ba576d4f79662
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java index 88d7e91860..f6935e1c67 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java @@ -12,6 +12,7 @@ package org.eclipse.jgit.api; import java.io.IOException; import java.text.MessageFormat; import java.text.ParseException; +import java.time.Instant; import java.util.Date; import java.util.Properties; import java.util.concurrent.ExecutionException; @@ -59,7 +60,7 @@ public class GarbageCollectCommand extends GitCommand<Properties> { private ProgressMonitor monitor; - private Date expire; + private Instant expire; private PackConfig pconfig; @@ -98,8 +99,29 @@ public class GarbageCollectCommand extends GitCommand<Properties> { * @param expire * minimal age of objects to be pruned. * @return this instance + * @deprecated use {@link #setExpire(Instant)} instead */ + @Deprecated(since = "7.2") public GarbageCollectCommand setExpire(Date expire) { + if (expire != null) { + this.expire = expire.toInstant(); + } + return this; + } + + /** + * During gc() or prune() each unreferenced, loose object which has been + * created or modified after <code>expire</code> will not be pruned. Only + * older objects may be pruned. If set to null then every object is a + * candidate for pruning. Use {@link org.eclipse.jgit.util.GitTimeParser} to + * parse time formats used by git gc. + * + * @param expire + * minimal age of objects to be pruned. + * @return this instance + * @since 7.2 + */ + public GarbageCollectCommand setExpire(Instant expire) { this.expire = expire; return this; } @@ -108,8 +130,8 @@ public class GarbageCollectCommand extends GitCommand<Properties> { * 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 * <code>true</code> 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. + * but every object is compressed again. Configuration variables pack.window + * and pack.depth are set to 250 for this GC. * * @since 3.6 * @param aggressive |