]> source.dussan.org Git - jgit.git/commitdiff
Add a setting for fsck to check connectivity only 17/111417/4
authorZhen Chen <czhen@google.com>
Sat, 11 Nov 2017 00:05:28 +0000 (16:05 -0800)
committerZhen Chen <czhen@google.com>
Sat, 11 Nov 2017 00:33:28 +0000 (19:33 -0500)
The object checks may take a long time and sometimes we are only
interested in connectivity check.

This is similar to 'git fsck --connectivity-only'.

Change-Id: I654e8fdccdb16d796f920088429d188cc96734bc
Signed-off-by: Zhen Chen <czhen@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsFsck.java

index daaa2208406e60f1d25892623e0f7e70be6fb590..97cdc14dfbe3aca89a075e42622ad576855b4ce1 100644 (file)
@@ -69,6 +69,7 @@ public class DfsFsck {
        private final DfsRepository repo;
        private final DfsObjDatabase objdb;
        private ObjectChecker objChecker = new ObjectChecker();
+       private boolean connectivityOnly;
 
        /**
         * Initialize DFS fsck.
@@ -97,7 +98,9 @@ public class DfsFsck {
                }
 
                FsckError errors = new FsckError();
-               checkPacks(pm, errors);
+               if (!connectivityOnly) {
+                       checkPacks(pm, errors);
+               }
                checkConnectivity(pm, errors);
                return errors;
        }
@@ -174,4 +177,14 @@ public class DfsFsck {
        public void setObjectChecker(ObjectChecker objChecker) {
                this.objChecker = objChecker;
        }
+
+       /**
+        * @param connectivityOnly
+        *             whether fsck should bypass object validity and integrity
+        *             checks and only check connectivity. The default is
+        *             {@code false}, meaning to run all checks.
+        */
+       public void setConnectivityOnly(boolean connectivityOnly) {
+               this.connectivityOnly = connectivityOnly;
+       }
 }