|
|
@ -69,6 +69,8 @@ import org.eclipse.jgit.internal.JGitText; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
import org.eclipse.jgit.util.ProcessResult.Status; |
|
|
|
import org.eclipse.jgit.util.ProcessResult.Status; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
|
|
/** Abstraction to support various file system operations not in Java. */ |
|
|
|
/** Abstraction to support various file system operations not in Java. */ |
|
|
|
public abstract class FS { |
|
|
|
public abstract class FS { |
|
|
@ -107,6 +109,8 @@ public abstract class FS { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static Logger LOG = LoggerFactory.getLogger(FS.class); |
|
|
|
|
|
|
|
|
|
|
|
/** The auto-detected implementation selected for this operating system and JRE. */ |
|
|
|
/** The auto-detected implementation selected for this operating system and JRE. */ |
|
|
|
public static final FS DETECTED = detect(); |
|
|
|
public static final FS DETECTED = detect(); |
|
|
|
|
|
|
|
|
|
|
@ -418,12 +422,12 @@ public abstract class FS { |
|
|
|
* @return the one-line output of the command |
|
|
|
* @return the one-line output of the command |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected static String readPipe(File dir, String[] command, String encoding) { |
|
|
|
protected static String readPipe(File dir, String[] command, String encoding) { |
|
|
|
final boolean debug = Boolean.parseBoolean(SystemReader.getInstance() |
|
|
|
final boolean debug = LOG.isDebugEnabled(); |
|
|
|
.getProperty("jgit.fs.debug")); //$NON-NLS-1$
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (debug) |
|
|
|
if (debug) { |
|
|
|
System.err.println("readpipe " + Arrays.asList(command) + "," //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
LOG.debug("readpipe " + Arrays.asList(command) + "," //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
+ dir); |
|
|
|
+ dir); |
|
|
|
|
|
|
|
} |
|
|
|
final Process p = Runtime.getRuntime().exec(command, null, dir); |
|
|
|
final Process p = Runtime.getRuntime().exec(command, null, dir); |
|
|
|
final BufferedReader lineRead = new BufferedReader( |
|
|
|
final BufferedReader lineRead = new BufferedReader( |
|
|
|
new InputStreamReader(p.getInputStream(), encoding)); |
|
|
|
new InputStreamReader(p.getInputStream(), encoding)); |
|
|
@ -451,8 +455,9 @@ public abstract class FS { |
|
|
|
is.close(); |
|
|
|
is.close(); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
// Just print on stderr for debugging
|
|
|
|
// Just print on stderr for debugging
|
|
|
|
if (debug) |
|
|
|
if (debug) { |
|
|
|
e.printStackTrace(System.err); |
|
|
|
LOG.debug("Caught exception in gobbler thread", e); //$NON-NLS-1$
|
|
|
|
|
|
|
|
} |
|
|
|
gooblerFail.set(true); |
|
|
|
gooblerFail.set(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -462,13 +467,14 @@ public abstract class FS { |
|
|
|
try { |
|
|
|
try { |
|
|
|
r = lineRead.readLine(); |
|
|
|
r = lineRead.readLine(); |
|
|
|
if (debug) { |
|
|
|
if (debug) { |
|
|
|
System.err.println("readpipe may return '" + r + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
LOG.debug("readpipe may return '" + r + "'"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
System.err.println("(ignoring remaing output:"); //$NON-NLS-1$
|
|
|
|
LOG.debug("(ignoring remaing output:"); //$NON-NLS-1$
|
|
|
|
} |
|
|
|
} |
|
|
|
String l; |
|
|
|
String l; |
|
|
|
while ((l = lineRead.readLine()) != null) { |
|
|
|
while ((l = lineRead.readLine()) != null) { |
|
|
|
if (debug) |
|
|
|
if (debug) { |
|
|
|
System.err.println(l); |
|
|
|
LOG.debug(l); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
p.getErrorStream().close(); |
|
|
|
p.getErrorStream().close(); |
|
|
@ -482,20 +488,20 @@ public abstract class FS { |
|
|
|
if (rc == 0 && r != null && r.length() > 0 |
|
|
|
if (rc == 0 && r != null && r.length() > 0 |
|
|
|
&& !gooblerFail.get()) |
|
|
|
&& !gooblerFail.get()) |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
if (debug) |
|
|
|
if (debug) { |
|
|
|
System.err.println("readpipe rc=" + rc); //$NON-NLS-1$
|
|
|
|
LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$
|
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} catch (InterruptedException ie) { |
|
|
|
} catch (InterruptedException ie) { |
|
|
|
// Stop bothering me, I have a zombie to reap.
|
|
|
|
// Stop bothering me, I have a zombie to reap.
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
if (debug) |
|
|
|
LOG.error("Caught exception in FS.readPipe()", e); //$NON-NLS-1$
|
|
|
|
System.err.println(e); |
|
|
|
} |
|
|
|
// Ignore error (but report)
|
|
|
|
if (debug) { |
|
|
|
|
|
|
|
LOG.debug("readpipe returns null"); //$NON-NLS-1$
|
|
|
|
} |
|
|
|
} |
|
|
|
if (debug) |
|
|
|
|
|
|
|
System.err.println("readpipe returns null"); //$NON-NLS-1$
|
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|