summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorPhilipp Thun2011-03-11 09:49:27 (EST)
committer Philipp Thun2011-03-15 08:57:15 (EDT)
commit8e1b581d39a8e1eadfb8f2ab7590546ec89c9abe (patch)
treea7e57825e3c29ff2cc4d47aacc5fa59db15e6fbc
parent317d8e2e8dbda0c9dc625b7fd439f78a60079d09 (diff)
downloadjgit-8e1b581d39a8e1eadfb8f2ab7590546ec89c9abe.zip
jgit-8e1b581d39a8e1eadfb8f2ab7590546ec89c9abe.tar.gz
jgit-8e1b581d39a8e1eadfb8f2ab7590546ec89c9abe.tar.bz2
Make --git-dir optional for 'jgit init'refs/changes/20/2720/1
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>
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java2
2 files changed, 3 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
index 98f086d..e1e38e5 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
@@ -69,7 +69,8 @@ class Init extends TextBuiltin {
protected void run() throws Exception {
InitCommand command = Git.init();
command.setBare(bare);
- command.setDirectory(new File(gitdir));
+ if (gitdir != null)
+ command.setDirectory(new File(gitdir));
Repository repository = command.call().getRepository();
out.println(MessageFormat.format(
CLIText.get().initializedEmptyGitRepositoryIn, repository
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 fdadf96..d68f4e2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/InitCommand.java
+++ b/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();