Package org.eclipse.jgit.api
Class SubmoduleDeinitCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<java.util.Collection<SubmoduleDeinitResult>>
-
- org.eclipse.jgit.api.SubmoduleDeinitCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.util.Collection<SubmoduleDeinitResult>>
public class SubmoduleDeinitCommand extends GitCommand<java.util.Collection<SubmoduleDeinitResult>>
A class used to execute a submodule deinit command.This will remove the module(s) from the working tree, but won't affect .git/modules.
- Since:
- 4.10
- See Also:
- Git documentation about submodules
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSubmoduleDeinitCommand.NoSuchSubmoduleExceptionThe user tried to deinitialize a submodule that doesn't exist in the index.static classSubmoduleDeinitCommand.SubmoduleDeinitStatusThe effect of a submodule deinit command for a given path
-
Field Summary
Fields Modifier and Type Field Description private booleanforceprivate java.util.Collection<java.lang.String>paths-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description SubmoduleDeinitCommand(Repository repo)Constructor of SubmoduleDeinitCommand
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SubmoduleDeinitCommandaddPath(java.lang.String path)Add repository-relative submodule path to deinitializejava.util.Collection<SubmoduleDeinitResult>call()private SubmoduleDeinitCommand.SubmoduleDeinitStatuscheckDirty(RevWalk revWalk, java.lang.String path)Check if a submodule is dirty.private voiddeinit(java.lang.String path)Recursively delete the *contents* of path, but leave path as an empty directorySubmoduleDeinitCommandsetForce(boolean force)Iftrue, call() will deinitialize modules with local changes; else it will refuse to do so.private booleansubmoduleExists(java.lang.String path)Check if this path is a submodule by checking the index, which is what git submodule deinit checks.-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
SubmoduleDeinitCommand
public SubmoduleDeinitCommand(Repository repo)
Constructor of SubmoduleDeinitCommand- Parameters:
repo-
-
-
Method Detail
-
call
public java.util.Collection<SubmoduleDeinitResult> call() throws GitAPIException
Execute the command
- Specified by:
callin interfacejava.util.concurrent.Callable<java.util.Collection<SubmoduleDeinitResult>>- Specified by:
callin classGitCommand<java.util.Collection<SubmoduleDeinitResult>>- Returns:
- the set of repositories successfully deinitialized.
- Throws:
SubmoduleDeinitCommand.NoSuchSubmoduleException- if any of the submodules which we might want to deinitialize don't existGitAPIException
-
deinit
private void deinit(java.lang.String path) throws java.io.IOExceptionRecursively delete the *contents* of path, but leave path as an empty directory- Parameters:
path- the path to clean- Throws:
java.io.IOException
-
checkDirty
private SubmoduleDeinitCommand.SubmoduleDeinitStatus checkDirty(RevWalk revWalk, java.lang.String path) throws GitAPIException, java.io.IOException
Check if a submodule is dirty. A submodule is dirty if there are local changes to the submodule relative to its HEAD, including untracked files. It is also dirty if the HEAD of the submodule does not match the value in the parent repo's index or HEAD.- Parameters:
revWalk-path-- Returns:
- status of the command
- Throws:
GitAPIExceptionjava.io.IOException
-
submoduleExists
private boolean submoduleExists(java.lang.String path) throws java.io.IOExceptionCheck if this path is a submodule by checking the index, which is what git submodule deinit checks.- Parameters:
path- path of the submodule- Returns:
trueif path exists and is a submodule in index,falseotherwise- Throws:
java.io.IOException
-
addPath
public SubmoduleDeinitCommand addPath(java.lang.String path)
Add repository-relative submodule path to deinitialize- Parameters:
path- (with/as separator)- Returns:
- this command
-
setForce
public SubmoduleDeinitCommand setForce(boolean force)
Iftrue, call() will deinitialize modules with local changes; else it will refuse to do so.- Parameters:
force-- Returns:
this
-
-