Selaa lähdekoodia

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>
tags/v0.10.1
Chris Aniszczyk 13 vuotta sitten
vanhempi
commit
8bbd4f1bad
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5
    2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java

+ 5
- 2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java Näytä tiedosto



import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.InitCommand; import org.eclipse.jgit.api.InitCommand;
import org.eclipse.jgit.lib.Repository;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;


@Command(common = true, usage = "usage_CreateAnEmptyGitRepository") @Command(common = true, usage = "usage_CreateAnEmptyGitRepository")
InitCommand command = Git.init(); InitCommand command = Git.init();
command.setBare(bare); command.setBare(bare);
command.setDirectory(gitdir); 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…
Peruuta
Tallenna