From c0112f97a1509d9b87da46f7a2a28206e26c616c Mon Sep 17 00:00:00 2001 From: Philipp Thun Date: Wed, 16 Mar 2011 01:36:56 +0100 Subject: 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 --- org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'org.eclipse.jgit/src') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java index d68f4e27f2..5b96cddac6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java @@ -82,8 +82,10 @@ public class InitCommand implements Callable { 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(); -- cgit v1.2.3