]> source.dussan.org Git - jgit.git/commitdiff
DfsObjDatabase: clear PackList dirty bit if no new packs 74/79374/2
authorShawn Pearce <spearce@spearce.org>
Fri, 19 Aug 2016 18:51:40 +0000 (11:51 -0700)
committerShawn Pearce <spearce@spearce.org>
Fri, 19 Aug 2016 19:06:03 +0000 (12:06 -0700)
If a reference was updated more recently than a pack was written
(typical) the PackList was perpetually dirty until the next GC
was completed for the repository.

Detect this condition by observing no changes to the PackList
membership and resetting the dirty bit.

Change-Id: Ie2133aca1f8083307c73b6a26358175864f100ef

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java

index f6e4c2391a4fbb3318709c891ce6eb6ddf438712..b1d6c0dd190a000cfd9370e003d8deaa3eafa4f5 100644 (file)
@@ -67,6 +67,11 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
                        return true;
                }
 
+               @Override
+               void clearDirty() {
+                       // Always dirty.
+               }
+
                @Override
                public void markDirty() {
                        // Always dirty.
@@ -443,8 +448,10 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
                        p.close();
                if (list.isEmpty())
                        return new PackListImpl(NO_PACKS.packs);
-               if (!foundNew)
+               if (!foundNew) {
+                       old.clearDirty();
                        return old;
+               }
                return new PackListImpl(list.toArray(new DfsPackFile[list.size()]));
        }
 
@@ -514,6 +521,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
                }
 
                abstract boolean dirty();
+               abstract void clearDirty();
 
                /**
                 * Mark pack list as dirty.
@@ -537,6 +545,11 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
                        return dirty;
                }
 
+               @Override
+               void clearDirty() {
+                       dirty = false;
+               }
+
                @Override
                public void markDirty() {
                        dirty = true;