java.lang.Object
org.eclipse.jgit.internal.diffmergetool.DiffTools
Manages diff tools.
-
Constructor Summary
ConstructorsConstructorDescriptionDiffTools
(Repository repo) Creates the external diff-tools manager for given repository.DiffTools
(StoredConfig config) Creates the external merge-tools manager for given configuration. -
Method Summary
Modifier and TypeMethodDescriptioncompare
(FileElement localFile, FileElement remoteFile, Optional<String> toolName, BooleanTriState prompt, boolean gui, BooleanTriState trustExitCode, PromptContinueHandler promptHandler, InformNoToolHandler noToolHandler) Compare two versions of a file.compare
(FileElement localFile, FileElement remoteFile, ExternalDiffTool tool, boolean trustExitCode) Compare two versions of a file.Get all tool names.getDefaultToolName
(boolean gui) Get default (gui-)tool name.ProvidesOptional
with the name of an external diff tool if specified in git configuration for a path.Get first available tool name.Checks the availability of the predefined tools in the system.Get predefined tool names.getPredefinedTools
(boolean checkAvailability) Get predefined tools map.Get user defined tool names.Get user defined tools map.boolean
Is interactive diff (prompt enabled) ?
-
Constructor Details
-
DiffTools
Creates the external diff-tools manager for given repository.- Parameters:
repo
- the repository
-
DiffTools
Creates the external merge-tools manager for given configuration.- Parameters:
config
- the git configuration
-
-
Method Details
-
compare
public Optional<FS.ExecutionResult> compare(FileElement localFile, FileElement remoteFile, Optional<String> toolName, BooleanTriState prompt, boolean gui, BooleanTriState trustExitCode, PromptContinueHandler promptHandler, InformNoToolHandler noToolHandler) throws ToolException Compare two versions of a file.- Parameters:
localFile
- The local/left version of the file.remoteFile
- The remote/right version of the file.toolName
- Optionally the name of the tool to use. If not given the default tool will be used.prompt
- Optionally a flag whether to prompt the user before compare. If not given the default will be used.gui
- A flag whether to prefer a gui tool.trustExitCode
- Optionally a flag whether to trust the exit code of the tool. If not given the default will be used.promptHandler
- The handler to use when needing to prompt the user if he wants to continue.noToolHandler
- The handler to use when needing to inform the user, that no tool is configured.- Returns:
- the optional result of executing the tool if it was executed
- Throws:
ToolException
- when the tool fails
-
compare
public FS.ExecutionResult compare(FileElement localFile, FileElement remoteFile, ExternalDiffTool tool, boolean trustExitCode) throws ToolException Compare two versions of a file.- Parameters:
localFile
- the local file elementremoteFile
- the remote file elementtool
- the selected tooltrustExitCode
- the "trust exit code" option- Returns:
- the execution result from tool
- Throws:
ToolException
- when the tool fails
-
getUserDefinedToolNames
Get user defined tool names.- Returns:
- the user defined tool names
-
getPredefinedToolNames
Get predefined tool names.- Returns:
- the predefined tool names
-
getAllToolNames
Get all tool names.- Returns:
- the all tool names (default or available tool name is the first in the set)
-
getExternalToolFromAttributes
ProvidesOptional
with the name of an external diff 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:
path
- path to the node in repository to parse git attributes for- Returns:
- name of the difftool if set
- Throws:
ToolException
- when the tool failed
-
getPredefinedAvailableTools
Checks the availability of the predefined tools in the system.- Returns:
- set of predefined available tools
-
getUserDefinedTools
Get user defined tools map.- Returns:
- the user defined tools
-
getPredefinedTools
Get predefined tools map.- Parameters:
checkAvailability
- true: for checking if tools can be executed; ATTENTION: this check took some time, do not execute often (store the map for other actions); false: availability is NOT checked: isAvailable() returns default false is this case!- Returns:
- the predefined tools with optionally checked availability (long running operation)
-
getFirstAvailableTool
Get first available tool name.- Returns:
- the name of first available predefined tool or null
-
getDefaultToolName
Get default (gui-)tool name.- Parameters:
gui
- use the diff.guitool setting ?- Returns:
- the default tool name
-
isInteractive
public boolean isInteractive()Is interactive diff (prompt enabled) ?- Returns:
- is interactive (config prompt enabled) ?
-