Class ExternalToolUtils
- java.lang.Object
-
- org.eclipse.jgit.internal.diffmergetool.ExternalToolUtils
-
public class ExternalToolUtils extends Object
Utilities for diff- and merge-tools.
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_DIFF_TOOL
Key for diff tool git configuration sectionstatic String
KEY_MERGE_TOOL
Key for merge tool git configuration section
-
Constructor Summary
Constructors Constructor Description ExternalToolUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<String>
createSortedToolSet(String defaultName, Set<String> userDefinedNames, Set<String> preDefinedNames)
static Optional<String>
getExternalToolFromAttributes(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)
static String
prepareCommand(String command, FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile)
Prepare command for execution.static Map<String,String>
prepareEnvironment(File gitDir, FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile)
Prepare environment needed for execution.static String
quotePath(String path)
-
-
-
Field Detail
-
KEY_MERGE_TOOL
public static final String KEY_MERGE_TOOL
Key for merge tool git configuration section- See Also:
- Constant Field Values
-
KEY_DIFF_TOOL
public static final String KEY_DIFF_TOOL
Key for diff tool git configuration section- See Also:
- Constant Field Values
-
-
Method Detail
-
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
-
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
-
quotePath
public static String quotePath(String path)
- Parameters:
path
- the path to be quoted- Returns:
- quoted path if it contains spaces
-
isToolAvailable
public static boolean isToolAvailable(FS fs, File gitDir, File directory, String path)
- 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)
- 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
-
-