diff options
author | Thomas Meyer <thomas.mey@web.de> | 2015-11-19 23:14:03 +0100 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2015-11-19 17:47:52 -0500 |
commit | 68cea21f5384e184bb3fc2c33e5d2213721d6bf5 (patch) | |
tree | 6200810c666f88e13e882d6473264b15116a75b9 /org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java | |
parent | d3e61db455174ce8af70fcc80a19f414881dfea9 (diff) | |
download | jgit-68cea21f5384e184bb3fc2c33e5d2213721d6bf5.tar.gz jgit-68cea21f5384e184bb3fc2c33e5d2213721d6bf5.zip |
git rev-parse: Add --verify option
Add the --verify option to be more compatible with git
Change-Id: I225a36ecc4711fd2eb9af67ca8fb79681d94c587
Signed-off-by: Thomas Meyer <thomas.mey@web.de>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java index 5530ac5c99..4456fd5348 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java @@ -1,6 +1,7 @@ /* * Copyright (C) 2009, Daniel Cheng (aka SDiZ) <git@sdiz.net> * Copyright (C) 2009, Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com> + * Copyright (C) 2015 Thomas Meyer <thomas@m3y3r.de> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -51,14 +52,19 @@ import java.util.List; import java.util.Map; import org.kohsuke.args4j.Argument; +import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.Option; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.pgm.internal.CLIText;; @Command(usage = "usage_RevParse") class RevParse extends TextBuiltin { @Option(name = "--all", usage = "usage_RevParseAll") - boolean all = false; + boolean all; + + @Option(name = "--verify", usage = "usage_RevParseVerify") + boolean verify; @Argument(index = 0, metaVar = "metaVar_commitish") private final List<ObjectId> commits = new ArrayList<ObjectId>(); @@ -67,11 +73,17 @@ class RevParse extends TextBuiltin { protected void run() throws Exception { if (all) { Map<String, Ref> allRefs = db.getRefDatabase().getRefs(ALL); - for (final Ref r : allRefs.values()) + for (final Ref r : allRefs.values()) { outw.println(r.getObjectId().name()); + } } else { - for (final ObjectId o : commits) + if (verify && commits.size() > 1) { + throw new CmdLineException(CLIText.get().needSingleRevision); + } + + for (final ObjectId o : commits) { outw.println(o.name()); + } } } } |