diff options
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java | 45 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java | 40 |
2 files changed, 36 insertions, 49 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index c224d8eeb8..728643e925 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -293,18 +293,20 @@ public abstract class BaseReceivePack { db = into; walk = new RevWalk(db); - final ReceiveConfig cfg = db.getConfig().get(ReceiveConfig.KEY); - objectChecker = cfg.newObjectChecker(); - allowCreates = cfg.allowCreates; + TransferConfig tc = db.getConfig().get(TransferConfig.KEY); + objectChecker = tc.newReceiveObjectChecker(); + + ReceiveConfig rc = db.getConfig().get(ReceiveConfig.KEY); + allowCreates = rc.allowCreates; allowAnyDeletes = true; - allowBranchDeletes = cfg.allowDeletes; - allowNonFastForwards = cfg.allowNonFastForwards; - allowOfsDelta = cfg.allowOfsDelta; + allowBranchDeletes = rc.allowDeletes; + allowNonFastForwards = rc.allowNonFastForwards; + allowOfsDelta = rc.allowOfsDelta; advertiseRefsHook = AdvertiseRefsHook.DEFAULT; refFilter = RefFilter.DEFAULT; advertisedHaves = new HashSet<ObjectId>(); clientShallowCommits = new HashSet<ObjectId>(); - signedPushConfig = cfg.signedPush; + signedPushConfig = rc.signedPush; } /** Configuration for receive operations. */ @@ -315,32 +317,13 @@ public abstract class BaseReceivePack { } }; - final boolean checkReceivedObjects; - final boolean allowLeadingZeroFileMode; - final boolean allowInvalidPersonIdent; - final boolean safeForWindows; - final boolean safeForMacOS; - final boolean allowCreates; final boolean allowDeletes; final boolean allowNonFastForwards; final boolean allowOfsDelta; - final SignedPushConfig signedPush; ReceiveConfig(final Config config) { - checkReceivedObjects = config.getBoolean( - "receive", "fsckobjects", //$NON-NLS-1$ //$NON-NLS-2$ - config.getBoolean("transfer", "fsckobjects", false)); //$NON-NLS-1$ //$NON-NLS-2$ - allowLeadingZeroFileMode = checkReceivedObjects - && config.getBoolean("fsck", "allowLeadingZeroFileMode", false); //$NON-NLS-1$ //$NON-NLS-2$ - allowInvalidPersonIdent = checkReceivedObjects - && config.getBoolean("fsck", "allowInvalidPersonIdent", false); //$NON-NLS-1$ //$NON-NLS-2$ - safeForWindows = checkReceivedObjects - && config.getBoolean("fsck", "safeForWindows", false); //$NON-NLS-1$ //$NON-NLS-2$ - safeForMacOS = checkReceivedObjects - && config.getBoolean("fsck", "safeForMacOS", false); //$NON-NLS-1$ //$NON-NLS-2$ - allowCreates = true; allowDeletes = !config.getBoolean("receive", "denydeletes", false); //$NON-NLS-1$ //$NON-NLS-2$ allowNonFastForwards = !config.getBoolean("receive", //$NON-NLS-1$ @@ -349,16 +332,6 @@ public abstract class BaseReceivePack { true); signedPush = SignedPushConfig.KEY.parse(config); } - - ObjectChecker newObjectChecker() { - if (!checkReceivedObjects) - return null; - return new ObjectChecker() - .setAllowLeadingZeroFileMode(allowLeadingZeroFileMode) - .setAllowInvalidPersonIdent(allowInvalidPersonIdent) - .setSafeForWindows(safeForWindows) - .setSafeForMacOS(safeForMacOS); - } } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java index f0c513427a..f9b74c84e5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.transport; import java.util.HashMap; import java.util.Map; +import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config.SectionParser; import org.eclipse.jgit.lib.ObjectChecker; @@ -65,7 +66,8 @@ public class TransferConfig { } }; - private final boolean checkReceivedObjects; + private final boolean fetchFsck; + private final boolean receiveFsck; private final boolean allowLeadingZeroFileMode; private final boolean allowInvalidPersonIdent; private final boolean safeForWindows; @@ -79,18 +81,14 @@ public class TransferConfig { } TransferConfig(final Config rc) { - checkReceivedObjects = rc.getBoolean( - "fetch", "fsckobjects", //$NON-NLS-1$ //$NON-NLS-2$ - rc.getBoolean("transfer", "fsckobjects", false)); //$NON-NLS-1$ //$NON-NLS-2$ - allowLeadingZeroFileMode = checkReceivedObjects - && rc.getBoolean("fsck", "allowLeadingZeroFileMode", false); //$NON-NLS-1$ //$NON-NLS-2$ - allowInvalidPersonIdent = checkReceivedObjects - && rc.getBoolean("fsck", "allowInvalidPersonIdent", false); //$NON-NLS-1$ //$NON-NLS-2$ - safeForWindows = checkReceivedObjects - && rc.getBoolean("fsck", "safeForWindows", //$NON-NLS-1$ //$NON-NLS-2$ + boolean fsck = rc.getBoolean("transfer", "fsckobjects", false); //$NON-NLS-1$ //$NON-NLS-2$ + fetchFsck = rc.getBoolean("fetch", "fsckobjects", fsck); //$NON-NLS-1$ //$NON-NLS-2$ + receiveFsck = rc.getBoolean("receive", "fsckobjects", fsck); //$NON-NLS-1$ //$NON-NLS-2$ + allowLeadingZeroFileMode = rc.getBoolean("fsck", "allowLeadingZeroFileMode", false); //$NON-NLS-1$ //$NON-NLS-2$ + allowInvalidPersonIdent = rc.getBoolean("fsck", "allowInvalidPersonIdent", false); //$NON-NLS-1$ //$NON-NLS-2$ + safeForWindows = rc.getBoolean("fsck", "safeForWindows", //$NON-NLS-1$ //$NON-NLS-2$ SystemReader.getInstance().isWindows()); - safeForMacOS = checkReceivedObjects - && rc.getBoolean("fsck", "safeForMacOS", //$NON-NLS-1$ //$NON-NLS-2$ + safeForMacOS = rc.getBoolean("fsck", "safeForMacOS", //$NON-NLS-1$ //$NON-NLS-2$ SystemReader.getInstance().isMacOS()); allowTipSha1InWant = rc.getBoolean( @@ -105,9 +103,25 @@ public class TransferConfig { * enabled in the repository configuration. * @since 3.6 */ + @Nullable public ObjectChecker newObjectChecker() { - if (!checkReceivedObjects) + return newObjectChecker(fetchFsck); + } + + /** + * @return checker to verify objects pushed into this repository, or null if + * checking is not enabled in the repository configuration. + * @since 4.2 + */ + @Nullable + public ObjectChecker newReceiveObjectChecker() { + return newObjectChecker(receiveFsck); + } + + private ObjectChecker newObjectChecker(boolean check) { + if (!check) { return null; + } return new ObjectChecker() .setAllowLeadingZeroFileMode(allowLeadingZeroFileMode) .setAllowInvalidPersonIdent(allowInvalidPersonIdent) |