summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-02-21 17:55:22 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2024-02-21 17:55:22 +0100
commit9377d3190d668827a24a5ff0c7ad9eeacb19bb7d (patch)
tree28adbf22e0d1cf8c0b28bf484c53c0388c5db15c
parentf1c39fb6ea015ca103fd587e810c55100a984d16 (diff)
parent7ba0cfa0c1c91838af9dc1b551b73ae2c4dc40ef (diff)
downloadjgit-9377d3190d668827a24a5ff0c7ad9eeacb19bb7d.tar.gz
jgit-9377d3190d668827a24a5ff0c7ad9eeacb19bb7d.zip
Merge branch 'stable-6.7' into stable-6.8
* stable-6.7: Delete org.eclipse.jgit.ssh.apache.agent/bin/.project Allow to discover bitmap on disk created after the packfile Change-Id: I01749bae6f46d1a8ebd25b890e667cc092f3a659
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcConcurrentTest.java11
-rw-r--r--org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/Pack.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java18
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 c54c811b57..19c90086aa 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.
bitmapUseNoopNoListener=Use NOOP instance for no listener
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 b7175508ee..700b54a7a6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -94,6 +94,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 bitmapUseNoopNoListener;
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 4f1d348844..333967c5e5 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
@@ -1177,6 +1177,19 @@ public class Pack implements Iterable<PackIndex.MutableEntry> {
return null;
}
+ synchronized void refreshBitmapIndex(PackFile bitmapIndexFile) {
+ this.bitmapIdx = Optionally.empty();
+ this.invalid = false;
+ this.bitmapIdxFile = bitmapIndexFile;
+ try {
+ getBitmapIndex();
+ } catch (IOException e) {
+ LOG.warn(JGitText.get().bitmapFailedToGet, bitmapIdxFile, e);
+ this.bitmapIdx = Optionally.empty();
+ this.bitmapIdxFile = null;
+ }
+ }
+
private synchronized PackReverseIndex getReverseIdx() throws IOException {
if (invalid) {
throw new PackInvalidException(packFile, invalidatingCause);
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 b1da1cb159..8221cff442 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
@@ -118,10 +118,13 @@ class PackDirectory {
}
Collection<Pack> 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));
}
@@ -457,6 +460,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;
}