From 23b9693a75b899c97da8a04c0b531874b225d236 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 27 Mar 2023 22:23:11 +0200 Subject: DirCache: support option index.skipHash Support the new option index.skipHash which was introduced in git 2.40 [1]. If it is set to true skip computing the git index checksum. This accelerates Git commands that manipulate the index, such as git add, git commit, or git status. Instead of storing the checksum, write a trailing set of bytes with value zero, indicating that the computation was skipped. Accept a skipped checksum consisting of 20 null bytes when reading the index since the option could have been set to true at the time when the index was written. [1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-indexskipHash Bug: 581723 Change-Id: I28ebe44c5ca1cbcb882438665d686452a0c111b2 --- .../eclipse/jgit/dircache/DirCacheBasicTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'org.eclipse.jgit.test') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBasicTest.java index 0fca652906..618ccc0a0c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBasicTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBasicTest.java @@ -17,19 +17,48 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; +import java.io.IOException; import java.text.MessageFormat; +import java.util.Arrays; +import java.util.Collection; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.junit.MockSystemReader; import org.eclipse.jgit.junit.RepositoryTestCase; +import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectInserter; +import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.util.SystemReader; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +@RunWith(Parameterized.class) public class DirCacheBasicTest extends RepositoryTestCase { + @Parameter(0) + public boolean skipHash; + + @Parameters(name = "skipHash: {0}") + public static Collection getSkipHashValues() { + return Arrays + .asList(new Boolean[][] { { Boolean.TRUE }, + { Boolean.FALSE } }); + } + + @Before + public void setup() throws IOException { + FileBasedConfig cfg = db.getConfig(); + cfg.setBoolean(ConfigConstants.CONFIG_INDEX_SECTION, null, + ConfigConstants.CONFIG_KEY_SKIPHASH, skipHash); + cfg.save(); + } + @Test public void testReadMissing_RealIndex() throws Exception { final File idx = new File(db.getDirectory(), "index"); -- cgit v1.2.3