diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-20 09:32:19 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-20 09:45:48 +0900 |
commit | aca07fac464834611bab83b91e828308838f361c (patch) | |
tree | d2075304ea161f9a02e4f874b67ca7db8501499c /org.eclipse.jgit.pgm | |
parent | 2ccea7f05a0f3e783f6a8fa3f07cc5f1001bc950 (diff) | |
parent | 4b93de43bafd419b973ebf242e4ca1dd3b3b87d1 (diff) | |
download | jgit-aca07fac464834611bab83b91e828308838f361c.tar.gz jgit-aca07fac464834611bab83b91e828308838f361c.zip |
Merge branch 'stable-4.2'
* stable-4.2:
CheckoutCommandTest: Create Git instances in try-with-resource
BranchCommandTest: Create Git instances in try-with-resource
CheckoutTest: Create Git instances in try-with-resource
BranchTest: Create Git instances in try-with-resource
URIishTest: Use @Test annotation's `expected` argument
Suppress "The allocated object is never used" warning in tests
Add $NON-NLS to suppress "Non-externalized string literal" warnings
Don't use deprecated constructors of CmdLineException
Prepare 4.2.0-SNAPSHOT builds
Remove org.eclipse.jgit.updatesite project from tools/version.sh
RevParse: Remove superfluous semicolon
RefUpdateTest: Use try-with-resource for auto-closable types
RefUpdateTest: Add null check to prevent potential NPE
CommitCommand: Remove redundant null check
JGit v4.2.0.201512141825-rc1
Change-Id: I2179859289b2f2e3d0b7c6d02ef7e7890c467f7b
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
15 files changed, 70 insertions, 63 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java index fde0a78bf6..2cee2cb007 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java @@ -129,20 +129,20 @@ abstract class AbstractFetchCommand extends TextBuiltin { final TrackingRefUpdate u) { final RefUpdate.Result r = u.getResult(); if (r == RefUpdate.Result.LOCK_FAILURE) - return "[lock fail]"; + return "[lock fail]"; //$NON-NLS-1$ if (r == RefUpdate.Result.IO_FAILURE) - return "[i/o error]"; + return "[i/o error]"; //$NON-NLS-1$ if (r == RefUpdate.Result.REJECTED) - return "[rejected]"; + return "[rejected]"; //$NON-NLS-1$ if (ObjectId.zeroId().equals(u.getNewObjectId())) - return "[deleted]"; + return "[deleted]"; //$NON-NLS-1$ if (r == RefUpdate.Result.NEW) { if (u.getRemoteName().startsWith(Constants.R_HEADS)) - return "[new branch]"; + return "[new branch]"; //$NON-NLS-1$ else if (u.getLocalName().startsWith(Constants.R_TAGS)) - return "[new tag]"; - return "[new]"; + return "[new tag]"; //$NON-NLS-1$ + return "[new]"; //$NON-NLS-1$ } if (r == RefUpdate.Result.FORCED) { @@ -158,7 +158,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { } if (r == RefUpdate.Result.NO_CHANGE) - return "[up to date]"; + return "[up to date]"; //$NON-NLS-1$ return "[" + r.name() + "]"; //$NON-NLS-1$//$NON-NLS-2$ } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java index 8569e9278e..faae13a4d7 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java @@ -74,7 +74,7 @@ class Config extends TextBuiltin { list(); else throw new NotSupportedException( - "only --list option is currently supported"); + "only --list option is currently supported"); //$NON-NLS-1$ } private void list() throws IOException, ConfigInvalidException { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index d43424c7ce..6947cdd100 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -324,7 +324,7 @@ class Log extends RevWalkTextBuiltin { return false; if (emptyLine) outw.println(); - outw.print("Notes"); + outw.print("Notes"); //$NON-NLS-1$ if (label != null) { outw.print(" ("); //$NON-NLS-1$ outw.print(label); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java index 9098c1263d..33ea1deb8e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java @@ -182,15 +182,15 @@ class Push extends TextBuiltin { switch (rru.getStatus()) { case OK: if (rru.isDelete()) - printUpdateLine('-', "[deleted]", null, remoteName, null); + printUpdateLine('-', "[deleted]", null, remoteName, null); //$NON-NLS-1$ else { final Ref oldRef = result.getAdvertisedRef(remoteName); if (oldRef == null) { final String summary; if (remoteName.startsWith(Constants.R_TAGS)) - summary = "[new tag]"; + summary = "[new tag]"; //$NON-NLS-1$ else - summary = "[new branch]"; + summary = "[new branch]"; //$NON-NLS-1$ printUpdateLine('*', summary, srcRef, remoteName, null); } else { boolean fastForward = rru.isFastForward(); @@ -206,16 +206,16 @@ class Push extends TextBuiltin { break; case NON_EXISTING: - printUpdateLine('X', "[no match]", null, remoteName, null); + printUpdateLine('X', "[no match]", null, remoteName, null); //$NON-NLS-1$ break; case REJECTED_NODELETE: - printUpdateLine('!', "[rejected]", null, remoteName, + printUpdateLine('!', "[rejected]", null, remoteName, //$NON-NLS-1$ CLIText.get().remoteSideDoesNotSupportDeletingRefs); break; case REJECTED_NONFASTFORWARD: - printUpdateLine('!', "[rejected]", srcRef, remoteName, + printUpdateLine('!', "[rejected]", srcRef, remoteName, //$NON-NLS-1$ CLIText.get().nonFastForward); break; @@ -223,22 +223,22 @@ class Push extends TextBuiltin { final String message = MessageFormat.format( CLIText.get().remoteRefObjectChangedIsNotExpectedOne, safeAbbreviate(reader, rru.getExpectedOldObjectId())); - printUpdateLine('!', "[rejected]", srcRef, remoteName, message); + printUpdateLine('!', "[rejected]", srcRef, remoteName, message); //$NON-NLS-1$ break; case REJECTED_OTHER_REASON: - printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru + printUpdateLine('!', "[remote rejected]", srcRef, remoteName, rru //$NON-NLS-1$ .getMessage()); break; case UP_TO_DATE: if (verbose) - printUpdateLine('=', "[up to date]", srcRef, remoteName, null); + printUpdateLine('=', "[up to date]", srcRef, remoteName, null); //$NON-NLS-1$ break; case NOT_ATTEMPTED: case AWAITING_REPORT: - printUpdateLine('?', "[unexpected push-process behavior]", srcRef, + printUpdateLine('?', "[unexpected push-process behavior]", srcRef, //$NON-NLS-1$ remoteName, rru.getMessage()); break; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java index eb222747d3..9cee37b791 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java @@ -89,7 +89,7 @@ class Reset extends TextBuiltin { if (hard) mode = selectMode(mode, ResetType.HARD); if (mode == null) - throw die("no reset mode set"); + throw die("no reset mode set"); //$NON-NLS-1$ command.setMode(mode); } command.call(); @@ -98,7 +98,7 @@ class Reset extends TextBuiltin { private static ResetType selectMode(ResetType mode, ResetType want) { if (mode != null) - throw die("reset modes are mutually exclusive, select one"); + throw die("reset modes are mutually exclusive, select one"); //$NON-NLS-1$ return want; } } 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 939f5836f3..c5ecb8496e 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 @@ -56,7 +56,8 @@ 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;; +import org.eclipse.jgit.pgm.internal.CLIText; +import org.eclipse.jgit.pgm.opt.CmdLineParser; @Command(usage = "usage_RevParse") class RevParse extends TextBuiltin { @@ -84,7 +85,8 @@ class RevParse extends TextBuiltin { } } else { if (verify && commits.size() > 1) { - throw new CmdLineException(CLIText.get().needSingleRevision); + final CmdLineParser clp = new CmdLineParser(this); + throw new CmdLineException(clp, CLIText.get().needSingleRevision); } for (final ObjectId o : commits) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java index d856989011..c96f2c1ba4 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java @@ -136,7 +136,7 @@ class DiffAlgorithms extends TextBuiltin { protected void run() throws Exception { mxBean = ManagementFactory.getThreadMXBean(); if (!mxBean.isCurrentThreadCpuTimeSupported()) - throw die("Current thread CPU time not supported on this JRE"); + throw die("Current thread CPU time not supported on this JRE"); //$NON-NLS-1$ if (gitDirs.isEmpty()) { RepositoryBuilder rb = new RepositoryBuilder() // @@ -248,18 +248,18 @@ class DiffAlgorithms extends TextBuiltin { File parent = directory.getParentFile(); if (name.equals(Constants.DOT_GIT) && parent != null) name = parent.getName(); - outw.println(name + ": start at " + startId.name()); + outw.println(name + ": start at " + startId.name()); //$NON-NLS-1$ } - outw.format(" %12d files, %8d commits\n", valueOf(files), + outw.format(" %12d files, %8d commits\n", valueOf(files), //$NON-NLS-1$ valueOf(commits)); - outw.format(" N=%10d min lines, %8d max lines\n", valueOf(minN), + outw.format(" N=%10d min lines, %8d max lines\n", valueOf(minN), //$NON-NLS-1$ valueOf(maxN)); - outw.format("%-25s %12s ( %12s %12s )\n", // - "Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); - outw.format("%-25s %12s ( %12s %12s )\n", // - "", "", "N=" + minN, "N=" + maxN); + outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$ + "Algorithm", "Time(ns)", "Time(ns) on", "Time(ns) on"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + outw.format("%-25s %12s ( %12s %12s )\n", //$NON-NLS-1$ + "", "", "N=" + minN, "N=" + maxN); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ outw.println("-----------------------------------------------------" //$NON-NLS-1$ + "----------------"); //$NON-NLS-1$ @@ -335,9 +335,9 @@ class DiffAlgorithms extends TextBuiltin { } } } catch (IllegalArgumentException e) { - throw die("Cannot determine names", e); + throw die("Cannot determine names", e); //$NON-NLS-1$ } catch (IllegalAccessException e) { - throw die("Cannot determine names", e); + throw die("Cannot determine names", e); //$NON-NLS-1$ } return all; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java index 6260cd99fa..e2f93f4814 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java @@ -167,7 +167,7 @@ class RebuildCommitGraph extends TextBuiltin { } } - pm.beginTask("Rewriting commits", queue.size()); + pm.beginTask("Rewriting commits", queue.size()); //$NON-NLS-1$ try (ObjectInserter oi = db.newObjectInserter()) { final ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, new byte[] {}); @@ -203,7 +203,7 @@ class RebuildCommitGraph extends TextBuiltin { newc.setAuthor(new PersonIdent(me, new Date(t.commitTime))); newc.setCommitter(newc.getAuthor()); newc.setParentIds(newParents); - newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-2$ + newc.setMessage("ORIGINAL " + t.oldId.name() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ t.newId = oi.insert(newc); rewrites.put(t.oldId, t.newId); pm.update(1); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java index d3eb245cd9..150fe6eecb 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowPackDelta.java @@ -87,9 +87,9 @@ class ShowPackDelta extends TextBuiltin { long size = reader.getObjectSize(obj, obj.getType()); try { if (BinaryDelta.getResultSize(delta) != size) - throw die("Object " + obj.name() + " is not a delta"); + throw die("Object " + obj.name() + " is not a delta"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (ArrayIndexOutOfBoundsException bad) { - throw die("Object " + obj.name() + " is not a delta"); + throw die("Object " + obj.name() + " is not a delta"); //$NON-NLS-1$ //$NON-NLS-2$ } outw.println(BinaryDelta.format(delta)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java index 887ad08af7..062f4e7a1f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java @@ -349,10 +349,10 @@ class TextHashFunctions extends TextBuiltin { name = parent.getName(); outw.println(name + ":"); //$NON-NLS-1$ } - outw.format(" %6d files; %5d avg. unique lines/file\n", // + outw.format(" %6d files; %5d avg. unique lines/file\n", //$NON-NLS-1$ valueOf(fileCnt), // valueOf(lineCnt / fileCnt)); - outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len"); + outw.format("%-20s %-15s %9s\n", "Hash", "Fold", "Max Len"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ outw.println("-----------------------------------------------"); //$NON-NLS-1$ String lastHashName = null; for (Function fun : all) { @@ -405,9 +405,9 @@ class TextHashFunctions extends TextBuiltin { } } } catch (IllegalArgumentException e) { - throw new RuntimeException("Cannot determine names", e); + throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$ } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot determine names", e); + throw new RuntimeException("Cannot determine names", e); //$NON-NLS-1$ } List<Function> all = new ArrayList<Function>(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java index 229fb67b0c..6b8a61d4d1 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java @@ -109,7 +109,7 @@ public class AbstractTreeIteratorHandler extends try { dirc = DirCache.read(new File(name), FS.DETECTED); } catch (IOException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnIndexFile, name), e); } setter.addValue(new DirCacheIterator(dirc)); return 1; @@ -119,20 +119,20 @@ public class AbstractTreeIteratorHandler extends try { id = clp.getRepository().resolve(name); } catch (IOException e) { - throw new CmdLineException(e.getMessage()); + throw new CmdLineException(clp, e.getMessage()); } if (id == null) - throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); final CanonicalTreeParser p = new CanonicalTreeParser(); try (ObjectReader curs = clp.getRepository().newObjectReader()) { p.reset(curs, clp.getRevWalk().parseTree(id)); } catch (MissingObjectException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); } catch (IOException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } setter.addValue(p); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java index fa24d4b02f..364809d835 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java @@ -86,14 +86,14 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { try { id = clp.getRepository().resolve(name); } catch (IOException e) { - throw new CmdLineException(e.getMessage()); + throw new CmdLineException(clp, e.getMessage()); } if (id != null) { setter.addValue(id); return 1; } - throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnObject, name)); } @Override diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java index b1be128db1..9ae56e4eaf 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java @@ -96,8 +96,10 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { final int dot2 = name.indexOf(".."); //$NON-NLS-1$ if (dot2 != -1) { if (!option.isMultiValued()) - throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn - , option.metaVar(), name)); + throw new CmdLineException(clp, + MessageFormat.format( + CLIText.get().onlyOneMetaVarExpectedIn, + option.metaVar(), name)); final String left = name.substring(0, dot2); final String right = name.substring(dot2 + 2); @@ -116,20 +118,20 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { try { id = clp.getRepository().resolve(name); } catch (IOException e) { - throw new CmdLineException(e.getMessage()); + throw new CmdLineException(clp, e.getMessage()); } if (id == null) - throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name)); final RevCommit c; try { c = clp.getRevWalk().parseCommit(id); } catch (MissingObjectException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name)); } catch (IOException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } if (interesting) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java index eb155af9f4..e2879e076a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java @@ -89,20 +89,20 @@ public class RevTreeHandler extends OptionHandler<RevTree> { try { id = clp.getRepository().resolve(name); } catch (IOException e) { - throw new CmdLineException(e.getMessage()); + throw new CmdLineException(clp, e.getMessage()); } if (id == null) - throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); final RevTree c; try { c = clp.getRevWalk().parseTree(id); } catch (MissingObjectException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); } catch (IncorrectObjectTypeException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name)); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name)); } catch (IOException e) { - throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); + throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage())); } setter.addValue(c); return 1; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java index c62ef0d2b8..96f3ed0afa 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java @@ -63,6 +63,8 @@ import org.eclipse.jgit.pgm.internal.CLIText; * we can execute at runtime with the remaining arguments of the parser. */ public class SubcommandHandler extends OptionHandler<TextBuiltin> { + private final org.eclipse.jgit.pgm.opt.CmdLineParser clp; + /** * Create a new handler for the command name. * <p> @@ -75,6 +77,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { public SubcommandHandler(final CmdLineParser parser, final OptionDef option, final Setter<? super TextBuiltin> setter) { super(parser, option, setter); + clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; } @Override @@ -82,7 +85,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { final String name = params.getParameter(0); final CommandRef cr = CommandCatalog.get(name); if (cr == null) - throw new CmdLineException(MessageFormat.format( + throw new CmdLineException(clp, MessageFormat.format( CLIText.get().notAJgitCommand, name)); // Force option parsing to stop. Everything after us should |