git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter

From
Halstrick, Christian <christian.halstrick@sap.com>
Date
Sep 23, 2009, 16:42 UTC
Message-ID
<D35B4A582834DC418CCF9AF41AB69B70016953F62F@DEWDFECCR04.wdf.sap.corp>
From: Christian Halstrick <christian.halstrick@sap.com>
JGit should understand configuration parameter logAllRefUpdates and should
only log updates of refs when
  either the log file for this ref is already present
  or this configuration parameter is set to true
Before this commit JGit was always writing logs, regardless of this
parameter or existence of logfiles.
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
---
 .../src/org/spearce/jgit/lib/CoreConfig.java       |   10 ++++++++++
 .../src/org/spearce/jgit/lib/RefLogWriter.java     |   18 ++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java
index ed3827b..ecd9544 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java
@@ -56,10 +56,13 @@ public CoreConfig parse(final Config cfg) {
 	private final int compression;
 
 	private final int packIndexVersion;
+	
+	private final boolean logAllRefUpdates;
 
 	private CoreConfig(final Config rc) {
 		compression = rc.getInt("core", "compression", DEFAULT_COMPRESSION);
 		packIndexVersion = rc.getInt("pack", "indexversion", 2);
+		logAllRefUpdates = rc.getBoolean("core", "logAllRefUpdates", false);
 	}
 
 	/**
@@ -77,4 +80,11 @@ public int getCompression() {
 	public int getPackIndexVersion() {
 		return packIndexVersion;
 	}
+	
+	/**
+	 * @return whether to log all refUpdates 
+	 */
+	public boolean isLogAllRefUpdates() {
+		return logAllRefUpdates;
+	}
 }
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java
index 4aad809..1e5155c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java
@@ -112,16 +112,18 @@ private static void appendOneRecord(final ObjectId oldId,
 		final byte[] rec = Constants.encode(r.toString());
 		final File logdir = new File(db.getDirectory(), Constants.LOGS);
 		final File reflog = new File(logdir, refName);
-		final File refdir = reflog.getParentFile();
+		if (reflog.exists() || db.getConfig().getCore().isLogAllRefUpdates()) {
+			final File refdir = reflog.getParentFile();
 
-		if (!refdir.exists() && !refdir.mkdirs())
-			throw new IOException("Cannot create directory " + refdir);
+			if (!refdir.exists() && !refdir.mkdirs())
+				throw new IOException("Cannot create directory " + refdir);
 
-		final FileOutputStream out = new FileOutputStream(reflog, true);
-		try {
-			out.write(rec);
-		} finally {
-			out.close();
+			final FileOutputStream out = new FileOutputStream(reflog, true);
+			try {
+				out.write(rec);
+			} finally {
+				out.close();
+			}
 		}
 	}
 
-- 
1.6.4.msysgit.0
Next: Robin Rosenberg
Message 1 of 3 in “add support for core.logAllRefUpdates configuration parameter”
  1. 1/2 add support for core.logAllRefUpdates configuration parameterHalstrick, Christian, Sep 23, 2009
  2. Robin RosenbergSep 25, 2009
  3. Robin RosenbergSep 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.