void service(String name, PacketLineOut pckOut) throws IOException { final StringBuilder cmd = new StringBuilder(); cmd.append(name); cmd.append(' '); cmd.append(uri.getPath()); cmd.append('\0'); cmd.append("host="); //$NON-NLS-1$ cmd.append(uri.getHost()); if (uri.getPort() > 0 && uri.getPort() != GIT_PORT) { cmd.append(":"); //$NON-NLS-1$ cmd.append(uri.getPort()); } cmd.append('\0'); pckOut.writeString(cmd.toString()); pckOut.flush(); }
Socket openConnection() throws TransportException { final int tms = getTimeout() > 0 ? getTimeout() * 1000 : 0; final int port = uri.getPort() > 0 ? uri.getPort() : GIT_PORT; @SuppressWarnings("resource") // Closed by the caller final Socket s = new Socket(); try { final InetAddress host = InetAddress.getByName(uri.getHost()); s.bind(null); s.connect(new InetSocketAddress(host, port), tms); } catch (IOException c) { try { s.close(); } catch (IOException closeErr) { // ignore a failure during close, we're already failing } if (c instanceof UnknownHostException) throw new TransportException(uri, JGitText.get().unknownHost); if (c instanceof ConnectException) throw new TransportException(uri, c.getMessage()); throw new TransportException(uri, c.getMessage(), c); } return s; }
@Override public Process exec(String command, int timeout) throws TransportException { String ssh = SystemReader.getInstance().getenv("GIT_SSH"); //$NON-NLS-1$ boolean putty = ssh.toLowerCase(Locale.ROOT).contains("plink"); //$NON-NLS-1$ List<String> args = new ArrayList<>(); args.add(ssh); if (putty && !ssh.toLowerCase(Locale.ROOT).contains("tortoiseplink")) //$NON-NLS-1$ args.add("-batch"); //$NON-NLS-1$ if (0 < getURI().getPort()) { args.add(putty ? "-P" : "-p"); //$NON-NLS-1$ //$NON-NLS-2$ args.add(String.valueOf(getURI().getPort())); } if (getURI().getUser() != null) args.add(getURI().getUser() + "@" + getURI().getHost()); //$NON-NLS-1$ else args.add(getURI().getHost()); args.add(command); ProcessBuilder pb = createProcess(args); try { return pb.start(); } catch (IOException err) { throw new TransportException(err.getMessage(), err); } }
/** {@inheritDoc} */ @Override public int hashCode() { int hc = 0; if (getScheme() != null) hc = hc * 31 + getScheme().hashCode(); if (getUser() != null) hc = hc * 31 + getUser().hashCode(); if (getPass() != null) hc = hc * 31 + getPass().hashCode(); if (getHost() != null) hc = hc * 31 + getHost().hashCode(); if (getPort() > 0) hc = hc * 31 + getPort(); if (getPath() != null) hc = hc * 31 + getPath().hashCode(); return hc; }
private void updateSslVerify(StoredConfig config, boolean value) { // Since git uses the original URI for matching, we must also use the // original URI and cannot use the current URI (which might be different // after redirects). String uriPattern = uri.getScheme() + "://" + uri.getHost(); //$NON-NLS-1$ int port = uri.getPort(); if (port > 0) { uriPattern += ":" + port; //$NON-NLS-1$ } config.setBoolean(HttpConfig.HTTP, uriPattern, HttpConfig.SSL_VERIFY_KEY, value); try { config.save(); } catch (IOException e) { LOG.error(JGitText.get().sslVerifyCannotSave, e); } }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (!(obj instanceof URIish)) return false; final URIish b = (URIish) obj; if (!eq(getScheme(), b.getScheme())) return false; if (!eq(getUser(), b.getUser())) return false; if (!eq(getPass(), b.getPass())) return false; if (!eq(getHost(), b.getHost())) return false; if (getPort() != b.getPort()) return false; if (!eq(getPath(), b.getPath())) return false; return true; }
final String pass = uri.getPass(); String host = uri.getHost(); int port = uri.getPort();
public int hashCode() { int hc = 0; if (getScheme() != null) hc = hc * 31 + getScheme().hashCode(); if (getUser() != null) hc = hc * 31 + getUser().hashCode(); if (getPass() != null) hc = hc * 31 + getPass().hashCode(); if (getHost() != null) hc = hc * 31 + getHost().hashCode(); if (getPort() > 0) hc = hc * 31 + getPort(); if (getPath() != null) hc = hc * 31 + getPath().hashCode(); return hc; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
private void updateSslVerify(StoredConfig config, boolean value) { // Since git uses the original URI for matching, we must also use the // original URI and cannot use the current URI (which might be different // after redirects). String uriPattern = uri.getScheme() + "://" + uri.getHost(); //$NON-NLS-1$ int port = uri.getPort(); if (port > 0) { uriPattern += ":" + port; //$NON-NLS-1$ } config.setBoolean(HttpConfig.HTTP, uriPattern, HttpConfig.SSL_VERIFY_KEY, value); try { config.save(); } catch (IOException e) { LOG.error(JGitText.get().sslVerifyCannotSave, e); } }
@Override public boolean handles(URIish uri) { if (getDefaultScheme().equals(uri.getScheme())) return true; if (uri.getHost() != null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getPath() == null) return false; if (uri.getScheme() == null) return FS.DETECTED .resolve(new File("."), uri.getPath()).isDirectory(); //$NON-NLS-1$ return false; } };
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
public boolean equals(final Object obj) { if (!(obj instanceof URIish)) return false; final URIish b = (URIish) obj; if (!eq(getScheme(), b.getScheme())) return false; if (!eq(getUser(), b.getUser())) return false; if (!eq(getPass(), b.getPass())) return false; if (!eq(getHost(), b.getHost())) return false; if (getPort() != b.getPort()) return false; if (!eq(getPath(), b.getPath())) return false; return true; }