From 3e624306dea4de6f7a78a7bcf34a57882f731a2d Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Wed, 10 Jan 2024 19:38:46 +0000 Subject: Allow to discover bitmap on disk created after the packfile When the bitmap file was created *after* a packfile had been loaded into the memory, JGit was unable to discover them. That happed because of two problems: 1. The PackDirectory.getPacks() does not implement the usual while loop that is scanning through the packs directory as in the other parts of JGit. 2. The scan packs does not look for newly created bitmap files if the packfile is already loaded in memory. Implement the normal packfiles scanning whenever the PackDirectory needs to return a list of packs, and make sure that any reused Pack object would have its associated bitmap properly refreshed from disk. Adapt the assertions in GcConcurrentTest with the rescanned list of Pack from the objects/packs directory. Bug: jgit-15 Change-Id: I2ed576cefd78a0e128b175228a59c9af51523d7b --- .../jgit/internal/storage/file/GcConcurrentTest.java | 11 +++++------ .../org/eclipse/jgit/internal/JGitText.properties | 2 ++ .../src/org/eclipse/jgit/internal/JGitText.java | 2 ++ .../org/eclipse/jgit/internal/storage/file/Pack.java | 13 +++++++++++++ .../jgit/internal/storage/file/PackDirectory.java | 18 ++++++++++++++---- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java index 1519873b62..96a064989b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java @@ -186,13 +186,12 @@ public class GcConcurrentTest extends GcTestCase { // make sure gc() has caused creation of a new packfile assertNotEquals(oldPackName, newPackName); - // Even when asking again for the set of packfiles outdated data - // will be returned. As long as the repository can work on cached data - // it will do so and not detect that a new packfile exists. - assertNotEquals(getSinglePack(repository).getPackName(), newPackName); + // When asking again for the set of packfiles the new updated data + // will be returned because of the rescan of the pack directory. + assertEquals(getSinglePack(repository).getPackName(), newPackName); - // Only when accessing object content it is required to rescan the pack - // directory and the new packfile will be detected. + // When accessing object content the new packfile refreshed from + // the rescan triggered from the list of packs. repository.getObjectDatabase().open(b).getSize(); assertEquals(getSinglePack(repository).getPackName(), newPackName); assertNotNull(getSinglePack(repository).getBitmapIndex()); diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index 45a67947f1..eabb0c6fa4 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -64,6 +64,8 @@ binaryHunkDecodeError=Binary hunk, line {0}: invalid input binaryHunkInvalidLength=Binary hunk, line {0}: input corrupt; expected length byte, got 0x{1} binaryHunkLineTooShort=Binary hunk, line {0}: input ended prematurely binaryHunkMissingNewline=Binary hunk, line {0}: input line not terminated by newline +bitmapAccessErrorForPackfile=Error whilst trying to access bitmap file for {} +bitmapFailedToGet=Failed to get bitmap index file {} bitmapMissingObject=Bitmap at {0} is missing {1}. bitmapsMustBePrepared=Bitmaps must be prepared before they may be written. blameNotCommittedYet=Not Committed Yet diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index c7cad43d96..1d5a2e1f6b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@ -93,6 +93,8 @@ public class JGitText extends TranslationBundle { /***/ public String binaryHunkInvalidLength; /***/ public String binaryHunkLineTooShort; /***/ public String binaryHunkMissingNewline; + /***/ public String bitmapAccessErrorForPackfile; + /***/ public String bitmapFailedToGet; /***/ public String bitmapMissingObject; /***/ public String bitmapsMustBePrepared; /***/ public String blameNotCommittedYet; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java index d6c25b2587..7d39b1fbcc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java @@ -1160,6 +1160,19 @@ public class Pack implements Iterable { return bitmapIdx; } + synchronized void refreshBitmapIndex(PackFile bitmapIndexFile) { + this.bitmapIdx = null; + this.invalid = false; + this.bitmapIdxFile = bitmapIndexFile; + try { + getBitmapIndex(); + } catch (IOException e) { + LOG.warn(JGitText.get().bitmapFailedToGet, bitmapIdxFile, e); + this.bitmapIdx = null; + this.bitmapIdxFile = null; + } + } + private synchronized PackReverseIndex getReverseIdx() throws IOException { if (reverseIdx == null) reverseIdx = new PackReverseIndex(idx()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java index 6a99cb3d83..1676d8bc18 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java @@ -115,10 +115,13 @@ class PackDirectory { } Collection getPacks() { - PackList list = packList.get(); - if (list == NO_PACKS) { - list = scanPacks(list); - } + PackList list; + do { + list = packList.get(); + if (list == NO_PACKS) { + list = scanPacks(list); + } + } while (searchPacksAgain(list)); Pack[] packs = list.packs; return Collections.unmodifiableCollection(Arrays.asList(packs)); } @@ -455,6 +458,13 @@ class PackDirectory { && !oldPack.getFileSnapshot().isModified(packFile)) { forReuse.remove(packFile.getName()); list.add(oldPack); + try { + if(oldPack.getBitmapIndex() == null) { + oldPack.refreshBitmapIndex(packFilesByExt.get(BITMAP_INDEX)); + } + } catch (IOException e) { + LOG.warn(JGitText.get().bitmapAccessErrorForPackfile, oldPack.getPackName(), e); + } continue; } -- cgit v1.2.3 From 89bf38087a9e9a0536742f5d9d408856e5ad2dc7 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 21 Feb 2024 16:43:43 +0100 Subject: Delete org.eclipse.jgit.ssh.apache.agent/bin/.project Change-Id: If2f50f81ffb8b5a1929b0ce403bff017ece29e2f --- org.eclipse.jgit.ssh.apache.agent/bin/.project | 28 -------------------------- 1 file changed, 28 deletions(-) delete mode 100644 org.eclipse.jgit.ssh.apache.agent/bin/.project diff --git a/org.eclipse.jgit.ssh.apache.agent/bin/.project b/org.eclipse.jgit.ssh.apache.agent/bin/.project deleted file mode 100644 index 73358f4a6b..0000000000 --- a/org.eclipse.jgit.ssh.apache.agent/bin/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jgit.ssh.apache.agent - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - -- cgit v1.2.3