Browse Source

Merge "Make --git-dir optional for 'jgit init'"

stable-0.12
Chris Aniszczyk 14 years ago committed by Code Review
parent
commit
2df51d9427
  1. 3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java

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

@ -69,7 +69,8 @@ class Init extends TextBuiltin {
protected void run() throws Exception { protected void run() throws Exception {
InitCommand command = Git.init(); InitCommand command = Git.init();
command.setBare(bare); command.setBare(bare);
command.setDirectory(new File(gitdir)); if (gitdir != null)
command.setDirectory(new File(gitdir));
Repository repository = command.call().getRepository(); Repository repository = command.call().getRepository();
out.println(MessageFormat.format( out.println(MessageFormat.format(
CLIText.get().initializedEmptyGitRepositoryIn, repository CLIText.get().initializedEmptyGitRepositoryIn, repository

2
org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java

@ -83,7 +83,7 @@ public class InitCommand implements Callable<Git> {
} else if (builder.getGitDir() == null) { } else if (builder.getGitDir() == null) {
File d = new File("."); File d = new File(".");
if (!bare) if (!bare)
d = new File(d, Constants.DOT_GIT); d = new File(d, Constants.DOT_GIT).getCanonicalFile();
builder.setGitDir(d); builder.setGitDir(d);
} }
Repository repository = builder.build(); Repository repository = builder.build();

Loading…
Cancel
Save