diff options
Diffstat (limited to 'org.eclipse.jgit.pgm')
47 files changed, 208 insertions, 225 deletions
diff --git a/org.eclipse.jgit.pgm/BUILD b/org.eclipse.jgit.pgm/BUILD index 07922687e3..bbf4b1c43d 100644 --- a/org.eclipse.jgit.pgm/BUILD +++ b/org.eclipse.jgit.pgm/BUILD @@ -25,6 +25,12 @@ java_library( ], ) +java_binary( + name = "jgit", + runtime_deps = [":pgm"], + main_class = "org.eclipse.jgit.pgm.Main", +) + java_import( name = "services", jars = [":services_jar"], diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF index c23cd5bd07..bf5ef804bf 100644 --- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.pgm Bundle-SymbolicName: org.eclipse.jgit.pgm -Bundle-Version: 4.11.2.qualifier +Bundle-Version: 5.0.3.qualifier Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy Bundle-Localization: plugin @@ -28,49 +28,49 @@ Import-Package: javax.servlet;version="[3.1.0,4.0.0)", org.eclipse.jetty.util.log;version="[9.4.5,10.0.0)", org.eclipse.jetty.util.security;version="[9.4.5,10.0.0)", org.eclipse.jetty.util.thread;version="[9.4.5,10.0.0)", - org.eclipse.jgit.api;version="[4.11.2,4.12.0)", - org.eclipse.jgit.api.errors;version="[4.11.2,4.12.0)", - org.eclipse.jgit.archive;version="[4.11.2,4.12.0)", - org.eclipse.jgit.awtui;version="[4.11.2,4.12.0)", - org.eclipse.jgit.blame;version="[4.11.2,4.12.0)", - org.eclipse.jgit.diff;version="[4.11.2,4.12.0)", - org.eclipse.jgit.dircache;version="[4.11.2,4.12.0)", - org.eclipse.jgit.errors;version="[4.11.2,4.12.0)", - org.eclipse.jgit.gitrepo;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.ketch;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.storage.dfs;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.storage.file;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.storage.io;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.storage.pack;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.storage.reftable;version="[4.11.2,4.12.0)", - org.eclipse.jgit.internal.storage.reftree;version="[4.11.2,4.12.0)", - org.eclipse.jgit.lfs;version="[4.11.2,4.12.0)", - org.eclipse.jgit.lfs.lib;version="[4.11.2,4.12.0)", - org.eclipse.jgit.lfs.server;version="[4.11.2,4.12.0)", - org.eclipse.jgit.lfs.server.fs;version="[4.11.2,4.12.0)", - org.eclipse.jgit.lfs.server.s3;version="[4.11.2,4.12.0)", - org.eclipse.jgit.lib;version="[4.11.2,4.12.0)", - org.eclipse.jgit.merge;version="[4.11.2,4.12.0)", - org.eclipse.jgit.nls;version="[4.11.2,4.12.0)", - org.eclipse.jgit.notes;version="[4.11.2,4.12.0)", - org.eclipse.jgit.revplot;version="[4.11.2,4.12.0)", - org.eclipse.jgit.revwalk;version="[4.11.2,4.12.0)", - org.eclipse.jgit.revwalk.filter;version="[4.11.2,4.12.0)", - org.eclipse.jgit.storage.file;version="[4.11.2,4.12.0)", - org.eclipse.jgit.storage.pack;version="[4.11.2,4.12.0)", - org.eclipse.jgit.transport;version="[4.11.2,4.12.0)", - org.eclipse.jgit.transport.http.apache;version="[4.11.2,4.12.0)", - org.eclipse.jgit.transport.resolver;version="[4.11.2,4.12.0)", - org.eclipse.jgit.treewalk;version="[4.11.2,4.12.0)", - org.eclipse.jgit.treewalk.filter;version="[4.11.2,4.12.0)", - org.eclipse.jgit.util;version="[4.11.2,4.12.0)", - org.eclipse.jgit.util.io;version="[4.11.2,4.12.0)", + org.eclipse.jgit.api;version="[5.0.3,5.1.0)", + org.eclipse.jgit.api.errors;version="[5.0.3,5.1.0)", + org.eclipse.jgit.archive;version="[5.0.3,5.1.0)", + org.eclipse.jgit.awtui;version="[5.0.3,5.1.0)", + org.eclipse.jgit.blame;version="[5.0.3,5.1.0)", + org.eclipse.jgit.diff;version="[5.0.3,5.1.0)", + org.eclipse.jgit.dircache;version="[5.0.3,5.1.0)", + org.eclipse.jgit.errors;version="[5.0.3,5.1.0)", + org.eclipse.jgit.gitrepo;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.ketch;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.storage.dfs;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.storage.file;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.storage.io;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.storage.pack;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.storage.reftable;version="[5.0.3,5.1.0)", + org.eclipse.jgit.internal.storage.reftree;version="[5.0.3,5.1.0)", + org.eclipse.jgit.lfs;version="[5.0.3,5.1.0)", + org.eclipse.jgit.lfs.lib;version="[5.0.3,5.1.0)", + org.eclipse.jgit.lfs.server;version="[5.0.3,5.1.0)", + org.eclipse.jgit.lfs.server.fs;version="[5.0.3,5.1.0)", + org.eclipse.jgit.lfs.server.s3;version="[5.0.3,5.1.0)", + org.eclipse.jgit.lib;version="[5.0.3,5.1.0)", + org.eclipse.jgit.merge;version="[5.0.3,5.1.0)", + org.eclipse.jgit.nls;version="[5.0.3,5.1.0)", + org.eclipse.jgit.notes;version="[5.0.3,5.1.0)", + org.eclipse.jgit.revplot;version="[5.0.3,5.1.0)", + org.eclipse.jgit.revwalk;version="[5.0.3,5.1.0)", + org.eclipse.jgit.revwalk.filter;version="[5.0.3,5.1.0)", + org.eclipse.jgit.storage.file;version="[5.0.3,5.1.0)", + org.eclipse.jgit.storage.pack;version="[5.0.3,5.1.0)", + org.eclipse.jgit.transport;version="[5.0.3,5.1.0)", + org.eclipse.jgit.transport.http.apache;version="[5.0.3,5.1.0)", + org.eclipse.jgit.transport.resolver;version="[5.0.3,5.1.0)", + org.eclipse.jgit.treewalk;version="[5.0.3,5.1.0)", + org.eclipse.jgit.treewalk.filter;version="[5.0.3,5.1.0)", + org.eclipse.jgit.util;version="[5.0.3,5.1.0)", + org.eclipse.jgit.util.io;version="[5.0.3,5.1.0)", org.kohsuke.args4j;version="[2.33.0,3.0.0)", org.kohsuke.args4j.spi;version="[2.33.0,3.0.0)" -Export-Package: org.eclipse.jgit.console;version="4.11.2"; +Export-Package: org.eclipse.jgit.console;version="5.0.3"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.util", - org.eclipse.jgit.pgm;version="4.11.2"; + org.eclipse.jgit.pgm;version="5.0.3"; uses:="org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.pgm.opt, @@ -81,11 +81,11 @@ Export-Package: org.eclipse.jgit.console;version="4.11.2"; org.eclipse.jgit.treewalk, javax.swing, org.eclipse.jgit.transport", - org.eclipse.jgit.pgm.debug;version="4.11.2"; + org.eclipse.jgit.pgm.debug;version="5.0.3"; uses:="org.eclipse.jgit.util.io, org.eclipse.jgit.pgm", - org.eclipse.jgit.pgm.internal;version="4.11.2";x-friends:="org.eclipse.jgit.pgm.test,org.eclipse.jgit.test", - org.eclipse.jgit.pgm.opt;version="4.11.2"; + org.eclipse.jgit.pgm.internal;version="5.0.3";x-friends:="org.eclipse.jgit.pgm.test,org.eclipse.jgit.test", + org.eclipse.jgit.pgm.opt;version="5.0.3"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.kohsuke.args4j.spi, diff --git a/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF index 5e2a62d4b3..60a0688f62 100644 --- a/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF @@ -3,5 +3,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: org.eclipse.jgit.pgm - Sources Bundle-SymbolicName: org.eclipse.jgit.pgm.source Bundle-Vendor: Eclipse.org - JGit -Bundle-Version: 4.11.2.qualifier -Eclipse-SourceBundle: org.eclipse.jgit.pgm;version="4.11.2.qualifier";roots="." +Bundle-Version: 5.0.3.qualifier +Eclipse-SourceBundle: org.eclipse.jgit.pgm;version="5.0.3.qualifier";roots="." diff --git a/org.eclipse.jgit.pgm/pom.xml b/org.eclipse.jgit.pgm/pom.xml index 21fbf41bfd..01357766f1 100644 --- a/org.eclipse.jgit.pgm/pom.xml +++ b/org.eclipse.jgit.pgm/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>4.11.2-SNAPSHOT</version> + <version>5.0.3-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.pgm</artifactId> diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index cb0ea1bc48..e9370930d1 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -343,6 +343,7 @@ usage_forEachRefOutput=for-each-ref output usage_forceCheckout=when switching branches, proceed even if the index or the working tree differs from HEAD usage_forceClean=required to delete files or directories usage_forceCreateBranchEvenExists=force create branch even exists +usage_forcedFetch=force ref update fetch option usage_forceReplacingAnExistingTag=force replacing an existing tag usage_getAndSetOptions=Get and set repository or global options usage_groups=Restrict manifest projects to ones with specified group(s), use "-" for excluding [default|all|G1,G2,G3|G4,-G5,-G6] 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 f0754b192c..9223e0fcd1 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 @@ -74,10 +74,10 @@ abstract class AbstractFetchCommand extends TextBuiltin { * @throws java.io.IOException * if any. */ - protected void showFetchResult(final FetchResult r) throws IOException { + protected void showFetchResult(FetchResult r) throws IOException { try (ObjectReader reader = db.newObjectReader()) { boolean shownURI = false; - for (final TrackingRefUpdate u : r.getTrackingRefUpdates()) { + for (TrackingRefUpdate u : r.getTrackingRefUpdates()) { if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE) continue; @@ -181,7 +181,7 @@ abstract class AbstractFetchCommand extends TextBuiltin { } } - private static char shortTypeOf(final RefUpdate.Result r) { + private static char shortTypeOf(RefUpdate.Result r) { if (r == RefUpdate.Result.LOCK_FAILURE) return '!'; if (r == RefUpdate.Result.IO_FAILURE) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java index cce889b76e..f4f8d8f50f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java @@ -105,7 +105,7 @@ class AmazonS3Client extends TextBuiltin { } } else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$ - for (final String k : s3.list(bucket, key)) + for (String k : s3.list(bucket, key)) outw.println(k); } else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java index e6685c2f65..a88354deba 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java @@ -292,7 +292,7 @@ class Branch extends TextBuiltin { addRefs(refs, Constants.R_REMOTES); try (ObjectReader reader = db.newObjectReader()) { - for (final Entry<String, Ref> e : printRefs.entrySet()) { + for (Entry<String, Ref> e : printRefs.entrySet()) { final Ref ref = e.getValue(); printHead(reader, e.getKey(), current.equals(ref.getName()), ref); @@ -302,15 +302,15 @@ class Branch extends TextBuiltin { } } - private void addRefs(final Collection<Ref> refs, final String prefix) { - for (final Ref ref : RefComparator.sort(refs)) { + private void addRefs(Collection<Ref> refs, String prefix) { + for (Ref ref : RefComparator.sort(refs)) { final String name = ref.getName(); if (name.startsWith(prefix)) addRef(name.substring(name.indexOf('/', 5) + 1), ref); } } - private void addRef(final String name, final Ref ref) { + private void addRef(String name, Ref ref) { printRefs.put(name, ref); maxNameLength = Math.max(maxNameLength, name.length()); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java index 81aeef8cdd..5754d7c44f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java @@ -43,11 +43,10 @@ package org.eclipse.jgit.pgm; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; @@ -88,7 +87,7 @@ public class CommandCatalog { * was derived from the DashLowerCaseForm class name. * @return the command instance; null if no command exists by that name. */ - public static CommandRef get(final String name) { + public static CommandRef get(String name) { return INSTANCE.commands.get(name); } @@ -108,17 +107,17 @@ public class CommandCatalog { */ public static CommandRef[] common() { final ArrayList<CommandRef> common = new ArrayList<>(); - for (final CommandRef c : INSTANCE.commands.values()) + for (CommandRef c : INSTANCE.commands.values()) if (c.isCommon()) common.add(c); return toSortedArray(common); } - private static CommandRef[] toSortedArray(final Collection<CommandRef> c) { + private static CommandRef[] toSortedArray(Collection<CommandRef> c) { final CommandRef[] r = c.toArray(new CommandRef[c.size()]); Arrays.sort(r, new Comparator<CommandRef>() { @Override - public int compare(final CommandRef o1, final CommandRef o2) { + public int compare(CommandRef o1, CommandRef o2) { return o1.getName().compareTo(o2.getName()); } }); @@ -147,36 +146,20 @@ public class CommandCatalog { } } - private void scan(final URL cUrl) { - final BufferedReader cIn; - try { - final InputStream in = cUrl.openStream(); - cIn = new BufferedReader(new InputStreamReader(in, UTF_8)); - } catch (IOException err) { - // If we cannot read from the service list, go to the next. - // - return; - } - - try { + private void scan(URL cUrl) { + try (BufferedReader cIn = new BufferedReader( + new InputStreamReader(cUrl.openStream(), CHARSET))) { String line; while ((line = cIn.readLine()) != null) { if (line.length() > 0 && !line.startsWith("#")) //$NON-NLS-1$ load(line); } - } catch (IOException err) { - // If we failed during a read, ignore the error. - // - } finally { - try { - cIn.close(); - } catch (IOException e) { - // Ignore the close error; we are only reading. - } + } catch (IOException e) { + // Ignore errors } } - private void load(final String cn) { + private void load(String cn) { final Class<? extends TextBuiltin> clazz; try { clazz = Class.forName(cn, false, ldr).asSubclass(TextBuiltin.class); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java index 2c9bc0dc75..1773de5d78 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java @@ -66,29 +66,29 @@ public class CommandRef { boolean common; - CommandRef(final Class<? extends TextBuiltin> clazz) { + CommandRef(Class<? extends TextBuiltin> clazz) { this(clazz, guessName(clazz)); } - CommandRef(final Class<? extends TextBuiltin> clazz, final Command cmd) { + CommandRef(Class<? extends TextBuiltin> clazz, Command cmd) { this(clazz, cmd.name().length() > 0 ? cmd.name() : guessName(clazz)); usage = cmd.usage(); common = cmd.common(); } - private CommandRef(final Class<? extends TextBuiltin> clazz, final String cn) { + private CommandRef(Class<? extends TextBuiltin> clazz, String cn) { impl = clazz; name = cn; usage = ""; //$NON-NLS-1$ } - private static String guessName(final Class<? extends TextBuiltin> clazz) { + private static String guessName(Class<? extends TextBuiltin> clazz) { final StringBuilder s = new StringBuilder(); if (clazz.getName().startsWith("org.eclipse.jgit.pgm.debug.")) //$NON-NLS-1$ s.append("debug-"); //$NON-NLS-1$ boolean lastWasDash = true; - for (final char c : clazz.getSimpleName().toCharArray()) { + for (char c : clazz.getSimpleName().toCharArray()) { if (Character.isUpperCase(c)) { if (!lastWasDash) s.append('-'); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java index d0ada67fc4..319b5e39dc 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java @@ -142,7 +142,7 @@ class Daemon extends TextBuiltin { packConfig.setExecutor(Executors.newFixedThreadPool(threads)); final FileResolver<DaemonClient> resolver = new FileResolver<>(); - for (final File f : directory) { + for (File f : directory) { outw.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath())); resolver.exportDirectory(f); } @@ -157,14 +157,14 @@ class Daemon extends TextBuiltin { if (0 <= timeout) d.setTimeout(timeout); - for (final String n : enable) + for (String n : enable) service(d, n).setEnabled(true); - for (final String n : disable) + for (String n : disable) service(d, n).setEnabled(false); - for (final String n : canOverride) + for (String n : canOverride) service(d, n).setOverridable(true); - for (final String n : forbidOverride) + for (String n : forbidOverride) service(d, n).setOverridable(false); if (ketchServerType == KetchServerType.LEADER) { startKetchLeader(d); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Die.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Die.java index 59de80c963..4ec5f04bb6 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Die.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Die.java @@ -63,7 +63,7 @@ public class Die extends RuntimeException { * @param why * the message to show to the end-user. */ - public Die(final String why) { + public Die(String why) { super(why); } @@ -75,7 +75,7 @@ public class Die extends RuntimeException { * @param cause * why the command has failed. */ - public Die(final String why, final Throwable cause) { + public Die(String why, Throwable cause) { super(why, cause); } @@ -100,7 +100,7 @@ public class Die extends RuntimeException { * can be null * @since 4.2 */ - public Die(boolean aborted, final Throwable cause) { + public Die(boolean aborted, Throwable cause) { super(cause != null ? cause.getMessage() : null, cause); this.aborted = aborted; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index ed6f7b426b..97e3df38d6 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -170,7 +170,7 @@ class Diff extends TextBuiltin { /** {@inheritDoc} */ @Override - protected void init(final Repository repository, final String gitDir) { + protected void init(Repository repository, String gitDir) { super.init(repository, gitDir); diffFmt = new DiffFormatter(new BufferedOutputStream(outs)); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java index 510406345f..42aabc2f49 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java @@ -75,9 +75,9 @@ class DiffTree extends TextBuiltin { /** {@inheritDoc} */ @Override protected void run() throws Exception { - try (final TreeWalk walk = new TreeWalk(db)) { + try (TreeWalk walk = new TreeWalk(db)) { walk.setRecursive(recursive); - for (final AbstractTreeIterator i : trees) + for (AbstractTreeIterator i : trees) walk.addTree(i); walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java index bc76372862..61fd521b80 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java @@ -100,6 +100,9 @@ class Fetch extends AbstractFetchCommand implements FetchCommand.Callback { tags = Boolean.FALSE; } + @Option(name = "--force", usage = "usage_forcedFetch", aliases = { "-f" }) + private Boolean force; + private FetchRecurseSubmodulesMode recurseSubmodules; @Option(name = "--recurse-submodules", usage = "usage_recurseSubmodules") @@ -155,6 +158,9 @@ class Fetch extends AbstractFetchCommand implements FetchCommand.Callback { if (quiet == null || !quiet.booleanValue()) fetch.setProgressMonitor(new TextProgressMonitor(errw)); fetch.setRecurseSubmodules(recurseSubmodules).setCallback(this); + if (force != null) { + fetch.setForceUpdate(force.booleanValue()); + } FetchResult result = fetch.call(); if (result.getTrackingRefUpdates().isEmpty() diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java index a081b7813f..2b5af5d7b7 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java @@ -75,7 +75,7 @@ class Glog extends RevWalkTextBuiltin { frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { @Override - public void windowClosing(final WindowEvent e) { + public void windowClosing(WindowEvent e) { frame.dispose(); } }); @@ -116,7 +116,7 @@ class Glog extends RevWalkTextBuiltin { /** {@inheritDoc} */ @Override - protected void show(final RevCommit c) throws Exception { + protected void show(RevCommit c) throws Exception { throw new UnsupportedOperationException(); } 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 75542d4454..ad92a78f69 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 @@ -186,7 +186,7 @@ class Log extends RevWalkTextBuiltin { /** {@inheritDoc} */ @Override - protected void init(final Repository repository, final String gitDir) { + protected void init(Repository repository, String gitDir) { super.init(repository, gitDir); diffFmt = new DiffFormatter(new BufferedOutputStream(outs)); } @@ -241,7 +241,7 @@ class Log extends RevWalkTextBuiltin { /** {@inheritDoc} */ @Override - protected void show(final RevCommit c) throws Exception { + protected void show(RevCommit c) throws Exception { outw.print(CLIText.get().commitLabel); outw.print(" "); //$NON-NLS-1$ c.getId().copyTo(outbuffer, outw); @@ -266,7 +266,7 @@ class Log extends RevWalkTextBuiltin { outw.println(); final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$ - for (final String s : lines) { + for (String s : lines) { outw.print(" "); //$NON-NLS-1$ outw.print(s); outw.println(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java index 9013ff6cfe..2711c15729 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java @@ -83,7 +83,7 @@ class LsRemote extends TextBuiltin { } }); refs.addAll(command.call()); - for (final Ref r : refs) { + for (Ref r : refs) { show(r.getObjectId(), r.getName()); if (r.getPeeledObjectId() != null) show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$ @@ -96,7 +96,7 @@ class LsRemote extends TextBuiltin { return false; } - private void show(final AnyObjectId id, final String name) + private void show(AnyObjectId id, String name) throws IOException { outw.print(id.name()); outw.print('\t'); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java index c57f9f2c37..01fa7eeb81 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java @@ -73,7 +73,7 @@ class LsTree extends TextBuiltin { /** {@inheritDoc} */ @Override protected void run() throws Exception { - try (final TreeWalk walk = new TreeWalk(db)) { + try (TreeWalk walk = new TreeWalk(db)) { walk.reset(); // drop the first empty tree, which we do not need here if (paths.size() > 0) walk.setFilter(PathFilterGroup.createFromStrings(paths)); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java index a376bc098d..ac53de9767 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.pgm; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import java.io.File; import java.io.IOException; @@ -71,6 +71,7 @@ import org.eclipse.jgit.lib.RepositoryBuilder; import org.eclipse.jgit.pgm.internal.CLIText; import org.eclipse.jgit.pgm.opt.CmdLineParser; import org.eclipse.jgit.pgm.opt.SubcommandHandler; +import org.eclipse.jgit.storage.file.WindowCacheConfig; import org.eclipse.jgit.transport.HttpTransport; import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory; import org.eclipse.jgit.util.CachedAuthenticator; @@ -105,10 +106,19 @@ public class Main { private ExecutorService gcExecutor; + private static final int MB = 1024 * 1024; + /** * <p>Constructor for Main.</p> */ public Main() { + final WindowCacheConfig c = new WindowCacheConfig(); + c.setPackedGitMMAP(true); + c.setPackedGitWindowSize(8 * 1024); + c.setPackedGitLimit(10 * MB); + c.setDeltaBaseCacheLimit(10 * MB); + c.setStreamFileThreshold(50 * MB); + c.install(); HttpTransport.setConnectionFactory(new HttpClientConnectionFactory()); BuiltinLFS.register(); gcExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() { @@ -131,7 +141,7 @@ public class Main { * arguments. * @throws java.lang.Exception */ - public static void main(final String[] argv) throws Exception { + public static void main(String[] argv) throws Exception { // make sure built-in filters are registered BuiltinLFS.register(); @@ -155,7 +165,7 @@ public class Main { * arguments. * @throws java.lang.Exception */ - protected void run(final String[] argv) throws Exception { + protected void run(String[] argv) throws Exception { writer = createErrorWriter(); try { if (!installConsole()) { @@ -217,10 +227,10 @@ public class Main { } PrintWriter createErrorWriter() { - return new PrintWriter(new OutputStreamWriter(System.err, UTF_8)); + return new PrintWriter(new OutputStreamWriter(System.err, CHARSET)); } - private void execute(final String[] argv) throws Exception { + private void execute(String[] argv) throws Exception { final CmdLineParser clp = new SubcommandLineParser(this); try { @@ -246,12 +256,12 @@ public class Main { writer.println(CLIText.get().mostCommonlyUsedCommandsAre); final CommandRef[] common = CommandCatalog.common(); int width = 0; - for (final CommandRef c : common) { + for (CommandRef c : common) { width = Math.max(width, c.getName().length()); } width += 2; - for (final CommandRef c : common) { + for (CommandRef c : common) { writer.print(' '); writer.print(c.getName()); for (int i = c.getName().length(); i < width; i++) { @@ -286,7 +296,7 @@ public class Main { } } - void init(final TextBuiltin cmd) throws IOException { + void init(TextBuiltin cmd) throws IOException { if (cmd.requiresRepository()) { cmd.init(openGitDir(gitdir), null); } else { @@ -350,7 +360,7 @@ public class Main { } } - private static void install(final String name) + private static void install(String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { try { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java index 62a88aeed6..6842d8ddbf 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java @@ -68,7 +68,7 @@ class MergeBase extends TextBuiltin { /** {@inheritDoc} */ @Override protected void run() throws Exception { - for (final RevCommit c : commits) + for (RevCommit c : commits) argWalk.markStart(c); argWalk.setRevFilter(RevFilter.MERGE_BASE); int max = all ? Integer.MAX_VALUE : 1; 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 309dca2a7f..be8ad374d3 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 @@ -149,7 +149,7 @@ class Push extends TextBuiltin { boolean everythingUpToDate = true; // at first, print up-to-date ones... - for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { + for (RemoteRefUpdate rru : result.getRemoteUpdates()) { if (rru.getStatus() == Status.UP_TO_DATE) { if (verbose) printRefUpdateResult(reader, uri, result, rru); @@ -157,13 +157,13 @@ class Push extends TextBuiltin { everythingUpToDate = false; } - for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { + for (RemoteRefUpdate rru : result.getRemoteUpdates()) { // ...then successful updates... if (rru.getStatus() == Status.OK) printRefUpdateResult(reader, uri, result, rru); } - for (final RemoteRefUpdate rru : result.getRemoteUpdates()) { + for (RemoteRefUpdate rru : result.getRemoteUpdates()) { // ...finally, others (problematic) if (rru.getStatus() != Status.OK && rru.getStatus() != Status.UP_TO_DATE) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java index 948cbc554c..3308e18f24 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java @@ -146,7 +146,7 @@ class Remote extends TextBuiltin { /** {@inheritDoc} */ @Override - public void printUsage(final String message, final CmdLineParser clp) + public void printUsage(String message, CmdLineParser clp) throws IOException { errw.println(message); errw.println("jgit remote [--verbose (-v)] [--help (-h)]"); //$NON-NLS-1$ diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevList.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevList.java index 8c88a5cdc7..101fbb27d6 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevList.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevList.java @@ -53,7 +53,7 @@ import org.eclipse.jgit.revwalk.RevTree; class RevList extends RevWalkTextBuiltin { /** {@inheritDoc} */ @Override - protected void show(final RevCommit c) throws Exception { + protected void show(RevCommit c) throws Exception { if (c.has(RevFlag.UNINTERESTING)) outw.print('-'); c.getId().copyTo(outbuffer, outw); @@ -67,7 +67,7 @@ class RevList extends RevWalkTextBuiltin { /** {@inheritDoc} */ @Override - protected void show(final ObjectWalk ow, final RevObject obj) + protected void show(ObjectWalk ow, RevObject obj) throws Exception { if (obj.has(RevFlag.UNINTERESTING)) outw.print('-'); 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 21adf738e0..ac08cd6ac3 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 @@ -45,11 +45,8 @@ package org.eclipse.jgit.pgm; -import static org.eclipse.jgit.lib.RefDatabase.ALL; - import java.util.ArrayList; import java.util.List; -import java.util.Map; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; @@ -74,8 +71,7 @@ class RevParse extends TextBuiltin { @Override protected void run() throws Exception { if (all) { - Map<String, Ref> allRefs = db.getRefDatabase().getRefs(ALL); - for (final Ref r : allRefs.values()) { + for (Ref r : db.getRefDatabase().getRefs()) { ObjectId objectId = r.getObjectId(); // getRefs skips dangling symrefs, so objectId should never be // null. @@ -91,7 +87,7 @@ class RevParse extends TextBuiltin { CLIText.format(CLIText.get().needSingleRevision)); } - for (final ObjectId o : commits) { + for (ObjectId o : commits) { outw.println(o.name()); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java index 3fc91013ac..15abeac96e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java @@ -47,14 +47,12 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import java.util.Map; import org.eclipse.jgit.diff.DiffConfig; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.RefDatabase; import org.eclipse.jgit.pgm.internal.CLIText; import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler; import org.eclipse.jgit.revwalk.FollowFilter; @@ -93,7 +91,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { private final EnumSet<RevSort> sorting = EnumSet.noneOf(RevSort.class); - private void enableRevSort(final RevSort type, final boolean on) { + private void enableRevSort(RevSort type, boolean on) { if (on) sorting.add(type); else @@ -101,22 +99,22 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { } @Option(name = "--date-order") - void enableDateOrder(final boolean on) { + void enableDateOrder(boolean on) { enableRevSort(RevSort.COMMIT_TIME_DESC, on); } @Option(name = "--topo-order") - void enableTopoOrder(final boolean on) { + void enableTopoOrder(boolean on) { enableRevSort(RevSort.TOPO, on); } @Option(name = "--reverse") - void enableReverse(final boolean on) { + void enableReverse(boolean on) { enableRevSort(RevSort.REVERSE, on); } @Option(name = "--boundary") - void enableBoundary(final boolean on) { + void enableBoundary(boolean on) { enableRevSort(RevSort.BOUNDARY, on); } @@ -132,17 +130,17 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { private final List<RevFilter> revLimiter = new ArrayList<>(); @Option(name = "--author") - void addAuthorRevFilter(final String who) { + void addAuthorRevFilter(String who) { revLimiter.add(AuthorRevFilter.create(who)); } @Option(name = "--committer") - void addCommitterRevFilter(final String who) { + void addCommitterRevFilter(String who) { revLimiter.add(CommitterRevFilter.create(who)); } @Option(name = "--grep") - void addCMessageRevFilter(final String msg) { + void addCMessageRevFilter(String msg) { revLimiter.add(MessageRevFilter.create(msg)); } @@ -153,7 +151,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { @Override protected void run() throws Exception { walk = createWalk(); - for (final RevSort s : sorting) + for (RevSort s : sorting) walk.sort(s, true); if (pathFilter == TreeFilter.ALL) { @@ -171,9 +169,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { walk.setRevFilter(AndRevFilter.create(revLimiter)); if (all) { - Map<String, Ref> refs = - db.getRefDatabase().getRefs(RefDatabase.ALL); - for (Ref a : refs.values()) { + for (Ref a : db.getRefDatabase().getRefs()) { ObjectId oid = a.getPeeledObjectId(); if (oid == null) oid = a.getObjectId(); @@ -191,7 +187,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD)); commits.add(walk.parseCommit(head)); } - for (final RevCommit c : commits) { + for (RevCommit c : commits) { final RevCommit real = argWalk == walk ? c : walk.parseCommit(c); if (c.has(RevFlag.UNINTERESTING)) walk.markUninteresting(real); @@ -237,7 +233,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { */ protected int walkLoop() throws Exception { int n = 0; - for (final RevCommit c : walk) { + for (RevCommit c : walk) { if (++n > maxCount && maxCount >= 0) break; show(c); @@ -264,7 +260,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin { * The current {@link org.eclipse.jgit.revwalk.RevCommit} * @throws java.lang.Exception */ - protected abstract void show(final RevCommit c) throws Exception; + protected abstract void show(RevCommit c) throws Exception; /** * "Show" the current RevCommit when called from the main processing loop. diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java index de04045e42..89a15fe4d8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java @@ -167,7 +167,7 @@ class Show extends TextBuiltin { /** {@inheritDoc} */ @Override - protected void init(final Repository repository, final String gitDir) { + protected void init(Repository repository, String gitDir) { super.init(repository, gitDir); diffFmt = new DiffFormatter(new BufferedOutputStream(outs)); } @@ -248,7 +248,7 @@ class Show extends TextBuiltin { outw.println(); final String[] lines = tag.getFullMessage().split("\n"); //$NON-NLS-1$ - for (final String s : lines) { + for (String s : lines) { outw.print(" "); //$NON-NLS-1$ outw.print(s); outw.println(); @@ -259,7 +259,7 @@ class Show extends TextBuiltin { private void show(RevTree obj) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { - try (final TreeWalk walk = new TreeWalk(db)) { + try (TreeWalk walk = new TreeWalk(db)) { walk.reset(); walk.addTree(obj); @@ -273,7 +273,7 @@ class Show extends TextBuiltin { } } - private void show(RevWalk rw, final RevCommit c) throws Exception { + private void show(RevWalk rw, RevCommit c) throws Exception { char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2]; outw.print(CLIText.get().commitLabel); @@ -292,7 +292,7 @@ class Show extends TextBuiltin { outw.println(); final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$ - for (final String s : lines) { + for (String s : lines) { outw.print(" "); //$NON-NLS-1$ outw.print(s); outw.println(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java index 7b59d437ac..6318a633ca 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java @@ -45,23 +45,19 @@ package org.eclipse.jgit.pgm; -import static org.eclipse.jgit.lib.RefDatabase.ALL; - import java.io.IOException; -import java.util.Map; -import java.util.SortedMap; +import java.util.List; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefComparator; -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()) { + for (Ref r : getSortedRefs()) { show(r.getObjectId(), r.getName()); if (r.getPeeledObjectId() != null) show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$ @@ -69,14 +65,13 @@ class ShowRef extends TextBuiltin { } private Iterable<Ref> getSortedRefs() throws Exception { - Map<String, Ref> all = db.getRefDatabase().getRefs(ALL); - if (all instanceof RefMap - || (all instanceof SortedMap && ((SortedMap) all).comparator() == null)) - return all.values(); - return RefComparator.sort(all.values()); + List<Ref> all = db.getRefDatabase().getRefs(); + // TODO(jrn) check if we can reintroduce fast-path by e.g. implementing + // SortedList + return RefComparator.sort(all); } - private void show(final AnyObjectId id, final String name) + private void show(AnyObjectId id, String name) throws IOException { outw.print(id.name()); outw.print('\t'); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java index bc3755d349..7e5b5451b6 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java @@ -129,7 +129,7 @@ public abstract class TextBuiltin { /** RevWalk used during command line parsing, if it was required. */ protected RevWalk argWalk; - final void setCommandName(final String name) { + final void setCommandName(String name) { commandName = name; } @@ -176,7 +176,7 @@ public abstract class TextBuiltin { * value of the {@code --git-dir} command line option, if * {@code repository} is null. */ - protected void init(final Repository repository, final String gitDir) { + protected void init(Repository repository, String gitDir) { try { final String outputEncoding = repository != null ? repository .getConfig().getString("i18n", null, "logOutputEncoding") : null; //$NON-NLS-1$ //$NON-NLS-2$ @@ -239,7 +239,7 @@ public abstract class TextBuiltin { * the arguments supplied on the command line, if any. * @throws java.io.IOException */ - protected void parseArguments(final String[] args) throws IOException { + protected void parseArguments(String[] args) throws IOException { final CmdLineParser clp = new CmdLineParser(this); help = containsHelp(args); try { @@ -267,7 +267,7 @@ public abstract class TextBuiltin { * a {@link org.eclipse.jgit.pgm.opt.CmdLineParser} object. * @throws java.io.IOException */ - public void printUsageAndExit(final CmdLineParser clp) throws IOException { + public void printUsageAndExit(CmdLineParser clp) throws IOException { printUsageAndExit("", clp); //$NON-NLS-1$ } @@ -280,7 +280,7 @@ public abstract class TextBuiltin { * a {@link org.eclipse.jgit.pgm.opt.CmdLineParser} object. * @throws java.io.IOException */ - public void printUsageAndExit(final String message, final CmdLineParser clp) throws IOException { + public void printUsageAndExit(String message, CmdLineParser clp) throws IOException { printUsage(message, clp); throw die(true); } @@ -295,7 +295,7 @@ public abstract class TextBuiltin { * @throws java.io.IOException * @since 4.2 */ - protected void printUsage(final String message, final CmdLineParser clp) + protected void printUsage(String message, CmdLineParser clp) throws IOException { errw.println(message); errw.print("jgit "); //$NON-NLS-1$ @@ -361,7 +361,7 @@ public abstract class TextBuiltin { return db; } - ObjectId resolve(final String s) throws IOException { + ObjectId resolve(String s) throws IOException { final ObjectId r = db.resolve(s); if (r == null) throw die(MessageFormat.format(CLIText.get().notARevision, s)); @@ -375,7 +375,7 @@ public abstract class TextBuiltin { * textual explanation * @return a runtime exception the caller is expected to throw */ - protected static Die die(final String why) { + protected static Die die(String why) { return new Die(why); } @@ -388,7 +388,7 @@ public abstract class TextBuiltin { * why the command has failed. * @return a runtime exception the caller is expected to throw */ - protected static Die die(final String why, final Throwable cause) { + protected static Die die(String why, Throwable cause) { return new Die(why, cause); } @@ -416,7 +416,7 @@ public abstract class TextBuiltin { * @return a runtime exception the caller is expected to throw * @since 4.2 */ - protected static Die die(boolean aborted, final Throwable cause) { + protected static Die die(boolean aborted, Throwable cause) { return new Die(aborted, cause); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java index 5efc03b287..58acc5cafd 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java @@ -96,14 +96,9 @@ class Version extends TextBuiltin { } private static String getBundleVersion(URL url) { - try { - InputStream is = url.openStream(); - try { - Manifest manifest = new Manifest(is); - return manifest.getMainAttributes().getValue("Bundle-Version"); //$NON-NLS-1$ - } finally { - is.close(); - } + try (InputStream is = url.openStream()) { + Manifest manifest = new Manifest(is); + return manifest.getMainAttributes().getValue("Bundle-Version"); //$NON-NLS-1$ } catch (IOException e) { // do nothing - will return null } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java index 248eaac8ad..575a122158 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.pgm.debug; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.lib.Constants.HEAD; import static org.eclipse.jgit.lib.Constants.MASTER; import static org.eclipse.jgit.lib.Constants.R_HEADS; @@ -154,7 +154,7 @@ class BenchmarkReftable extends TextBuiltin { throws IOException, FileNotFoundException { RefList.Builder<Ref> list = new RefList.Builder<>(); try (BufferedReader br = new BufferedReader(new InputStreamReader( - new FileInputStream(lsRemotePath), UTF_8))) { + new FileInputStream(lsRemotePath), CHARSET))) { Ref last = null; String line; while ((line = br.readLine()) != null) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java index 127e541741..2a1326d4b8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/MakeCacheTree.java @@ -65,7 +65,7 @@ class MakeCacheTree extends TextBuiltin { show(tree); } - private void show(final DirCacheTree tree) throws IOException { + private void show(DirCacheTree tree) throws IOException { outw.println(MessageFormat.format(CLIText.get().cacheTreePathInfo, tree.getPathString(), valueOf(tree.getEntrySpan()), valueOf(tree.getChildCount()))); 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 2e41eec7cb..2d16fefa71 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 @@ -43,8 +43,6 @@ package org.eclipse.jgit.pgm.debug; -import static org.eclipse.jgit.lib.RefDatabase.ALL; - import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -117,7 +115,7 @@ class RebuildCommitGraph extends TextBuiltin { /** {@inheritDoc} */ @Override protected void run() throws Exception { - if (!really && !db.getRefDatabase().getRefs(ALL).isEmpty()) { + if (!really && db.getRefDatabase().hasRefs()) { File directory = db.getDirectory(); String absolutePath = directory == null ? "null" //$NON-NLS-1$ : directory.getAbsolutePath(); @@ -224,7 +222,7 @@ class RebuildCommitGraph extends TextBuiltin { ObjectId newId; - ToRewrite(final ObjectId o, final long t, final ObjectId[] p) { + ToRewrite(ObjectId o, long t, ObjectId[] p) { oldId = o; commitTime = t; oldParents = p; @@ -247,8 +245,7 @@ class RebuildCommitGraph extends TextBuiltin { private void deleteAllRefs() throws Exception { final RevWalk rw = new RevWalk(db); - Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL); - for (final Ref r : refs.values()) { + for (Ref r : db.getRefDatabase().getRefs()) { if (Constants.HEAD.equals(r.getName())) continue; final RefUpdate u = db.updateRef(r.getName()); @@ -261,7 +258,7 @@ class RebuildCommitGraph extends TextBuiltin { final Map<String, Ref> refs = computeNewRefs(); new RefWriter(refs.values()) { @Override - protected void writeFile(final String name, final byte[] content) + protected void writeFile(String name, byte[] content) throws IOException { final File file = new File(db.getDirectory(), name); final LockFile lck = new LockFile(file); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java index 3172483953..063600f4ea 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java @@ -154,14 +154,14 @@ class RebuildRefTree extends TextBuiltin { head)); } - for (Ref r : refdb.getRefs(RefDatabase.ALL).values()) { + for (Ref r : refdb.getRefs()) { if (r.getName().equals(txnCommitted) || r.getName().equals(HEAD) || r.getName().startsWith(txnNamespace)) { continue; } cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command( null, - db.peel(r))); + db.getRefDatabase().peel(r))); } tree.apply(cmds); return tree; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java index 20fa4a3fe5..6b97e08e44 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCacheTree.java @@ -67,7 +67,7 @@ class ShowCacheTree extends TextBuiltin { show(tree); } - private void show(final DirCacheTree tree) throws IOException { + private void show(DirCacheTree tree) throws IOException { outw.println(MessageFormat.format(CLIText.get().cacheTreePathInfo, tree.getPathString(), valueOf(tree.getEntrySpan()), valueOf(tree.getChildCount()))); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java index a960ec6dd3..af56d65c0f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java @@ -65,11 +65,11 @@ class ShowCommands extends TextBuiltin { final CommandRef[] list = CommandCatalog.all(); int width = 0; - for (final CommandRef c : list) + for (CommandRef c : list) width = Math.max(width, c.getName().length()); width += 2; - for (final CommandRef c : list) { + for (CommandRef c : list) { errw.print(c.isCommon() ? '*' : ' '); errw.print(' '); @@ -87,7 +87,7 @@ class ShowCommands extends TextBuiltin { /** */ USAGE { @Override - void print(ThrowingPrintWriter err, final CommandRef c) throws IOException { + void print(ThrowingPrintWriter err, CommandRef c) throws IOException { String usage = c.getUsage(); if (usage != null && usage.length() > 0) err.print(CLIText.get().resourceBundle().getString(usage)); @@ -97,7 +97,7 @@ class ShowCommands extends TextBuiltin { /** */ CLASSES { @Override - void print(ThrowingPrintWriter err, final CommandRef c) throws IOException { + void print(ThrowingPrintWriter err, CommandRef c) throws IOException { err.print(c.getImplementationClassName()); } }, @@ -105,7 +105,7 @@ class ShowCommands extends TextBuiltin { /** */ URLS { @Override - void print(ThrowingPrintWriter err, final CommandRef c) throws IOException { + void print(ThrowingPrintWriter err, CommandRef c) throws IOException { final ClassLoader ldr = c.getImplementationClassLoader(); String cn = c.getImplementationClassName(); 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 bbc1b0f330..f39ecbecf2 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 @@ -125,12 +125,13 @@ class ShowPackDelta extends TextBuiltin { ptr++; ptr++; - @SuppressWarnings("resource" /* java 7 */) - TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap(bufArray.length); - InflaterInputStream inf = new InflaterInputStream( - new ByteArrayInputStream(bufArray, ptr, bufArray.length)); - raw.copy(inf); - inf.close(); - return raw.toByteArray(); + try (TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap( + bufArray.length); + InflaterInputStream inf = new InflaterInputStream( + new ByteArrayInputStream(bufArray, ptr, + bufArray.length))) { + raw.copy(inf); + return raw.toByteArray(); + } } } 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 83b7bcea26..bb51b50487 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 @@ -288,11 +288,8 @@ class TextHashFunctions extends TextBuiltin { else rb.findGitDir(dir); - Repository repo = rb.build(); - try { + try (Repository repo = rb.build()) { run(repo); - } finally { - repo.close(); } } } @@ -502,7 +499,7 @@ class TextHashFunctions extends TextBuiltin { } } - private static int tableBits(final int sz) { + private static int tableBits(int sz) { int bits = 31 - Integer.numberOfLeadingZeros(sz); if (bits == 0) bits = 1; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java index 6cbc1b082b..c5ea028be8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/WriteReftable.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.pgm.debug; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.lib.Constants.HEAD; import static org.eclipse.jgit.lib.Constants.MASTER; import static org.eclipse.jgit.lib.Constants.R_HEADS; @@ -192,7 +192,7 @@ class WriteReftable extends TextBuiltin { static List<Ref> readRefs(String inputFile) throws IOException { List<Ref> refs = new ArrayList<>(); try (BufferedReader br = new BufferedReader( - new InputStreamReader(new FileInputStream(inputFile), UTF_8))) { + new InputStreamReader(new FileInputStream(inputFile), CHARSET))) { String line; while ((line = br.readLine()) != null) { ObjectId id = ObjectId.fromString(line.substring(0, 40)); @@ -227,7 +227,7 @@ class WriteReftable extends TextBuiltin { List<LogEntry> log = new ArrayList<>(); try (BufferedReader br = new BufferedReader( - new InputStreamReader(new FileInputStream(logPath), UTF_8))) { + new InputStreamReader(new FileInputStream(logPath), CHARSET))) { @SuppressWarnings("nls") Pattern pattern = Pattern.compile("([^,]+)" // 1: ref + ",([0-9]+(?:[.][0-9]+)?)" // 2: time 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 6fe7927166..a14f6514fe 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 @@ -98,7 +98,7 @@ public class AbstractTreeIteratorHandler extends /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { final String name = params.getParameter(0); if (new File(name).isDirectory()) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java index e071bdf839..5cc98ca8ac 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java @@ -111,7 +111,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { * if the option bean class is using args4j annotations * incorrectly. */ - public CmdLineParser(final Object bean) { + public CmdLineParser(Object bean) { this(bean, null); } @@ -130,7 +130,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { * if the option bean class is using args4j annotations * incorrectly. */ - public CmdLineParser(final Object bean, Repository repo) { + public CmdLineParser(Object bean, Repository repo) { super(bean); if (bean instanceof TextBuiltin) { cmd = (TextBuiltin) bean; @@ -143,7 +143,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { /** {@inheritDoc} */ @Override - public void parseArgument(final String... args) throws CmdLineException { + public void parseArgument(String... args) throws CmdLineException { final ArrayList<String> tmp = new ArrayList<>(args.length); for (int argi = 0; argi < args.length; argi++) { final String str = args[argi]; @@ -232,7 +232,7 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser { * @return true if the given array contains help option * @since 4.2 */ - protected boolean containsHelp(final String... args) { + protected boolean containsHelp(String... args) { return TextBuiltin.containsHelp(args); } 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 0e5b0f5b16..5f7e81ec78 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 @@ -84,7 +84,7 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> { /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { final String name = params.getParameter(0); final ObjectId id; try { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java index 33d669ca66..d99f88e35b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/PathTreeFilterHandler.java @@ -84,7 +84,7 @@ public class PathTreeFilterHandler extends OptionHandler<TreeFilter> { /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { final List<PathFilter> filters = new ArrayList<>(); for (int idx = 0;; idx++) { final String path; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java index dd8520af74..29577ed025 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RefSpecHandler.java @@ -78,7 +78,7 @@ public class RefSpecHandler extends OptionHandler<RefSpec> { /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { setter.addValue(new RefSpec(params.getParameter(0))); return 1; } 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 d2fa764326..b925e31f85 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 @@ -88,7 +88,7 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { String name = params.getParameter(0); boolean interesting = true; @@ -115,7 +115,7 @@ public class RevCommitHandler extends OptionHandler<RevCommit> { return 1; } - private void addOne(final String name, final boolean interesting) + private void addOne(String name, boolean interesting) throws CmdLineException { final ObjectId id; try { 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 9444363be0..85922a27ba 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 @@ -87,7 +87,7 @@ public class RevTreeHandler extends OptionHandler<RevTree> { /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { final String name = params.getParameter(0); final ObjectId id; try { 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 d60071f178..92eebf47f9 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 @@ -84,7 +84,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> { /** {@inheritDoc} */ @Override - public int parseArguments(final Parameters params) throws CmdLineException { + public int parseArguments(Parameters params) throws CmdLineException { final String name = params.getParameter(0); final CommandRef cr = CommandCatalog.get(name); if (cr == null) |