The multiValued attribute on @Option was removed. When the field is a List, it's not actually needed (even with earlier versions of args4j), see RmTest. In other cases, we have a custom handler, where it's also not needed. Bug: 413163 Change-Id: I4bb951e9fab5f4ae4271bd7e11be799dc234ab80tags/v4.9.0.201710071750-r
/* | |||||
* Copyright (C) 2013 Robin Stocker <robin@nibor.org> and others. | |||||
* | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Distribution License v1.0 which | |||||
* accompanies this distribution, is reproduced below, and is | |||||
* available at http://www.eclipse.org/org/documents/edl-v10.php | |||||
* | |||||
* All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or | |||||
* without modification, are permitted provided that the following | |||||
* conditions are met: | |||||
* | |||||
* - Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* - Redistributions in binary form must reproduce the above | |||||
* copyright notice, this list of conditions and the following | |||||
* disclaimer in the documentation and/or other materials provided | |||||
* with the distribution. | |||||
* | |||||
* - Neither the name of the Eclipse Foundation, Inc. nor the | |||||
* names of its contributors may be used to endorse or promote | |||||
* products derived from this software without specific prior | |||||
* written permission. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND | |||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | |||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
*/ | |||||
package org.eclipse.jgit.pgm; | |||||
import static org.junit.Assert.assertArrayEquals; | |||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertNull; | |||||
import java.io.File; | |||||
import org.eclipse.jgit.api.Git; | |||||
import org.eclipse.jgit.dircache.DirCache; | |||||
import org.eclipse.jgit.lib.CLIRepositoryTestCase; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
public class RmTest extends CLIRepositoryTestCase { | |||||
private Git git; | |||||
@Override | |||||
@Before | |||||
public void setUp() throws Exception { | |||||
super.setUp(); | |||||
git = new Git(db); | |||||
} | |||||
@Test | |||||
public void multiplePathsShouldBeRemoved() throws Exception { | |||||
File a = writeTrashFile("a", "Hello"); | |||||
File b = writeTrashFile("b", "world!"); | |||||
git.add().addFilepattern("a").addFilepattern("b").call(); | |||||
String[] result = execute("git rm a b"); | |||||
assertArrayEquals(new String[] { "" }, result); | |||||
DirCache cache = db.readDirCache(); | |||||
assertNull(cache.getEntry("a")); | |||||
assertNull(cache.getEntry("b")); | |||||
assertFalse(a.exists()); | |||||
assertFalse(b.exists()); | |||||
} | |||||
} |
@Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") | @Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity") | ||||
int timeout = -1; | int timeout = -1; | ||||
@Option(name = "--enable", metaVar = "metaVar_service", usage = "usage_enableTheServiceInAllRepositories", multiValued = true) | |||||
@Option(name = "--enable", metaVar = "metaVar_service", usage = "usage_enableTheServiceInAllRepositories") | |||||
final List<String> enable = new ArrayList<>(); | final List<String> enable = new ArrayList<>(); | ||||
@Option(name = "--disable", metaVar = "metaVar_service", usage = "usage_disableTheServiceInAllRepositories", multiValued = true) | |||||
@Option(name = "--disable", metaVar = "metaVar_service", usage = "usage_disableTheServiceInAllRepositories") | |||||
final List<String> disable = new ArrayList<>(); | final List<String> disable = new ArrayList<>(); | ||||
@Option(name = "--allow-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename", multiValued = true) | |||||
@Option(name = "--allow-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename") | |||||
final List<String> canOverride = new ArrayList<>(); | final List<String> canOverride = new ArrayList<>(); | ||||
@Option(name = "--forbid-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename", multiValued = true) | |||||
@Option(name = "--forbid-override", metaVar = "metaVar_service", usage = "usage_configureTheServiceInDaemonServicename") | |||||
final List<String> forbidOverride = new ArrayList<>(); | final List<String> forbidOverride = new ArrayList<>(); | ||||
@Option(name = "--export-all", usage = "usage_exportWithoutGitDaemonExportOk") | @Option(name = "--export-all", usage = "usage_exportWithoutGitDaemonExportOk") |
@Option(name = "--long", usage = "usage_LongFormat") | @Option(name = "--long", usage = "usage_LongFormat") | ||||
private boolean longDesc; | private boolean longDesc; | ||||
@Option(name = "--match", multiValued = true, usage = "usage_Match", metaVar = "metaVar_pattern") | |||||
@Option(name = "--match", usage = "usage_Match", metaVar = "metaVar_pattern") | |||||
private List<String> patterns = new ArrayList<>(); | private List<String> patterns = new ArrayList<>(); | ||||
@Override | @Override |
@Option(name = "--cached", usage = "usage_cached") | @Option(name = "--cached", usage = "usage_cached") | ||||
private boolean cached; | private boolean cached; | ||||
@Option(name = "--", metaVar = "metaVar_paths", multiValued = true, handler = PathTreeFilterHandler.class) | |||||
@Option(name = "--", metaVar = "metaVar_paths", handler = PathTreeFilterHandler.class) | |||||
private TreeFilter pathFilter = TreeFilter.ALL; | private TreeFilter pathFilter = TreeFilter.ALL; | ||||
// BEGIN -- Options shared with Log | // BEGIN -- Options shared with Log |
@Argument(index = 1, metaVar = "metaVar_treeish", required = true) | @Argument(index = 1, metaVar = "metaVar_treeish", required = true) | ||||
private final List<AbstractTreeIterator> trees = new ArrayList<>(); | private final List<AbstractTreeIterator> trees = new ArrayList<>(); | ||||
@Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) | |||||
@Option(name = "--", metaVar = "metaVar_path", handler = PathTreeFilterHandler.class) | |||||
private TreeFilter pathFilter = TreeFilter.ALL; | private TreeFilter pathFilter = TreeFilter.ALL; | ||||
@Override | @Override |
private AbstractTreeIterator tree; | private AbstractTreeIterator tree; | ||||
@Argument(index = 1) | @Argument(index = 1) | ||||
@Option(name = "--", metaVar = "metaVar_paths", multiValued = true, handler = StopOptionHandler.class) | |||||
@Option(name = "--", metaVar = "metaVar_paths", handler = StopOptionHandler.class) | |||||
private List<String> paths = new ArrayList<>(); | private List<String> paths = new ArrayList<>(); | ||||
@Override | @Override |
@Argument(index = 0, metaVar = "metaVar_commitish") | @Argument(index = 0, metaVar = "metaVar_commitish") | ||||
private final List<RevCommit> commits = new ArrayList<>(); | private final List<RevCommit> commits = new ArrayList<>(); | ||||
@Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) | |||||
@Option(name = "--", metaVar = "metaVar_path", handler = PathTreeFilterHandler.class) | |||||
protected TreeFilter pathFilter = TreeFilter.ALL; | protected TreeFilter pathFilter = TreeFilter.ALL; | ||||
private final List<RevFilter> revLimiter = new ArrayList<>(); | private final List<RevFilter> revLimiter = new ArrayList<>(); |
@Command(usage = "usage_StopTrackingAFile", common = true) | @Command(usage = "usage_StopTrackingAFile", common = true) | ||||
class Rm extends TextBuiltin { | class Rm extends TextBuiltin { | ||||
@Argument(metaVar = "metaVar_path", usage = "usage_path", multiValued = true, required = true) | |||||
@Argument(metaVar = "metaVar_path", usage = "usage_path", required = true) | |||||
@Option(name = "--", handler = StopOptionHandler.class) | @Option(name = "--", handler = StopOptionHandler.class) | ||||
private List<String> paths = new ArrayList<>(); | private List<String> paths = new ArrayList<>(); | ||||
@Override | @Override | ||||
protected void run() throws Exception { | protected void run() throws Exception { | ||||
try (Git git = new Git(db)) { | try (Git git = new Git(db)) { |
@Argument(index = 0, metaVar = "metaVar_object") | @Argument(index = 0, metaVar = "metaVar_object") | ||||
private String objectName; | private String objectName; | ||||
@Option(name = "--", metaVar = "metaVar_path", multiValued = true, handler = PathTreeFilterHandler.class) | |||||
@Option(name = "--", metaVar = "metaVar_path", handler = PathTreeFilterHandler.class) | |||||
protected TreeFilter pathFilter = TreeFilter.ALL; | protected TreeFilter pathFilter = TreeFilter.ALL; | ||||
// BEGIN -- Options shared with Diff | // BEGIN -- Options shared with Diff |
// | // | ||||
// | // | ||||
@Option(name = "--algorithm", multiValued = true, metaVar = "NAME", usage = "Enable algorithm(s)") | |||||
@Option(name = "--algorithm", metaVar = "NAME", usage = "Enable algorithm(s)") | |||||
List<String> algorithms = new ArrayList<>(); | List<String> algorithms = new ArrayList<>(); | ||||
@Option(name = "--text-limit", metaVar = "LIMIT", usage = "Maximum size in KiB to scan per file revision") | @Option(name = "--text-limit", metaVar = "LIMIT", usage = "Maximum size in KiB to scan per file revision") | ||||
int textLimit = 15 * 1024; // 15 MiB as later we do * 1024. | int textLimit = 15 * 1024; // 15 MiB as later we do * 1024. | ||||
@Option(name = "--repository", aliases = { "-r" }, multiValued = true, metaVar = "GIT_DIR", usage = "Repository to scan") | |||||
@Option(name = "--repository", aliases = { "-r" }, metaVar = "GIT_DIR", usage = "Repository to scan") | |||||
List<File> gitDirs = new ArrayList<>(); | List<File> gitDirs = new ArrayList<>(); | ||||
@Option(name = "--count", metaVar = "LIMIT", usage = "Number of file revisions to be compared") | @Option(name = "--count", metaVar = "LIMIT", usage = "Number of file revisions to be compared") |
// | // | ||||
// | // | ||||
@Option(name = "--hash", multiValued = true, metaVar = "NAME", usage = "Enable hash function(s)") | |||||
@Option(name = "--hash", metaVar = "NAME", usage = "Enable hash function(s)") | |||||
List<String> hashFunctions = new ArrayList<>(); | List<String> hashFunctions = new ArrayList<>(); | ||||
@Option(name = "--fold", multiValued = true, metaVar = "NAME", usage = "Enable fold function(s)") | |||||
@Option(name = "--fold", metaVar = "NAME", usage = "Enable fold function(s)") | |||||
List<String> foldFunctions = new ArrayList<>(); | List<String> foldFunctions = new ArrayList<>(); | ||||
@Option(name = "--text-limit", metaVar = "LIMIT", usage = "Maximum size in KiB to scan") | @Option(name = "--text-limit", metaVar = "LIMIT", usage = "Maximum size in KiB to scan") | ||||
int textLimit = 15 * 1024; // 15 MiB as later we do * 1024. | int textLimit = 15 * 1024; // 15 MiB as later we do * 1024. | ||||
@Option(name = "--repository", aliases = { "-r" }, multiValued = true, metaVar = "GIT_DIR", usage = "Repository to scan") | |||||
@Option(name = "--repository", aliases = { "-r" }, metaVar = "GIT_DIR", usage = "Repository to scan") | |||||
List<File> gitDirs = new ArrayList<>(); | List<File> gitDirs = new ArrayList<>(); | ||||
@Override | @Override |