Change-Id: I74616f6e8ef69bef4db2f13a9b47ddf57714fd1f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>tags/v4.10.0.201712302008-r
@@ -58,7 +58,9 @@ import org.eclipse.jgit.util.CachedAuthenticator; | |||
* @since 4.0 | |||
*/ | |||
public class ConsoleAuthenticator extends CachedAuthenticator { | |||
/** Install this authenticator implementation into the JVM. */ | |||
/** | |||
* Install this authenticator implementation into the JVM. | |||
*/ | |||
public static void install() { | |||
final ConsoleAuthenticator c = new ConsoleAuthenticator(); | |||
if (c.cons == null) | |||
@@ -69,6 +71,7 @@ public class ConsoleAuthenticator extends CachedAuthenticator { | |||
private final Console cons = System.console(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected PasswordAuthentication promptPasswordAuthentication() { | |||
final String realm = formatRealm(); |
@@ -61,7 +61,9 @@ import org.eclipse.jgit.transport.URIish; | |||
* @since 4.0 | |||
*/ | |||
public class ConsoleCredentialsProvider extends CredentialsProvider { | |||
/** Install this implementation as the default. */ | |||
/** | |||
* Install this implementation as the default. | |||
*/ | |||
public static void install() { | |||
final ConsoleCredentialsProvider c = new ConsoleCredentialsProvider(); | |||
if (c.cons == null) | |||
@@ -74,11 +76,13 @@ public class ConsoleCredentialsProvider extends CredentialsProvider { | |||
private final Console cons = System.console(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean isInteractive() { | |||
return true; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean supports(CredentialItem... items) { | |||
for (CredentialItem i : items) { | |||
@@ -100,6 +104,7 @@ public class ConsoleCredentialsProvider extends CredentialsProvider { | |||
return true; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public boolean get(URIish uri, CredentialItem... items) | |||
throws UnsupportedCredentialItem { |
@@ -66,6 +66,14 @@ abstract class AbstractFetchCommand extends TextBuiltin { | |||
@Option(name = "--verbose", aliases = { "-v" }, usage = "usage_beMoreVerbose") | |||
private boolean verbose; | |||
/** | |||
* Show fetch result. | |||
* | |||
* @param r | |||
* a {@link org.eclipse.jgit.transport.FetchResult} object. | |||
* @throws java.io.IOException | |||
* if any. | |||
*/ | |||
protected void showFetchResult(final FetchResult r) throws IOException { | |||
try (ObjectReader reader = db.newObjectReader()) { | |||
boolean shownURI = false; |
@@ -60,6 +60,7 @@ class Add extends TextBuiltin { | |||
@Argument(required = true, metaVar = "metaVar_filepattern", usage = "usage_filesToAddContentFrom") | |||
private List<String> filepatterns = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -75,11 +75,13 @@ class AmazonS3Client extends TextBuiltin { | |||
@Argument(index = 3, metaVar = "metaVar_KEY", required = true) | |||
private String key; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected final boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final AmazonS3 s3 = new AmazonS3(properties()); |
@@ -74,6 +74,7 @@ class Archive extends TextBuiltin { | |||
@Option(name = "--output", aliases = { "-o" }, metaVar = "metaVar_file", usage = "usage_archiveOutput") | |||
private String output; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (tree == null) |
@@ -134,6 +134,7 @@ class Blame extends TextBuiltin { | |||
private BlameResult blame; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (file == null) { |
@@ -87,6 +87,12 @@ class Branch extends TextBuiltin { | |||
private List<String> delete; | |||
/** | |||
* Delete branches | |||
* | |||
* @param names | |||
* a {@link java.util.List} of branch names. | |||
*/ | |||
@Option(name = "--delete", aliases = { | |||
"-d" }, metaVar = "metaVar_branchNames", usage = "usage_deleteFullyMergedBranch", handler = OptionWithValuesListHandler.class) | |||
public void delete(List<String> names) { | |||
@@ -98,6 +104,12 @@ class Branch extends TextBuiltin { | |||
private List<String> deleteForce; | |||
/** | |||
* Forcefully delete branches | |||
* | |||
* @param names | |||
* a {@link java.util.List} of branch names. | |||
*/ | |||
@Option(name = "--delete-force", aliases = { | |||
"-D" }, metaVar = "metaVar_branchNames", usage = "usage_deleteBranchEvenIfNotMerged", handler = OptionWithValuesListHandler.class) | |||
public void deleteForce(List<String> names) { | |||
@@ -107,6 +119,12 @@ class Branch extends TextBuiltin { | |||
deleteForce = names; | |||
} | |||
/** | |||
* Forcefully create a list of branches | |||
* | |||
* @param branchAndStartPoint | |||
* a branch name and a start point | |||
*/ | |||
@Option(name = "--create-force", aliases = { | |||
"-f" }, metaVar = "metaVar_branchAndStartPoint", usage = "usage_forceCreateBranchEvenExists", handler = OptionWithValuesListHandler.class) | |||
public void createForce(List<String> branchAndStartPoint) { | |||
@@ -125,6 +143,12 @@ class Branch extends TextBuiltin { | |||
} | |||
} | |||
/** | |||
* Move or rename a branch | |||
* | |||
* @param currentAndNew | |||
* the current and the new branch name | |||
*/ | |||
@Option(name = "--move", aliases = { | |||
"-m" }, metaVar = "metaVar_oldNewBranchNames", usage = "usage_moveRenameABranch", handler = OptionWithValuesListHandler.class) | |||
public void moveRename(List<String> currentAndNew) { | |||
@@ -156,6 +180,7 @@ class Branch extends TextBuiltin { | |||
private int maxNameLength; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (delete != null || deleteForce != null) { |
@@ -80,6 +80,7 @@ class Checkout extends TextBuiltin { | |||
@Option(name = "--", metaVar = "metaVar_paths", handler = RestOfArgumentsHandler.class) | |||
private List<String> paths = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (createBranch) { |
@@ -62,6 +62,7 @@ class Clean extends TextBuiltin { | |||
@Option(name = "--dryRun", aliases = { "-n" }) | |||
private boolean dryRun = false; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -86,11 +86,13 @@ class Clone extends AbstractFetchCommand implements CloneCommand.Callback { | |||
@Argument(index = 1, metaVar = "metaVar_directory") | |||
private String localName; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected final boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (localName != null && gitdir != null) | |||
@@ -148,6 +150,7 @@ class Clone extends AbstractFetchCommand implements CloneCommand.Callback { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void initializedSubmodules(Collection<String> submodules) { | |||
try { | |||
@@ -161,6 +164,7 @@ class Clone extends AbstractFetchCommand implements CloneCommand.Callback { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void cloningSubmodule(String path) { | |||
try { | |||
@@ -172,6 +176,7 @@ class Clone extends AbstractFetchCommand implements CloneCommand.Callback { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void checkingOut(AnyObjectId commit, String path) { | |||
try { |
@@ -50,7 +50,7 @@ import java.lang.annotation.Retention; | |||
import java.lang.annotation.Target; | |||
/** | |||
* Annotation to document a {@link TextBuiltin}. | |||
* Annotation to document a {@link org.eclipse.jgit.pgm.TextBuiltin}. | |||
* <p> | |||
* This is an optional annotation for TextBuiltin subclasses and it carries | |||
* documentation forward into the runtime system describing what the command is | |||
@@ -60,6 +60,8 @@ import java.lang.annotation.Target; | |||
@Target( { TYPE }) | |||
public @interface Command { | |||
/** | |||
* Get the command name | |||
* | |||
* @return name the command is invoked as from the command line. If the | |||
* (default) empty string is supplied the name will be generated | |||
* from the class name. | |||
@@ -67,11 +69,15 @@ public @interface Command { | |||
public String name() default ""; | |||
/** | |||
* Get command description | |||
* | |||
* @return one line description of the command's feature set. | |||
*/ | |||
public String usage() default ""; | |||
/** | |||
* If this command is considered to be commonly used | |||
* | |||
* @return true if this command is considered to be commonly used. | |||
*/ | |||
public boolean common() default false; |
@@ -60,9 +60,10 @@ import java.util.Vector; | |||
/** | |||
* List of all commands known by jgit's command line tools. | |||
* <p> | |||
* Commands are implementations of {@link TextBuiltin}, with an optional | |||
* {@link Command} class annotation to insert additional documentation or | |||
* override the default command name (which is guessed from the class name). | |||
* Commands are implementations of {@link org.eclipse.jgit.pgm.TextBuiltin}, | |||
* with an optional {@link org.eclipse.jgit.pgm.Command} class annotation to | |||
* insert additional documentation or override the default command name (which | |||
* is guessed from the class name). | |||
* <p> | |||
* Commands may be registered by adding them to a services file in the same JAR | |||
* (or classes directory) as the command implementation. The service file name | |||
@@ -90,6 +91,8 @@ public class CommandCatalog { | |||
} | |||
/** | |||
* Get all commands sorted by their name | |||
* | |||
* @return all known commands, sorted by command name. | |||
*/ | |||
public static CommandRef[] all() { | |||
@@ -97,6 +100,8 @@ public class CommandCatalog { | |||
} | |||
/** | |||
* Get all common commands sorted by their name | |||
* | |||
* @return all common commands, sorted by command name. | |||
*/ | |||
public static CommandRef[] common() { |
@@ -50,7 +50,8 @@ import java.text.MessageFormat; | |||
import org.eclipse.jgit.pgm.internal.CLIText; | |||
/** | |||
* Description of a command (a {@link TextBuiltin} subclass. | |||
* Description of a command (a {@link org.eclipse.jgit.pgm.TextBuiltin} | |||
* subclass). | |||
* <p> | |||
* These descriptions are lightweight compared to creating a command instance | |||
* and are therefore suitable for catalogs of "known" commands without linking | |||
@@ -102,6 +103,8 @@ public class CommandRef { | |||
} | |||
/** | |||
* Get the <code>name</code>. | |||
* | |||
* @return name the command is invoked as from the command line. | |||
*/ | |||
public String getName() { | |||
@@ -109,6 +112,8 @@ public class CommandRef { | |||
} | |||
/** | |||
* Get <code>usage</code>. | |||
* | |||
* @return one line description of the command's feature set. | |||
*/ | |||
public String getUsage() { | |||
@@ -116,6 +121,8 @@ public class CommandRef { | |||
} | |||
/** | |||
* Is this command commonly used | |||
* | |||
* @return true if this command is considered to be commonly used. | |||
*/ | |||
public boolean isCommon() { | |||
@@ -123,6 +130,8 @@ public class CommandRef { | |||
} | |||
/** | |||
* Get implementation class name | |||
* | |||
* @return name of the Java class which implements this command. | |||
*/ | |||
public String getImplementationClassName() { | |||
@@ -130,6 +139,8 @@ public class CommandRef { | |||
} | |||
/** | |||
* Get implementation class loader | |||
* | |||
* @return loader for {@link #getImplementationClassName()}. | |||
*/ | |||
public ClassLoader getImplementationClassLoader() { | |||
@@ -137,6 +148,8 @@ public class CommandRef { | |||
} | |||
/** | |||
* Create an instance of the command implementation | |||
* | |||
* @return a new instance of the command implementation. | |||
*/ | |||
public TextBuiltin create() { | |||
@@ -166,6 +179,7 @@ public class CommandRef { | |||
return r; | |||
} | |||
/** {@inheritDoc} */ | |||
@SuppressWarnings("nls") | |||
@Override | |||
public String toString() { |
@@ -77,6 +77,7 @@ class Commit extends TextBuiltin { | |||
@Argument(metaVar = "metaVar_commitPaths", usage = "usage_CommitPaths") | |||
private List<String> paths = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws NoHeadException, NoMessageException, | |||
ConcurrentRefUpdateException, JGitInternalException, Exception { |
@@ -68,6 +68,7 @@ class Config extends TextBuiltin { | |||
@Option(name = "--file", aliases = { "-f" }, metaVar = "metaVar_file", usage = "usage_configFile") | |||
private File configFile; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (list) |
@@ -111,11 +111,13 @@ class Daemon extends TextBuiltin { | |||
@Argument(required = true, metaVar = "metaVar_directory", usage = "usage_directoriesToExport") | |||
List<File> directory = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
PackConfig packConfig = new PackConfig(); |
@@ -65,6 +65,7 @@ class Describe extends TextBuiltin { | |||
@Option(name = "--match", usage = "usage_Match", metaVar = "metaVar_pattern") | |||
private List<String> patterns = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -45,7 +45,8 @@ | |||
package org.eclipse.jgit.pgm; | |||
/** | |||
* Indicates a {@link TextBuiltin} implementation has failed during execution. | |||
* Indicates a {@link org.eclipse.jgit.pgm.TextBuiltin} implementation has | |||
* failed during execution. | |||
* <p> | |||
* Typically the stack trace for a Die exception is not shown to the user as it | |||
* may indicate a simple error condition that the end-user can fix on their own, |
@@ -168,12 +168,14 @@ class Diff extends TextBuiltin { | |||
// END -- Options shared with Log | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void init(final Repository repository, final String gitDir) { | |||
super.init(repository, gitDir); | |||
diffFmt = new DiffFormatter(new BufferedOutputStream(outs)); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
diffFmt.setRepository(db); |
@@ -72,6 +72,7 @@ class DiffTree extends TextBuiltin { | |||
@Option(name = "--", metaVar = "metaVar_path", handler = PathTreeFilterHandler.class) | |||
private TreeFilter pathFilter = TreeFilter.ALL; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (final TreeWalk walk = new TreeWalk(db)) { |
@@ -131,6 +131,7 @@ class Fetch extends AbstractFetchCommand implements FetchCommand.Callback { | |||
@Argument(index = 1, metaVar = "metaVar_refspec") | |||
private List<RefSpec> toget; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { | |||
@@ -164,6 +165,7 @@ class Fetch extends AbstractFetchCommand implements FetchCommand.Callback { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void fetchingSubmodule(String name) { | |||
try { |
@@ -58,6 +58,7 @@ class Gc extends TextBuiltin { | |||
@Option(name = "--prune-preserved", usage = "usage_PrunePreserved") | |||
private boolean prunePreserved; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
Git git = Git.wrap(db); |
@@ -102,6 +102,7 @@ class Glog extends RevWalkTextBuiltin { | |||
frame.getContentPane().add(world); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected int walkLoop() throws Exception { | |||
graphPane.getCommitList().source(walk); | |||
@@ -113,11 +114,13 @@ class Glog extends RevWalkTextBuiltin { | |||
return graphPane.getCommitList().size(); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void show(final RevCommit c) throws Exception { | |||
throw new UnsupportedOperationException(); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected RevWalk createWalk() { | |||
if (objects) |
@@ -60,6 +60,7 @@ class IndexPack extends TextBuiltin { | |||
@Option(name = "--index-version", usage = "usage_indexFileFormatToCreate") | |||
private int indexVersion = -1; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
BufferedInputStream in = new BufferedInputStream(ins); |
@@ -66,11 +66,13 @@ class Init extends TextBuiltin { | |||
@Argument(index = 0, metaVar = "metaVar_directory") | |||
private String directory; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected final boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
InitCommand command = Git.init(); |
@@ -184,12 +184,14 @@ class Log extends RevWalkTextBuiltin { | |||
dateFormatter = new GitDateFormatter(Format.DEFAULT); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void init(final Repository repository, final String gitDir) { | |||
super.init(repository, gitDir); | |||
diffFmt = new DiffFormatter(new BufferedOutputStream(outs)); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
diffFmt.setRepository(db); | |||
@@ -237,6 +239,7 @@ class Log extends RevWalkTextBuiltin { | |||
NoteMap.read(argWalk.getObjectReader(), notesCommit)); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void show(final RevCommit c) throws Exception { | |||
outw.print(CLIText.get().commitLabel); |
@@ -70,6 +70,7 @@ class LsRemote extends TextBuiltin { | |||
@Argument(index = 0, metaVar = "metaVar_uriish", required = true) | |||
private String remote; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote) | |||
@@ -89,6 +90,7 @@ class LsRemote extends TextBuiltin { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected boolean requiresRepository() { | |||
return false; |
@@ -70,6 +70,7 @@ class LsTree extends TextBuiltin { | |||
@Option(name = "--", metaVar = "metaVar_paths", handler = StopOptionHandler.class) | |||
private List<String> paths = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (final TreeWalk walk = new TreeWalk(db)) { |
@@ -80,7 +80,9 @@ import org.kohsuke.args4j.CmdLineException; | |||
import org.kohsuke.args4j.Option; | |||
import org.kohsuke.args4j.OptionHandlerFilter; | |||
/** Command line entry point. */ | |||
/** | |||
* Command line entry point. | |||
*/ | |||
public class Main { | |||
@Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) | |||
private boolean help; | |||
@@ -105,7 +107,7 @@ public class Main { | |||
private ExecutorService gcExecutor; | |||
/** | |||
* | |||
* <p>Constructor for Main.</p> | |||
*/ | |||
public Main() { | |||
HttpTransport.setConnectionFactory(new HttpClientConnectionFactory()); | |||
@@ -129,7 +131,7 @@ public class Main { | |||
* | |||
* @param argv | |||
* arguments. | |||
* @throws Exception | |||
* @throws java.lang.Exception | |||
*/ | |||
public static void main(final String[] argv) throws Exception { | |||
new Main().run(argv); | |||
@@ -150,7 +152,7 @@ public class Main { | |||
* | |||
* @param argv | |||
* arguments. | |||
* @throws Exception | |||
* @throws java.lang.Exception | |||
*/ | |||
protected void run(final String[] argv) throws Exception { | |||
writer = createErrorWriter(); | |||
@@ -309,7 +311,7 @@ public class Main { | |||
* the {@code --git-dir} option given on the command line. May be | |||
* null if it was not supplied. | |||
* @return the repository to operate on. | |||
* @throws IOException | |||
* @throws java.io.IOException | |||
* the repository cannot be opened. | |||
*/ | |||
protected Repository openGitDir(String aGitdir) throws IOException { |
@@ -101,6 +101,7 @@ class Merge extends TextBuiltin { | |||
@Option(name = "-m", usage = "usage_message") | |||
private String message; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (squash && ff == FastForwardMode.NO_FF) |
@@ -65,6 +65,7 @@ class MergeBase extends TextBuiltin { | |||
@Argument(index = 1, metaVar = "metaVar_commitish", required = true) | |||
private List<RevCommit> commits = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
for (final RevCommit c : commits) |
@@ -113,6 +113,7 @@ class Push extends TextBuiltin { | |||
private boolean shownURI; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -58,11 +58,13 @@ class ReceivePack extends TextBuiltin { | |||
@Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReceiveInto") | |||
File dstGitdir; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected final boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final org.eclipse.jgit.transport.ReceivePack rp; |
@@ -57,6 +57,7 @@ class Reflog extends TextBuiltin { | |||
@Argument(metaVar = "metaVar_ref") | |||
private String ref; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -84,6 +84,7 @@ class Remote extends TextBuiltin { | |||
@Argument(index = 2, metaVar = "metaVar_uriish") | |||
private String uri; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { | |||
@@ -143,6 +144,7 @@ class Remote extends TextBuiltin { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void printUsage(final String message, final CmdLineParser clp) | |||
throws IOException { |
@@ -58,6 +58,7 @@ class Repo extends TextBuiltin { | |||
@Argument(required = true, metaVar = "metaVar_path", usage = "usage_pathToXml") | |||
private String path; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
new RepoCommand(db) |
@@ -72,6 +72,7 @@ class Reset extends TextBuiltin { | |||
@Option(name = "--", metaVar = "metaVar_paths", handler = RestOfArgumentsHandler.class) | |||
private List<String> paths = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -51,6 +51,7 @@ import org.eclipse.jgit.revwalk.RevTree; | |||
@Command(usage = "usage_RevList") | |||
class RevList extends RevWalkTextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void show(final RevCommit c) throws Exception { | |||
if (c.has(RevFlag.UNINTERESTING)) | |||
@@ -64,6 +65,7 @@ class RevList extends RevWalkTextBuiltin { | |||
outw.println(); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void show(final ObjectWalk ow, final RevObject obj) | |||
throws Exception { |
@@ -70,6 +70,7 @@ class RevParse extends TextBuiltin { | |||
@Argument(index = 0, metaVar = "metaVar_commitish") | |||
private List<ObjectId> commits = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (all) { |
@@ -149,6 +149,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { | |||
@Option(name = "--max-count", aliases = "-n", metaVar = "metaVar_n") | |||
private int maxCount = -1; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
walk = createWalk(); | |||
@@ -210,6 +211,11 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { | |||
} | |||
} | |||
/** | |||
* Create RevWalk | |||
* | |||
* @return a {@link org.eclipse.jgit.revwalk.RevWalk} object. | |||
*/ | |||
protected RevWalk createWalk() { | |||
RevWalk result; | |||
if (objects) | |||
@@ -222,6 +228,13 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { | |||
return result; | |||
} | |||
/** | |||
* Loop the walk | |||
* | |||
* @return number of RevCommits walked | |||
* @throws java.lang.Exception | |||
* if any. | |||
*/ | |||
protected int walkLoop() throws Exception { | |||
int n = 0; | |||
for (final RevCommit c : walk) { | |||
@@ -248,8 +261,8 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { | |||
* RevWalkTextBuiltin. | |||
* | |||
* @param c | |||
* The current {@link RevCommit} | |||
* @throws Exception | |||
* The current {@link org.eclipse.jgit.revwalk.RevCommit} | |||
* @throws java.lang.Exception | |||
*/ | |||
protected abstract void show(final RevCommit c) throws Exception; | |||
@@ -260,10 +273,11 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { | |||
* process RevCommits. | |||
* | |||
* @param objectWalk | |||
* the {@link ObjectWalk} used by {@link #walkLoop()} | |||
* the {@link org.eclipse.jgit.revwalk.ObjectWalk} used by | |||
* {@link #walkLoop()} | |||
* @param currentObject | |||
* The current {@link RevObject} | |||
* @throws Exception | |||
* The current {@link org.eclipse.jgit.revwalk.RevObject} | |||
* @throws java.lang.Exception | |||
*/ | |||
protected void show(final ObjectWalk objectWalk, | |||
final RevObject currentObject) throws Exception { |
@@ -59,6 +59,7 @@ class Rm extends TextBuiltin { | |||
@Option(name = "--", handler = StopOptionHandler.class) | |||
private List<String> paths = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -165,12 +165,14 @@ class Show extends TextBuiltin { | |||
fmt = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy ZZZZZ", Locale.US); //$NON-NLS-1$ | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void init(final Repository repository, final String gitDir) { | |||
super.init(repository, gitDir); | |||
diffFmt = new DiffFormatter(new BufferedOutputStream(outs)); | |||
} | |||
/** {@inheritDoc} */ | |||
@SuppressWarnings("boxing") | |||
@Override | |||
protected void run() throws Exception { |
@@ -58,6 +58,7 @@ import org.eclipse.jgit.util.RefMap; | |||
@Command(usage = "usage_ShowRef") | |||
class ShowRef extends TextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
for (final Ref r : getSortedRefs()) { |
@@ -86,6 +86,7 @@ class Status extends TextBuiltin { | |||
@Option(name = "--", metaVar = "metaVar_paths", handler = RestOfArgumentsHandler.class) | |||
protected List<String> filterPaths; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { | |||
@@ -261,6 +262,15 @@ class Status extends TextBuiltin { | |||
} | |||
} | |||
/** | |||
* Print section header | |||
* | |||
* @param pattern | |||
* a {@link java.lang.String} object. | |||
* @param arguments | |||
* a {@link java.lang.Object} object. | |||
* @throws java.io.IOException | |||
*/ | |||
protected void printSectionHeader(String pattern, Object... arguments) | |||
throws IOException { | |||
if (!porcelain) { | |||
@@ -272,6 +282,14 @@ class Status extends TextBuiltin { | |||
} | |||
} | |||
/** | |||
* Print String list | |||
* | |||
* @param list | |||
* a {@link java.util.Collection} object. | |||
* @return a int. | |||
* @throws java.io.IOException | |||
*/ | |||
protected int printList(Collection<String> list) throws IOException { | |||
if (!list.isEmpty()) { | |||
List<String> sortedList = new ArrayList<>(list); | |||
@@ -286,6 +304,26 @@ class Status extends TextBuiltin { | |||
return 0; | |||
} | |||
/** | |||
* Print String list | |||
* | |||
* @param status1 | |||
* a {@link java.lang.String} object. | |||
* @param status2 | |||
* a {@link java.lang.String} object. | |||
* @param status3 | |||
* a {@link java.lang.String} object. | |||
* @param list | |||
* a {@link java.util.Collection} object. | |||
* @param set1 | |||
* a {@link java.util.Collection} object. | |||
* @param set2 | |||
* a {@link java.util.Collection} object. | |||
* @param set3 | |||
* a {@link java.util.Collection} object. | |||
* @return a int. | |||
* @throws java.io.IOException | |||
*/ | |||
protected int printList(String status1, String status2, String status3, | |||
Collection<String> list, Collection<String> set1, | |||
Collection<String> set2, |
@@ -80,6 +80,7 @@ class Tag extends TextBuiltin { | |||
@Argument(index = 1, metaVar = "metaVar_object") | |||
private ObjectId object; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (Git git = new Git(db)) { |
@@ -133,7 +133,11 @@ public abstract class TextBuiltin { | |||
commandName = name; | |||
} | |||
/** @return true if {@link #db}/{@link #getRepository()} is required. */ | |||
/** | |||
* If this command requires a repository. | |||
* | |||
* @return true if {@link #db}/{@link #getRepository()} is required | |||
*/ | |||
protected boolean requiresRepository() { | |||
return true; | |||
} | |||
@@ -214,7 +218,7 @@ public abstract class TextBuiltin { | |||
* | |||
* @param args | |||
* command line arguments passed after the command name. | |||
* @throws Exception | |||
* @throws java.lang.Exception | |||
* an error occurred while processing the command. The main | |||
* framework will catch the exception and print a message on | |||
* standard error. | |||
@@ -233,7 +237,7 @@ public abstract class TextBuiltin { | |||
* | |||
* @param args | |||
* the arguments supplied on the command line, if any. | |||
* @throws IOException | |||
* @throws java.io.IOException | |||
*/ | |||
protected void parseArguments(final String[] args) throws IOException { | |||
final CmdLineParser clp = new CmdLineParser(this); | |||
@@ -260,7 +264,8 @@ public abstract class TextBuiltin { | |||
* Print the usage line | |||
* | |||
* @param clp | |||
* @throws IOException | |||
* a {@link org.eclipse.jgit.pgm.opt.CmdLineParser} object. | |||
* @throws java.io.IOException | |||
*/ | |||
public void printUsageAndExit(final CmdLineParser clp) throws IOException { | |||
printUsageAndExit("", clp); //$NON-NLS-1$ | |||
@@ -270,8 +275,10 @@ public abstract class TextBuiltin { | |||
* Print an error message and the usage line | |||
* | |||
* @param message | |||
* a {@link java.lang.String} object. | |||
* @param clp | |||
* @throws IOException | |||
* a {@link org.eclipse.jgit.pgm.opt.CmdLineParser} object. | |||
* @throws java.io.IOException | |||
*/ | |||
public void printUsageAndExit(final String message, final CmdLineParser clp) throws IOException { | |||
printUsage(message, clp); | |||
@@ -279,11 +286,13 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Print usage help text. | |||
* | |||
* @param message | |||
* non null | |||
* @param clp | |||
* parser used to print options | |||
* @throws IOException | |||
* @throws java.io.IOException | |||
* @since 4.2 | |||
*/ | |||
protected void printUsage(final String message, final CmdLineParser clp) | |||
@@ -302,6 +311,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Get error writer | |||
* | |||
* @return error writer, typically this is standard error. | |||
* @since 4.2 | |||
*/ | |||
@@ -310,6 +321,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Get output writer | |||
* | |||
* @return output writer, typically this is standard output. | |||
* @since 4.9 | |||
*/ | |||
@@ -318,6 +331,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Get resource bundle with localized texts | |||
* | |||
* @return the resource bundle that will be passed to args4j for purpose of | |||
* string localization | |||
*/ | |||
@@ -330,7 +345,7 @@ public abstract class TextBuiltin { | |||
* <p> | |||
* This method should only be invoked by {@link #execute(String[])}. | |||
* | |||
* @throws Exception | |||
* @throws java.lang.Exception | |||
* an error occurred while processing the command. The main | |||
* framework will catch the exception and print a message on | |||
* standard error. | |||
@@ -338,6 +353,8 @@ public abstract class TextBuiltin { | |||
protected abstract void run() throws Exception; | |||
/** | |||
* Get the repository | |||
* | |||
* @return the repository this command accesses. | |||
*/ | |||
public Repository getRepository() { | |||
@@ -352,6 +369,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Exit the command with an error message | |||
* | |||
* @param why | |||
* textual explanation | |||
* @return a runtime exception the caller is expected to throw | |||
@@ -361,6 +380,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Exit the command with an error message and an exception | |||
* | |||
* @param why | |||
* textual explanation | |||
* @param cause | |||
@@ -372,8 +393,11 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Exit the command | |||
* | |||
* @param aborted | |||
* boolean indicating that the execution has been aborted before running | |||
* boolean indicating that the execution has been aborted before | |||
* running | |||
* @return a runtime exception the caller is expected to throw | |||
* @since 3.4 | |||
*/ | |||
@@ -382,6 +406,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Exit the command | |||
* | |||
* @param aborted | |||
* boolean indicating that the execution has been aborted before | |||
* running | |||
@@ -405,6 +431,8 @@ public abstract class TextBuiltin { | |||
} | |||
/** | |||
* Check if the arguments contain a help option | |||
* | |||
* @param args | |||
* non null | |||
* @return true if the given array contains help option |
@@ -62,11 +62,13 @@ class UploadPack extends TextBuiltin { | |||
@Argument(index = 0, required = true, metaVar = "metaVar_directory", usage = "usage_RepositoryToReadFrom") | |||
File srcGitdir; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected final boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final org.eclipse.jgit.transport.UploadPack up; |
@@ -55,6 +55,7 @@ import org.eclipse.jgit.pgm.internal.CLIText; | |||
@Command(common = true, usage = "usage_DisplayTheVersionOfJgit") | |||
class Version extends TextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
// read the Implementation-Version from Manifest | |||
@@ -73,6 +74,7 @@ class Version extends TextBuiltin { | |||
outw.println(MessageFormat.format(CLIText.get().jgitVersion, version)); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected final boolean requiresRepository() { | |||
return false; |
@@ -95,6 +95,7 @@ class BenchmarkReftable extends TextBuiltin { | |||
@Argument(index = 1) | |||
private String reftablePath; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
switch (test) { |
@@ -130,11 +130,13 @@ class DiffAlgorithms extends TextBuiltin { | |||
private ThreadMXBean mxBean; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
mxBean = ManagementFactory.getThreadMXBean(); |
@@ -214,11 +214,13 @@ class LfsStore extends TextBuiltin { | |||
String secretKey; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
AppServer server = new AppServer(port); |
@@ -57,6 +57,7 @@ import org.eclipse.jgit.pgm.internal.CLIText; | |||
@Command(usage = "usage_MakeCacheTree") | |||
class MakeCacheTree extends TextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final DirCache cache = db.readDirCache(); |
@@ -54,6 +54,7 @@ import org.eclipse.jgit.pgm.internal.CLIText; | |||
@Command(usage = "usage_ReadDirCache") | |||
class ReadDirCache extends TextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final int cnt = 100; |
@@ -63,6 +63,7 @@ class ReadReftable extends TextBuiltin { | |||
@Argument(index = 1, required = false) | |||
private String ref; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (FileInputStream in = new FileInputStream(input); |
@@ -114,6 +114,7 @@ class RebuildCommitGraph extends TextBuiltin { | |||
private Map<ObjectId, ObjectId> rewrites = new HashMap<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (!really && !db.getRefDatabase().getRefs(ALL).isEmpty()) { |
@@ -73,6 +73,7 @@ class RebuildRefTree extends TextBuiltin { | |||
private String txnNamespace; | |||
private String txnCommitted; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
try (ObjectReader reader = db.newObjectReader(); |
@@ -57,6 +57,7 @@ import org.eclipse.jgit.pgm.internal.CLIText; | |||
@Command(usage = "usage_ShowCacheTree") | |||
class ShowCacheTree extends TextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final DirCache cache = db.readDirCache(); |
@@ -59,6 +59,7 @@ class ShowCommands extends TextBuiltin { | |||
@Option(name = "--pretty", metaVar = "metaVar_commandDetail", usage = "usage_alterTheDetailShown") | |||
private Format pretty = Format.USAGE; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final CommandRef[] list = CommandCatalog.all(); |
@@ -64,6 +64,7 @@ class ShowDirCache extends TextBuiltin { | |||
@Option(name = "--millis", aliases = { "-m" }, usage = "usage_showTimeInMilliseconds") | |||
private boolean millis = false; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final SimpleDateFormat fmt; |
@@ -72,6 +72,7 @@ class ShowPackDelta extends TextBuiltin { | |||
@Argument(index = 0) | |||
private ObjectId objectId; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
ObjectReader reader = db.newObjectReader(); |
@@ -262,11 +262,13 @@ class TextHashFunctions extends TextBuiltin { | |||
@Option(name = "--repository", aliases = { "-r" }, metaVar = "GIT_DIR", usage = "Repository to scan") | |||
List<File> gitDirs = new ArrayList<>(); | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected boolean requiresRepository() { | |||
return false; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
if (gitDirs.isEmpty()) { |
@@ -75,6 +75,7 @@ class VerifyReftable extends TextBuiltin { | |||
@Argument(index = 1) | |||
private String reftablePath; | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
List<Ref> refs = WriteReftable.readRefs(lsRemotePath); |
@@ -51,6 +51,7 @@ import org.eclipse.jgit.pgm.internal.CLIText; | |||
@Command(usage = "usage_WriteDirCache") | |||
class WriteDirCache extends TextBuiltin { | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected void run() throws Exception { | |||
final DirCache cache = db.readDirCache(); |
@@ -104,6 +104,7 @@ class WriteReftable extends TextBuiltin { | |||
@Argument(index = 1) | |||
private String out; | |||
/** {@inheritDoc} */ | |||
@SuppressWarnings({ "nls", "boxing" }) | |||
@Override | |||
protected void run() throws Exception { |
@@ -79,6 +79,8 @@ public class CLIText extends TranslationBundle { | |||
} | |||
/** | |||
* Format text | |||
* | |||
* @param text | |||
* the text to format. | |||
* @return a new Format instance. | |||
@@ -88,6 +90,8 @@ public class CLIText extends TranslationBundle { | |||
} | |||
/** | |||
* Get an instance of this translation bundle | |||
* | |||
* @return an instance of this translation bundle | |||
*/ | |||
public static CLIText get() { |
@@ -68,7 +68,8 @@ import org.kohsuke.args4j.spi.Parameters; | |||
import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Custom argument handler {@link AbstractTreeIterator} from string values. | |||
* Custom argument handler | |||
* {@link org.eclipse.jgit.treewalk.AbstractTreeIterator} from string values. | |||
* <p> | |||
* Assumes the parser has been initialized with a Repository. | |||
*/ | |||
@@ -82,8 +83,11 @@ public class AbstractTreeIteratorHandler extends | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public AbstractTreeIteratorHandler(final CmdLineParser parser, | |||
final OptionDef option, | |||
@@ -92,6 +96,7 @@ public class AbstractTreeIteratorHandler extends | |||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
final String name = params.getParameter(0); | |||
@@ -144,6 +149,7 @@ public class AbstractTreeIteratorHandler extends | |||
return 1; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_treeish; |
@@ -61,11 +61,9 @@ import org.eclipse.jgit.revwalk.RevTree; | |||
import org.eclipse.jgit.revwalk.RevWalk; | |||
import org.eclipse.jgit.transport.RefSpec; | |||
import org.eclipse.jgit.treewalk.AbstractTreeIterator; | |||
import org.kohsuke.args4j.Argument; | |||
import org.kohsuke.args4j.CmdLineException; | |||
import org.kohsuke.args4j.IllegalAnnotationError; | |||
import org.kohsuke.args4j.NamedOptionDef; | |||
import org.kohsuke.args4j.Option; | |||
import org.kohsuke.args4j.OptionDef; | |||
import org.kohsuke.args4j.OptionHandlerRegistry; | |||
import org.kohsuke.args4j.spi.OptionHandler; | |||
@@ -105,9 +103,10 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { | |||
* them into the given object. | |||
* | |||
* @param bean | |||
* instance of a class annotated by {@link Option} and | |||
* {@link Argument}. this object will receive values. | |||
* | |||
* instance of a class annotated by | |||
* {@link org.kohsuke.args4j.Option} and | |||
* {@link org.kohsuke.args4j.Argument}. this object will receive | |||
* values. | |||
* @throws IllegalAnnotationError | |||
* if the option bean class is using args4j annotations | |||
* incorrectly. | |||
@@ -121,8 +120,10 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { | |||
* them into the given object. | |||
* | |||
* @param bean | |||
* instance of a class annotated by {@link Option} and | |||
* {@link Argument}. this object will receive values. | |||
* instance of a class annotated by | |||
* {@link org.kohsuke.args4j.Option} and | |||
* {@link org.kohsuke.args4j.Argument}. this object will receive | |||
* values. | |||
* @param repo | |||
* repository this parser can translate options through. | |||
* @throws IllegalAnnotationError | |||
@@ -140,6 +141,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { | |||
this.db = repo; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void parseArgument(final String... args) throws CmdLineException { | |||
final ArrayList<String> tmp = new ArrayList<>(args.length); | |||
@@ -223,6 +225,8 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { | |||
} | |||
/** | |||
* Check if array contains help option | |||
* | |||
* @param args | |||
* non null | |||
* @return true if the given array contains help option | |||
@@ -292,6 +296,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { | |||
} | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
protected OptionHandler createOptionHandler(OptionDef o, Setter setter) { | |||
if (o instanceof NamedOptionDef) | |||
@@ -301,6 +306,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public void printSingleLineUsage(Writer w, ResourceBundle rb) { | |||
List<OptionHandler> options = getOptions(); |
@@ -56,7 +56,8 @@ import org.kohsuke.args4j.spi.Parameters; | |||
import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Custom argument handler {@link ObjectId} from string values. | |||
* Custom argument handler {@link org.eclipse.jgit.lib.ObjectId} from string | |||
* values. | |||
* <p> | |||
* Assumes the parser has been initialized with a Repository. | |||
*/ | |||
@@ -69,8 +70,11 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public ObjectIdHandler(final CmdLineParser parser, final OptionDef option, | |||
final Setter<? super ObjectId> setter) { | |||
@@ -78,6 +82,7 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { | |||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
final String name = params.getParameter(0); | |||
@@ -96,6 +101,7 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { | |||
CLIText.format(CLIText.get().notAnObject), name); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_object; |
@@ -19,15 +19,21 @@ import org.kohsuke.args4j.spi.Setter; | |||
public class OptionWithValuesListHandler extends OptionHandler<List<?>> { | |||
/** | |||
* Constructor for OptionWithValuesListHandler. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public OptionWithValuesListHandler(CmdLineParser parser, | |||
OptionDef option, Setter<List<?>> setter) { | |||
super(parser, option, setter); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(Parameters params) throws CmdLineException { | |||
final List<String> list = new ArrayList<>(); | |||
@@ -44,6 +50,7 @@ public class OptionWithValuesListHandler extends OptionHandler<List<?>> { | |||
return list.size(); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_values; |
@@ -59,10 +59,11 @@ import org.kohsuke.args4j.spi.Parameters; | |||
import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Create a {@link TreeFilter} to patch math names. | |||
* Create a {@link org.eclipse.jgit.treewalk.filter.TreeFilter} to patch math | |||
* names. | |||
* <p> | |||
* This handler consumes all arguments to the end of the command line, and is | |||
* meant to be used on an {@link Option} of name "--". | |||
* meant to be used on an {@link org.kohsuke.args4j.Option} of name "--". | |||
*/ | |||
public class PathTreeFilterHandler extends OptionHandler<TreeFilter> { | |||
/** | |||
@@ -71,14 +72,18 @@ public class PathTreeFilterHandler extends OptionHandler<TreeFilter> { | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public PathTreeFilterHandler(final CmdLineParser parser, | |||
final OptionDef option, final Setter<? super TreeFilter> setter) { | |||
super(parser, option, setter); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
final List<PathFilter> filters = new ArrayList<>(); | |||
@@ -102,6 +107,7 @@ public class PathTreeFilterHandler extends OptionHandler<TreeFilter> { | |||
return filters.size(); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_paths; |
@@ -53,7 +53,8 @@ import org.kohsuke.args4j.spi.Parameters; | |||
import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Custom argument handler {@link RefSpec} from string values. | |||
* Custom argument handler {@link org.eclipse.jgit.transport.RefSpec} from | |||
* string values. | |||
* <p> | |||
* Assumes the parser has been initialized with a Repository. | |||
*/ | |||
@@ -64,20 +65,25 @@ public class RefSpecHandler extends OptionHandler<RefSpec> { | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public RefSpecHandler(final CmdLineParser parser, final OptionDef option, | |||
final Setter<? super RefSpec> setter) { | |||
super(parser, option, setter); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
setter.addValue(new RefSpec(params.getParameter(0))); | |||
return 1; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_refspec; |
@@ -60,7 +60,8 @@ import org.kohsuke.args4j.spi.Parameters; | |||
import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Custom argument handler {@link RevCommit} from string values. | |||
* Custom argument handler {@link org.eclipse.jgit.revwalk.RevCommit} from | |||
* string values. | |||
* <p> | |||
* Assumes the parser has been initialized with a Repository. | |||
*/ | |||
@@ -73,8 +74,11 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public RevCommitHandler(final CmdLineParser parser, final OptionDef option, | |||
final Setter<? super RevCommit> setter) { | |||
@@ -82,6 +86,7 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { | |||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
String name = params.getParameter(0); | |||
@@ -145,6 +150,7 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { | |||
setter.addValue(c); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_commitish; |
@@ -59,7 +59,8 @@ import org.kohsuke.args4j.spi.Parameters; | |||
import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Custom argument handler {@link RevTree} from string values. | |||
* Custom argument handler {@link org.eclipse.jgit.revwalk.RevTree} from string | |||
* values. | |||
* <p> | |||
* Assumes the parser has been initialized with a Repository. | |||
*/ | |||
@@ -72,8 +73,11 @@ public class RevTreeHandler extends OptionHandler<RevTree> { | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public RevTreeHandler(final CmdLineParser parser, final OptionDef option, | |||
final Setter<? super RevTree> setter) { | |||
@@ -81,6 +85,7 @@ public class RevTreeHandler extends OptionHandler<RevTree> { | |||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
final String name = params.getParameter(0); | |||
@@ -112,6 +117,7 @@ public class RevTreeHandler extends OptionHandler<RevTree> { | |||
return 1; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_treeish; |
@@ -57,8 +57,9 @@ import org.kohsuke.args4j.spi.Setter; | |||
/** | |||
* Custom Argument handler for jgit command selection. | |||
* <p> | |||
* Translates a single argument string to a {@link TextBuiltin} instance which | |||
* we can execute at runtime with the remaining arguments of the parser. | |||
* Translates a single argument string to a | |||
* {@link org.eclipse.jgit.pgm.TextBuiltin} instance which 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; | |||
@@ -69,8 +70,11 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { | |||
* This constructor is used only by args4j. | |||
* | |||
* @param parser | |||
* a {@link org.kohsuke.args4j.CmdLineParser} object. | |||
* @param option | |||
* a {@link org.kohsuke.args4j.OptionDef} object. | |||
* @param setter | |||
* a {@link org.kohsuke.args4j.spi.Setter} object. | |||
*/ | |||
public SubcommandHandler(final CmdLineParser parser, | |||
final OptionDef option, final Setter<? super TextBuiltin> setter) { | |||
@@ -78,6 +82,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { | |||
clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(final Parameters params) throws CmdLineException { | |||
final String name = params.getParameter(0); | |||
@@ -95,6 +100,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { | |||
return 1; | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public String getDefaultMetaVariable() { | |||
return CLIText.get().metaVar_command; |
@@ -71,6 +71,8 @@ import org.kohsuke.args4j.spi.StringOptionHandler; | |||
public class UntrackedFilesHandler extends StringOptionHandler { | |||
/** | |||
* <p>Constructor for UntrackedFilesHandler.</p> | |||
* | |||
* @param parser | |||
* The parser to which this handler belongs to. | |||
* @param option | |||
@@ -83,6 +85,7 @@ public class UntrackedFilesHandler extends StringOptionHandler { | |||
super(parser, option, setter); | |||
} | |||
/** {@inheritDoc} */ | |||
@Override | |||
public int parseArguments(Parameters params) throws CmdLineException { | |||
String alias = params.getParameter(-1); |