enableReceivePack();
- db.getConfig().setInt("core", null, "compression", 0);
- db.getConfig().setInt("http", null, "postbuffer", 8 * 1024);
- db.getConfig().save();
+ final FileBasedConfig cfg = db.getConfig();
+ cfg.setInt("core", null, "compression", 0);
+ cfg.setInt("http", null, "postbuffer", 8 * 1024);
+ cfg.save();
t = Transport.open(db, remoteURI);
try {
import org.eclipse.jgit.lib.WorkDirCheckout;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
dst = new FileRepository(gitdir);
dst.create();
- dst.getConfig().setBoolean("core", null, "bare", false);
- dst.getConfig().save();
+ final FileBasedConfig dstcfg = dst.getConfig();
+ dstcfg.setBoolean("core", null, "bare", false);
+ dstcfg.save();
db = dst;
out.print(MessageFormat.format(
private void saveRemote(final URIish uri) throws URISyntaxException,
IOException {
- final RemoteConfig rc = new RemoteConfig(dst.getConfig(), remoteName);
+ final FileBasedConfig dstcfg = dst.getConfig();
+ final RemoteConfig rc = new RemoteConfig(dstcfg, remoteName);
rc.addURI(uri);
rc.addFetchRefSpec(new RefSpec().setForceUpdate(true)
.setSourceDestination(Constants.R_HEADS + "*",
Constants.R_REMOTES + remoteName + "/*"));
- rc.update(dst.getConfig());
- dst.getConfig().save();
+ rc.update(dstcfg);
+ dstcfg.save();
}
private FetchResult runFetch() throws NotSupportedException,
workdir.mkdir();
FileRepository repo1initial = new FileRepository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create();
- repo1initial.getConfig().setString("core", null, "worktree",
- workdir.getAbsolutePath());
- repo1initial.getConfig().save();
+ final FileBasedConfig cfg = repo1initial.getConfig();
+ cfg.setString("core", null, "worktree", workdir.getAbsolutePath());
+ cfg.save();
repo1initial.close();
File theDir = new File(repo1Parent, Constants.DOT_GIT);
workdir.mkdir();
FileRepository repo1initial = new FileRepository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create();
- repo1initial.getConfig()
- .setString("core", null, "worktree", "../../rw");
- repo1initial.getConfig().save();
+ final FileBasedConfig cfg = repo1initial.getConfig();
+ cfg.setString("core", null, "worktree", "../../rw");
+ cfg.save();
repo1initial.close();
File theDir = new File(repo1Parent, Constants.DOT_GIT);
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
String shortenedName = fullName
.substring(Constants.R_HEADS.length());
// remove upstream configuration if any
- repo.getConfig().unsetSection(
+ final StoredConfig cfg = repo.getConfig();
+ cfg.unsetSection(
ConfigConstants.CONFIG_BRANCH_SECTION,
shortenedName);
- repo.getConfig().save();
+ cfg.save();
}
} else
throw new JGitInternalException(MessageFormat.format(
String remoteUri;
FetchResult fetchRes;
if (isRemote) {
- remoteUri = repo.getConfig().getString("remote", remote,
+ remoteUri = repoConfig.getString("remote", remote,
ConfigConstants.CONFIG_KEY_URL);
if (remoteUri == null) {
String missingKey = ConfigConstants.CONFIG_REMOTE_SECTION + DOT
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefRename;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.RefUpdate.Result;
/**
// move the upstream configuration over to the new branch
String shortOldName = fullOldName
.substring(Constants.R_HEADS.length());
- String oldRemote = repo.getConfig().getString(
+ final StoredConfig repoConfig = repo.getConfig();
+ String oldRemote = repoConfig.getString(
ConfigConstants.CONFIG_BRANCH_SECTION,
shortOldName, ConfigConstants.CONFIG_KEY_REMOTE);
if (oldRemote != null) {
- repo.getConfig().setString(
+ repoConfig.setString(
ConfigConstants.CONFIG_BRANCH_SECTION, newName,
ConfigConstants.CONFIG_KEY_REMOTE, oldRemote);
}
- String oldMerge = repo.getConfig().getString(
+ String oldMerge = repoConfig.getString(
ConfigConstants.CONFIG_BRANCH_SECTION,
shortOldName, ConfigConstants.CONFIG_KEY_MERGE);
if (oldMerge != null) {
- repo.getConfig().setString(
+ repoConfig.setString(
ConfigConstants.CONFIG_BRANCH_SECTION, newName,
ConfigConstants.CONFIG_KEY_MERGE, oldMerge);
}
- repo.getConfig()
+ repoConfig
.unsetSection(
ConfigConstants.CONFIG_BRANCH_SECTION,
shortOldName);
- repo.getConfig().save();
+ repoConfig.save();
}
} else
loadUserConfig();
loadRepoConfig();
- getConfig().addChangeListener(new ConfigChangedListener() {
+ repoConfig.addChangeListener(new ConfigChangedListener() {
public void onConfigChanged(ConfigChangedEvent event) {
fireEvent(event);
}