From 695e38a83bafbc5477c326050e39b1b63ea0f5f0 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 21 Jun 2017 15:23:03 -0400 Subject: [PATCH] Add a test for parsing fsck config options and expose FsckMode enum These config options allow overriding the message type (error, warn or ignore) of a specific message ID such as missingEmail. The supported fsck message IDs are defined in ObjectChecker.ErrorType. Since TransferConfig.FsckMode wasn't public parsing fsck configuration options like e.g. fsck.missingEmail=ignore failed with an IllegalAccessException. Fix this by declaring this enum public. Change-Id: I3f41ff7a76a846250a63ce92a9fd111eb347269f Signed-off-by: David Turner Signed-off-by: Matthias Sohn --- .../org/eclipse/jgit/api/PushCommandTest.java | 5 +++++ .../jgit/transport/TransferConfig.java | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java index 8c613ec48..e0c149903 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java @@ -83,6 +83,11 @@ public class PushCommandTest extends RepositoryTestCase { // create other repository Repository db2 = createWorkRepository(); + final StoredConfig config2 = db2.getConfig(); + + // this tests that this config can be parsed properly + config2.setString("fsck", "", "missingEmail", "ignore"); + config2.save(); // setup the first repository final StoredConfig config = db.getConfig(); 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 2198b50f0..d4cd1c367 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java @@ -76,8 +76,24 @@ public class TransferConfig { } }; - enum FsckMode { - ERROR, WARN, IGNORE; + /** + * A git configuration value for how to handle a fsck failure of a particular kind. + * Used in e.g. fsck.missingEmail. + * @since 4.9 + */ + public enum FsckMode { + /** + * Treat it as an error (the default). + */ + ERROR, + /** + * Issue a warning (in fact, jgit treats this like IGNORE, but git itself does warn). + */ + WARN, + /** + * Ignore the error. + */ + IGNORE; } private final boolean fetchFsck;