Browse Source

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

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>
stable-0.12
Philipp Thun 14 years ago
parent
commit
8e1b581d39
  1. 1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java

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

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

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) {
File d = new File(".");
if (!bare)
d = new File(d, Constants.DOT_GIT);
d = new File(d, Constants.DOT_GIT).getCanonicalFile();
builder.setGitDir(d);
}
Repository repository = builder.build();

Loading…
Cancel
Save