{"thread":{"id":"15332","subject":"[JGIT PATCH 3/3] Add a tiny \"jgit version\" program","startedAt":"2008-09-02T16:28:10Z","lastAt":"2008-09-02T16:28:12Z","messageCount":3,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"89512","messageId":"1220372892-15423-1-git-send-email-spearce@spearce.org","threadId":"15332","inReplyTo":null,"subject":"[JGIT PATCH 1/3] Make all files in our JAR have the same timestamp","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-02T16:28:10Z","receivedAt":"2008-09-02T16:28:10Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"When we link together our classes into a JAR we want to use the same\ntimestamp for all entries in the archive.  Using different times from\nthe local filesystem is fairly meaningless.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../org/spearce/jgit/pgm/build/JarLinkUtil.java    |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java\nindex 46ae0ea..929ee55 100644\n--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java\n+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java\n@@ -93,6 +93,8 @@ public static void main(final String[] argv) throws IOException {\n \n \tprivate final Map<String, File> chosenSources = new HashMap<String, File>();\n \n+\tprivate long creationTime;\n+\n \tprivate ZipOutputStream zos;\n \n \tprivate JarLinkUtil() {\n@@ -109,6 +111,7 @@ private void run() throws IOException {\n \t\tfor (final Map.Entry<String, String> e : files.entrySet())\n \t\t\tchosenSources.put(e.getKey(), new File(e.getValue()));\n \n+\t\tcreationTime = System.currentTimeMillis();\n \t\tzos = new ZipOutputStream(System.out);\n \t\tzos.setLevel(9);\n \n@@ -180,9 +183,8 @@ else if (chosenSources.get(pfx + e.getName()) == rootDir)\n \tprivate void appendFile(final File path, final String name)\n \t\t\tthrows IOException {\n \t\tfinal long len = path.length();\n-\t\tfinal long time = path.lastModified();\n \t\tfinal InputStream is = new FileInputStream(path);\n-\t\tappendEntry(name, len, time, is);\n+\t\tappendEntry(name, len, creationTime, is);\n \t}\n \n \tprivate void appendEntry(final String name, final long len,\n-- \n1.6.0.1.207.g020e5\n"},{"id":"89513","messageId":"1220372892-15423-2-git-send-email-spearce@spearce.org","threadId":"15332","inReplyTo":"1220372892-15423-1-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 2/3] Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-02T16:28:11Z","receivedAt":"2008-09-02T16:28:11Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"When we build jgit the CLI executable we have the classes already\ncompiled so we can easily construct a jgit.jar and jgit_src.zip\nat the same time.  This makes it easier for folks who need the\nlibrary and not the command line interface package.\n\nWe do not include JSch in jgit.jar as we assume the downstream\nuser can supply us the package.  In an IDE scenario it is quite\nlikely the IDE already has a copy of JSch available for use, so\nwe really don't want to supply our own and potentially put two\ndifferent versions on the classpath.\n\nThe version we embed within our JAR manifest is now more like\nthe dotted format used by C Git or git-gui.  In particular we\nembed the \"-dirty\" suffix if the tree contains modifications.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .gitignore   |    2 ++\n make_jgit.sh |   54 ++++++++++++++++++++++++++++++++++++++++++------------\n 2 files changed, 44 insertions(+), 12 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex 0763732..baf2766 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,3 @@\n /jgit\n+/jgit.jar\n+/jgit_src.zip\ndiff --git a/make_jgit.sh b/make_jgit.sh\nindex c119202..a15f73f 100755\n--- a/make_jgit.sh\n+++ b/make_jgit.sh\n@@ -1,6 +1,9 @@\n #!/bin/sh\n \n-O=jgit\n+O_CLI=jgit\n+O_JAR=jgit.jar\n+O_SRC=jgit_src.zip\n+\n PLUGINS=\"\n \torg.spearce.jgit\n \torg.spearce.jgit.pgm\n@@ -11,7 +14,7 @@ JARS=\"\n \"\n \n PSEP=\":\"\n-T=\".temp$$.$O\"\n+T=\".temp$$.$O_CLI\"\n T_MF=\"$T.MF\"\n R=`pwd`\n if [ \"$OSTYPE\" = \"cygwin\" ]\n@@ -30,7 +33,7 @@ then\n fi\n \n cleanup_bin() {\n-\trm -f $T $O+ $T_MF\n+\trm -f $T $O_CLI+ $O_JAR+ $O_SRC+ $T_MF\n \tfor p in $PLUGINS\n \tdo\n \t\trm -rf $p/bin2\n@@ -39,13 +42,21 @@ cleanup_bin() {\n \n die() {\n \tcleanup_bin\n-\trm -f $O\n+\trm -f $O_CLI $O_JAR $O_SRC\n \techo >&2 \"$@\"\n \texit 1\n }\n \n cleanup_bin\n-rm -f $O\n+rm -f $O_CLI $O_JAR $O_SRC\n+\n+VN=`git describe --abbrev=4 HEAD 2>/dev/null`\n+git update-index -q --refresh\n+if [ -n \"`git diff-index --name-only HEAD --`\" ]\n+then\n+\tVN=\"$VN-dirty\"\n+fi\n+VN=`echo \"$VN\" | sed -e s/-/./g`\n \n CLASSPATH=\n for j in $JARS\n@@ -73,20 +84,39 @@ do\n \t\t-d ../bin2) || die \"Building $p failed.\"\n \tCLASSPATH=\"${CLASSPATH}${PSEP}$R/$p/bin2\"\n done\n+echo\n \n+echo \"Version $VN\" &&\n echo Manifest-Version: 1.0 >$T_MF &&\n echo Implementation-Title: jgit >>$T_MF &&\n-echo Implementation-Version: `git describe HEAD` >>$T_MF &&\n+echo Implementation-Version: $VN >>$T_MF &&\n+\n+java org.spearce.jgit.pgm.build.JarLinkUtil \\\n+\t-include org.spearce.jgit/bin2 \\\n+\t-file META-INF/MANIFEST.MF=$T_MF \\\n+\t>$O_JAR+ &&\n+chmod 555 $O_JAR+ &&\n+mv $O_JAR+ $O_JAR &&\n+echo \"Created $O_JAR.\" &&\n+\n+java org.spearce.jgit.pgm.build.JarLinkUtil \\\n+\t-include org.spearce.jgit/src \\\n+\t-file META-INF/MANIFEST.MF=$T_MF \\\n+\t>$O_SRC+ &&\n+chmod 555 $O_SRC+ &&\n+mv $O_SRC+ $O_SRC &&\n+echo \"Created $O_SRC.\" &&\n \n-sed s/@@use_self@@/1/ jgit.sh >$O+ &&\n+M_TB=META-INF/services/org.spearce.jgit.pgm.TextBuiltin &&\n+sed s/@@use_self@@/1/ jgit.sh >$O_CLI+ &&\n java org.spearce.jgit.pgm.build.JarLinkUtil \\\n \t`for p in $JARS   ; do printf %s \" -include $p\"     ;done` \\\n \t`for p in $PLUGINS; do printf %s \" -include $p/bin2\";done` \\\n-\t-file META-INF/services/org.spearce.jgit.pgm.TextBuiltin=org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin \\\n+\t-file $M_TB=org.spearce.jgit.pgm/src/$M_TB \\\n \t-file META-INF/MANIFEST.MF=$T_MF \\\n-\t>>$O+ &&\n-chmod 555 $O+ &&\n-mv $O+ $O &&\n-echo \"Created $O.\" || die \"Creating $O failed.\"\n+\t>>$O_CLI+ &&\n+chmod 555 $O_CLI+ &&\n+mv $O_CLI+ $O_CLI &&\n+echo \"Created $O_CLI.\" || die \"Build failed.\"\n \n cleanup_bin\n-- \n1.6.0.1.207.g020e5\n"},{"id":"89511","messageId":"1220372892-15423-3-git-send-email-spearce@spearce.org","threadId":"15332","inReplyTo":"1220372892-15423-2-git-send-email-spearce@spearce.org","subject":"[JGIT PATCH 3/3] Add a tiny \"jgit version\" program","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-02T16:28:12Z","receivedAt":"2008-09-02T16:28:12Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Displays the current version of the JAR.  This is probably the same\nas the library code since they are currently packaged together but\nmay in the future represent only the version of the CLI (.pgm).\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../services/org.spearce.jgit.pgm.TextBuiltin      |    1 +\n .../src/org/spearce/jgit/pgm/Version.java          |   52 ++++++++++++++++++++\n 2 files changed, 53 insertions(+), 0 deletions(-)\n create mode 100644 org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java\n\ndiff --git a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin\nindex 39ae664..e2e7938 100644\n--- a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin\n+++ b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin\n@@ -12,6 +12,7 @@ org.spearce.jgit.pgm.RevList\n org.spearce.jgit.pgm.Rm\n org.spearce.jgit.pgm.ShowRev\n org.spearce.jgit.pgm.Tag\n+org.spearce.jgit.pgm.Version\n \n org.spearce.jgit.pgm.debug.MakeCacheTree\n org.spearce.jgit.pgm.debug.ReadDirCache\ndiff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java\nnew file mode 100644\nindex 0000000..e4cd707\n--- /dev/null\n+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java\n@@ -0,0 +1,52 @@\n+/*\n+ * Copyright (C) 2008, Google Inc.\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+\n+package org.spearce.jgit.pgm;\n+\n+@Command(common = true, usage = \"Display the version of jgit\")\n+class Version extends TextBuiltin {\n+\t@Override\n+\tprotected void run() throws Exception {\n+\t\tfinal Package pkg = getClass().getPackage();\n+\t\tif (pkg == null || pkg.getImplementationVersion() == null)\n+\t\t\tthrow die(\"Cannot read package information.\");\n+\n+\t\tout.print(\"jgit version \");\n+\t\tout.print(pkg.getImplementationVersion());\n+\t\tout.println();\n+\t}\n+}\n-- \n1.6.0.1.207.g020e5\n"}]}