Browse Source

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>
stable-0.12
Philipp Thun 14 years ago
parent
commit
c0112f97a1
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java

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

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

Loading…
Cancel
Save