Avoid NPE in Init
We should grab the repository directory from the command to
avoid an NPE if no git directory is passed in via the CLI.
Change-Id: I649467c6d84bbc0d26a070d0d4ff1e6f81fd5bad
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
index 497be90..c56540a 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
@@ -51,6 +51,7 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.InitCommand;
+import org.eclipse.jgit.lib.Repository;
import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_CreateAnEmptyGitRepository")
@@ -68,7 +69,9 @@ protected void run() throws Exception {
InitCommand command = Git.init();
command.setBare(bare);
command.setDirectory(gitdir);
- command.call();
- out.println(MessageFormat.format(CLIText.get().initializedEmptyGitRepositoryIn, gitdir.getAbsolutePath()));
+ Repository repository = command.call().getRepository();
+ out.println(MessageFormat.format(
+ CLIText.get().initializedEmptyGitRepositoryIn, repository
+ .getDirectory().getAbsolutePath()));
}
}