{"thread":{"id":"20935","subject":"[PATCH JGit] Adding update-server-info functionality","startedAt":"2009-09-13T18:44:16Z","lastAt":"2009-09-15T19:23:45Z","messageCount":25,"participants":["mr.gaffo@gmail.com","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"123078","messageId":"1252867475-858-1-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":null,"subject":"[PATCH JGit] Adding update-server-info functionality","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:16Z","receivedAt":"2009-09-13T18:44:16Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"This patch series implements update-server-info functionality\nin JGit and integrates it with ReceivePack so that repositories\nhosted by git-http can also be hosted by JGit.\n"},{"id":"123079","messageId":"1252867475-858-2-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-1-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 01/19] adding tests for ObjectDirectory","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:17Z","receivedAt":"2009-09-13T18:44:17Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   80 ++++++++++++++++++++\n 1 files changed, 80 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\nnew file mode 100644\nindex 0000000..fe019af\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n@@ -0,0 +1,80 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+import java.util.UUID;\n+\n+import junit.framework.TestCase;\n+\n+public class ObjectDirectoryTest extends TestCase {\n+\t\n+\tprivate File testDir;\n+\n+\t@Override\n+\tprotected void setUp() throws Exception {\n+\t\ttestDir = new File(new File(System.getProperty(\"java.io.tmpdir\")), UUID.randomUUID().toString());\n+\t}\n+\t\n+\t@Override\n+\tprotected void tearDown() throws Exception {\n+\t\tif (testDir.exists()){\n+\t\t\tdeleteDir(testDir);\n+\t\t}\n+\t}\n+\n+\tpublic void testCanGetDirectory() throws Exception {\n+\t\tObjectDirectory od = new ObjectDirectory(testDir);\n+\t\tassertEquals(testDir, od.getDirectory());\n+\t}\n+\t\n+\tpublic void testExistsWithExistingDirectory() throws Exception {\n+\t\tcreateTestDir();\n+\t\tObjectDirectory od = new ObjectDirectory(testDir);\n+\t\tassertTrue(od.exists());\n+\t}\n+\t\n+\tpublic void testExistsWithNonExistantDirectory() throws Exception {\n+\t\tassertFalse(new ObjectDirectory(new File(\"/some/nonexistant/file\")).exists());\n+\t}\n+\t\n+\tpublic void testCreateMakesCorrectDirectories() throws Exception {\n+\t\tassertFalse(testDir.exists());\n+\t\tnew ObjectDirectory(testDir).create();\n+\t\tassertTrue(testDir.exists());\n+\t\t\n+\t\tFile infoDir = new File(testDir, \"info\");\n+\t\tassertTrue(infoDir.exists());\n+\t\tassertTrue(infoDir.isDirectory());\n+\t\t\n+\t\tFile packDir = new File(testDir, \"pack\");\n+\t\tassertTrue(packDir.exists());\n+\t\tassertTrue(packDir.isDirectory());\n+\t}\n+\t\n+\tpublic void testGettingObjectFile() throws Exception {\n+\t\tObjectDirectory od = new ObjectDirectory(testDir);\n+\t\tassertEquals(new File(testDir, \"02/829ae153935095e4223f30cfc98c835de71bee\"), \n+\t\t\t\t\t od.fileFor(ObjectId.fromString(\"02829ae153935095e4223f30cfc98c835de71bee\")));\n+\t\tassertEquals(new File(testDir, \"b0/52a1272310d8df34de72f60204dee7e28a43d0\"), \n+\t\t\t\t od.fileFor(ObjectId.fromString(\"b052a1272310d8df34de72f60204dee7e28a43d0\")));\n+\t}\n+\t\n+\tpublic boolean deleteDir(File dir) {\n+        if (dir.isDirectory()) {\n+            String[] children = dir.list();\n+            for (int i=0; i<children.length; i++) {\n+                boolean success = deleteDir(new File(dir, children[i]));\n+                if (!success) {\n+                    return false;\n+                }\n+            }\n+        }\n+    \n+        // The directory is now empty so delete it\n+        return dir.delete();\n+    }\n+\n+\tprivate void createTestDir(){\n+\t\ttestDir.mkdir();\n+\t}\n+\t\n+}\n-- \n1.6.4.2\n"},{"id":"123094","messageId":"1252867475-858-3-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-2-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 02/19] Create abstract method on ObjectDatabase for accessing the list of local pack files.","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:18Z","receivedAt":"2009-09-13T18:44:18Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\nImplemented the method for AlternateRepository database as a passthrough\n\nImplemented the method for ObjectDirectory as a toList of the current\ncached private PackList.\n\nHopefully this will allow easier reference to the list of packs for\nothers like the server side of fetch.\n---\n .../jgit/lib/AlternateRepositoryDatabase.java      |    6 ++++++\n .../src/org/spearce/jgit/lib/ObjectDatabase.java   |   11 ++++++++++-\n .../src/org/spearce/jgit/lib/ObjectDirectory.java  |    5 +++++\n 3 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\nindex ee4c4cf..68ad488 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\n@@ -39,6 +39,7 @@\n \n import java.io.IOException;\n import java.util.Collection;\n+import java.util.List;\n \n /**\n  * An ObjectDatabase of another {@link Repository}.\n@@ -124,4 +125,9 @@ void openObjectInAllPacks1(final Collection<PackedObjectLoader> out,\n \tprotected void closeAlternates(final ObjectDatabase[] alt) {\n \t\t// Do nothing; these belong to odb to close, not us.\n \t}\n+\n+\t@Override\n+\tpublic List<PackFile> listLocalPacks() {\n+\t\treturn odb.listLocalPacks();\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\nindex a547052..722c802 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\n@@ -39,6 +39,7 @@\n \n import java.io.IOException;\n import java.util.Collection;\n+import java.util.List;\n import java.util.concurrent.atomic.AtomicReference;\n \n /**\n@@ -64,7 +65,15 @@\n \tprotected ObjectDatabase() {\n \t\talternates = new AtomicReference<ObjectDatabase[]>();\n \t}\n-\n+\t\n+\t/**\n+\t * The list of Packs THIS repo contains\n+\t * \n+\t * @return List<PackFile> of package names contained in this repo. \n+\t * \t\t   Should be an empty list if there are none.\n+\t */\n+\tpublic abstract List<PackFile> listLocalPacks();\n+\t\n \t/**\n \t * Does this database exist yet?\n \t *\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\nindex 859824d..fe219c6 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n@@ -508,4 +508,9 @@ boolean tryAgain(final long currLastModified) {\n \t\t\treturn true;\n \t\t}\n \t}\n+\n+\t@Override\n+\tpublic List<PackFile> listLocalPacks() {\n+\t\treturn new ArrayList<PackFile>(Arrays.asList(packList.get().packs));\n+\t}\n }\n-- \n1.6.4.2\n"},{"id":"123082","messageId":"1252867475-858-4-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-3-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 03/19] Add abstract method for updating the object db's info cache Implemented passthrough on Alternate for the update of infocache","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:19Z","receivedAt":"2009-09-13T18:44:19Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/AlternateRepositoryDatabase.java      |    5 +++++\n .../src/org/spearce/jgit/lib/ObjectDatabase.java   |    7 +++++++\n 2 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\nindex 68ad488..5cb0579 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\n@@ -130,4 +130,9 @@ protected void closeAlternates(final ObjectDatabase[] alt) {\n \tpublic List<PackFile> listLocalPacks() {\n \t\treturn odb.listLocalPacks();\n \t}\n+\n+\t@Override\n+\tpublic void updateInfoCache() {\n+\t\todb.updateInfoCache();\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\nindex 722c802..68ff523 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\n@@ -75,6 +75,13 @@ protected ObjectDatabase() {\n \tpublic abstract List<PackFile> listLocalPacks();\n \t\n \t/**\n+\t * Creates the caches that are typically done by \n+\t * update-server-info, namely objects/info/packs and \n+\t * info/refs\n+\t */\n+\tpublic abstract void updateInfoCache();\n+\t\n+\t/**\n \t * Does this database exist yet?\n \t *\n \t * @return true if this database is already created; false if the caller\n-- \n1.6.4.2\n"},{"id":"123080","messageId":"1252867475-858-5-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-4-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:20Z","receivedAt":"2009-09-13T18:44:20Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/PacksFileContentsCreatorTest.java     |   37 ++++++++++++++++++++\n .../spearce/jgit/lib/PacksFileContentsCreator.java |   21 +++++++++++\n 2 files changed, 58 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\n create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\nnew file mode 100644\nindex 0000000..ef28a26\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\n@@ -0,0 +1,37 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import org.spearce.jgit.util.JGitTestUtil;\n+\n+import junit.framework.TestCase;\n+\n+public class PacksFileContentsCreatorTest extends TestCase {\n+\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n+\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n+\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n+\n+\tpublic void testGettingPacksContentsSinglePack() throws Exception {\n+\t\tList<PackFile> packs = new ArrayList<PackFile>();\n+\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n+\t\t\n+\t\tassertEquals(\"P \" + TEST_PACK.getName() + '\\r', new PacksFileContentsCreator(packs).toString());\n+\t}\n+\t\n+\tpublic void testGettingPacksContentsMultiplePacks() throws Exception {\n+\t\tList<PackFile> packs = new ArrayList<PackFile>();\n+\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n+\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n+\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n+\t\t\n+\t\tStringBuilder expected = new StringBuilder();\n+\t\texpected.append(\"P \").append(TEST_PACK.getName()).append(\"\\r\");\n+\t\texpected.append(\"P \").append(TEST_PACK.getName()).append(\"\\r\");\n+\t\texpected.append(\"P \").append(TEST_PACK.getName()).append(\"\\r\");\n+\t\t\n+\t\tassertEquals(expected.toString(), new PacksFileContentsCreator(packs).toString());\n+\t}\n+\t\n+}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\nnew file mode 100644\nindex 0000000..3dd0418\n--- /dev/null\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n@@ -0,0 +1,21 @@\n+package org.spearce.jgit.lib;\n+\n+import java.util.List;\n+\n+public class PacksFileContentsCreator {\n+\n+\tprivate List<PackFile> packs;\n+\n+\tpublic PacksFileContentsCreator(List<PackFile> packs) {\n+\t\tthis.packs = packs;\n+\t}\n+\t\n+\tpublic String toString(){\n+\t\tStringBuilder builder = new StringBuilder();\n+\t\tfor (PackFile packFile : packs) {\n+\t\t\tbuilder.append(\"P \").append(packFile.getPackFile().getName()).append('\\r');\n+\t\t}\n+\t\treturn builder.toString();\n+\t}\n+\n+}\n-- \n1.6.4.2\n"},{"id":"123083","messageId":"1252867475-858-6-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-5-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:21Z","receivedAt":"2009-09-13T18:44:21Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   24 ++++++++++++++++++++\n .../jgit/lib/UpdateDirectoryInfoCacheTest.java     |   11 +++++++++\n .../tst/org/spearce/jgit/util/JGitTestUtil.java    |   21 ++++++++++++++++-\n .../src/org/spearce/jgit/lib/ObjectDirectory.java  |    6 +++++\n .../spearce/jgit/lib/UpdateDirectoryInfoCache.java |   22 ++++++++++++++++++\n 5 files changed, 83 insertions(+), 1 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\nindex fe019af..8e4d8e5 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n@@ -1,11 +1,17 @@\n package org.spearce.jgit.lib;\n \n import java.io.File;\n+import java.util.List;\n import java.util.UUID;\n \n+import org.spearce.jgit.util.JGitTestUtil;\n+\n import junit.framework.TestCase;\n \n public class ObjectDirectoryTest extends TestCase {\n+\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n+\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n+\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n \t\n \tprivate File testDir;\n \n@@ -58,6 +64,24 @@ public void testGettingObjectFile() throws Exception {\n \t\t\t\t od.fileFor(ObjectId.fromString(\"b052a1272310d8df34de72f60204dee7e28a43d0\")));\n \t}\n \t\n+\tpublic void testListLocalPacksNotCreated() throws Exception {\n+\t\tassertEquals(0, new ObjectDirectory(testDir).listLocalPacks().size());\n+\t}\n+\t\n+\tpublic void testListLocalPacksWhenThereIsAPack() throws Exception {\n+\t\tcreateTestDir();\n+\t\tFile packsDir = new File(testDir, \"pack\");\n+\t\tpacksDir.mkdirs();\n+\t\t\n+\t\tJGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));\n+\t\tJGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));\n+\n+\t\tObjectDirectory od = new ObjectDirectory(testDir);\n+\t\tList<PackFile> localPacks = od.listLocalPacks();\n+\t\tassertEquals(1, localPacks.size());\n+\t\tassertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());\n+\t}\n+\t\n \tpublic boolean deleteDir(File dir) {\n         if (dir.isDirectory()) {\n             String[] children = dir.list();\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\nnew file mode 100644\nindex 0000000..11d183e\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n@@ -0,0 +1,11 @@\n+package org.spearce.jgit.lib;\n+\n+import junit.framework.TestCase;\n+\n+public class UpdateDirectoryInfoCacheTest extends TestCase {\n+\t\n+\tpublic void testBase() throws Exception {\n+\t\tfail(\"nyi\");\n+\t}\n+\n+}\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\nindex eee0c14..04184d7 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n@@ -38,6 +38,12 @@\n package org.spearce.jgit.util;\n \n import java.io.File;\n+import java.io.FileInputStream;\n+import java.io.FileNotFoundException;\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.OutputStream;\n import java.net.URISyntaxException;\n import java.net.URL;\n \n@@ -60,11 +66,24 @@ public static File getTestResourceFile(final String fileName) {\n \t\t}\n \t\ttry {\n \t\t\treturn new File(url.toURI());\n-\t\t} catch(URISyntaxException e) {\n+\t\t} catch (URISyntaxException e) {\n \t\t\treturn new File(url.getPath());\n \t\t}\n \t}\n \n+\tpublic static void copyFile(final File fromFile, final File toFile) throws IOException {\n+\t\tInputStream in = new FileInputStream(fromFile);\n+\t\tOutputStream out = new FileOutputStream(toFile);\n+\n+\t\tbyte[] buf = new byte[1024];\n+\t\tint len;\n+\t\twhile ((len = in.read(buf)) > 0) {\n+\t\t\tout.write(buf, 0, len);\n+\t\t}\n+\t\tin.close();\n+\t\tout.close();\n+\t}\n+\n \tprivate static ClassLoader cl() {\n \t\treturn JGitTestUtil.class.getClassLoader();\n \t}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\nindex fe219c6..a90ae00 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n@@ -511,6 +511,12 @@ boolean tryAgain(final long currLastModified) {\n \n \t@Override\n \tpublic List<PackFile> listLocalPacks() {\n+\t\ttryAgain1();\n \t\treturn new ArrayList<PackFile>(Arrays.asList(packList.get().packs));\n \t}\n+\n+\t@Override\n+\tpublic void updateInfoCache() {\n+\t\tnew UpdateDirectoryInfoCache(this.listLocalPacks(), this.infoDirectory).execute();\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\nnew file mode 100644\nindex 0000000..2bceb9e\n--- /dev/null\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n@@ -0,0 +1,22 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+import java.util.List;\n+\n+public class UpdateDirectoryInfoCache {\n+\n+\tprivate List<PackFile> packsList;\n+\tprivate File infoDirectory;\n+\n+\tpublic UpdateDirectoryInfoCache(List<PackFile> packsList,\n+\t\t\tFile infoDirectory) {\n+\t\tthis.packsList = packsList;\n+\t\tthis.infoDirectory = infoDirectory;\n+\t}\n+\n+\tpublic void execute() {\n+//\t\tFile objectFile = objectDatabase.\n+//\t\tString packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();\n+\t}\n+\n+}\n-- \n1.6.4.2\n"},{"id":"123081","messageId":"1252867475-858-7-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-6-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 06/19] added utility for reading the contents of a file as a string","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:22Z","receivedAt":"2009-09-13T18:44:22Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../tst/org/spearce/jgit/util/JGitTestUtil.java    |   20 +++++++++++++++++++-\n 1 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\nindex 04184d7..b958282 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n@@ -37,10 +37,12 @@\n \n package org.spearce.jgit.util;\n \n+import java.io.BufferedReader;\n import java.io.File;\n import java.io.FileInputStream;\n import java.io.FileNotFoundException;\n import java.io.FileOutputStream;\n+import java.io.FileReader;\n import java.io.IOException;\n import java.io.InputStream;\n import java.io.OutputStream;\n@@ -71,7 +73,8 @@ public static File getTestResourceFile(final String fileName) {\n \t\t}\n \t}\n \n-\tpublic static void copyFile(final File fromFile, final File toFile) throws IOException {\n+\tpublic static void copyFile(final File fromFile, final File toFile)\n+\t\t\tthrows IOException {\n \t\tInputStream in = new FileInputStream(fromFile);\n \t\tOutputStream out = new FileOutputStream(toFile);\n \n@@ -84,6 +87,21 @@ public static void copyFile(final File fromFile, final File toFile) throws IOExc\n \t\tout.close();\n \t}\n \n+\tpublic static String readFileAsString(final File file)\n+\t\t\tthrows java.io.IOException {\n+\t\tStringBuilder fileData = new StringBuilder(1000);\n+\t\tBufferedReader reader = new BufferedReader(new FileReader(file));\n+\t\tchar[] buf = new char[1024];\n+\t\tint numRead = 0;\n+\t\twhile ((numRead = reader.read(buf)) != -1) {\n+\t\t\tString readData = String.valueOf(buf, 0, numRead);\n+\t\t\tfileData.append(readData);\n+\t\t\tbuf = new char[1024];\n+\t\t}\n+\t\treader.close();\n+\t\treturn fileData.toString();\n+\t}\n+\n \tprivate static ClassLoader cl() {\n \t\treturn JGitTestUtil.class.getClassLoader();\n \t}\n-- \n1.6.4.2\n"},{"id":"123084","messageId":"1252867475-858-8-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-7-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 07/19] implemented the packs file update functionality","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:23Z","receivedAt":"2009-09-13T18:44:23Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/UpdateDirectoryInfoCacheTest.java     |   23 ++++++++++++++++++-\n .../spearce/jgit/lib/UpdateDirectoryInfoCache.java |   17 +++++++++-----\n 2 files changed, 32 insertions(+), 8 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\nindex 11d183e..25b78c5 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n@@ -1,11 +1,30 @@\n package org.spearce.jgit.lib;\n \n+import java.io.File;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n import junit.framework.TestCase;\n \n+import org.spearce.jgit.util.JGitTestUtil;\n+\n public class UpdateDirectoryInfoCacheTest extends TestCase {\n+\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n+\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n+\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n \t\n-\tpublic void testBase() throws Exception {\n-\t\tfail(\"nyi\");\n+\tpublic void testCreatesTheFileAndPutsTheContentsIn() throws Exception {\n+\t\tList<PackFile> packs = new ArrayList<PackFile>();\n+\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n+\t\t\n+\t\tFile packsFile = File.createTempFile(UpdateDirectoryInfoCacheTest.class.getSimpleName(), \"tstdata\");\n+\t\tpacksFile.deleteOnExit();\n+\t\t\n+\t\tString expectedContents = new PacksFileContentsCreator(packs).toString();\n+\t\t\n+\t\tnew UpdateDirectoryInfoCache(packs, packsFile).execute();\n+\t\t\n+\t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n \t}\n \n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\nindex 2bceb9e..72a315a 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n@@ -1,22 +1,27 @@\n package org.spearce.jgit.lib;\n \n+import java.io.BufferedWriter;\n import java.io.File;\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n import java.util.List;\n \n public class UpdateDirectoryInfoCache {\n \n \tprivate List<PackFile> packsList;\n-\tprivate File infoDirectory;\n+\tprivate File infoPacksFile;\n \n \tpublic UpdateDirectoryInfoCache(List<PackFile> packsList,\n-\t\t\tFile infoDirectory) {\n+\t\t\t\t\t\t\t\t\tFile infoPacksFile) {\n \t\tthis.packsList = packsList;\n-\t\tthis.infoDirectory = infoDirectory;\n+\t\tthis.infoPacksFile = infoPacksFile;\n \t}\n \n-\tpublic void execute() {\n-//\t\tFile objectFile = objectDatabase.\n-//\t\tString packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();\n+\tpublic void execute() throws IOException {\n+\t\tString packsContents = new PacksFileContentsCreator(packsList).toString();\n+\t\tFileOutputStream fos = new FileOutputStream(infoPacksFile);\n+\t\tfos.write(packsContents.getBytes());\n+\t\tfos.close();\n \t}\n \n }\n-- \n1.6.4.2\n"},{"id":"123088","messageId":"1252867475-858-9-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-8-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 08/19] changed signature to allow a IOException","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:24Z","receivedAt":"2009-09-13T18:44:24Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/AlternateRepositoryDatabase.java      |    2 +-\n .../src/org/spearce/jgit/lib/ObjectDatabase.java   |    3 ++-\n .../src/org/spearce/jgit/lib/ObjectDirectory.java  |    4 ++--\n 3 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\nindex 5cb0579..70ce505 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/AlternateRepositoryDatabase.java\n@@ -132,7 +132,7 @@ protected void closeAlternates(final ObjectDatabase[] alt) {\n \t}\n \n \t@Override\n-\tpublic void updateInfoCache() {\n+\tpublic void updateInfoCache() throws IOException {\n \t\todb.updateInfoCache();\n \t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\nindex 68ff523..5ded7bb 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDatabase.java\n@@ -78,8 +78,9 @@ protected ObjectDatabase() {\n \t * Creates the caches that are typically done by \n \t * update-server-info, namely objects/info/packs and \n \t * info/refs\n+\t * @throws IOException \n \t */\n-\tpublic abstract void updateInfoCache();\n+\tpublic abstract void updateInfoCache() throws IOException;\n \t\n \t/**\n \t * Does this database exist yet?\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\nindex a90ae00..95618b9 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n@@ -516,7 +516,7 @@ boolean tryAgain(final long currLastModified) {\n \t}\n \n \t@Override\n-\tpublic void updateInfoCache() {\n-\t\tnew UpdateDirectoryInfoCache(this.listLocalPacks(), this.infoDirectory).execute();\n+\tpublic void updateInfoCache() throws IOException {\n+\t\tnew UpdateDirectoryInfoCache(this.listLocalPacks(), new File(this.infoDirectory, \"packs\")).execute();\n \t}\n }\n-- \n1.6.4.2\n"},{"id":"123095","messageId":"1252867475-858-10-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-9-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:25Z","receivedAt":"2009-09-13T18:44:25Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../UpdateDirectoryBasedPacksInfoCacheTest.java    |   30 ++++++++++++++++++++\n .../jgit/lib/UpdateDirectoryInfoCacheTest.java     |   30 --------------------\n .../src/org/spearce/jgit/lib/ObjectDirectory.java  |    2 +-\n .../lib/UpdateDirectoryBasedPacksInfoCache.java    |   27 ++++++++++++++++++\n .../spearce/jgit/lib/UpdateDirectoryInfoCache.java |   27 ------------------\n 5 files changed, 58 insertions(+), 58 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java\n delete mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\n delete mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java\nnew file mode 100644\nindex 0000000..f5163e4\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java\n@@ -0,0 +1,30 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import junit.framework.TestCase;\n+\n+import org.spearce.jgit.util.JGitTestUtil;\n+\n+public class UpdateDirectoryBasedPacksInfoCacheTest extends TestCase {\n+\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n+\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n+\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n+\t\n+\tpublic void testCreatesTheFileAndPutsTheContentsIn() throws Exception {\n+\t\tList<PackFile> packs = new ArrayList<PackFile>();\n+\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n+\t\t\n+\t\tFile packsFile = File.createTempFile(UpdateDirectoryBasedPacksInfoCacheTest.class.getSimpleName(), \"tstdata\");\n+\t\tpacksFile.deleteOnExit();\n+\t\t\n+\t\tString expectedContents = new PacksFileContentsCreator(packs).toString();\n+\t\t\n+\t\tnew UpdateDirectoryBasedPacksInfoCache(packs, packsFile).execute();\n+\t\t\n+\t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n+\t}\n+\n+}\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\ndeleted file mode 100644\nindex 25b78c5..0000000\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n+++ /dev/null\n@@ -1,30 +0,0 @@\n-package org.spearce.jgit.lib;\n-\n-import java.io.File;\n-import java.util.ArrayList;\n-import java.util.List;\n-\n-import junit.framework.TestCase;\n-\n-import org.spearce.jgit.util.JGitTestUtil;\n-\n-public class UpdateDirectoryInfoCacheTest extends TestCase {\n-\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n-\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n-\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n-\t\n-\tpublic void testCreatesTheFileAndPutsTheContentsIn() throws Exception {\n-\t\tList<PackFile> packs = new ArrayList<PackFile>();\n-\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n-\t\t\n-\t\tFile packsFile = File.createTempFile(UpdateDirectoryInfoCacheTest.class.getSimpleName(), \"tstdata\");\n-\t\tpacksFile.deleteOnExit();\n-\t\t\n-\t\tString expectedContents = new PacksFileContentsCreator(packs).toString();\n-\t\t\n-\t\tnew UpdateDirectoryInfoCache(packs, packsFile).execute();\n-\t\t\n-\t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n-\t}\n-\n-}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\nindex 95618b9..71536c9 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n@@ -517,6 +517,6 @@ boolean tryAgain(final long currLastModified) {\n \n \t@Override\n \tpublic void updateInfoCache() throws IOException {\n-\t\tnew UpdateDirectoryInfoCache(this.listLocalPacks(), new File(this.infoDirectory, \"packs\")).execute();\n+\t\tnew UpdateDirectoryBasedPacksInfoCache(this.listLocalPacks(), new File(this.infoDirectory, \"packs\")).execute();\n \t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\nnew file mode 100644\nindex 0000000..3e24cd2\n--- /dev/null\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\n@@ -0,0 +1,27 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.BufferedWriter;\n+import java.io.File;\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n+import java.util.List;\n+\n+public class UpdateDirectoryBasedPacksInfoCache {\n+\n+\tprivate List<PackFile> packsList;\n+\tprivate File infoPacksFile;\n+\n+\tpublic UpdateDirectoryBasedPacksInfoCache(List<PackFile> packsList,\n+\t\t\t\t\t\t\t\t\tFile infoPacksFile) {\n+\t\tthis.packsList = packsList;\n+\t\tthis.infoPacksFile = infoPacksFile;\n+\t}\n+\n+\tpublic void execute() throws IOException {\n+\t\tString packsContents = new PacksFileContentsCreator(packsList).toString();\n+\t\tFileOutputStream fos = new FileOutputStream(infoPacksFile);\n+\t\tfos.write(packsContents.getBytes());\n+\t\tfos.close();\n+\t}\n+\n+}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\ndeleted file mode 100644\nindex 72a315a..0000000\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n+++ /dev/null\n@@ -1,27 +0,0 @@\n-package org.spearce.jgit.lib;\n-\n-import java.io.BufferedWriter;\n-import java.io.File;\n-import java.io.FileOutputStream;\n-import java.io.IOException;\n-import java.util.List;\n-\n-public class UpdateDirectoryInfoCache {\n-\n-\tprivate List<PackFile> packsList;\n-\tprivate File infoPacksFile;\n-\n-\tpublic UpdateDirectoryInfoCache(List<PackFile> packsList,\n-\t\t\t\t\t\t\t\t\tFile infoPacksFile) {\n-\t\tthis.packsList = packsList;\n-\t\tthis.infoPacksFile = infoPacksFile;\n-\t}\n-\n-\tpublic void execute() throws IOException {\n-\t\tString packsContents = new PacksFileContentsCreator(packsList).toString();\n-\t\tFileOutputStream fos = new FileOutputStream(infoPacksFile);\n-\t\tfos.write(packsContents.getBytes());\n-\t\tfos.close();\n-\t}\n-\n-}\n-- \n1.6.4.2\n"},{"id":"123085","messageId":"1252867475-858-11-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-10-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 10/19] moved test up to a higher level to test actual functionality","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:26Z","receivedAt":"2009-09-13T18:44:26Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   32 ++++++++++++++++----\n .../UpdateDirectoryBasedPacksInfoCacheTest.java    |   30 ------------------\n 2 files changed, 26 insertions(+), 36 deletions(-)\n delete mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\nindex 8e4d8e5..4ac62fa 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n@@ -1,6 +1,8 @@\n package org.spearce.jgit.lib;\n \n import java.io.File;\n+import java.io.IOException;\n+import java.util.ArrayList;\n import java.util.List;\n import java.util.UUID;\n \n@@ -69,12 +71,7 @@ public void testListLocalPacksNotCreated() throws Exception {\n \t}\n \t\n \tpublic void testListLocalPacksWhenThereIsAPack() throws Exception {\n-\t\tcreateTestDir();\n-\t\tFile packsDir = new File(testDir, \"pack\");\n-\t\tpacksDir.mkdirs();\n-\t\t\n-\t\tJGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));\n-\t\tJGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));\n+\t\tcreateSamplePacksDir();\n \n \t\tObjectDirectory od = new ObjectDirectory(testDir);\n \t\tList<PackFile> localPacks = od.listLocalPacks();\n@@ -82,6 +79,20 @@ public void testListLocalPacksWhenThereIsAPack() throws Exception {\n \t\tassertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());\n \t}\n \t\n+\tpublic void testUpdateInfoCacheCreatesPacksFile() throws Exception {\n+\t\tcreateSamplePacksDir();\n+\n+\t\tObjectDirectory od = new ObjectDirectory(testDir);\n+\t\tod.create();\n+\t\tod.updateInfoCache();\n+\t\t\n+\t\tString expectedContents = new PacksFileContentsCreator(od.listLocalPacks()).toString();\n+\t\tFile packsFile = new File(od.getDirectory(), \"info/packs\");\n+\n+\t\tassertTrue(packsFile.exists());\n+\t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n+\t}\n+\t\n \tpublic boolean deleteDir(File dir) {\n         if (dir.isDirectory()) {\n             String[] children = dir.list();\n@@ -100,5 +111,14 @@ public boolean deleteDir(File dir) {\n \tprivate void createTestDir(){\n \t\ttestDir.mkdir();\n \t}\n+\n+\tprivate void createSamplePacksDir() throws IOException {\n+\t\tcreateTestDir();\n+\t\tFile packsDir = new File(testDir, \"pack\");\n+\t\tpacksDir.mkdirs();\n+\t\t\n+\t\tJGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));\n+\t\tJGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));\n+\t}\n \t\n }\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java\ndeleted file mode 100644\nindex f5163e4..0000000\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCacheTest.java\n+++ /dev/null\n@@ -1,30 +0,0 @@\n-package org.spearce.jgit.lib;\n-\n-import java.io.File;\n-import java.util.ArrayList;\n-import java.util.List;\n-\n-import junit.framework.TestCase;\n-\n-import org.spearce.jgit.util.JGitTestUtil;\n-\n-public class UpdateDirectoryBasedPacksInfoCacheTest extends TestCase {\n-\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n-\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n-\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n-\t\n-\tpublic void testCreatesTheFileAndPutsTheContentsIn() throws Exception {\n-\t\tList<PackFile> packs = new ArrayList<PackFile>();\n-\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n-\t\t\n-\t\tFile packsFile = File.createTempFile(UpdateDirectoryBasedPacksInfoCacheTest.class.getSimpleName(), \"tstdata\");\n-\t\tpacksFile.deleteOnExit();\n-\t\t\n-\t\tString expectedContents = new PacksFileContentsCreator(packs).toString();\n-\t\t\n-\t\tnew UpdateDirectoryBasedPacksInfoCache(packs, packsFile).execute();\n-\t\t\n-\t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n-\t}\n-\n-}\n-- \n1.6.4.2\n"},{"id":"123096","messageId":"1252867475-858-12-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-11-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 11/19] removed unused import","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:27Z","receivedAt":"2009-09-13T18:44:27Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../lib/UpdateDirectoryBasedPacksInfoCache.java    |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\nindex 3e24cd2..e4caa43 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\n@@ -1,6 +1,5 @@\n package org.spearce.jgit.lib;\n \n-import java.io.BufferedWriter;\n import java.io.File;\n import java.io.FileOutputStream;\n import java.io.IOException;\n-- \n1.6.4.2\n"},{"id":"123092","messageId":"1252867475-858-13-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-12-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 12/19] moved info/packs into a constant","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:28Z","receivedAt":"2009-09-13T18:44:28Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |    5 ++---\n .../src/org/spearce/jgit/lib/Constants.java        |    3 +++\n .../src/org/spearce/jgit/lib/ObjectDirectory.java  |    2 +-\n 3 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\nindex 4ac62fa..b27f2f8 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n@@ -79,7 +79,7 @@ public void testListLocalPacksWhenThereIsAPack() throws Exception {\n \t\tassertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());\n \t}\n \t\n-\tpublic void testUpdateInfoCacheCreatesPacksFile() throws Exception {\n+\tpublic void testUpdateInfoCacheCreatesPacksAndRefsFile() throws Exception {\n \t\tcreateSamplePacksDir();\n \n \t\tObjectDirectory od = new ObjectDirectory(testDir);\n@@ -87,7 +87,7 @@ public void testUpdateInfoCacheCreatesPacksFile() throws Exception {\n \t\tod.updateInfoCache();\n \t\t\n \t\tString expectedContents = new PacksFileContentsCreator(od.listLocalPacks()).toString();\n-\t\tFile packsFile = new File(od.getDirectory(), \"info/packs\");\n+\t\tFile packsFile = new File(od.getDirectory(), Constants.CACHED_PACKS_FILE);\n \n \t\tassertTrue(packsFile.exists());\n \t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n@@ -103,7 +103,6 @@ public boolean deleteDir(File dir) {\n                 }\n             }\n         }\n-    \n         // The directory is now empty so delete it\n         return dir.delete();\n     }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java\nindex 9afea67..2d78dda 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Constants.java\n@@ -224,6 +224,9 @@\n \n \t/** Info refs folder */\n \tpublic static final String INFO_REFS = \"info/refs\";\n+\t\n+\t/** cached packs file */\n+\tpublic static final String CACHED_PACKS_FILE = \"info/packs\"; \n \n \t/** Packed refs file */\n \tpublic static final String PACKED_REFS = \"packed-refs\";\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\nindex 71536c9..f4251c1 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n@@ -517,6 +517,6 @@ boolean tryAgain(final long currLastModified) {\n \n \t@Override\n \tpublic void updateInfoCache() throws IOException {\n-\t\tnew UpdateDirectoryBasedPacksInfoCache(this.listLocalPacks(), new File(this.infoDirectory, \"packs\")).execute();\n+\t\tnew UpdateDirectoryBasedPacksInfoCache(this.listLocalPacks(), new File(this.getDirectory(), Constants.CACHED_PACKS_FILE)).execute();\n \t}\n }\n-- \n1.6.4.2\n"},{"id":"123091","messageId":"1252867475-858-14-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-13-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 13/19] made the call update the object database's info cache","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:29Z","receivedAt":"2009-09-13T18:44:29Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/transport/ReceivePack.java    |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\nindex eb21254..5865736 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n@@ -521,6 +521,16 @@ void sendString(final String s) throws IOException {\n \t\t\t}\n \n \t\t\tpostReceive.onPostReceive(this, filterCommands(Result.OK));\n+\t\t\tupdateObjectInfoCache();\n+\t\t}\n+\t}\n+\n+\tprivate void updateObjectInfoCache() {\n+\t\ttry{\n+\t\t\tgetRepository().getObjectDatabase().updateInfoCache();\n+\t\t} \n+\t\tcatch (IOException e){\n+\t\t\tsendMessage(\"error updating server info: \" + e.getMessage());\n \t\t}\n \t}\n \n-- \n1.6.4.2\n"},{"id":"123090","messageId":"1252867475-858-15-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-14-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 14/19] pulled out some helper functions that will be useful for other tests","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:30Z","receivedAt":"2009-09-13T18:44:30Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   21 ++-----------------\n .../tst/org/spearce/jgit/util/JGitTestUtil.java    |   20 ++++++++++++++++++-\n 2 files changed, 22 insertions(+), 19 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\nindex b27f2f8..4fecce7 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n@@ -4,7 +4,6 @@\n import java.io.IOException;\n import java.util.ArrayList;\n import java.util.List;\n-import java.util.UUID;\n \n import org.spearce.jgit.util.JGitTestUtil;\n \n@@ -19,13 +18,13 @@\n \n \t@Override\n \tprotected void setUp() throws Exception {\n-\t\ttestDir = new File(new File(System.getProperty(\"java.io.tmpdir\")), UUID.randomUUID().toString());\n+\t\ttestDir = JGitTestUtil.generateTempDirectoryFileObject();\n \t}\n-\t\n+\n \t@Override\n \tprotected void tearDown() throws Exception {\n \t\tif (testDir.exists()){\n-\t\t\tdeleteDir(testDir);\n+\t\t\tJGitTestUtil.deleteDir(testDir);\n \t\t}\n \t}\n \n@@ -93,20 +92,6 @@ public void testUpdateInfoCacheCreatesPacksAndRefsFile() throws Exception {\n \t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n \t}\n \t\n-\tpublic boolean deleteDir(File dir) {\n-        if (dir.isDirectory()) {\n-            String[] children = dir.list();\n-            for (int i=0; i<children.length; i++) {\n-                boolean success = deleteDir(new File(dir, children[i]));\n-                if (!success) {\n-                    return false;\n-                }\n-            }\n-        }\n-        // The directory is now empty so delete it\n-        return dir.delete();\n-    }\n-\n \tprivate void createTestDir(){\n \t\ttestDir.mkdir();\n \t}\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\nindex b958282..7506553 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n@@ -40,7 +40,6 @@\n import java.io.BufferedReader;\n import java.io.File;\n import java.io.FileInputStream;\n-import java.io.FileNotFoundException;\n import java.io.FileOutputStream;\n import java.io.FileReader;\n import java.io.IOException;\n@@ -48,6 +47,7 @@\n import java.io.OutputStream;\n import java.net.URISyntaxException;\n import java.net.URL;\n+import java.util.UUID;\n \n public abstract class JGitTestUtil {\n \tpublic static final String CLASSPATH_TO_RESOURCES = \"org/spearce/jgit/test/resources/\";\n@@ -105,4 +105,22 @@ public static String readFileAsString(final File file)\n \tprivate static ClassLoader cl() {\n \t\treturn JGitTestUtil.class.getClassLoader();\n \t}\n+\n+\tpublic static boolean deleteDir(File dir) {\n+\t    if (dir.isDirectory()) {\n+\t        String[] children = dir.list();\n+\t        for (int i=0; i<children.length; i++) {\n+\t            boolean success = deleteDir(new File(dir, children[i]));\n+\t            if (!success) {\n+\t                return false;\n+\t            }\n+\t        }\n+\t    }\n+\t    // The directory is now empty so delete it\n+\t    return dir.delete();\n+\t}\n+\n+\tpublic static File generateTempDirectoryFileObject() {\n+\t\treturn new File(new File(System.getProperty(\"java.io.tmpdir\")), UUID.randomUUID().toString());\n+\t}\n }\n-- \n1.6.4.2\n"},{"id":"123098","messageId":"1252867475-858-16-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-15-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 15/19] Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory.","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:31Z","receivedAt":"2009-09-13T18:44:31Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\nCurrently only creates itself.\n---\n .../jgit/lib/InfoDirectoryDatabaseTest.java        |   30 ++++++++++++++++++++\n .../src/org/spearce/jgit/lib/InfoDatabase.java     |    8 +++++\n .../spearce/jgit/lib/InfoDirectoryDatabase.java    |   18 ++++++++++++\n .../src/org/spearce/jgit/lib/Repository.java       |   11 +++++++\n .../org/spearce/jgit/transport/ReceivePack.java    |    1 +\n 5 files changed, 68 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\n create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\n create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\nnew file mode 100644\nindex 0000000..2b7fb5b\n--- /dev/null\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\n@@ -0,0 +1,30 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+\n+import org.spearce.jgit.util.JGitTestUtil;\n+\n+import junit.framework.TestCase;\n+\n+public class InfoDirectoryDatabaseTest extends TestCase {\n+\n+\tprivate File testDir;\n+\n+\t@Override\n+\tprotected void setUp() throws Exception {\n+\t\ttestDir = JGitTestUtil.generateTempDirectoryFileObject();\n+\t}\n+\n+\t@Override\n+\tprotected void tearDown() throws Exception {\n+\t\tif (testDir.exists()){\n+\t\t\tJGitTestUtil.deleteDir(testDir);\n+\t\t}\n+\t}\n+\t\n+\tpublic void testCreateCreatesDirectory() throws Exception {\n+\t\tassertFalse(testDir.exists());\n+\t\tnew InfoDirectoryDatabase(testDir).create();\n+\t\tassertTrue(testDir.exists());\n+\t}\n+}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\nnew file mode 100644\nindex 0000000..2f1f398\n--- /dev/null\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\n@@ -0,0 +1,8 @@\n+package org.spearce.jgit.lib;\n+\n+public abstract class InfoDatabase {\n+\n+\tpublic void create() {\n+\t}\n+\n+}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\nnew file mode 100644\nindex 0000000..20d8a70\n--- /dev/null\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\n@@ -0,0 +1,18 @@\n+package org.spearce.jgit.lib;\n+\n+import java.io.File;\n+\n+public class InfoDirectoryDatabase extends InfoDatabase {\n+\n+\tprivate File info;\n+\n+\tpublic InfoDirectoryDatabase(final File directory) {\n+\t\tinfo = directory;\n+\t}\n+\t\n+\t@Override\n+\tpublic void create() {\n+\t\tinfo.mkdirs();\n+\t}\n+\n+}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\nindex 46b7804..f658b5c 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\n@@ -97,6 +97,8 @@\n \tprivate final RefDatabase refs;\n \n \tprivate final ObjectDirectory objectDatabase;\n+\t\n+\tprivate final InfoDatabase infoDatabase;\n \n \tprivate GitIndex index;\n \n@@ -116,6 +118,7 @@ public Repository(final File d) throws IOException {\n \t\tgitDir = d.getAbsoluteFile();\n \t\trefs = new RefDatabase(this);\n \t\tobjectDatabase = new ObjectDirectory(FS.resolve(gitDir, \"objects\"));\n+\t\tinfoDatabase = new InfoDirectoryDatabase(FS.resolve(gitDir, \"info\"));\n \n \t\tfinal FileBasedConfig userConfig;\n \t\tuserConfig = SystemReader.getInstance().openUserConfig();\n@@ -177,6 +180,7 @@ public void create(boolean bare) throws IOException {\n \t\tgitDir.mkdirs();\n \t\trefs.create();\n \t\tobjectDatabase.create();\n+\t\tinfoDatabase.create();\n \n \t\tnew File(gitDir, \"branches\").mkdir();\n \t\tnew File(gitDir, \"remotes\").mkdir();\n@@ -210,6 +214,13 @@ public File getObjectsDirectory() {\n \tpublic ObjectDatabase getObjectDatabase() {\n \t\treturn objectDatabase;\n \t}\n+\t\n+\t/**\n+\t * @return the info database which stores this repository's info\n+\t */\n+\tpublic InfoDatabase getInfoDatabase() {\n+\t\treturn infoDatabase;\n+\t}\n \n \t/**\n \t * @return the configuration of this repository\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\nindex 5865736..baa1dec 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n@@ -62,6 +62,7 @@\n import org.spearce.jgit.lib.PersonIdent;\n import org.spearce.jgit.lib.Ref;\n import org.spearce.jgit.lib.RefUpdate;\n+import org.spearce.jgit.lib.RefWriter;\n import org.spearce.jgit.lib.Repository;\n import org.spearce.jgit.lib.Config.SectionParser;\n import org.spearce.jgit.revwalk.ObjectWalk;\n-- \n1.6.4.2\n"},{"id":"123089","messageId":"1252867475-858-17-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-16-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 16/19] added tests for the file based info cache update and made pass","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:32Z","receivedAt":"2009-09-13T18:44:32Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/InfoDirectoryDatabaseTest.java        |   30 ++++++++++++++++++++\n .../src/org/spearce/jgit/lib/InfoDatabase.java     |   15 ++++++++++\n .../spearce/jgit/lib/InfoDirectoryDatabase.java    |   15 ++++++++++\n 3 files changed, 60 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\nindex 2b7fb5b..22972fa 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\n@@ -1,6 +1,10 @@\n package org.spearce.jgit.lib;\n \n import java.io.File;\n+import java.io.IOException;\n+import java.io.StringWriter;\n+import java.util.ArrayList;\n+import java.util.Collection;\n \n import org.spearce.jgit.util.JGitTestUtil;\n \n@@ -27,4 +31,30 @@ public void testCreateCreatesDirectory() throws Exception {\n \t\tnew InfoDirectoryDatabase(testDir).create();\n \t\tassertTrue(testDir.exists());\n \t}\n+\t\n+\tpublic void testUpdateInfoCache() throws Exception {\n+\t\tCollection<Ref> refs = new ArrayList<Ref>();\n+\t\trefs.add(new Ref(Ref.Storage.LOOSE, \"refs/heads/master\", ObjectId.fromString(\"32aae7aef7a412d62192f710f2130302997ec883\")));\n+\t\trefs.add(new Ref(Ref.Storage.LOOSE, \"refs/heads/development\", ObjectId.fromString(\"184063c9b594f8968d61a686b2f6052779551613\")));\n+\n+\t\tFile expectedFile = new File(testDir, \"refs\");\n+\t\tassertFalse(expectedFile.exists());\n+\t\t\n+\t\t\n+\t\tfinal StringWriter expectedString = new StringWriter();\n+\t\tnew RefWriter(refs) {\n+\t\t\t@Override\n+\t\t\tprotected void writeFile(String file, byte[] content) throws IOException {\n+\t\t\t\texpectedString.write(new String(content));\n+\t\t\t}\n+\t\t}.writeInfoRefs();\n+\t\t\n+\t\tInfoDirectoryDatabase out = new InfoDirectoryDatabase(testDir);\n+\t\tout.create();\n+\t\tout.updateInfoCache(refs);\n+\t\tassertTrue(expectedFile.exists());\n+\t\t\n+\t\tString actual = JGitTestUtil.readFileAsString(expectedFile);\n+\t\tassertEquals(expectedString.toString(), actual);\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\nindex 2f1f398..26f8f22 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\n@@ -1,8 +1,23 @@\n package org.spearce.jgit.lib;\n \n+import java.io.IOException;\n+import java.util.Collection;\n+\n public abstract class InfoDatabase {\n \n+\t/**\n+\t * Create the info database\n+\t */\n \tpublic void create() {\n \t}\n \n+\t/**\n+\t * Updates the info cache typically done by update-server-info command.\n+\t * This writes THIS repository's refs out to the info/refs file.\n+\t * @param collection the collections of refs to update the info cache with\n+\t * @throws IOException for any type of failure on the local or remote \n+\t * \t\t\t\t\t   data store\n+\t */\n+\tpublic abstract void updateInfoCache(Collection<Ref> collection) throws IOException;\n+\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\nindex 20d8a70..f95be2f 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\n@@ -1,6 +1,9 @@\n package org.spearce.jgit.lib;\n \n import java.io.File;\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n+import java.util.Collection;\n \n public class InfoDirectoryDatabase extends InfoDatabase {\n \n@@ -15,4 +18,16 @@ public void create() {\n \t\tinfo.mkdirs();\n \t}\n \n+\t@Override\n+\tpublic void updateInfoCache(Collection<Ref> refs) throws IOException {\n+\t\tnew RefWriter(refs) {\n+\t\t\t@Override\n+\t\t\tprotected void writeFile(String file, byte[] content) throws IOException {\n+\t\t\t\tFileOutputStream fos = new FileOutputStream(new File(info, \"refs\"));\n+\t\t\t\tfos.write(content);\n+\t\t\t\tfos.close();\n+\t\t\t}\n+\t\t}.writeInfoRefs();\n+\t}\n+\n }\n-- \n1.6.4.2\n"},{"id":"123086","messageId":"1252867475-858-18-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-17-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 17/19] added call to update the info refs file","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:33Z","receivedAt":"2009-09-13T18:44:33Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../org/spearce/jgit/transport/ReceivePack.java    |   10 ++++++++++\n 1 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\nindex baa1dec..0c818d9 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java\n@@ -523,6 +523,16 @@ void sendString(final String s) throws IOException {\n \n \t\t\tpostReceive.onPostReceive(this, filterCommands(Result.OK));\n \t\t\tupdateObjectInfoCache();\n+\t\t\tupdateInfoRefsCache();\n+\t\t}\n+\t}\n+\n+\tprivate void updateInfoRefsCache() {\n+\t\ttry{\n+\t\t\tgetRepository().getInfoDatabase().updateInfoCache(getRepository().getAllRefs().values());\n+\t\t}\n+\t\tcatch (IOException e){\n+\t\t\tsendMessage(\"error updating info/refs: \" + e.getMessage());\n \t\t}\n \t}\n \n-- \n1.6.4.2\n"},{"id":"123093","messageId":"1252867475-858-19-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-18-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 18/19] Added Copyright Notices","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:34Z","receivedAt":"2009-09-13T18:44:34Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/InfoDirectoryDatabaseTest.java        |   36 +++++++++++++++++\n .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   41 ++++++++++++++++++-\n .../jgit/lib/PacksFileContentsCreatorTest.java     |   36 +++++++++++++++++\n .../src/org/spearce/jgit/lib/InfoDatabase.java     |   36 +++++++++++++++++\n .../spearce/jgit/lib/InfoDirectoryDatabase.java    |   36 +++++++++++++++++\n .../spearce/jgit/lib/PacksFileContentsCreator.java |   36 +++++++++++++++++\n .../lib/UpdateDirectoryBasedPacksInfoCache.java    |   36 +++++++++++++++++\n 7 files changed, 254 insertions(+), 3 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\nindex 22972fa..3aa0fd6 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java\n@@ -1,3 +1,39 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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.File;\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\nindex 4fecce7..e14db75 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n@@ -1,14 +1,49 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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.File;\n import java.io.IOException;\n-import java.util.ArrayList;\n import java.util.List;\n \n-import org.spearce.jgit.util.JGitTestUtil;\n-\n import junit.framework.TestCase;\n \n+import org.spearce.jgit.util.JGitTestUtil;\n+\n public class ObjectDirectoryTest extends TestCase {\n \tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n \tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\nindex ef28a26..8dc9109 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\n@@ -1,3 +1,39 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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.File;\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\nindex 26f8f22..96a39fc 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java\n@@ -1,3 +1,39 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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;\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\nindex f95be2f..48f60d1 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java\n@@ -1,3 +1,39 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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.File;\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\nindex 3dd0418..0efc244 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n@@ -1,3 +1,39 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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.util.List;\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\nindex e4caa43..af61069 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryBasedPacksInfoCache.java\n@@ -1,3 +1,39 @@\n+/*\n+ * Copyright (C) 2009, Mike Gaffney.\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.File;\n-- \n1.6.4.2\n"},{"id":"123087","messageId":"1252867475-858-20-git-send-email-mr.gaffo@gmail.com","threadId":"20935","inReplyTo":"1252867475-858-19-git-send-email-mr.gaffo@gmail.com","subject":"[PATCH JGit 19/19] changed \\r to \\n per compliance with real git","fromName":"","fromEmail":"mr.gaffo@gmail.com","sentAt":"2009-09-13T18:44:35Z","receivedAt":"2009-09-13T18:44:35Z","isPatch":true,"sender":{"key":"mr.gaffo@gmail.com","avatar":"https://gravatar.com/avatar/5af46a60cbd83f2ddb0c2cf4d02b91db42fd25e2ac568ff0d71f699d852ee79d?d=mp&s=160"},"body":"From: mike.gaffney <mike.gaffney@asolutions.com>\n\n---\n .../jgit/lib/PacksFileContentsCreatorTest.java     |    9 +++++----\n .../spearce/jgit/lib/PacksFileContentsCreator.java |    3 ++-\n 2 files changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\nindex 8dc9109..bf61a59 100644\n--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\n+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PacksFileContentsCreatorTest.java\n@@ -53,7 +53,7 @@ public void testGettingPacksContentsSinglePack() throws Exception {\n \t\tList<PackFile> packs = new ArrayList<PackFile>();\n \t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n \t\t\n-\t\tassertEquals(\"P \" + TEST_PACK.getName() + '\\r', new PacksFileContentsCreator(packs).toString());\n+\t\tassertEquals(\"P \" + TEST_PACK.getName() + \"\\n\\n\", new PacksFileContentsCreator(packs).toString());\n \t}\n \t\n \tpublic void testGettingPacksContentsMultiplePacks() throws Exception {\n@@ -63,9 +63,10 @@ public void testGettingPacksContentsMultiplePacks() throws Exception {\n \t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n \t\t\n \t\tStringBuilder expected = new StringBuilder();\n-\t\texpected.append(\"P \").append(TEST_PACK.getName()).append(\"\\r\");\n-\t\texpected.append(\"P \").append(TEST_PACK.getName()).append(\"\\r\");\n-\t\texpected.append(\"P \").append(TEST_PACK.getName()).append(\"\\r\");\n+\t\texpected.append(\"P \").append(TEST_PACK.getName()).append('\\n');\n+\t\texpected.append(\"P \").append(TEST_PACK.getName()).append('\\n');\n+\t\texpected.append(\"P \").append(TEST_PACK.getName()).append('\\n');\n+\t\texpected.append('\\n');\n \t\t\n \t\tassertEquals(expected.toString(), new PacksFileContentsCreator(packs).toString());\n \t}\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\nindex 0efc244..e8b90a2 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n@@ -49,8 +49,9 @@ public PacksFileContentsCreator(List<PackFile> packs) {\n \tpublic String toString(){\n \t\tStringBuilder builder = new StringBuilder();\n \t\tfor (PackFile packFile : packs) {\n-\t\t\tbuilder.append(\"P \").append(packFile.getPackFile().getName()).append('\\r');\n+\t\t\tbuilder.append(\"P \").append(packFile.getPackFile().getName()).append('\\n');\n \t\t}\n+\t\tbuilder.append('\\n');\n \t\treturn builder.toString();\n \t}\n \n-- \n1.6.4.2\n"},{"id":"123266","messageId":"200909151735.58992.robin.rosenberg.lists@dewire.com","threadId":"20935","inReplyTo":"1252867475-858-5-git-send-email-mr.gaffo@gmail.com","subject":"Re: [PATCH JGit 04/19] added utility that generates the contents of the objects/info/packs file as a string from a list of PackFiles","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-09-15T15:35:58Z","receivedAt":"2009-09-15T15:35:58Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n> new file mode 100644\n> index 0000000..3dd0418\n> --- /dev/null\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PacksFileContentsCreator.java\n> @@ -0,0 +1,21 @@\n> +package org.spearce.jgit.lib;\n> +\n> +import java.util.List;\n> +\n> +public class PacksFileContentsCreator {\n> +\n> +\tprivate List<PackFile> packs;\n> +\n> +\tpublic PacksFileContentsCreator(List<PackFile> packs) {\nWe want good javadocs for (at least) all public and protected methods and \nclasses. (We enforce this for Eclipse users). If we had similar configuration files\nfor, perhaps netbeans we might have those too. (not finished thinking about that\nproposition...)\n\n> +\t\tthis.packs = packs;\n> +\t}\n> +\t\n> +\tpublic String toString(){\n\nDon't overload toString. Let it be useful for debug like purposes. With this style we cannot\nmake it useful since the application depends on its exact behaviour. You may define\na toString anyway that does the exact same thing, but please provide a specific method for \nassisting with the formatting of the file. A writeTo(OutputStream) is a useful interface in general.\n\n> +\t\tStringBuilder builder = new StringBuilder();\n> +\t\tfor (PackFile packFile : packs) {\n> +\t\t\tbuilder.append(\"P \").append(packFile.getPackFile().getName()).append('\\r');\n\nAt least my git formats the file with \\n as line terminator, so I think JGit should too.. \nGit ends the file with an extra \\n, though I'm not sure it's relevant.\n\n> +\t\t}\n> +\t\treturn builder.toString();\n> +\t}\n\nThe name is somewhat confusing as the s is hard to spot. The suggestion InfoPacksFileGenerator\nperhaps. It's a bit uglier by easier not to mix with generation of pack files.\n\n-- robin\n"},{"id":"123267","messageId":"200909151738.05742.robin.rosenberg.lists@dewire.com","threadId":"20935","inReplyTo":"1252867475-858-2-git-send-email-mr.gaffo@gmail.com","subject":"Re: [PATCH JGit 01/19] adding tests for ObjectDirectory","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-09-15T15:38:05Z","receivedAt":"2009-09-15T15:38:05Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndag 13 september 2009 20:44:17 skrev mr.gaffo@gmail.com:\n> From: mike.gaffney <mike.gaffney@asolutions.com>\n> \n> ---\n>  .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   80 ++++++++++++++++++++\n>  1 files changed, 80 insertions(+), 0 deletions(-)\n>  create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n> \n> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n> new file mode 100644\n> index 0000000..fe019af\n> --- /dev/null\n> +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n> @@ -0,0 +1,80 @@\n> +package org.spearce.jgit.lib;\n> +\n> +import java.io.File;\n> +import java.util.UUID;\n> +\n> +import junit.framework.TestCase;\n> +\n> +public class ObjectDirectoryTest extends TestCase {\n> +\t\n> +\tprivate File testDir;\n> +\n> +\t@Override\n> +\tprotected void setUp() throws Exception {\n> +\t\ttestDir = new File(new File(System.getProperty(\"java.io.tmpdir\")), UUID.randomUUID().toString());\n> +\t}\n\nGood. Now that we're on Java5 we might use this more.\n\n> +\tpublic void testGettingObjectFile() throws Exception {\n> +\t\tObjectDirectory od = new ObjectDirectory(testDir);\n> +\t\tassertEquals(new File(testDir, \"02/829ae153935095e4223f30cfc98c835de71bee\"), \n> +\t\t\t\t\t od.fileFor(ObjectId.fromString(\"02829ae153935095e4223f30cfc98c835de71bee\")));\n> +\t\tassertEquals(new File(testDir, \"b0/52a1272310d8df34de72f60204dee7e28a43d0\"), \n> +\t\t\t\t od.fileFor(ObjectId.fromString(\"b052a1272310d8df34de72f60204dee7e28a43d0\")));\n> +\t}\n> +\t\n> +\tpublic boolean deleteDir(File dir) {\n\nRepositoryTestcase already contains a recursive delete, including a static one\nthat you can use even without inheritance since you are within the same package. It is rather\nstandalone so it could perhaps move to JGitTestUtil.\n\n> +        if (dir.isDirectory()) {\n> +            String[] children = dir.list();\n> +            for (int i=0; i<children.length; i++) {\n> +                boolean success = deleteDir(new File(dir, children[i]));\n> +                if (!success) {\n> +                    return false;\n> +                }\n> +            }\n> +        }\n> +    \n> +        // The directory is now empty so delete it\n> +        return dir.delete();\n> +    }\n> +\n> +\tprivate void createTestDir(){\n> +\t\ttestDir.mkdir();\n\nNo error checking. If mkdirfails the test probably fails for mysterious  reasons,\n\n> +\t}\n> +\t\n> +}\n"},{"id":"123269","messageId":"200909151813.47782.robin.rosenberg.lists@dewire.com","threadId":"20935","inReplyTo":"1252867475-858-6-git-send-email-mr.gaffo@gmail.com","subject":"Re: [PATCH JGit 05/19] Made tests for listLocalPacks function on ObjectDirectory and made them pass","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-09-15T16:13:47Z","receivedAt":"2009-09-15T16:13:47Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndag 13 september 2009 20:44:21 skrev mr.gaffo@gmail.com:\n> From: mike.gaffney <mike.gaffney@asolutions.com>\n> \n> ---\n>  .../org/spearce/jgit/lib/ObjectDirectoryTest.java  |   24 ++++++++++++++++++++\n>  .../jgit/lib/UpdateDirectoryInfoCacheTest.java     |   11 +++++++++\n>  .../tst/org/spearce/jgit/util/JGitTestUtil.java    |   21 ++++++++++++++++-\n>  .../src/org/spearce/jgit/lib/ObjectDirectory.java  |    6 +++++\n>  .../spearce/jgit/lib/UpdateDirectoryInfoCache.java |   22 ++++++++++++++++++\n>  5 files changed, 83 insertions(+), 1 deletions(-)\n>  create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n>  create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n> \n> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n> index fe019af..8e4d8e5 100644\n> --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n> +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java\n> @@ -1,11 +1,17 @@\n>  package org.spearce.jgit.lib;\n>  \n>  import java.io.File;\n> +import java.util.List;\n>  import java.util.UUID;\n>  \n> +import org.spearce.jgit.util.JGitTestUtil;\n> +\n>  import junit.framework.TestCase;\n>  \n>  public class ObjectDirectoryTest extends TestCase {\n> +\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n> +\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n> +\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n>  \t\n>  \tprivate File testDir;\n>  \n> @@ -58,6 +64,24 @@ public void testGettingObjectFile() throws Exception {\n>  \t\t\t\t od.fileFor(ObjectId.fromString(\"b052a1272310d8df34de72f60204dee7e28a43d0\")));\n>  \t}\n>  \t\n> +\tpublic void testListLocalPacksNotCreated() throws Exception {\n> +\t\tassertEquals(0, new ObjectDirectory(testDir).listLocalPacks().size());\n> +\t}\n> +\t\n> +\tpublic void testListLocalPacksWhenThereIsAPack() throws Exception {\n> +\t\tcreateTestDir();\n> +\t\tFile packsDir = new File(testDir, \"pack\");\n> +\t\tpacksDir.mkdirs();\n> +\t\t\n> +\t\tJGitTestUtil.copyFile(TEST_PACK, new File(packsDir, TEST_PACK.getName()));\n> +\t\tJGitTestUtil.copyFile(TEST_IDX, new File(packsDir, TEST_IDX.getName()));\n> +\n> +\t\tObjectDirectory od = new ObjectDirectory(testDir);\n> +\t\tList<PackFile> localPacks = od.listLocalPacks();\n> +\t\tassertEquals(1, localPacks.size());\n> +\t\tassertEquals(TEST_PACK.getName(), localPacks.get(0).getPackFile().getName());\n> +\t}\n> +\t\n>  \tpublic boolean deleteDir(File dir) {\n>          if (dir.isDirectory()) {\n>              String[] children = dir.list();\n> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n> new file mode 100644\n> index 0000000..11d183e\n> --- /dev/null\n> +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n> @@ -0,0 +1,11 @@\n> +package org.spearce.jgit.lib;\n> +\n> +import junit.framework.TestCase;\n> +\n> +public class UpdateDirectoryInfoCacheTest extends TestCase {\n> +\t\n> +\tpublic void testBase() throws Exception {\n> +\t\tfail(\"nyi\");\n> +\t}\n> +\n> +}\n> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n> index eee0c14..04184d7 100644\n> --- a/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n> +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/util/JGitTestUtil.java\n> @@ -38,6 +38,12 @@\n>  package org.spearce.jgit.util;\n>  \n>  import java.io.File;\n> +import java.io.FileInputStream;\n> +import java.io.FileNotFoundException;\n> +import java.io.FileOutputStream;\n> +import java.io.IOException;\n> +import java.io.InputStream;\n> +import java.io.OutputStream;\n>  import java.net.URISyntaxException;\n>  import java.net.URL;\n>  \n> @@ -60,11 +66,24 @@ public static File getTestResourceFile(final String fileName) {\n>  \t\t}\n>  \t\ttry {\n>  \t\t\treturn new File(url.toURI());\n> -\t\t} catch(URISyntaxException e) {\n> +\t\t} catch (URISyntaxException e) {\n>  \t\t\treturn new File(url.getPath());\n>  \t\t}\n>  \t}\n>  \n> +\tpublic static void copyFile(final File fromFile, final File toFile) throws IOException {\n> +\t\tInputStream in = new FileInputStream(fromFile);\n> +\t\tOutputStream out = new FileOutputStream(toFile);\n> +\n> +\t\tbyte[] buf = new byte[1024];\n> +\t\tint len;\n> +\t\twhile ((len = in.read(buf)) > 0) {\n> +\t\t\tout.write(buf, 0, len);\n> +\t\t}\n> +\t\tin.close();\n> +\t\tout.close();\n> +\t}\n\nYou need to check for short reads, i.e. read could retrieve\nfewer bytes than requested, Less important, a larger buffer size could\nperhaps be used too (like 8192 which is the default BufferedReader buffer size).\n\n>  \tprivate static ClassLoader cl() {\n>  \t\treturn JGitTestUtil.class.getClassLoader();\n>  \t}\n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n> index fe219c6..a90ae00 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectDirectory.java\n> @@ -511,6 +511,12 @@ boolean tryAgain(final long currLastModified) {\n>  \n>  \t@Override\n>  \tpublic List<PackFile> listLocalPacks() {\n> +\t\ttryAgain1();\nmmmm. probably good.\n\n> +\tpublic void execute() {\n> +//\t\tFile objectFile = objectDatabase.\n> +//\t\tString packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();\n\nOut commented code is a no-no.\n\n-- robin\n"},{"id":"123282","messageId":"200909152123.39766.robin.rosenberg.lists@dewire.com","threadId":"20935","inReplyTo":"1252867475-858-10-git-send-email-mr.gaffo@gmail.com","subject":"Re: [PATCH JGit 09/19] Didn't like the old name, this is more specific to it just updating the packs info cache","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-09-15T19:23:39Z","receivedAt":"2009-09-15T19:23:39Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"\nOk, I stop reading here. Clean up and resubmit. Could you also set your real\nin the patches name like the rest of us, i.e. Mike Gaffney instead of mike.gaffney\nand add the Signed-Off-by and everything else mentioned in the SUBMITTING_PATCHES\ndocument at the root of the JGit repo.\n\n-- robin\n"},{"id":"123281","messageId":"200909152123.46131.robin.rosenberg.lists@dewire.com","threadId":"20935","inReplyTo":"1252867475-858-8-git-send-email-mr.gaffo@gmail.com","subject":"Re: [PATCH JGit 07/19] implemented the packs file update functionality","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-09-15T19:23:45Z","receivedAt":"2009-09-15T19:23:45Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndag 13 september 2009 20:44:23 skrev mr.gaffo@gmail.com:\n> From: mike.gaffney <mike.gaffney@asolutions.com>\n> \n> ---\n>  .../jgit/lib/UpdateDirectoryInfoCacheTest.java     |   23 ++++++++++++++++++-\n>  .../spearce/jgit/lib/UpdateDirectoryInfoCache.java |   17 +++++++++-----\n>  2 files changed, 32 insertions(+), 8 deletions(-)\n> \n> diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n> index 11d183e..25b78c5 100644\n> --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n> +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/UpdateDirectoryInfoCacheTest.java\n> @@ -1,11 +1,30 @@\n>  package org.spearce.jgit.lib;\n>  \n> +import java.io.File;\n> +import java.util.ArrayList;\n> +import java.util.List;\n> +\n>  import junit.framework.TestCase;\n>  \n> +import org.spearce.jgit.util.JGitTestUtil;\n> +\n>  public class UpdateDirectoryInfoCacheTest extends TestCase {\n> +\tprivate static final String PACK_NAME = \"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f\";\n> +\tprivate static final File TEST_PACK = JGitTestUtil.getTestResourceFile(PACK_NAME + \".pack\");\n> +\tprivate static final File TEST_IDX = JGitTestUtil.getTestResourceFile(PACK_NAME + \".idx\");\n>  \t\n> -\tpublic void testBase() throws Exception {\n> -\t\tfail(\"nyi\");\n> +\tpublic void testCreatesTheFileAndPutsTheContentsIn() throws Exception {\n> +\t\tList<PackFile> packs = new ArrayList<PackFile>();\n> +\t\tpacks.add(new PackFile(TEST_IDX, TEST_PACK));\n> +\t\t\n> +\t\tFile packsFile = File.createTempFile(UpdateDirectoryInfoCacheTest.class.getSimpleName(), \"tstdata\");\n> +\t\tpacksFile.deleteOnExit();\n> +\t\t\n> +\t\tString expectedContents = new PacksFileContentsCreator(packs).toString();\n> +\t\t\n> +\t\tnew UpdateDirectoryInfoCache(packs, packsFile).execute();\n> +\t\t\n> +\t\tassertEquals(expectedContents, JGitTestUtil.readFileAsString(packsFile));\n>  \t}\n>  \n>  }\n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n> index 2bceb9e..72a315a 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/UpdateDirectoryInfoCache.java\n> @@ -1,22 +1,27 @@\n>  package org.spearce.jgit.lib;\n>  \n> +import java.io.BufferedWriter;\n>  import java.io.File;\n> +import java.io.FileOutputStream;\n> +import java.io.IOException;\n>  import java.util.List;\n>  \n>  public class UpdateDirectoryInfoCache {\n>  \n>  \tprivate List<PackFile> packsList;\n> -\tprivate File infoDirectory;\n> +\tprivate File infoPacksFile;\n>  \n>  \tpublic UpdateDirectoryInfoCache(List<PackFile> packsList,\n> -\t\t\tFile infoDirectory) {\n> +\t\t\t\t\t\t\t\t\tFile infoPacksFile) {\n>  \t\tthis.packsList = packsList;\n> -\t\tthis.infoDirectory = infoDirectory;\n> +\t\tthis.infoPacksFile = infoPacksFile;\n>  \t}\n>  \n> -\tpublic void execute() {\n> -//\t\tFile objectFile = objectDatabase.\n> -//\t\tString packsContents = new PacksFileContentsCreator(this.objectDatabase.listLocalPacks()).toString();\n> +\tpublic void execute() throws IOException {\n> +\t\tString packsContents = new PacksFileContentsCreator(packsList).toString();\n> +\t\tFileOutputStream fos = new FileOutputStream(infoPacksFile);\n> +\t\tfos.write(packsContents.getBytes());\n> +\t\tfos.close();\n>  \t}\n>  \n>  }\n\nThese cleanups could have been done by rewriting the patch set before submitting.\n\n-- robin\n"}]}