View Javadoc
1   /*
2    * Copyright (C) 2010, Chris Aniszczyk <caniszczyk@gmail.com>
3    * Copyright (C) 2008, Google Inc. and others
4    *
5    * This program and the accompanying materials are made available under the
6    * terms of the Eclipse Distribution License v. 1.0 which is available at
7    * https://www.eclipse.org/org/documents/edl-v10.php.
8    *
9    * SPDX-License-Identifier: BSD-3-Clause
10   */
11  
12  package org.eclipse.jgit.pgm;
13  
14  import java.util.ArrayList;
15  import java.util.List;
16  
17  import org.eclipse.jgit.api.Git;
18  import org.eclipse.jgit.api.RmCommand;
19  import org.eclipse.jgit.api.errors.GitAPIException;
20  import org.kohsuke.args4j.Argument;
21  import org.kohsuke.args4j.Option;
22  import org.kohsuke.args4j.spi.StopOptionHandler;
23  
24  @Command(usage = "usage_StopTrackingAFile", common = true)
25  class Rm extends TextBuiltin {
26  	@Argument(metaVar = "metaVar_path", usage = "usage_path", required = true)
27  	@Option(name = "--", handler = StopOptionHandler.class)
28  	private List<String> paths = new ArrayList<>();
29  
30  	/** {@inheritDoc} */
31  	@Override
32  	protected void run() {
33  		try (Gitit.html#Git">Git git = new Git(db)) {
34  			RmCommand command = git.rm();
35  			for (String p : paths) {
36  				command.addFilepattern(p);
37  			}
38  			command.call();
39  		} catch (GitAPIException e) {
40  			throw die(e.getMessage(), e);
41  		}
42  	}
43  }