java.lang.Object
org.eclipse.jgit.internal.diffmergetool.ExternalToolUtils
Utilities for diff- and merge-tools.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate sorted tool setgetExternalToolFromAttributes
(Repository repository, String path, String toolKey) ProvidesOptional
with the name of an external tool if specified in git configuration for a path.static boolean
isToolAvailable
(FS fs, File gitDir, File directory, String path) Whether tool is availablestatic String
prepareCommand
(String command, FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile) Prepare command for execution.prepareEnvironment
(File gitDir, FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile) Prepare environment needed for execution.static String
Quote path
-
Field Details
-
KEY_MERGE_TOOL
Key for merge tool git configuration section- See Also:
-
KEY_DIFF_TOOL
Key for diff tool git configuration section- See Also:
-
-
Constructor Details
-
ExternalToolUtils
public ExternalToolUtils()
-
-
Method Details
-
prepareCommand
public static String prepareCommand(String command, FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile) throws IOException Prepare command for execution.- Parameters:
command
- the input "command" stringlocalFile
- the local file (ours)remoteFile
- the remote file (theirs)mergedFile
- the merged file (worktree)baseFile
- the base file (can be null)- Returns:
- the prepared (with replaced variables) command string
- Throws:
IOException
- if an IO error occurred
-
prepareEnvironment
public static Map<String,String> prepareEnvironment(File gitDir, FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile) throws IOException Prepare environment needed for execution.- Parameters:
gitDir
- the .git directorylocalFile
- the local file (ours)remoteFile
- the remote file (theirs)mergedFile
- the merged file (worktree)baseFile
- the base file (can be null)- Returns:
- the environment map with variables and values (file paths)
- Throws:
IOException
- if an IO error occurred
-
quotePath
Quote path- Parameters:
path
- the path to be quoted- Returns:
- quoted path if it contains spaces
-
isToolAvailable
Whether tool is available- Parameters:
fs
- the file system abstractiongitDir
- the .git directorydirectory
- the working directorypath
- the tool path- Returns:
- true if tool available and false otherwise
-
createSortedToolSet
public static Set<String> createSortedToolSet(String defaultName, Set<String> userDefinedNames, Set<String> preDefinedNames) Create sorted tool set- Parameters:
defaultName
- the default tool nameuserDefinedNames
- the user defined tool namespreDefinedNames
- the pre defined tool names- Returns:
- the sorted tool names set: first element is default tool name if valid, then user defined tool names and then pre defined tool names
-
getExternalToolFromAttributes
public static Optional<String> getExternalToolFromAttributes(Repository repository, String path, String toolKey) throws ToolException ProvidesOptional
with the name of an external tool if specified in git configuration for a path. The formed git configuration results from global rules as well as merged rules from info and worktree attributes. TriggersTreeWalk
until specified path found in the tree.- Parameters:
repository
- target repository to traverse intopath
- path to the node in repository to parse git attributes fortoolKey
- config key name for the tool- Returns:
- attribute value for the given tool key if set
- Throws:
ToolException
- if the tool failed
-