summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorPhilipp Thun <philipp.thun@sap.com>2011-03-11 14:25:46 +0100
committerPhilipp Thun <philipp.thun@sap.com>2011-03-11 14:25:46 +0100
commita490afedba12676a53338bc52b729b9bb779f3a1 (patch)
tree5761c6a81f0f67e264410137d05214d7e67eed3b /org.eclipse.jgit.pgm/src
parent42f0b11153d2917f96be1a0be94896bdf9eb1044 (diff)
downloadjgit-a490afedba12676a53338bc52b729b9bb779f3a1.tar.gz
jgit-a490afedba12676a53338bc52b729b9bb779f3a1.zip
Add -o option to commit command
This change adds the --only/ -o option to the commit command. Change-Id: I44352d56877f8204d985cb7a35a2e0faffb7d341 Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java1
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java19
2 files changed, 18 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
index 1c7e936343..c460bc3b4a 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java
@@ -133,6 +133,7 @@ public class CLIText extends TranslationBundle {
/***/ public String noteObjectTooLargeToPrint;
/***/ public String onlyOneMetaVarExpectedIn;
/***/ public String pushTo;
+ /***/ public String pathsRequired;
/***/ public String remoteMessage;
/***/ public String remoteRefObjectChangedIsNotExpectedOne;
/***/ public String remoteSideDoesNotSupportDeletingRefs;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
index 2737422dc2..ba66a30a24 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
@@ -37,6 +37,9 @@
*/
package org.eclipse.jgit.pgm;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
@@ -47,6 +50,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.util.RawParseUtils;
+import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_recordChangesToRepository")
@@ -54,12 +58,18 @@ class Commit extends TextBuiltin {
// I don't support setting the committer, because also the native git
// command doesn't allow this.
- @Option(name = "--author", metaVar="metaVar_author", usage = "usage_CommitAuthor")
+ @Option(name = "--author", metaVar = "metaVar_author", usage = "usage_CommitAuthor")
private String author;
- @Option(name = "--message", aliases = { "-m" }, metaVar="metaVar_message", usage="usage_CommitMessage", required=true)
+ @Option(name = "--message", aliases = { "-m" }, metaVar = "metaVar_message", usage = "usage_CommitMessage", required = true)
private String message;
+ @Option(name = "--only", aliases = { "-o" }, usage = "usage_CommitOnly")
+ private boolean only;
+
+ @Argument(metaVar = "metaVar_commitPaths", usage = "usage_CommitPaths")
+ private List<String> paths = new ArrayList<String>();
+
@Override
protected void run() throws NoHeadException, NoMessageException,
ConcurrentRefUpdateException, JGitInternalException, Exception {
@@ -68,6 +78,11 @@ class Commit extends TextBuiltin {
commitCmd.setAuthor(RawParseUtils.parsePersonIdent(author));
if (message != null)
commitCmd.setMessage(message);
+ if (only && paths.isEmpty())
+ throw die(CLIText.get().pathsRequired);
+ if (!paths.isEmpty())
+ for (String p : paths)
+ commitCmd.setOnly(p);
Ref head = db.getRef(Constants.HEAD);
RevCommit commit = commitCmd.call();