{"thread":{"id":"21034","subject":"[JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter","startedAt":"2009-09-23T16:42:29Z","lastAt":"2009-09-25T22:52:39Z","messageCount":3,"participants":["Halstrick, Christian","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"123676","messageId":"D35B4A582834DC418CCF9AF41AB69B70016953F62F@DEWDFECCR04.wdf.sap.corp","threadId":"21034","inReplyTo":null,"subject":"[JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter","fromName":"Halstrick, Christian","fromEmail":"christian.halstrick@sap.com","sentAt":"2009-09-23T16:42:29Z","receivedAt":"2009-09-23T16:42:29Z","isPatch":true,"sender":{"key":"christian.halstrick@sap.com","avatar":"https://gravatar.com/avatar/032940727041870bc7374e44e8f659ac0a8f8d97d679b4c2cbd05bcb39b088bb?d=mp&s=160"},"body":"From: Christian Halstrick <christian.halstrick@sap.com>\n\nJGit should understand configuration parameter logAllRefUpdates and should\nonly log updates of refs when\n  either the log file for this ref is already present\n  or this configuration parameter is set to true\nBefore this commit JGit was always writing logs, regardless of this\nparameter or existence of logfiles.\n\nSigned-off-by: Christian Halstrick <christian.halstrick@sap.com>\nSigned-off-by: Matthias Sohn <matthias.sohn@sap.com>\n---\n .../src/org/spearce/jgit/lib/CoreConfig.java       |   10 ++++++++++\n .../src/org/spearce/jgit/lib/RefLogWriter.java     |   18 ++++++++++--------\n 2 files changed, 20 insertions(+), 8 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java b/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java\nindex ed3827b..ecd9544 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/CoreConfig.java\n@@ -56,10 +56,13 @@ public CoreConfig parse(final Config cfg) {\n \tprivate final int compression;\n \n \tprivate final int packIndexVersion;\n+\t\n+\tprivate final boolean logAllRefUpdates;\n \n \tprivate CoreConfig(final Config rc) {\n \t\tcompression = rc.getInt(\"core\", \"compression\", DEFAULT_COMPRESSION);\n \t\tpackIndexVersion = rc.getInt(\"pack\", \"indexversion\", 2);\n+\t\tlogAllRefUpdates = rc.getBoolean(\"core\", \"logAllRefUpdates\", false);\n \t}\n \n \t/**\n@@ -77,4 +80,11 @@ public int getCompression() {\n \tpublic int getPackIndexVersion() {\n \t\treturn packIndexVersion;\n \t}\n+\t\n+\t/**\n+\t * @return whether to log all refUpdates \n+\t */\n+\tpublic boolean isLogAllRefUpdates() {\n+\t\treturn logAllRefUpdates;\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java\nindex 4aad809..1e5155c 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/RefLogWriter.java\n@@ -112,16 +112,18 @@ private static void appendOneRecord(final ObjectId oldId,\n \t\tfinal byte[] rec = Constants.encode(r.toString());\n \t\tfinal File logdir = new File(db.getDirectory(), Constants.LOGS);\n \t\tfinal File reflog = new File(logdir, refName);\n-\t\tfinal File refdir = reflog.getParentFile();\n+\t\tif (reflog.exists() || db.getConfig().getCore().isLogAllRefUpdates()) {\n+\t\t\tfinal File refdir = reflog.getParentFile();\n \n-\t\tif (!refdir.exists() && !refdir.mkdirs())\n-\t\t\tthrow new IOException(\"Cannot create directory \" + refdir);\n+\t\t\tif (!refdir.exists() && !refdir.mkdirs())\n+\t\t\t\tthrow new IOException(\"Cannot create directory \" + refdir);\n \n-\t\tfinal FileOutputStream out = new FileOutputStream(reflog, true);\n-\t\ttry {\n-\t\t\tout.write(rec);\n-\t\t} finally {\n-\t\t\tout.close();\n+\t\t\tfinal FileOutputStream out = new FileOutputStream(reflog, true);\n+\t\t\ttry {\n+\t\t\t\tout.write(rec);\n+\t\t\t} finally {\n+\t\t\t\tout.close();\n+\t\t\t}\n \t\t}\n \t}\n \n-- \n1.6.4.msysgit.0\n"},{"id":"123819","messageId":"200909260045.21171.robin.rosenberg@dewire.com","threadId":"21034","inReplyTo":"D35B4A582834DC418CCF9AF41AB69B70016953F62F@DEWDFECCR04.wdf.sap.corp","subject":"Re: [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2009-09-25T22:45:20Z","receivedAt":"2009-09-25T22:45:20Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"onsdag 23 september 2009 18:42:29 skrev \"Halstrick, Christian\" <christian.halstrick@sap.com>:\n> From: Christian Halstrick <christian.halstrick@sap.com>\n> \n> JGit should understand configuration parameter logAllRefUpdates and should\n> only log updates of refs when\n>   either the log file for this ref is already present\n>   or this configuration parameter is set to true\n> Before this commit JGit was always writing logs, regardless of this\n> parameter or existence of logfiles.\n\nA few minor things:\nFormat the comment nicely and space betwee paragraphs.\nStart the comment with a capital letter\nA cover letter for multiple patches is nice, though in this case you could\nactually just squash there patches into one patch.\n\nand one major.\nRefUpdateTest broke.\n\nProbably because of this.\n> +\t\tlogAllRefUpdates = rc.getBoolean(\"core\", \"logAllRefUpdates\", false);\n\nAccording to the git-config man page logAllRefUpdates is true by default for non-bare\nrepos and false for bare repos.\n\nI had some trouble applying these patches as git-am did not like them. Apparently\ngit-am doesn't like base64. Could you set your mailer to use a more plain-ish format\nor use git-send-email. \n\n-- robin\n"},{"id":"123821","messageId":"200909260052.39469.robin.rosenberg.lists@dewire.com","threadId":"21034","inReplyTo":"200909260045.21171.robin.rosenberg@dewire.com","subject":"Re: [JGIT PATCH 1/2] add support for core.logAllRefUpdates configuration parameter","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-09-25T22:52:39Z","receivedAt":"2009-09-25T22:52:39Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"lördag 26 september 2009 00:45:20 skrev Robin Rosenberg <robin.rosenberg@dewire.com>:\n> onsdag 23 september 2009 18:42:29 skrev \"Halstrick, Christian\" <christian.halstrick@sap.com>:\n> > From: Christian Halstrick <christian.halstrick@sap.com>\n> > \n> > JGit should understand configuration parameter logAllRefUpdates and should\n> > only log updates of refs when\n> >   either the log file for this ref is already present\n> >   or this configuration parameter is set to true\n> > Before this commit JGit was always writing logs, regardless of this\n> > parameter or existence of logfiles.\n> \n> A few minor things:\nForgot: Please:\n> Format the comment nicely and space betwee paragraphs.\n[...]\n\n-- robin\n"}]}