summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/.classpath8
-rw-r--r--org.eclipse.jgit.pgm/.gitignore5
-rw-r--r--org.eclipse.jgit.pgm/.project17
-rw-r--r--org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.ui.prefs54
-rw-r--r--org.eclipse.jgit.pgm/.settings/org.eclipse.pde.core.prefs3
-rw-r--r--org.eclipse.jgit.pgm/META-INF/services/org.eclipse.jgit.pgm.TextBuiltin (renamed from org.eclipse.jgit.pgm/src/META-INF/services/org.eclipse.jgit.pgm.TextBuiltin)0
-rw-r--r--org.eclipse.jgit.pgm/jgit.sh83
-rw-r--r--org.eclipse.jgit.pgm/pom.xml183
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java136
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java14
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java109
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/build/JarLinkUtil.java212
14 files changed, 574 insertions, 256 deletions
diff --git a/org.eclipse.jgit.pgm/.classpath b/org.eclipse.jgit.pgm/.classpath
deleted file mode 100644
index a91b30e8bb..0000000000
--- a/org.eclipse.jgit.pgm/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib" path="lib/args4j-2.0.9.jar" sourcepath="lib/args4j-2.0.9.zip"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/org.eclipse.jgit"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.jgit.pgm/.gitignore b/org.eclipse.jgit.pgm/.gitignore
index 5e56e040ec..7351243d9d 100644
--- a/org.eclipse.jgit.pgm/.gitignore
+++ b/org.eclipse.jgit.pgm/.gitignore
@@ -1 +1,4 @@
-/bin
+/target
+/.project
+/.classpath
+/.settings/org.maven.ide.eclipse.prefs
diff --git a/org.eclipse.jgit.pgm/.project b/org.eclipse.jgit.pgm/.project
deleted file mode 100644
index bbaafc2612..0000000000
--- a/org.eclipse.jgit.pgm/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jgit.pgm</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.ui.prefs
index 7210d0f74f..25a50c5ef9 100644
--- a/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.ui.prefs
+++ b/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.ui.prefs
@@ -1,5 +1,6 @@
-#Fri Oct 02 18:43:47 PDT 2009
+#Sat Oct 31 14:52:59 PDT 2009
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_JGit Format
formatter_settings_version=11
org.eclipse.jdt.ui.ignorelowercasenames=true
@@ -7,3 +8,54 @@ org.eclipse.jdt.ui.importorder=java;javax;org;com;
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=99
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=false
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=false
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/org.eclipse.jgit.pgm/.settings/org.eclipse.pde.core.prefs b/org.eclipse.jgit.pgm/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000000..75c779a483
--- /dev/null
+++ b/org.eclipse.jgit.pgm/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+#Sat Oct 31 18:40:07 PDT 2009
+eclipse.preferences.version=1
+resolve.requirebundle=false
diff --git a/org.eclipse.jgit.pgm/src/META-INF/services/org.eclipse.jgit.pgm.TextBuiltin b/org.eclipse.jgit.pgm/META-INF/services/org.eclipse.jgit.pgm.TextBuiltin
index de63adbbc0..de63adbbc0 100644
--- a/org.eclipse.jgit.pgm/src/META-INF/services/org.eclipse.jgit.pgm.TextBuiltin
+++ b/org.eclipse.jgit.pgm/META-INF/services/org.eclipse.jgit.pgm.TextBuiltin
diff --git a/org.eclipse.jgit.pgm/jgit.sh b/org.eclipse.jgit.pgm/jgit.sh
new file mode 100644
index 0000000000..e6a2119ef1
--- /dev/null
+++ b/org.eclipse.jgit.pgm/jgit.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+# Copyright (C) 2008-2009, Google Inc.
+# Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
+# and other copyright owners as documented in the project's IP log.
+#
+# This program and the accompanying materials are made available
+# under the terms of the Eclipse Distribution License v1.0 which
+# accompanies this distribution, is reproduced below, and is
+# available at http://www.eclipse.org/org/documents/edl-v10.php
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+# - Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# - Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+#
+# - Neither the name of the Eclipse Foundation, Inc. nor the
+# names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+this_script=`which "$0" 2>/dev/null`
+[ $? -gt 0 -a -f "$0" ] && this_script="$0"
+cp=$this_script
+
+if [ -n "$JGIT_CLASSPATH" ]
+then
+ cp="$cp:$JGIT_CLASSPATH"
+fi
+
+# Cleanup paths for Cygwin.
+#
+case "`uname`" in
+CYGWIN*)
+ cp=`cygpath --windows --mixed --path "$cp"`
+ ;;
+Darwin)
+ if test -e /System/Library/Frameworks/JavaVM.framework
+ then
+ java_args='
+ -Dcom.apple.mrj.application.apple.menu.about.name=JGit
+ -Dcom.apple.mrj.application.growbox.intrudes=false
+ -Dapple.laf.useScreenMenuBar=true
+ -Xdock:name=JGit
+ '
+ fi
+ ;;
+esac
+
+CLASSPATH="$cp"
+export CLASSPATH
+
+java=java
+if test -n "$JAVA_HOME"
+then
+ java="$JAVA_HOME/bin/java"
+fi
+
+exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@"
+exit 1
diff --git a/org.eclipse.jgit.pgm/pom.xml b/org.eclipse.jgit.pgm/pom.xml
new file mode 100644
index 0000000000..7b25efe19f
--- /dev/null
+++ b/org.eclipse.jgit.pgm/pom.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2009, Google Inc.
+ and other copyright owners as documented in the project's IP log.
+
+ This program and the accompanying materials are made available
+ under the terms of the Eclipse Distribution License v1.0 which
+ accompanies this distribution, is reproduced below, and is
+ available at http://www.eclipse.org/org/documents/edl-v10.php
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, are permitted provided that the following
+ conditions are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ - Neither the name of the Eclipse Foundation, Inc. nor the
+ names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit-parent</artifactId>
+ <version>0.6.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.jgit.pgm</artifactId>
+ <name>JGit - Command Line Interface</name>
+
+ <description>
+ Command line client tools built on top of JGit.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>args4j</groupId>
+ <artifactId>args4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit.ui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>java6</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit.console</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+ <build>
+ <sourceDirectory>src/</sourceDirectory>
+
+ <resources>
+ <resource>
+ <directory>.</directory>
+ <includes>
+ <include>META-INF/services/org.eclipse.jgit.pgm.TextBuiltin</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <finalName>jgit-cli</finalName>
+ <createDependencyReducedPom>false</createDependencyReducedPom>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <manifestEntries>
+ <Main-Class>org.eclipse.jgit.pgm.Main</Main-Class>
+ <Implementation-Title>JGit Command Line Interface</Implementation-Title>
+ </manifestEntries>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create_jgit</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <concat destfile="${basedir}/target/jgit" force="yes" binary="true">
+ <fileset file="${basedir}/jgit.sh" />
+ <fileset file="${basedir}/target/jgit-cli.jar" />
+ </concat>
+ <chmod file="${basedir}/target/jgit" perm="a+x"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach_jgit</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${basedir}/target/jgit</file>
+ <type>sh</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java
new file mode 100644
index 0000000000..179a32bdbf
--- /dev/null
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2009, Google Inc.
+ * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.pgm;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLConnection;
+import java.util.Properties;
+
+import org.eclipse.jgit.transport.AmazonS3;
+import org.kohsuke.args4j.Argument;
+
+@Command(name = "amazon-s3-client", common = false, usage = "Command line client for Amazon's S3 service")
+class AmazonS3Client extends TextBuiltin {
+ @Argument(index = 0, metaVar = "conn.prop", required = true)
+ private File propertyFile;
+
+ @Argument(index = 1, metaVar = "OP", required = true)
+ private String op;
+
+ @Argument(index = 2, metaVar = "BUCKET", required = true)
+ private String bucket;
+
+ @Argument(index = 3, metaVar = "KEY", required = true)
+ private String key;
+
+ @Override
+ protected final boolean requiresRepository() {
+ return false;
+ }
+
+ @Override
+ protected void run() throws Exception {
+ final AmazonS3 s3 = new AmazonS3(properties());
+
+ if ("get".equals(op)) {
+ final URLConnection c = s3.get(bucket, key);
+ int len = c.getContentLength();
+ final InputStream in = c.getInputStream();
+ try {
+ final byte[] tmp = new byte[2048];
+ while (len > 0) {
+ final int n = in.read(tmp);
+ if (n < 0)
+ throw new EOFException("Expected " + len + " bytes.");
+ System.out.write(tmp, 0, n);
+ len -= n;
+ }
+ } finally {
+ in.close();
+ }
+
+ } else if ("ls".equals(op) || "list".equals(op)) {
+ for (final String k : s3.list(bucket, key))
+ System.out.println(k);
+
+ } else if ("rm".equals(op) || "delete".equals(op)) {
+ s3.delete(bucket, key);
+
+ } else if ("put".equals(op)) {
+ final OutputStream os = s3.beginPut(bucket, key, null, null);
+ final byte[] tmp = new byte[2048];
+ int n;
+ while ((n = System.in.read(tmp)) > 0)
+ os.write(tmp, 0, n);
+ os.close();
+
+ } else {
+ throw die("Unsupported operation: " + op);
+ }
+ }
+
+ private Properties properties() {
+ try {
+ final InputStream in = new FileInputStream(propertyFile);
+ try {
+ final Properties p = new Properties();
+ p.load(in);
+ return p;
+ } finally {
+ in.close();
+ }
+ } catch (FileNotFoundException e) {
+ throw die("no such file: " + propertyFile, e);
+ } catch (IOException e) {
+ throw die("cannot read " + propertyFile, e);
+ }
+ }
+}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
index 605f9552f8..3fe50d6682 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
@@ -73,7 +73,7 @@ import org.eclipse.jgit.transport.URIish;
@Command(common = true, usage = "Clone a repository into a new directory")
class Clone extends AbstractFetchCommand {
@Option(name = "--origin", aliases = { "-o" }, metaVar = "name", usage = "use <name> instead of 'origin' to track upstream")
- private String remoteName = "origin";
+ private String remoteName = Constants.DEFAULT_REMOTE_NAME;
@Argument(index = 0, required = true, metaVar = "uri-ish")
private String sourceUri;
@@ -93,15 +93,11 @@ class Clone extends AbstractFetchCommand {
final URIish uri = new URIish(sourceUri);
if (localName == null) {
- String p = uri.getPath();
- while (p.endsWith("/"))
- p = p.substring(0, p.length() - 1);
- final int s = p.lastIndexOf('/');
- if (s < 0)
+ try {
+ localName = uri.getHumanishName();
+ } catch (IllegalArgumentException e) {
throw die("cannot guess local name from " + sourceUri);
- localName = p.substring(s + 1);
- if (localName.endsWith(".git"))
- localName = localName.substring(0, localName.length() - 4);
+ }
}
if (gitdir == null)
gitdir = new File(localName, ".git");
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
index 7315e44cb5..6ed468510f 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008-2009, Google Inc.
+ * Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
*
@@ -48,6 +49,7 @@ import java.util.List;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
@@ -81,7 +83,7 @@ class Fetch extends AbstractFetchCommand {
}
@Argument(index = 0, metaVar = "uri-ish")
- private String remote = "origin";
+ private String remote = Constants.DEFAULT_REMOTE_NAME;
@Argument(index = 1, metaVar = "refspec")
private List<RefSpec> toget;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
index 45d941e2d3..b4c5660a6d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
@@ -45,16 +45,24 @@
package org.eclipse.jgit.pgm;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.jgit.awtui.AwtAuthenticator;
+import org.eclipse.jgit.awtui.AwtSshSessionFactory;
import org.eclipse.jgit.errors.TransportException;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.pgm.opt.CmdLineParser;
import org.eclipse.jgit.pgm.opt.SubcommandHandler;
+import org.eclipse.jgit.util.CachedAuthenticator;
+import org.eclipse.jgit.util.SystemReader;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.ExampleMode;
@@ -79,14 +87,17 @@ public class Main {
/**
* Execute the command line.
- *
+ *
* @param argv
* arguments.
*/
public static void main(final String[] argv) {
final Main me = new Main();
try {
- AwtAuthenticator.install();
+ if (!installConsole()) {
+ AwtAuthenticator.install();
+ AwtSshSessionFactory.install();
+ }
configureHttpProxy();
me.execute(argv);
} catch (Die err) {
@@ -152,13 +163,50 @@ public class Main {
final TextBuiltin cmd = subcommand;
if (cmd.requiresRepository()) {
+ if (gitdir == null) {
+ String gitDirEnv = SystemReader.getInstance().getenv(Constants.GIT_DIR_KEY);
+ if (gitDirEnv != null)
+ gitdir = new File(gitDirEnv);
+ }
if (gitdir == null)
gitdir = findGitDir();
+
+ File gitworktree;
+ String gitWorkTreeEnv = SystemReader.getInstance().getenv(Constants.GIT_WORK_TREE_KEY);
+ if (gitWorkTreeEnv != null)
+ gitworktree = new File(gitWorkTreeEnv);
+ else
+ gitworktree = null;
+
+ File indexfile;
+ String indexFileEnv = SystemReader.getInstance().getenv(Constants.GIT_INDEX_KEY);
+ if (indexFileEnv != null)
+ indexfile = new File(indexFileEnv);
+ else
+ indexfile = null;
+
+ File objectdir;
+ String objectDirEnv = SystemReader.getInstance().getenv(Constants.GIT_OBJECT_DIRECTORY_KEY);
+ if (objectDirEnv != null)
+ objectdir = new File(objectDirEnv);
+ else
+ objectdir = null;
+
+ File[] altobjectdirs;
+ String altObjectDirEnv = SystemReader.getInstance().getenv(Constants.GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY);
+ if (altObjectDirEnv != null) {
+ String[] parserdAltObjectDirEnv = altObjectDirEnv.split(File.pathSeparator);
+ altobjectdirs = new File[parserdAltObjectDirEnv.length];
+ for (int i = 0; i < parserdAltObjectDirEnv.length; i++)
+ altobjectdirs[i] = new File(parserdAltObjectDirEnv[i]);
+ } else
+ altobjectdirs = null;
+
if (gitdir == null || !gitdir.isDirectory()) {
System.err.println("error: can't find git directory");
System.exit(1);
}
- cmd.init(new Repository(gitdir), gitdir);
+ cmd.init(new Repository(gitdir, gitworktree, objectdir, altobjectdirs, indexfile), gitdir);
} else {
cmd.init(null, gitdir);
}
@@ -171,16 +219,64 @@ public class Main {
}
private static File findGitDir() {
- File current = new File(".").getAbsoluteFile();
+ Set<String> ceilingDirectories = new HashSet<String>();
+ String ceilingDirectoriesVar = SystemReader.getInstance().getenv(
+ Constants.GIT_CEILING_DIRECTORIES_KEY);
+ if (ceilingDirectoriesVar != null) {
+ ceilingDirectories.addAll(Arrays.asList(ceilingDirectoriesVar
+ .split(File.pathSeparator)));
+ }
+ File current = new File("").getAbsoluteFile();
while (current != null) {
final File gitDir = new File(current, ".git");
if (gitDir.isDirectory())
return gitDir;
current = current.getParentFile();
+ if (ceilingDirectories.contains(current.getPath()))
+ break;
}
return null;
}
+ private static boolean installConsole() {
+ try {
+ install("org.eclipse.jgit.console.ConsoleAuthenticator");
+ install("org.eclipse.jgit.console.ConsoleSshSessionFactory");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ } catch (NoClassDefFoundError e) {
+ return false;
+ } catch (UnsupportedClassVersionError e) {
+ return false;
+
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException("Cannot setup console", e);
+ } catch (SecurityException e) {
+ throw new RuntimeException("Cannot setup console", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Cannot setup console", e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException("Cannot setup console", e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Cannot setup console", e);
+ }
+ }
+
+ private static void install(final String name)
+ throws IllegalAccessException, InvocationTargetException,
+ NoSuchMethodException, ClassNotFoundException {
+ try {
+ Class.forName(name).getMethod("install").invoke(null);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof RuntimeException)
+ throw (RuntimeException) e.getCause();
+ if (e.getCause() instanceof Error)
+ throw (Error) e.getCause();
+ throw e;
+ }
+ }
+
/**
* Configure the JRE's standard HTTP based on <code>http_proxy</code>.
* <p>
@@ -215,8 +311,9 @@ public class Main {
final int c = userpass.indexOf(':');
final String user = userpass.substring(0, c);
final String pass = userpass.substring(c + 1);
- AwtAuthenticator.add(new AwtAuthenticator.CachedAuthentication(
- proxyHost, proxyPort, user, pass));
+ CachedAuthenticator
+ .add(new CachedAuthenticator.CachedAuthentication(
+ proxyHost, proxyPort, user, pass));
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
index 8afa5227d2..6248ec2991 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
@@ -65,7 +65,7 @@ class Push extends TextBuiltin {
int timeout = -1;
@Argument(index = 0, metaVar = "uri-ish")
- private String remote = "origin";
+ private String remote = Constants.DEFAULT_REMOTE_NAME;
@Argument(index = 1, metaVar = "refspec")
private final List<RefSpec> refSpecs = new ArrayList<RefSpec>();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/build/JarLinkUtil.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/build/JarLinkUtil.java
deleted file mode 100644
index e63f39c01e..0000000000
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/build/JarLinkUtil.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
- * and other copyright owners as documented in the project's IP log.
- *
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Distribution License v1.0 which
- * accompanies this distribution, is reproduced below, and is
- * available at http://www.eclipse.org/org/documents/edl-v10.php
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * - Neither the name of the Eclipse Foundation, Inc. nor the
- * names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.eclipse.jgit.pgm.build;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
-
-import org.kohsuke.args4j.CmdLineException;
-import org.kohsuke.args4j.CmdLineParser;
-import org.kohsuke.args4j.Option;
-import org.kohsuke.args4j.spi.MapOptionHandler;
-
-/**
- * Combines multiple JAR and directory sources into a single JAR file.
- * <p>
- * This is a crude command line utility to combine multiple JAR files into a
- * single JAR file, without first needing to unpack the individual JARs.
- * <p>
- * The output ZIP stream is sent to standard out and can be redirected onto the
- * end of a shell script which starts the JRE.
- */
-public class JarLinkUtil {
- /**
- * Combine multiple JARs.
- *
- * @param argv
- * the command line arguments indicating the files to pack.
- * @throws IOException
- * a source file could not be read.
- */
- public static void main(final String[] argv) throws IOException {
- final JarLinkUtil util = new JarLinkUtil();
- final CmdLineParser clp = new CmdLineParser(util);
- try {
- clp.parseArgument(argv);
- } catch (CmdLineException e) {
- clp.printSingleLineUsage(System.err);
- System.exit(1);
- }
- util.run();
- }
-
- @Option(name = "-include", required = true)
- private List<File> includes = new ArrayList<File>();
-
- @Option(name = "-file", handler = MapOptionHandler.class)
- private Map<String, String> files = new HashMap<String, String>();
-
- private final Map<String, File> chosenSources = new HashMap<String, File>();
-
- private long creationTime;
-
- private ZipOutputStream zos;
-
- private JarLinkUtil() {
- // Command line utility only.
- }
-
- private void run() throws IOException {
- for (final File src : includes) {
- if (src.isFile())
- scanJar(src);
- else
- scanDirectory(src, src, "");
- }
- for (final Map.Entry<String, String> e : files.entrySet())
- chosenSources.put(e.getKey(), new File(e.getValue()));
-
- creationTime = System.currentTimeMillis();
- zos = new ZipOutputStream(System.out);
- zos.setLevel(9);
-
- for (final File src : includes) {
- if (src.isFile())
- appendJar(src);
- else
- appendDirectory(src, src, "");
- }
- for (final String name : files.keySet())
- appendFile(chosenSources.get(name), name);
-
- zos.close();
- }
-
- private void scanJar(final File jarPath) throws IOException {
- final ZipFile zf = new ZipFile(jarPath);
- final Enumeration<? extends ZipEntry> e = zf.entries();
- while (e.hasMoreElements())
- chosenSources.put(e.nextElement().getName(), jarPath);
- zf.close();
- }
-
- private void scanDirectory(final File rootPath, final File dirPath,
- final String pfx) throws IOException {
- final File[] entries = dirPath.listFiles();
- if (entries == null)
- return;
- for (final File e : entries) {
- if (e.getName().equals(".") || e.getName().equals(".."))
- continue;
-
- if (e.isDirectory())
- scanDirectory(rootPath, e, pfx + e.getName() + "/");
- else
- chosenSources.put(pfx + e.getName(), rootPath);
- }
- }
-
- private void appendJar(final File jarPath) throws IOException {
- final ZipFile zf = new ZipFile(jarPath);
- final Enumeration<? extends ZipEntry> e = zf.entries();
- while (e.hasMoreElements()) {
- final ZipEntry ze = e.nextElement();
- final String name = ze.getName();
- if (chosenSources.get(name) == jarPath)
- appendEntry(name, ze.getSize(), ze.getTime(), zf
- .getInputStream(ze));
- }
- zf.close();
- }
-
- private void appendDirectory(final File rootDir, final File dirPath,
- final String pfx) throws IOException {
- final File[] entries = dirPath.listFiles();
- if (entries == null)
- return;
- for (final File e : entries) {
- if (e.getName().equals(".") || e.getName().equals(".."))
- continue;
-
- if (e.isDirectory())
- appendDirectory(rootDir, e, pfx + e.getName() + "/");
- else if (chosenSources.get(pfx + e.getName()) == rootDir)
- appendFile(e, pfx + e.getName());
- }
- }
-
- private void appendFile(final File path, final String name)
- throws IOException {
- final long len = path.length();
- final InputStream is = new FileInputStream(path);
- appendEntry(name, len, creationTime, is);
- }
-
- private void appendEntry(final String name, final long len,
- final long time, final InputStream is) throws IOException {
- final ZipEntry ze = new ZipEntry(name);
- ze.setSize(len);
- ze.setTime(time);
- zos.putNextEntry(ze);
- try {
- final byte[] buf = new byte[4096];
- int n;
- while ((n = is.read(buf)) >= 0)
- zos.write(buf, 0, n);
- } finally {
- is.close();
- }
- zos.closeEntry();
- }
-}