This way the default constructor used by the option parser does not cause the output stream to allocate until we have chosen to really work with this builtin command and have a repository for it to read/write against. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/pgm/Main.java | 2 +- .../src/org/spearce/jgit/pgm/TextBuiltin.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java index a155039..68748bf 100644 --- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Main.java @@ -110,7 +110,7 @@ public class Main { } final TextBuiltin cmd = createCommand(argv[argi++]); - cmd.db = new Repository(gitdir); + cmd.init(new Repository(gitdir)); try { cmd.execute(subarray(argv, argi)); } finally { diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java index 5f2fbce..05ad211 100644 --- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java +++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/TextBuiltin.java @@ -71,13 +71,14 @@ public abstract class TextBuiltin { /** Git repository the command was invoked within. */ protected Repository db; - TextBuiltin() { + void init(final Repository repo) { try { out = new PrintWriter(new BufferedWriter(new OutputStreamWriter( System.out, "UTF-8"))); } catch (IOException e) { throw die("cannot create output stream"); } + db = repo; } /** -- 1.5.6.3.569.ga9185 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html