Browse Source

Allow to amend commits with JGit CLI

Change-Id: I0e8d365b56e079ac4ccece7fcf80ea140c319c78
stable-1.3
Tomasz Zarna 13 years ago
parent
commit
8c60468ff4
  1. 1
      org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties
  2. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java

1
org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties

@ -141,6 +141,7 @@ usage_CommandLineClientForamazonsS3Service=Command line client for Amazon's S3 s
usage_CommitAuthor=Override the author name used in the commit. You can use the standard A U Thor <author@example.com> format. 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_CommitMessage=Use the given <msg> as the commit message
usage_CommitOnly=commit specified paths only usage_CommitOnly=commit specified paths only
usage_CommitAmend=Amend the tip of the current branch
usage_CommitPaths=see --only usage_CommitPaths=see --only
usage_CreateABareRepository=Create a bare repository usage_CreateABareRepository=Create a bare repository
usage_CreateATag=Create a tag usage_CreateATag=Create a tag

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java

@ -67,6 +67,9 @@ class Commit extends TextBuiltin {
@Option(name = "--only", aliases = { "-o" }, usage = "usage_CommitOnly") @Option(name = "--only", aliases = { "-o" }, usage = "usage_CommitOnly")
private boolean only; private boolean only;
@Option(name = "--amend", usage = "usage_CommitAmend")
private boolean amend;
@Argument(metaVar = "metaVar_commitPaths", usage = "usage_CommitPaths") @Argument(metaVar = "metaVar_commitPaths", usage = "usage_CommitPaths")
private List<String> paths = new ArrayList<String>(); private List<String> paths = new ArrayList<String>();
@ -83,6 +86,7 @@ class Commit extends TextBuiltin {
if (!paths.isEmpty()) if (!paths.isEmpty())
for (String p : paths) for (String p : paths)
commitCmd.setOnly(p); commitCmd.setOnly(p);
commitCmd.setAmend(amend);
Ref head = db.getRef(Constants.HEAD); Ref head = db.getRef(Constants.HEAD);
RevCommit commit = commitCmd.call(); RevCommit commit = commitCmd.call();

Loading…
Cancel
Save