Browse Source

Use CoreConfig, UserConfig and TransferConfig directly

Rather than relying on the helpers in RepositoryConfig to get
these objects, obtain them directly through the Config API.
Its only slightly more verbose, but permits us to work with the
base Config class, which is more flexible than the highly file
specific RepositoryConfig.

This is what I really meant to do when I added the section parser
and caching support to Config, we just failed to finish updating
all of the call sites.

Change-Id: I481cb365aa00bfa8c21e5ad0cd367ddd9c6c0edd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
e1b312b5f7
  1. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
  2. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java
  3. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java
  5. 2
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java
  6. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java
  7. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java

@ -49,6 +49,7 @@ import java.io.File;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import org.eclipse.jgit.lib.CoreConfig;
import org.eclipse.jgit.lib.TextProgressMonitor;
class IndexPack extends TextBuiltin {
@ -64,7 +65,8 @@ class IndexPack extends TextBuiltin {
@Override
protected void run() throws Exception {
if (indexVersion == -1)
indexVersion = db.getConfig().getCore().getPackIndexVersion();
indexVersion = db.getConfig().get(CoreConfig.KEY)
.getPackIndexVersion();
final BufferedInputStream in;
final org.eclipse.jgit.transport.IndexPack ip;
in = new BufferedInputStream(System.in);

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java

@ -70,7 +70,7 @@ public class ReflogConfigTest extends RepositoryTestCase {
// set the logAllRefUpdates parameter to true and check it
db.getConfig().setBoolean("core", null, "logallrefupdates", true);
assertTrue(db.getConfig().getCore().isLogAllRefUpdates());
assertTrue(db.getConfig().get(CoreConfig.KEY).isLogAllRefUpdates());
// do one commit and check that reflog size is increased to 1
addFileToTree(t, "i-am-another-file", "and this is other data in me\n");
@ -83,7 +83,7 @@ public class ReflogConfigTest extends RepositoryTestCase {
// set the logAllRefUpdates parameter to false and check it
db.getConfig().setBoolean("core", null, "logallrefupdates", false);
assertFalse(db.getConfig().getCore().isLogAllRefUpdates());
assertFalse(db.getConfig().get(CoreConfig.KEY).isLogAllRefUpdates());
// do one commit and check that reflog size is 2
addFileToTree(t, "i-am-anotheranother-file",

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java

@ -238,8 +238,10 @@ public class PackWriter {
this.db = repo;
initMonitor = imonitor == null ? NullProgressMonitor.INSTANCE : imonitor;
writeMonitor = wmonitor == null ? NullProgressMonitor.INSTANCE : wmonitor;
this.deflater = new Deflater(db.getConfig().getCore().getCompression());
outputVersion = repo.getConfig().getCore().getPackIndexVersion();
final CoreConfig coreConfig = db.getConfig().get(CoreConfig.KEY);
this.deflater = new Deflater(coreConfig.getCompression());
outputVersion = coreConfig.getPackIndexVersion();
}
/**

2
org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java

@ -77,7 +77,7 @@ public class PersonIdent {
* @param repo
*/
public PersonIdent(final Repository repo) {
final RepositoryConfig config = repo.getConfig();
final UserConfig config = repo.getConfig().get(UserConfig.KEY);
name = config.getCommitterName();
emailAddress = config.getCommitterEmail();
when = SystemReader.getInstance().getCurrentTime();

2
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java

@ -590,7 +590,7 @@ public class RefDirectory extends RefDatabase {
}
private boolean isLogAllRefUpdates() {
return parent.getConfig().getCore().isLogAllRefUpdates();
return parent.getConfig().get(CoreConfig.KEY).isLogAllRefUpdates();
}
private boolean shouldAutoCreateLog(final String refName) {

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/IndexPack.java

@ -67,6 +67,7 @@ import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.BinaryDelta;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.CoreConfig;
import org.eclipse.jgit.lib.InflaterCache;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.ObjectChecker;
@ -127,7 +128,8 @@ public class IndexPack {
base = new File(objdir, n.substring(0, n.length() - suffix.length()));
final IndexPack ip = new IndexPack(db, is, base);
ip.setIndexVersion(db.getConfig().getCore().getPackIndexVersion());
ip.setIndexVersion(db.getConfig().get(CoreConfig.KEY)
.getPackIndexVersion());
return ip;
}

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java

@ -566,7 +566,7 @@ public abstract class Transport {
* URI passed to {@link #open(Repository, URIish)}.
*/
protected Transport(final Repository local, final URIish uri) {
final TransferConfig tc = local.getConfig().getTransfer();
final TransferConfig tc = local.getConfig().get(TransferConfig.KEY);
this.local = local;
this.uri = uri;
this.checkFetchedObjects = tc.isFsckObjects();

Loading…
Cancel
Save