summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorNed Twigg <ned.twigg@diffplug.com>2016-03-18 00:11:04 -0700
committerNed Twigg <ned.twigg@diffplug.com>2017-09-21 14:48:45 -0400
commitc1fbef3cab782db50b79fac0bb6d892231acf8f5 (patch)
treebe5e3eccce7ca1fc459df9e1e8a520abbaab2e60 /org.eclipse.jgit.pgm
parente32aed6d7536ca569a3b8fbd7daef3d7c827ce8c (diff)
downloadjgit-c1fbef3cab782db50b79fac0bb6d892231acf8f5.tar.gz
jgit-c1fbef3cab782db50b79fac0bb6d892231acf8f5.zip
Added API to TextBuiltin for piped usage.
Added a public method to TextBuiltin which makes it possible for clients to initialize all of its state, including output and error streams. This gives clients the ability to customize the way in which a command is run. Change-Id: If718236964d2c5cf869e120c74f1a12965f4812e Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java
index 0dc549c7d7..c3b45e8de9 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java
@@ -139,6 +139,31 @@ public abstract class TextBuiltin {
}
/**
+ * Initializes the command to work with a repository, including setting the
+ * output and error streams.
+ *
+ * @param repository
+ * the opened repository that the command should work on.
+ * @param gitDir
+ * value of the {@code --git-dir} command line option, if
+ * {@code repository} is null.
+ * @param input
+ * input stream from which input will be read
+ * @param output
+ * output stream to which output will be written
+ * @param error
+ * error stream to which errors will be written
+ * @since 4.9
+ */
+ public void initRaw(final Repository repository, final String gitDir,
+ InputStream input, OutputStream output, OutputStream error) {
+ this.ins = input;
+ this.outs = output;
+ this.errs = error;
+ init(repository, gitDir);
+ }
+
+ /**
* Initialize the command to work with a repository.
*
* @param repository
@@ -285,6 +310,14 @@ public abstract class TextBuiltin {
}
/**
+ * @return output writer, typically this is standard output.
+ * @since 4.9
+ */
+ public ThrowingPrintWriter getOutputWriter() {
+ return outw;
+ }
+
+ /**
* @return the resource bundle that will be passed to args4j for purpose of
* string localization
*/