From 0ff5ff01121617e4bcdda25e67da46f71dcbc85c Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 9 Mar 2011 16:45:06 +0100 Subject: [PATCH] Enable git reflog for all newly created projects Gerrit changed it's behavior with JGit commit ffc8b42957a2f294960d5ad027e2c7e41d3f70cd and since then sets core.logallrefupdates = false for new projects. Prior to that change Gerrit did set core.logallrefupdates = true for newly created projects. Reverting to the old behavior as being able to inspect the reflog is desirable. Change-Id: If6ffa8c98658c996a01811ccaa8823c7042af08a Signed-off-by: Matthias Sohn --- .../com/google/gerrit/sshd/commands/CreateProject.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateProject.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateProject.java index e353ba6581..f8e4452897 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateProject.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateProject.java @@ -34,6 +34,7 @@ import com.google.inject.Inject; import org.apache.sshd.server.Environment; import org.eclipse.jgit.lib.CommitBuilder; +import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; @@ -41,6 +42,7 @@ import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RefUpdate.Result; +import org.eclipse.jgit.lib.StoredConfig; import org.kohsuke.args4j.Option; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -139,6 +141,11 @@ final class CreateProject extends BaseCommand { try { repo.create(true); + StoredConfig config = repo.getConfig(); + config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, + null, ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, true); + config.save(); + RefUpdate u = repo.updateRef(Constants.HEAD); u.disableRefLog(); u.link(branch);