{"thread":{"id":"21035","subject":"[JGIT PATCH 2/2] added some tests for config param logAllRefUpdates","startedAt":"2009-09-23T16:45:28Z","lastAt":"2009-09-23T16:45:28Z","messageCount":1,"participants":["Halstrick, Christian"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"123677","messageId":"D35B4A582834DC418CCF9AF41AB69B70016953F633@DEWDFECCR04.wdf.sap.corp","threadId":"21035","inReplyTo":null,"subject":"[JGIT PATCH 2/2] added some tests for config param logAllRefUpdates","fromName":"Halstrick, Christian","fromEmail":"christian.halstrick@sap.com","sentAt":"2009-09-23T16:45:28Z","receivedAt":"2009-09-23T16:45:28Z","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\nSigned-off-by: Christian Halstrick <christian.halstrick@sap.com>\nSigned-off-by: Matthias Sohn <matthias.sohn@sap.com>\n---\n .../tst/org/spearce/jgit/lib/ReflogConfigTest.java |  111 ++++++++++++++++++++\n 1 files changed, 111 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReflogConfigTest.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReflogConfigTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReflogConfigTest.java\nnew file mode 100644\nindex 0000000..0e696a0\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ReflogConfigTest.java\n@@ -0,0 +1,111 @@\n+/*\n+ * Copyright (C) 2009, Christian Halstrick, Matthias Sohn, SAP AG\n+ *\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or\n+ * without modification, are permitted provided that the following\n+ * conditions are met:\n+ *\n+ * - Redistributions of source code must retain the above copyright\n+ *   notice, this list of conditions and the following disclaimer.\n+ *\n+ * - Redistributions in binary form must reproduce the above\n+ *   copyright notice, this list of conditions and the following\n+ *   disclaimer in the documentation and/or other materials provided\n+ *   with the distribution.\n+ *\n+ * - Neither the name of the Git Development Community nor the\n+ *   names of its contributors may be used to endorse or promote\n+ *   products derived from this software without specific prior\n+ *   written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\n+ * CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,\n+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+package org.spearce.jgit.lib;\n+\n+import java.io.IOException;\n+\n+public class ReflogConfigTest extends RepositoryTestCase {\n+\tpublic void testlogAllRefUpdates() throws Exception {\n+\t\tlong commitTime = 1154236443000L;\n+\t\tint tz = -4 * 60;\n+\t\tassertFalse(db.getConfig().getCore().isLogAllRefUpdates());\n+\t\tassertTrue(\"Reflog for HEAD should be empty\", db.getReflogReader(\n+\t\t\t\tConstants.HEAD).getReverseEntries().size() == 0);\n+\n+\t\t// do one commit and check that reflog size is 0: no reflogs should be\n+\t\t// written\n+\t\tfinal Tree t = new Tree(db);\n+\t\taddFileToTree(t, \"i-am-a-file\", \"and this is the data in me\\n\");\n+\t\tcommit(t, \"A Commit\\n\", new PersonIdent(jauthor, commitTime, tz),\n+\t\t\t\tnew PersonIdent(jcommitter, commitTime, tz));\n+\t\tcommitTime += 100;\n+\t\tassertTrue(\n+\t\t\t\t\"Reflog for HEAD should contain one entry\",\n+\t\t\t\tdb.getReflogReader(Constants.HEAD).getReverseEntries().size() == 0);\n+\n+\t\t// set the logAllRefUpdates parameter to true and check it\n+\t\tdb.getConfig().setBoolean(\"core\", null, \"logAllRefUpdates\", true);\n+\t\tassertTrue(db.getConfig().getCore().isLogAllRefUpdates());\n+\n+\t\t// do one commit and check that reflog size is 1\n+\t\taddFileToTree(t, \"i-am-another-file\", \"and this is other data in me\\n\");\n+\t\tcommit(t, \"A Commit\\n\", new PersonIdent(jauthor, commitTime, tz),\n+\t\t\t\tnew PersonIdent(jcommitter, commitTime, tz));\n+\t\tcommitTime += 100;\n+\t\tassertTrue(\n+\t\t\t\t\"Reflog for HEAD should contain one entry\",\n+\t\t\t\tdb.getReflogReader(Constants.HEAD).getReverseEntries().size() == 1);\n+\n+\t\t// set the logAllRefUpdates parameter to false and check it\n+\t\tdb.getConfig().setBoolean(\"core\", null, \"logAllRefUpdates\", false);\n+\t\tassertFalse(db.getConfig().getCore().isLogAllRefUpdates());\n+\n+\t\t// do one commit and check that reflog size is 2\n+\t\taddFileToTree(t, \"i-am-anotheranother-file\",\n+\t\t\t\t\"and this is other other data in me\\n\");\n+\t\tcommit(t, \"A Commit\\n\", new PersonIdent(jauthor, commitTime, tz),\n+\t\t\t\tnew PersonIdent(jcommitter, commitTime, tz));\n+\t\tassertTrue(\n+\t\t\t\t\"Reflog for HEAD should contain one entry\",\n+\t\t\t\tdb.getReflogReader(Constants.HEAD).getReverseEntries().size() == 2);\n+\t}\n+\n+\tprivate void addFileToTree(final Tree t, String filename, String content)\n+\t\t\tthrows IOException {\n+\t\tFileTreeEntry f = t.addFile(filename);\n+\t\twriteTrashFile(f.getName(), content);\n+\t\tt.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);\n+\t}\n+\n+\tprivate void commit(final Tree t, String commitMsg, PersonIdent author,\n+\t\t\tPersonIdent committer) throws IOException {\n+\t\tfinal Commit commit = new Commit(db);\n+\t\tcommit.setAuthor(author);\n+\t\tcommit.setCommitter(committer);\n+\t\tcommit.setMessage(commitMsg);\n+\t\tcommit.setTree(t);\n+\t\tObjectWriter writer = new ObjectWriter(db);\n+\t\tcommit.setCommitId(writer.writeCommit(commit));\n+\n+\t\tint nl = commitMsg.indexOf('\\n');\n+\t\tfinal RefUpdate ru = db.updateRef(Constants.HEAD);\n+\t\tru.setNewObjectId(commit.getCommitId());\n+\t\tru.setRefLogMessage(\"commit : \"\n+\t\t\t\t+ ((nl == -1) ? commitMsg : commitMsg.substring(0, nl)), false);\n+\t\tru.forceUpdate();\n+\t}\n+}\n\\ No newline at end of file\n-- \n1.6.4.msysgit.0\n\n"}]}