Use parent directory in InitCommand if directory is "."

If no directory is set before executing an InitCommand, the current
directory (".") is used by default. By calling File.getParentFile() we
get the actual directory this points to. Using this directory makes it
easier to read paths.

Change-Id: I6245941395dae920e4f90b8985be6ef3cce570d3
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
This commit is contained in:
Philipp Thun 2011-03-16 01:36:56 +01:00
parent 8aef29c114
commit c0112f97a1
1 changed files with 3 additions and 1 deletions

View File

@ -82,8 +82,10 @@ public Git call() throws JGitInternalException {
builder.setGitDir(d);
} else if (builder.getGitDir() == null) {
File d = new File(".");
if (d.getParentFile() != null)
d = d.getParentFile();
if (!bare)
d = new File(d, Constants.DOT_GIT).getCanonicalFile();
d = new File(d, Constants.DOT_GIT);
builder.setGitDir(d);
}
Repository repository = builder.build();