Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Add pack options to preserve and prune old pack files
  Allow to perform PackedBatchRefUpdate without locking loose refs
  Document option "core.sha1Implementation" introduced in 59029aec

Change-Id: I423f410578f5bbe178832b80fef8998a5372182c
This commit is contained in:
Matthias Sohn 2023-02-16 16:42:58 +01:00
commit c46eb91611
7 changed files with 148 additions and 11 deletions

View File

@ -42,6 +42,7 @@ For details on native git options see also the official [git config documentatio
| `core.precomposeUnicode` | `true` on Mac OS | ✅ | MacOS only. When `true`, JGit reverts the unicode decomposition of filenames done by Mac OS. |
| `core.quotePath` | `true` | ✅ | Commands that output paths (e.g. ls-files, diff), will quote "unusual" characters in the pathname by enclosing the pathname in double-quotes and escaping those characters with backslashes in the same way C escapes control characters (e.g. `\t` for TAB, `\n` for LF, `\\` for backslash) or bytes with values larger than `0x80` (e.g. octal `\302\265` for "micro" in UTF-8). |
| `core.repositoryFormatVersion` | `1` | ⃞ | Internal version identifying the repository format and layout version. Don't set manually. |
| `core.sha1Implementation` | `java` | ⃞ | Choose the SHA1 implementation used by JGit. Set it to `java` to use JGit's Java implementation which detects SHA1 collisions if system property `org.eclipse.jgit.util.sha1.detectCollision` is unset or `true`. Set it to `jdkNative` to use the native implementation available in the JDK, can also be set using system property `org.eclipse.jgit.util.sha1.implementation`. If both are set the system property takes precedence. Performance of `jdkNative` is around 10% higher than `java` when `detectCollision=false` and 30% higher when `detectCollision=true`.|
| `core.streamFileThreshold` | `50 MiB` | ⃞ | The size threshold beyond which objects must be streamed. |
| `core.supportsAtomicFileCreation` | `true` | ⃞ | Whether the filesystem supports atomic file creation. |
| `core.symlinks` | Auto detect if filesystem supports symlinks| ✅ | If false, symbolic links are checked out as small plain files that contain the link text. |
@ -99,8 +100,8 @@ Proxy configuration uses the standard Java mechanisms via class `java.net.ProxyS
| `pack.depth` | `50` | ✅ | Maximum depth of delta chain set up for the pack writer. |
| `pack.indexVersion` | `2` | ✅ | Pack index file format version. |
| `pack.minSizePreventRacyPack` | `100 MiB` | ⃞ | Minimum packfile size for which we wait before opening a newly written pack to prevent its lastModified timestamp could be racy if `pack.waitPreventRacyPack` is `true`. |
| `pack.preserveOldPacks` | `false` | ⃞ | Whether to preserve old packs in a preserved directory. |
| `prunePreserved`, only via API of PackConfig | `false` | ⃞ | Whether to remove preserved pack files in a preserved directory. |
| `pack.preserveOldPacks` | `false` | ⃞ | Whether to preserve old packs during gc in the `objects/pack/preserved` directory. This can avoid rare races between gc removing pack files and other concurrent operations. If this option is false data loss can occur in rare cases when an object is believed to be unreferenced when object repacking is running, and then garbage collection deletes it while another concurrent operation references this object shortly before garbage collection deletes it. When this happens, a new reference is created which points to a now missing object. |
| `pack.prunePreserved` | `false` | ⃞ | Whether to prune preserved pack files from the previous run of gc from the `objects/pack/preserved` directory. This helps to limit the additional storage space needed to preserve old packs when `pack.preserveOldPacks = true`. |
| `pack.reuseDeltas` | `true` |⃞ | Whether to reuse deltas existing in repository. |
| `pack.reuseObjects` | `true` | ⃞ | Whether to reuse existing objects representation in repository. |
| `pack.searchForReuseTimeout` | | ⃞ | Search for reuse phase timeout. Expressed as a `Duration`, i.e.: `50sec`. |

View File

@ -10,6 +10,7 @@
package org.eclipse.jgit.pgm;
import org.eclipse.jgit.api.GarbageCollectCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.TextProgressMonitor;
@ -21,20 +22,25 @@ class Gc extends TextBuiltin {
private boolean aggressive;
@Option(name = "--preserve-oldpacks", usage = "usage_PreserveOldPacks")
private boolean preserveOldPacks;
private Boolean preserveOldPacks;
@Option(name = "--prune-preserved", usage = "usage_PrunePreserved")
private boolean prunePreserved;
private Boolean prunePreserved;
/** {@inheritDoc} */
@Override
protected void run() {
Git git = Git.wrap(db);
try {
git.gc().setAggressive(aggressive)
.setPreserveOldPacks(preserveOldPacks)
.setPrunePreserved(prunePreserved)
.setProgressMonitor(new TextProgressMonitor(errw)).call();
GarbageCollectCommand command = git.gc().setAggressive(aggressive)
.setProgressMonitor(new TextProgressMonitor(errw));
if (preserveOldPacks != null) {
command.setPreserveOldPacks(preserveOldPacks.booleanValue());
}
if (prunePreserved != null) {
command.setPrunePreserved(prunePreserved.booleanValue());
}
command.call();
} catch (GitAPIException e) {
throw die(e.getMessage(), e);
}

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jgit" version="2">
<resource path="src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java" type="org.eclipse.jgit.errors.NoRemoteRepositoryException">
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.1"/>
<message_argument value="NoRemoteRepositoryException(URIish, String, Throwable)"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="CONFIG_KEY_BITMAP_EXCLUDED_REFS_PREFIXES"/>
</message_arguments>
</filter>
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="CONFIG_KEY_PRESERVE_OLD_PACKS"/>
</message_arguments>
</filter>
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="CONFIG_KEY_PRUNE_PRESERVED"/>
</message_arguments>
</filter>
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="SHA1_IMPLEMENTATION"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/lib/Repository.java" type="org.eclipse.jgit.lib.Repository">
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="getReflogReader(Ref)"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/storage/pack/PackConfig.java" type="org.eclipse.jgit.storage.pack.PackConfig">
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="DEFAULT_BITMAP_EXCLUDED_REFS_PREFIXES"/>
</message_arguments>
</filter>
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="getBitmapExcludedRefsPrefixes()"/>
</message_arguments>
</filter>
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="setBitmapExcludedRefsPrefixes(String[])"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/transport/AwsRequestSignerV4.java" type="org.eclipse.jgit.transport.AwsRequestSignerV4">
<filter id="1109393411">
<message_arguments>
<message_argument value="5.13.1"/>
<message_argument value="org.eclipse.jgit.transport.AwsRequestSignerV4"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/util/HttpSupport.java" type="org.eclipse.jgit.util.HttpSupport">
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.1"/>
<message_argument value="urlEncode(String, boolean)"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/jgit/util/sha1/SHA1.java" type="org.eclipse.jgit.util.sha1.SHA1$Sha1Implementation">
<filter id="1142947843">
<message_arguments>
<message_argument value="5.13.2"/>
<message_argument value="Sha1Implementation"/>
</message_arguments>
</filter>
</resource>
</component>

View File

@ -86,10 +86,16 @@
*/
class PackedBatchRefUpdate extends BatchRefUpdate {
private RefDirectory refdb;
private boolean shouldLockLooseRefs;
PackedBatchRefUpdate(RefDirectory refdb) {
super(refdb);
this.refdb = refdb;
this(refdb, true);
}
PackedBatchRefUpdate(RefDirectory refdb, boolean shouldLockLooseRefs) {
super(refdb);
this.refdb = refdb;
this.shouldLockLooseRefs = shouldLockLooseRefs;
}
/** {@inheritDoc} */
@ -155,7 +161,7 @@ public void execute(RevWalk walk, ProgressMonitor monitor,
refdb.inProcessPackedRefsLock.lock();
try {
PackedRefList oldPackedList;
if (!refdb.isInClone()) {
if (!refdb.isInClone() && shouldLockLooseRefs) {
locks = lockLooseRefs(pending);
if (locks == null) {
return;

View File

@ -587,6 +587,21 @@ public PackedBatchRefUpdate newBatchUpdate() {
return new PackedBatchRefUpdate(this);
}
/**
* Create a new batch update to attempt on this database.
*
* @param shouldLockLooseRefs
* whether loose refs should be locked during the batch ref
* update. Note that this should only be set to {@code false} if
* the application using this ensures that no other ref updates
* run concurrently to avoid lost updates caused by a race. In
* such cases it can improve performance.
* @return a new batch update object
*/
public PackedBatchRefUpdate newBatchUpdate(boolean shouldLockLooseRefs) {
return new PackedBatchRefUpdate(this, shouldLockLooseRefs);
}
/** {@inheritDoc} */
@Override
public boolean performsAtomicTransactions() {

View File

@ -771,4 +771,18 @@ public final class ConfigConstants {
*/
public static final String CONFIG_KEY_SEARCH_FOR_REUSE_TIMEOUT = "searchforreusetimeout";
/**
* The "pack.preserveOldPacks" key
*
* @since 5.13.2
*/
public static final String CONFIG_KEY_PRESERVE_OLD_PACKS = "preserveoldpacks";
/**
* The "pack.prunePreserved" key
*
* @since 5.13.2
*/
public static final String CONFIG_KEY_PRUNE_PRESERVED = "prunepreserved";
}

View File

@ -37,6 +37,8 @@
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WINDOW;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_WINDOW_MEMORY;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_PACK_SECTION;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PRESERVE_OLD_PACKS;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PRUNE_PRESERVED;
import java.time.Duration;
import java.util.concurrent.Executor;
@ -1267,6 +1269,10 @@ public void fromConfig(Config rc) {
setMinSizePreventRacyPack(rc.getLong(CONFIG_PACK_SECTION,
CONFIG_KEY_MIN_SIZE_PREVENT_RACYPACK,
getMinSizePreventRacyPack()));
setPreserveOldPacks(rc.getBoolean(CONFIG_PACK_SECTION,
CONFIG_KEY_PRESERVE_OLD_PACKS, DEFAULT_PRESERVE_OLD_PACKS));
setPrunePreserved(rc.getBoolean(CONFIG_PACK_SECTION,
CONFIG_KEY_PRUNE_PRESERVED, DEFAULT_PRUNE_PRESERVED));
}
/** {@inheritDoc} */