{"thread":{"id":"17831","subject":"[JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","startedAt":"2009-02-16T20:12:29Z","lastAt":"2009-02-20T20:32:15Z","messageCount":10,"participants":["Nigel Magnay","Johannes Schindelin","Shawn O. Pearce","Robin Rosenberg","Sverre Rabbelier"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"104998","messageId":"320075ff0902161212s1980cd70r8cdc4c21550333ee@mail.gmail.com","threadId":"17831","inReplyTo":null,"subject":"[JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Nigel Magnay","fromEmail":"nigel.magnay@gmail.com","sentAt":"2009-02-16T20:12:29Z","receivedAt":"2009-02-16T20:12:29Z","isPatch":true,"sender":{"key":"nigel.magnay@gmail.com","avatar":"https://gravatar.com/avatar/d85cf38287bef3a8e4fa02358d2756d7589f8676c5eeb881ce2f6d731e4526c3?d=mp&s=160"},"body":"JGit is used as a library in external projects such as build tools.\nSome of the representations of git data structures are useful\nin these external tools - but - it is often desirable to be able to\neither persist these objects, or serialize them across the wire.\n\nApply Externalizable to URIish and RefSpec, and Serializable to\nObjectId and RemoteConfig (in order to avoid the undesirable\nrequirement of a public, no-args constructor needed for Externalizable).\n\n Signed-off-by: Nigel Magnay <nigel.magnay@gmail.com>\n\n---\n .../src/org/spearce/jgit/lib/ObjectId.java         |   22 +++++-\n .../src/org/spearce/jgit/transport/RefSpec.java    |   77 +++++++++++++------\n .../org/spearce/jgit/transport/RemoteConfig.java   |   79 +++++++++++++++++++-\n .../src/org/spearce/jgit/transport/URIish.java     |   29 +++++++-\n 4 files changed, 179 insertions(+), 28 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java\nb/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java\nindex 52ce0d4..7c3b922 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java\n@@ -38,6 +38,10 @@\n\n package org.spearce.jgit.lib;\n\n+import java.io.IOException;\n+import java.io.ObjectInputStream;\n+import java.io.ObjectOutputStream;\n+import java.io.Serializable;\n import java.io.UnsupportedEncodingException;\n\n import org.spearce.jgit.util.NB;\n@@ -45,7 +49,7 @@\n /**\n  * A SHA-1 abstraction.\n  */\n-public class ObjectId extends AnyObjectId {\n+public class ObjectId extends AnyObjectId implements Serializable {\n \tprivate static final ObjectId ZEROID;\n\n \tprivate static final String ZEROID_STR;\n@@ -269,4 +273,20 @@ protected ObjectId(final AnyObjectId src) {\n \tpublic ObjectId toObjectId() {\n \t\treturn this;\n \t}\n+\n+\tprivate void writeObject(ObjectOutputStream os)  throws IOException {\n+\t\tos.writeInt(w1);\n+\t\tos.writeInt(w2);\n+\t\tos.writeInt(w3);\n+\t\tos.writeInt(w4);\n+\t\tos.writeInt(w5);\n+\t}\n+\t\n+\tprivate void readObject(ObjectInputStream ois)  throws IOException {\n+\t\tw1 = ois.readInt();\n+\t\tw2 = ois.readInt();\n+\t\tw3 = ois.readInt();\n+\t\tw4 = ois.readInt();\n+\t\tw5 = ois.readInt();\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\nb/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\nindex 521110b..0ee89b0 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RefSpec.java\n@@ -37,6 +37,11 @@\n\n package org.spearce.jgit.transport;\n\n+import java.io.Externalizable;\n+import java.io.IOException;\n+import java.io.ObjectInput;\n+import java.io.ObjectOutput;\n+\n import org.spearce.jgit.lib.Constants;\n import org.spearce.jgit.lib.Ref;\n\n@@ -46,7 +51,7 @@\n  * A ref specification provides matching support and limited rules to rewrite a\n  * reference in one repository to another reference in another repository.\n  */\n-public class RefSpec {\n+public class RefSpec implements Externalizable {\n \t/**\n \t * Suffix for wildcard ref spec component, that indicate matching all refs\n \t * with specified prefix.\n@@ -109,30 +114,7 @@ public RefSpec() {\n \t *             the specification is invalid.\n \t */\n \tpublic RefSpec(final String spec) {\n-\t\tString s = spec;\n-\t\tif (s.startsWith(\"+\")) {\n-\t\t\tforce = true;\n-\t\t\ts = s.substring(1);\n-\t\t}\n-\n-\t\tfinal int c = s.indexOf(':');\n-\t\tif (c == 0) {\n-\t\t\ts = s.substring(1);\n-\t\t\tif (isWildcard(s))\n-\t\t\t\tthrow new IllegalArgumentException(\"Invalid wildcards \" + spec);\n-\t\t\tdstName = s;\n-\t\t} else if (c > 0) {\n-\t\t\tsrcName = s.substring(0, c);\n-\t\t\tdstName = s.substring(c + 1);\n-\t\t\tif (isWildcard(srcName) && isWildcard(dstName))\n-\t\t\t\twildcard = true;\n-\t\t\telse if (isWildcard(srcName) || isWildcard(dstName))\n-\t\t\t\tthrow new IllegalArgumentException(\"Invalid wildcards \" + spec);\n-\t\t} else {\n-\t\t\tif (isWildcard(s))\n-\t\t\t\tthrow new IllegalArgumentException(\"Invalid wildcards \" + spec);\n-\t\t\tsrcName = s;\n-\t\t}\n+\t\tinitializeFromString(spec);\n \t}\n\n \t/**\n@@ -161,6 +143,42 @@ private RefSpec(final RefSpec p) {\n \t}\n\n \t/**\n+\t * Initialize the ref specification from a string.\n+\t *\n+\t * @param spec\n+\t *            string describing the specification.\n+\t * @throws IllegalArgumentException\n+\t *             the specification is invalid.\n+\t */\n+\tprivate void initializeFromString(final String spec) {\n+\t\tsrcName = null;\n+\t\tString s = spec;\n+\t\tif (s.startsWith(\"+\")) {\n+\t\t\tforce = true;\n+\t\t\ts = s.substring(1);\n+\t\t}\n+\n+\t\tfinal int c = s.indexOf(':');\n+\t\tif (c == 0) {\n+\t\t\ts = s.substring(1);\n+\t\t\tif (isWildcard(s))\n+\t\t\t\tthrow new IllegalArgumentException(\"Invalid wildcards \" + spec);\n+\t\t\tdstName = s;\n+\t\t} else if (c > 0) {\n+\t\t\tsrcName = s.substring(0, c);\n+\t\t\tdstName = s.substring(c + 1);\n+\t\t\tif (isWildcard(srcName) && isWildcard(dstName))\n+\t\t\t\twildcard = true;\n+\t\t\telse if (isWildcard(srcName) || isWildcard(dstName))\n+\t\t\t\tthrow new IllegalArgumentException(\"Invalid wildcards \" + spec);\n+\t\t} else {\n+\t\t\tif (isWildcard(s))\n+\t\t\t\tthrow new IllegalArgumentException(\"Invalid wildcards \" + spec);\n+\t\t\tsrcName = s;\n+\t\t}\n+\t}\n+\t\n+\t/**\n \t * Check if this specification wants to forcefully update the destination.\n \t *\n \t * @return true if this specification asks for updates without merge tests.\n@@ -421,4 +439,13 @@ public String toString() {\n \t\t}\n \t\treturn r.toString();\n \t}\n+\n+\tpublic void readExternal(ObjectInput in) throws IOException,\n+\t\t\tClassNotFoundException {\n+\t\tinitializeFromString(in.readUTF());\t\n+\t}\n+\n+\tpublic void writeExternal(ObjectOutput out) throws IOException {\n+\t\tout.writeUTF(toString());\n+\t}\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\nb/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\nindex 5bbf664..899f73f 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n@@ -38,6 +38,10 @@\n\n package org.spearce.jgit.transport;\n\n+import java.io.IOException;\n+import java.io.ObjectInputStream;\n+import java.io.ObjectOutputStream;\n+import java.io.Serializable;\n import java.net.URISyntaxException;\n import java.util.ArrayList;\n import java.util.Collections;\n@@ -53,7 +57,7 @@\n  * describing how refs should be transferred between this repository and the\n  * remote repository.\n  */\n-public class RemoteConfig {\n+public class RemoteConfig implements Serializable {\n \tprivate static final String SECTION = \"remote\";\n\n \tprivate static final String KEY_URL = \"url\";\n@@ -382,4 +386,77 @@ public TagOpt getTagOpt() {\n \tpublic void setTagOpt(final TagOpt option) {\n \t\ttagopt = option != null ? option : TagOpt.AUTO_FOLLOW;\n \t}\n+\t\n+\tprivate void writeObject(ObjectOutputStream os) throws IOException {\n+\n+\t    // Name\n+\t    os.writeUTF(name);\n+\t\n+\t    // Key, Value pairs\n+\t    for (URIish uri : uris) {\n+            os.writeUTF(KEY_URL);\n+            os.writeUTF(uri.toPrivateString());\n+        }\n+\n+        for (RefSpec refspec : fetch) {\n+            os.writeUTF(KEY_FETCH);\n+            os.writeUTF(refspec.toString());\n+        }\n+\n+        for (RefSpec refspec : push) {\n+        \tos.writeUTF(KEY_PUSH);\n+            os.writeUTF(refspec.toString());\n+        }\n+\n+        os.writeUTF(KEY_UPLOADPACK);\n+        os.writeUTF(uploadpack);\n+\n+        os.writeUTF(KEY_RECEIVEPACK);\n+        os.writeUTF(receivepack);\n+\n+        os.writeUTF(KEY_TAGOPT);\n+        os.writeUTF(tagopt.option());\n+\n+        // End marker\n+        os.writeUTF(\"\");\n+    }\n+\n+    private void readObject(ObjectInputStream ois) throws IOException {\n+\t\turis = new ArrayList<URIish>();\n+        fetch = new ArrayList<RefSpec>();\n+        push = new ArrayList<RefSpec>();\n+        uploadpack = DEFAULT_UPLOAD_PACK;\n+        receivepack = DEFAULT_RECEIVE_PACK;\n+\n+        name = ois.readUTF();\n+\n+\t\tfor (String key = ois.readUTF(); key.length() > 0; key = ois.readUTF()) {\n+\t\t\tString value = ois.readUTF();\n+\n+\t\t\tif (key.equals(KEY_URL)) {\n+\t\t\t\ttry {\n+\t\t\t\t\turis.add(new URIish(value));\n+\t\t\t\t} catch (URISyntaxException e) {\n+\t\t\t\t\tthrow new IOException(\"Invalid URI in RemoteConfig : \"\n+\t\t\t\t\t\t\t+ value);\n+\t\t\t\t}\n+\t\t\t} else if (key.equals(KEY_FETCH)) {\n+\t\t\t\tfetch.add(new RefSpec(value));\n+\n+\t\t\t} else if (key.equals(KEY_PUSH)) {\n+\t\t\t\tpush.add(new RefSpec(value));\n+\n+\t\t\t} else if (key.equals(KEY_UPLOADPACK)) {\n+\t\t\t\tuploadpack = value;\n+\n+\t\t\t} else if (key.equals(KEY_RECEIVEPACK)) {\n+\t\t\t\treceivepack = value;\n+\n+\t\t\t} else if (key.equals(KEY_TAGOPT)) {\n+\t\t\t\ttagopt = TagOpt.fromOption(value);\n+\t\t\t}\n+\n+\t\t}\n+\n+    }\n }\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/URIish.java\nb/org.spearce.jgit/src/org/spearce/jgit/transport/URIish.java\nindex b86e00c..6b85f45 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/URIish.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/URIish.java\n@@ -38,6 +38,10 @@\n\n package org.spearce.jgit.transport;\n\n+import java.io.Externalizable;\n+import java.io.IOException;\n+import java.io.ObjectInput;\n+import java.io.ObjectOutput;\n import java.net.URISyntaxException;\n import java.net.URL;\n import java.util.regex.Matcher;\n@@ -49,7 +53,7 @@\n  * RFC 2396 URI's is that no URI encoding/decoding ever takes place. A space or\n  * any special character is written as-is.\n  */\n-public class URIish {\n+public class URIish implements Externalizable {\n \tprivate static final Pattern FULL_URI = Pattern\n \t\t\t.compile(\"^(?:([a-z][a-z0-9+-]+)://(?:([^/]+?)(?::([^/]+?))?@)?(?:([^/]+?))?(?::(\\\\d+))?)?((?:[A-Za-z]:)?/.+)$\");\n\n@@ -75,6 +79,16 @@\n \t * @throws URISyntaxException\n \t */\n \tpublic URIish(String s) throws URISyntaxException {\n+\t\tinitializeFromString(s);\n+\t}\n+\t\n+\t/**\n+\t * Set fields from string based URI.\n+\t *\n+\t * @param s\n+\t * @throws URISyntaxException\n+\t */\n+\tprivate void initializeFromString(String s)  throws URISyntaxException {\n \t\ts = s.replace('\\\\', '/');\n \t\tMatcher matcher = FULL_URI.matcher(s);\n \t\tif (matcher.matches()) {\n@@ -357,4 +371,17 @@ private String format(final boolean includePassword) {\n\n \t\treturn r.toString();\n \t}\n+\n+\tpublic void readExternal(ObjectInput in) throws IOException,\n+\t\t\tClassNotFoundException {\n+\t    try {\n+\t\t\tinitializeFromString(in.readUTF());\n+\t\t} catch (URISyntaxException e) {\n+\t\t\tthrow new IOException(\"Incorrect format URI\");\n+\t\t}\n+\t}\n+\n+\tpublic void writeExternal(ObjectOutput out) throws IOException {\n+\t\tout.writeUTF(format(true));\n+\t}\n }\n-- \n1.6.0.2\n"},{"id":"105003","messageId":"alpine.DEB.1.00.0902162115350.6289@intel-tinevez-2-302","threadId":"17831","inReplyTo":"320075ff0902161212s1980cd70r8cdc4c21550333ee@mail.gmail.com","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-16T20:16:02Z","receivedAt":"2009-02-16T20:16:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 16 Feb 2009, Nigel Magnay wrote:\n\n> JGit is used as a library in external projects such as build tools.\n> Some of the representations of git data structures are useful\n> in these external tools - but - it is often desirable to be able to\n> either persist these objects, or serialize them across the wire.\n\nI am still missing the description of the format.\n\n>  Signed-off-by: Nigel Magnay <nigel.magnay@gmail.com>\n\nAnd I wonder what that leading space is all about.\n\nCiao,\nDscho\n"},{"id":"105320","messageId":"20090218163002.GB22848@spearce.org","threadId":"17831","inReplyTo":"320075ff0902161212s1980cd70r8cdc4c21550333ee@mail.gmail.com","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-18T16:30:02Z","receivedAt":"2009-02-18T16:30:02Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nigel Magnay <nigel.magnay@gmail.com> wrote:\n> +public class ObjectId extends AnyObjectId implements Serializable {\n\nWe should define our own serialVersionUID:\n\n  private static final long serialVersionUID = 1L;\n\nis good enough to make Java happy.\n\n> @@ -269,4 +273,20 @@ protected ObjectId(final AnyObjectId src) {\n>  \tpublic ObjectId toObjectId() {\n>  \t\treturn this;\n>  \t}\n> +\n> +\tprivate void writeObject(ObjectOutputStream os)  throws IOException {\n> +\tprivate void readObject(ObjectInputStream ois)  throws IOException {\n\nMinor nit: Only 1 space between ) and throws, please.\n\n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n> b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n> index 5bbf664..899f73f 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/RemoteConfig.java\n> @@ -53,7 +57,7 @@\n>   * describing how refs should be transferred between this repository and the\n>   * remote repository.\n>   */\n> -public class RemoteConfig {\n> +public class RemoteConfig implements Serializable {\n\nPlease set a serialVersionUID.\n\n> @@ -382,4 +386,77 @@ public TagOpt getTagOpt() {\n>  \tpublic void setTagOpt(final TagOpt option) {\n>  \t\ttagopt = option != null ? option : TagOpt.AUTO_FOLLOW;\n>  \t}\n> +\t\n> +\tprivate void writeObject(ObjectOutputStream os) throws IOException {\n> +\n> +\t    // Name\n> +\t    os.writeUTF(name);\n> +\t\n> +\t    // Key, Value pairs\n> +\t    for (URIish uri : uris) {\n> +            os.writeUTF(KEY_URL);\n> +            os.writeUTF(uri.toPrivateString());\n> +        }\n> +\n> +        for (RefSpec refspec : fetch) {\n\nThere is some sort of whitespace damage here, the second for loop\nis not lined up at the same starting column as the first for loop.\nMy guess is, you have tabs in here.  We only indent with spaces.\n\n> +            os.writeUTF(KEY_FETCH);\n> +            os.writeUTF(refspec.toString());\n> +        }\n> +\n> +        for (RefSpec refspec : push) {\n> +        \tos.writeUTF(KEY_PUSH);\n> +            os.writeUTF(refspec.toString());\n> +        }\n\nShould we maybe allow RefSpec to serialize itself with\nos.writeObject() rather than using writeUTF() directly?\n\nFWIW, I did find this new implementation to be much easier to read.\nThanks.\n\n-- \nShawn.\n"},{"id":"105340","messageId":"200902182159.51027.robin.rosenberg.lists@dewire.com","threadId":"17831","inReplyTo":"20090218163002.GB22848@spearce.org","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-02-18T20:59:50Z","receivedAt":"2009-02-18T20:59:50Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Shawn wrote:\n> > +            os.writeUTF(KEY_FETCH);\n> > +            os.writeUTF(refspec.toString());\n> > +        }\n> > +\n> > +        for (RefSpec refspec : push) {\n> > +        \tos.writeUTF(KEY_PUSH);\n> > +            os.writeUTF(refspec.toString());\n> > +        }\n> \n> Should we maybe allow RefSpec to serialize itself with\n> os.writeObject() rather than using writeUTF() directly?\n\nDoesn't the style above make it easy to define and document\na format that is easy for non-java programs to write and read,\nwhile writeObject introduces java-centric stuff (depending on\nthe full class name etc).\n\n-- robin\n"},{"id":"105347","messageId":"20090218214859.GN22848@spearce.org","threadId":"17831","inReplyTo":"200902182159.51027.robin.rosenberg.lists@dewire.com","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-18T21:48:59Z","receivedAt":"2009-02-18T21:48:59Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:\n> Shawn wrote:\n> > > +            os.writeUTF(KEY_FETCH);\n> > > +            os.writeUTF(refspec.toString());\n> > > +        }\n> > > +\n> > > +        for (RefSpec refspec : push) {\n> > > +        \tos.writeUTF(KEY_PUSH);\n> > > +            os.writeUTF(refspec.toString());\n> > > +        }\n> > \n> > Should we maybe allow RefSpec to serialize itself with\n> > os.writeObject() rather than using writeUTF() directly?\n> \n> Doesn't the style above make it easy to define and document\n> a format that is easy for non-java programs to write and read,\n> while writeObject introduces java-centric stuff (depending on\n> the full class name etc).\n\nNon-Java reading a Java serialization stream?  Seriously?\n\n-- \nShawn.\n"},{"id":"105352","messageId":"bd6139dc0902181419n504dde97y8b3a8862b3f081cc@mail.gmail.com","threadId":"17831","inReplyTo":"20090218214859.GN22848@spearce.org","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-02-18T22:19:15Z","receivedAt":"2009-02-18T22:19:15Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"On Wed, Feb 18, 2009 at 22:48, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Non-Java reading a Java serialization stream?  Seriously?\n\nThat would be a contender for UJSFWIINI :P (with JS standing for Java\nSerialization).\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"105359","messageId":"200902190021.33382.robin.rosenberg.lists@dewire.com","threadId":"17831","inReplyTo":"20090218214859.GN22848@spearce.org","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-02-18T23:21:33Z","receivedAt":"2009-02-18T23:21:33Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"onsdag 18 februari 2009 22:48:59 skrev \"Shawn O. Pearce\" <spearce@spearce.org>:\n> Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:\n> > Shawn wrote:\n> > > > +            os.writeUTF(KEY_FETCH);\n> > > > +            os.writeUTF(refspec.toString());\n> > > > +        }\n> > > > +\n> > > > +        for (RefSpec refspec : push) {\n> > > > +        \tos.writeUTF(KEY_PUSH);\n> > > > +            os.writeUTF(refspec.toString());\n> > > > +        }\n> > > \n> > > Should we maybe allow RefSpec to serialize itself with\n> > > os.writeObject() rather than using writeUTF() directly?\n> > \n> > Doesn't the style above make it easy to define and document\n> > a format that is easy for non-java programs to write and read,\n> > while writeObject introduces java-centric stuff (depending on\n> > the full class name etc).\n> \n> Non-Java reading a Java serialization stream?  Seriously?\n\nNo, that was my objection to using writeObject, as that make\nit a Java-only stream, but then it might not be worth doing\nit via the serialization mechanism.\n\n-- robin\n"},{"id":"105360","messageId":"20090218232745.GP22848@spearce.org","threadId":"17831","inReplyTo":"200902190021.33382.robin.rosenberg.lists@dewire.com","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-18T23:27:45Z","receivedAt":"2009-02-18T23:27:45Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:\n> onsdag 18 februari 2009 22:48:59 skrev \"Shawn O. Pearce\" <spearce@spearce.org>:\n> > \n> > Non-Java reading a Java serialization stream?  Seriously?\n> \n> No, that was my objection to using writeObject, as that make\n> it a Java-only stream, but then it might not be worth doing\n> it via the serialization mechanism.\n\nIMHO, if we are talking about either java.io.Serializable or\njava.io.Externalizable, there's no point in considering a non\nJava peer.\n\nIf you want a non-Java format, we'd need to consider a much\nmore neutral encoding, like Google's protobuf, or *shudder*\nXML/JSON, or cooking up our own format.\n\nThat wasn't this thread started with.  The original poster just\nwanted an easy way to serialize some basic data types from JGit,\nas part of some higher level stream being done in the container\napplication.  Since that higher level stream is a apparently a\nJava object serialization stream, we just need to match that.\n\n-- \nShawn.\n"},{"id":"105593","messageId":"320075ff0902200128o6b9772a4tcbd652e7654524e@mail.gmail.com","threadId":"17831","inReplyTo":"320075ff0902200127m3e516621m60a608bc891ab992@mail.gmail.com","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Nigel Magnay","fromEmail":"nigel.magnay@gmail.com","sentAt":"2009-02-20T09:28:38Z","receivedAt":"2009-02-20T09:28:38Z","isPatch":true,"sender":{"key":"nigel.magnay@gmail.com","avatar":"https://gravatar.com/avatar/d85cf38287bef3a8e4fa02358d2756d7589f8676c5eeb881ce2f6d731e4526c3?d=mp&s=160"},"body":"On Wed, Feb 18, 2009 at 4:30 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n>\n> Nigel Magnay <nigel.magnay@gmail.com> wrote:\n> > +public class ObjectId extends AnyObjectId implements Serializable {\n>\n> We should define our own serialVersionUID:\n>\n>  private static final long serialVersionUID = 1L;\n>\n> is good enough to make Java happy.\n\nI'll re-roll. Actually both that and the whitespace damage I'm\npartially blaming on eclipse. Eclipse curiously removes the warning to\ndeclare serialVersionUID if you declare both writeObject and\nreadObject - that's wrong!\n\nAlso the formatting came from\n.settings/org.eclipse.core.resources.prefs which has a tab policy of\n\"Tabs only\" which has overridden my environment setting of\nspaces-only.\n\nI can modify it to spaces only - but the comment in 9268ced9d38 talks\nabout spaces-per-tab..?\n"},{"id":"105650","messageId":"20090220203215.GD22848@spearce.org","threadId":"17831","inReplyTo":"320075ff0902200127m3e516621m60a608bc891ab992@mail.gmail.com","subject":"Re: [JGIT PATCH] 1/2 : (reworked) Externalizable/Serializable Items","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-20T20:32:15Z","receivedAt":"2009-02-20T20:32:15Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nigel Magnay <nigel.magnay@gmail.com> wrote:\n> On Wed, Feb 18, 2009 at 4:30 PM, Shawn O. Pearce <spearce@spearce.org>wrote:\n> \n> > Nigel Magnay <nigel.magnay@gmail.com> wrote:\n> > > +public class ObjectId extends AnyObjectId implements Serializable {\n> >\n> > We should define our own serialVersionUID:\n> >\n> >  private static final long serialVersionUID = 1L;\n> >\n> > is good enough to make Java happy.\n> >\n> \n> I'll re-roll. Actually both that and the whitespace damage I'm partially\n> blaming on eclipse. Eclipse curiously removes the warning to declare\n> serialVersionUID if you declare both writeObject and readObject - that's\n> wrong!\n\nYikes.  What a nice feature.\n \n> Also the formatting came from .settings/org.eclipse.core.resources.prefs\n> which has a tab policy of \"Tabs only\" which has overridden my environment\n> setting of spaces-only.\n>\n> I can modify it to spaces only - but the comment in 9268ced9d38 talks about\n> spaces-per-tab..?\n\nOh, yea, my bad.\n\nWe prefer tabs, and only tabs, and we only indent the leading part of\nthe line, we never try to \"line up\" columns of variables (for example).\n\nI guess there was a mixture here.  Not sure why.  Sometimes I've\nseen Eclipse not immediately honor the per-project settings files.\nClosing or deleting and re-importing the project usually fixes it,\nbut not always.  :-|\n\n-- \nShawn.\n"}]}