Class DiffTools
- java.lang.Object
-
- org.eclipse.jgit.internal.diffmergetool.DiffTools
-
public class DiffTools extends Object
Manages diff tools.
-
-
Constructor Summary
Constructors Constructor Description DiffTools(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<FS.ExecutionResult>
compare(FileElement localFile, FileElement remoteFile, Optional<String> toolName, BooleanTriState prompt, boolean gui, BooleanTriState trustExitCode, PromptContinueHandler promptHandler, InformNoToolHandler noToolHandler)
Compare two versions of a file.FS.ExecutionResult
compare(FileElement localFile, FileElement remoteFile, ExternalDiffTool tool, boolean trustExitCode)
Compare two versions of a file.Set<String>
getAllToolNames()
Get all tool names.String
getDefaultToolName(boolean gui)
Get default (gui-)tool name.Optional<String>
getExternalToolFromAttributes(String path)
ProvidesOptional
with the name of an external diff tool if specified in git configuration for a path.String
getFirstAvailableTool()
Get first available tool name.Set<String>
getPredefinedAvailableTools()
Checks the availability of the predefined tools in the system.Set<String>
getPredefinedToolNames()
Get predefined tool names.Map<String,ExternalDiffTool>
getPredefinedTools(boolean checkAvailability)
Get predefined tools map.Set<String>
getUserDefinedToolNames()
Get user defined tool names.Map<String,ExternalDiffTool>
getUserDefinedTools()
Get user defined tools map.boolean
isInteractive()
Is interactive diff (prompt enabled) ?
-
-
-
Constructor Detail
-
DiffTools
public DiffTools(Repository repo)
Creates the external diff-tools manager for given repository.- Parameters:
repo
- the repository
-
DiffTools
public DiffTools(StoredConfig config)
Creates the external merge-tools manager for given configuration.- Parameters:
config
- the git configuration
-
-
Method Detail
-
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
-
getUserDefinedToolNames
public Set<String> getUserDefinedToolNames()
Get user defined tool names.- Returns:
- the user defined tool names
-
getPredefinedToolNames
public Set<String> getPredefinedToolNames()
Get predefined tool names.- Returns:
- the predefined tool names
-
getAllToolNames
public Set<String> getAllToolNames()
Get all tool names.- Returns:
- the all tool names (default or available tool name is the first in the set)
-
getExternalToolFromAttributes
public Optional<String> getExternalToolFromAttributes(String path) throws ToolException
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
-
getPredefinedAvailableTools
public Set<String> getPredefinedAvailableTools()
Checks the availability of the predefined tools in the system.- Returns:
- set of predefined available tools
-
getUserDefinedTools
public Map<String,ExternalDiffTool> getUserDefinedTools()
Get user defined tools map.- Returns:
- the user defined tools
-
getPredefinedTools
public Map<String,ExternalDiffTool> getPredefinedTools(boolean checkAvailability)
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
public String getFirstAvailableTool()
Get first available tool name.- Returns:
- the name of first available predefined tool or null
-
getDefaultToolName
public String getDefaultToolName(boolean gui)
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) ?
-
-