summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
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
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')
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties6
-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
3 files changed, 23 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
index 01b3fba9cc..718c57ad2e 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
@@ -62,8 +62,9 @@ metaVar_base=base
metaVar_bucket=BUCKET
metaVar_command=command
metaVar_commandDetail=DETAIL
-metaVar_commitOrTag=COMMIT|TAG
metaVar_commitish=commit-ish
+metaVar_commitOrTag=COMMIT|TAG
+metaVar_commitPaths=paths
metaVar_configFile=FILE
metaVar_connProp=conn.prop
metaVar_diffAlg=ALGORITHM
@@ -113,6 +114,7 @@ notFound=!! NOT FOUND !!
noteObjectTooLargeToPrint=Note object {0} too large to print
onlyOneMetaVarExpectedIn=Only one {0} expected in {1}.
pushTo=To {0}
+pathsRequired=at least one path has to be specified when using --only
remoteMessage=remote: {0}
remoteRefObjectChangedIsNotExpectedOne=remote ref object changed - is not expected one {0}
remoteSideDoesNotSupportDeletingRefs=remote side does not support deleting refs
@@ -125,6 +127,8 @@ unsupportedOperation=Unsupported operation: {0}
usage_CommandLineClientForamazonsS3Service=Command line client for Amazon's S3 service
usage_CommitAuthor=Override the author name used in the commit. You can use the standard A U Thor <author@example.com> format.
usage_CommitMessage=Use the given <msg> as the commit message
+usage_CommitOnly=commit specified paths only
+usage_CommitPaths=see --only
usage_CreateABareRepository=Create a bare repository
usage_CreateATag=Create a tag
usage_CreateAnEmptyGitRepository=Create an empty git repository
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();