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