From: Christian Halstrick <christian.halstrick@xxxxxxx> 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@xxxxxxx> Signed-off-by: Matthias Sohn <matthias.sohn@xxxxxxx> --- .../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 ��.n��������+%������w��{.n��������n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�m