summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorRüdiger Herrmann <ruediger.herrmann@gmx.de>2016-05-21 15:11:29 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2016-05-22 22:11:03 +0200
commit8ff08994a4d1253c36de36090212806046d4331c (patch)
treeccaa493989161d1f5bb565dd30508aa4528da11d /org.eclipse.jgit.pgm
parentb3f4abdda1f00c7ca72f3c7c95e180e28b9aa776 (diff)
downloadjgit-8ff08994a4d1253c36de36090212806046d4331c.tar.gz
jgit-8ff08994a4d1253c36de36090212806046d4331c.zip
JGit CLI: allow to call git init with specific directory
With this change it is possible to initialize repositories with 'git init /path/to/new/repo' Change-Id: Ia9b288b4fb34887e8f5e2f3f270e521c44d41b6a Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java11
1 files changed, 10 insertions, 1 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 b3e73b5d99..a7bee7f7b9 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
@@ -4,6 +4,7 @@
* Copyright (C) 2010, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com>
* Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com>
+ * Copyright (C) 2016, Rüdiger Herrmann <ruediger.herrmann@gmx.de>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -54,6 +55,7 @@ import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.InitCommand;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.pgm.internal.CLIText;
+import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_CreateAnEmptyGitRepository")
@@ -61,6 +63,9 @@ class Init extends TextBuiltin {
@Option(name = "--bare", usage = "usage_CreateABareRepository")
private boolean bare;
+ @Argument(index = 0, metaVar = "metaVar_directory")
+ private String directory;
+
@Override
protected final boolean requiresRepository() {
return false;
@@ -70,8 +75,12 @@ class Init extends TextBuiltin {
protected void run() throws Exception {
InitCommand command = Git.init();
command.setBare(bare);
- if (gitdir != null)
+ if (gitdir != null) {
command.setDirectory(new File(gitdir));
+ }
+ if (directory != null) {
+ command.setDirectory(new File(directory));
+ }
Repository repository = command.call().getRepository();
outw.println(MessageFormat.format(
CLIText.get().initializedEmptyGitRepositoryIn, repository