For compatibility reasons with regards to native git and also to make the init command easier to use from the command line, argument --git-dir should not be required. Additionally the path created in case --git-dir is not supplied now is canonical and thus easier to read. Change-Id: Idb7d77e983a78c4b21fbf232fc1e75ef581e5ed1 Signed-off-by: Philipp Thun <philipp.thun@sap.com>tags/v0.12.1
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 |
} 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(); |