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. */
}
};
- 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$
true);
signedPush = SignedPushConfig.KEY.parse(config);
}
-
- ObjectChecker newObjectChecker() {
- if (!checkReceivedObjects)
- return null;
- return new ObjectChecker()
- .setAllowLeadingZeroFileMode(allowLeadingZeroFileMode)
- .setAllowInvalidPersonIdent(allowInvalidPersonIdent)
- .setSafeForWindows(safeForWindows)
- .setSafeForMacOS(safeForMacOS);
- }
}
/**
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;
}
};
- private final boolean checkReceivedObjects;
+ private final boolean fetchFsck;
+ private final boolean receiveFsck;
private final boolean allowLeadingZeroFileMode;
private final boolean allowInvalidPersonIdent;
private final boolean safeForWindows;
}
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(
* 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)