git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter
@ 2009-09-23 16:42 Halstrick, Christian
  2009-09-25 22:45 ` Robin Rosenberg
  0 siblings, 1 reply; 3+ messages in thread
From: Halstrick, Christian @ 2009-09-23 16:42 UTC (permalink / raw
  To: Shawn O. Pearce, Robin Rosenberg; +Cc: git@vger.kernel.org

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter
  2009-09-23 16:42 [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter Halstrick, Christian
@ 2009-09-25 22:45 ` Robin Rosenberg
  2009-09-25 22:52   ` Robin Rosenberg
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Rosenberg @ 2009-09-25 22:45 UTC (permalink / raw
  To: Halstrick, Christian; +Cc: Shawn O. Pearce, git@vger.kernel.org

onsdag 23 september 2009 18:42:29 skrev "Halstrick, Christian" <christian.halstrick@sap.com>:
> 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.

A few minor things:
Format the comment nicely and space betwee paragraphs.
Start the comment with a capital letter
A cover letter for multiple patches is nice, though in this case you could
actually just squash there patches into one patch.

and one major.
RefUpdateTest broke.

Probably because of this.
> +		logAllRefUpdates = rc.getBoolean("core", "logAllRefUpdates", false);

According to the git-config man page logAllRefUpdates is true by default for non-bare
repos and false for bare repos.

I had some trouble applying these patches as git-am did not like them. Apparently
git-am doesn't like base64. Could you set your mailer to use a more plain-ish format
or use git-send-email. 

-- robin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter
  2009-09-25 22:45 ` Robin Rosenberg
@ 2009-09-25 22:52   ` Robin Rosenberg
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Rosenberg @ 2009-09-25 22:52 UTC (permalink / raw
  To: Halstrick, Christian; +Cc: Shawn O. Pearce, git@vger.kernel.org

lördag 26 september 2009 00:45:20 skrev Robin Rosenberg <robin.rosenberg@dewire.com>:
> onsdag 23 september 2009 18:42:29 skrev "Halstrick, Christian" <christian.halstrick@sap.com>:
> > 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.
> 
> A few minor things:
Forgot: Please:
> Format the comment nicely and space betwee paragraphs.
[...]

-- robin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-09-25 22:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-23 16:42 [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter Halstrick, Christian
2009-09-25 22:45 ` Robin Rosenberg
2009-09-25 22:52   ` Robin Rosenberg

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).