]> source.dussan.org Git - jgit.git/commitdiff
Avoid NPE in Init 57/2057/1
authorChris Aniszczyk <caniszczyk@gmail.com>
Tue, 7 Dec 2010 15:10:07 +0000 (09:10 -0600)
committerChris Aniszczyk <caniszczyk@gmail.com>
Tue, 7 Dec 2010 15:10:07 +0000 (09:10 -0600)
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>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

index 497be909be3272a232cf932cd6e59c20290b86b0..c56540a76a3a87024d40675b5f5163014fd00522 100644 (file)
@@ -51,6 +51,7 @@ import java.text.MessageFormat;
 
 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 @@ class Init extends TextBuiltin {
                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()));
        }
 }