Browse Source

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>
stable-0.10
Chris Aniszczyk 14 years ago
parent
commit
8bbd4f1bad
  1. 7
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

7
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

@ -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()));
}
}

Loading…
Cancel
Save