aboutsummaryrefslogtreecommitdiffstats
path: root/git-mergetool--lib.sh
AgeCommit message (Collapse)AuthorFilesLines
2023-04-05mergetool: new config guiDefault supports auto-toggling gui by DISPLAYTao Klerks1-0/+40
When no merge.tool or diff.tool is configured or manually selected, the selection of a default tool is sensitive to the DISPLAY variable; in a GUI session a gui-specific tool will be proposed if found, and otherwise a terminal-based one. This "GUI-optimizing" behavior is important because a GUI can make a huge difference to a user's ability to understand and correctly complete a non-trivial conflicting merge. Some time ago the merge.guitool and diff.guitool config options were introduced to enable users to configure both a GUI tool, and a non-GUI tool (with fallback if no GUI tool configured), in the same environment. Unfortunately, the --gui argument introduced to support the selection of the guitool is still explicit. When using configured tools, there is no equivalent of the no-tool-configured "propose a GUI tool if we are in a GUI environment" behavior. As proposed in <xmqqmtb8jsej.fsf@gitster.g>, introduce new configuration options, difftool.guiDefault and mergetool.guiDefault, supporting a special value "auto" which causes the corresponding tool or guitool to be selected depending on the presence of a non-empty DISPLAY value. Also support "true" to say "default to the guitool (unless --no-gui is passed on the commandline)", and "false" as the previous default behavior when these new configuration options are not specified. Signed-off-by: Tao Klerks <tao@klerks.biz> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-04-03vimdiff: add tool documentationFernando Ramos1-1/+9
Running 'git {merge,diff}tool --tool-help' now also prints usage information about the vimdiff tool (and its variants) instead of just its name. Two new functions ('diff_cmd_help()' and 'merge_cmd_help()') have been added to the set of functions that each merge tool (ie. scripts found inside "mergetools/") can overwrite to provided tool specific information. Right now, only 'mergetools/vimdiff' implements these functions, but other tools are encouraged to do so in the future, specially if they take configuration options not explained anywhere else (as it is the case with the 'vimdiff' tool and the new 'layout' option) Note that the function 'show_tool_names', used in the implementation of 'git mergetool --tool-help', is also used in Documentation/Makefile to generate the list of allowed values for the configuration variables '{diff,merge}.{gui,}tool'. Adjust the rule so its output is an Asciidoc "description list" instead of a plain list, with the tool name as the item and the newly added tool description as the description. In addition, a section has been added to "Documentation/git-mergetool.txt" to explain the new "layout" configuration option with examples. Helped-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Fernando Ramos <greenfoo@u92.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-02-17Merge branch 'sh/mergetool-hideresolved'Junio C Hamano1-3/+8
"git mergetool" feeds three versions (base, local and remote) of a conflicted path unmodified. The command learned to optionally prepare these files with unconflicted parts already resolved. * sh/mergetool-hideresolved: mergetool: add per-tool support and overrides for the hideResolved flag mergetool: break setup_tool out into separate initialization function mergetool: add hideResolved configuration
2021-02-09mergetool: add per-tool support and overrides for the hideResolved flagSeth House1-0/+4
Add a per-tool override flag so that users may enable the flag for one tool and disable it for another by setting `mergetool.<tool>.hideResolved` to `false`. In addition, the author or maintainer of a mergetool may optionally override the default `hideResolved` value for that mergetool. If the `mergetools/<tool>` shell script contains a `hide_resolved_enabled` function it will be called when the mergetool is invoked and the return value will be used as the default for the `hideResolved` flag. hide_resolved_enabled () { return 1 } Disabling may be desirable if the mergetool wants or needs access to the original, unmodified 'LOCAL' and 'REMOTE' versions of the conflicted file. For example: - A tool may use a custom conflict resolution algorithm and prefer to ignore the results of Git's conflict resolution. - A tool may want to visually compare/constrast the version of the file from before the merge (saved to 'LOCAL', 'REMOTE', and 'BASE') with Git's conflict resolution results (saved to 'MERGED'). Helped-by: Johannes Sixt <j6t@kdbg.org> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Seth House <seth@eseth.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-02-09mergetool: break setup_tool out into separate initialization functionSeth House1-3/+4
This is preparation for the following commit where we need to source the mergetool shell script to look for overrides before `run_merge_tool` is called. Previously `run_merge_tool` both sourced that script and invoked the mergetool. In the case of the following commit, we need the result of the `hide_resolved` override, if present, before we actually run `run_merge_tool`. The new `initialize_merge_tool` wrapper is exposed and documented as a public interface for consistency with the existing `run_merge_tool` which is also public. Although `setup_tool` could instead be exposed directly, the related `setup_user_tool` would probably also want to be elevated to match and this felt the cleanest to me. Signed-off-by: Seth House <seth@eseth.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-15Merge branch 'pb/mergetool-tool-help-fix'Junio C Hamano1-2/+4
Fix 2.29 regression where "git mergetool --tool-help" fails to list all the available tools. * pb/mergetool-tool-help-fix: mergetool--lib: fix '--tool-help' to correctly show available tools
2021-01-06mergetool--lib: fix '--tool-help' to correctly show available toolsPhilippe Blain1-2/+4
Commit 83bbf9b92e (mergetool--lib: improve support for vimdiff-style tool variants, 2020-07-29) introduced a regression in the output of `git mergetool --tool-help` and `git difftool --tool-help` [1]. In function 'show_tool_names' in git-mergetool--lib.sh, we loop over the supported mergetools and their variants and accumulate them in the variable 'variants', separating them with a literal '\n'. The code then uses 'echo $variants' to turn these '\n' into newlines, but this behaviour is not portable, it just happens to work in some shells, like dash(1)'s 'echo' builtin. For shells in which 'echo' does not turn '\n' into newlines, the end result is that the only tools that are shown are the existing variants (except the last variant alphabetically), since the variants are separated by actual newlines in '$variants' because of the several 'echo' calls in mergetools/{bc,vimdiff}::list_tool_variants. Fix this bug by embedding an actual line feed into `variants` in show_tool_names(). While at it, replace `sort | uniq` by `sort -u`. To prevent future regressions, add a simple test that checks that a few known tools are correctly shown (let's avoid counting the total number of tools to lessen the maintenance burden when new tools are added or if '--tool-help' learns additional logic, like hiding tools depending on the current platform). [1] https://lore.kernel.org/git/CADtb9DyozjgAsdFYL8fFBEWmq7iz4=prZYVUdH9W-J5CKVS4OA@mail.gmail.com/ Reported-by: Philippe Blain <levraiphilippeblain@gmail.com> Based-on-patch-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-11mergetool: avoid letting `list_tool_variants` break user-defined setupsJohannes Schindelin1-0/+4
In 83bbf9b92ea8 (mergetool--lib: improve support for vimdiff-style tool variants, 2020-07-29), we introduced a `list_tool_variants` function in the spirit of Postel's Law: be lenient in what you accept as input. In this particular instance, we wanted to allow not only `bc` but also `bc3` as name for the Beyond Compare tool. However, what this patch overlooked is that it is totally allowed for users to override the defaults in `mergetools/`. But now that we strip off trailing digits, the name that the user gave the tool might not actually be in the list produced by `list_tool_variants`. So let's do the same as for the `diff_cmd` and the `merge_cmd`: override it with the trivial version in case a user-defined setup was detected. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-07-29mergetools: add support for nvimdiff (neovim) familypudinha1-2/+5
Signed-off-by: pudinha <rogi@skylittlesystem.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-07-29mergetool--lib: improve support for vimdiff-style tool variantspudinha1-5/+23
The merge tools vimdiff2, vimdiff3, gvimdiff2, gvimdiff3 and bc3 are all variants of the main tools vimdiff and bc. They are implemented in the main and a one-liner script that just sources it exist for each. Allow variants ending in [0-9] to be correctly wired without the need for such one-liners, so instead of 5 scripts, only 1 (gvimdiff) is needed. Signed-off-by: pudinha <rogi@skylittlesystem.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-05-19Merge branch 'dl/difftool-mergetool'Junio C Hamano1-12/+35
Update "git difftool" and "git mergetool" so that the combinations of {diff,merge}.{tool,guitool} configuration variables serve as fallback settings of each other in a sensible order. * dl/difftool-mergetool: difftool: fallback on merge.guitool difftool: make --gui, --tool and --extcmd mutually exclusive mergetool: fallback to tool when guitool unavailable mergetool--lib: create gui_mode function mergetool: use get_merge_tool function t7610: add mergetool --gui tests t7610: unsuppress output
2019-05-13mergetool: fallback to tool when guitool unavailableDenton Liu1-9/+26
In git-difftool, if the tool is called with --gui but `diff.guitool` is not set, it falls back to `diff.tool`. Make git-mergetool also fallback from `merge.guitool` to `merge.tool` if the former is undefined. If git-difftool, when called with `--gui`, were to use `get_configured_mergetool` in a future patch, it would also get the fallback behavior in the following precedence: 1. diff.guitool 2. merge.guitool 3. diff.tool 4. merge.tool The behavior for when difftool or mergetool are called without `--gui` should be identical with or without this patch. Note that the search loop could be written as sections="merge" keys="tool" if diff_mode then sections="diff $sections" fi if gui_mode then keys="guitool $keys" fi merge_tool=$( IFS=' ' for key in $keys do for section in $sections do selected=$(git config $section.$key) if test -n "$selected" then echo "$selected" return fi done done) which would make adding a mode in the future much easier. However, adding a new mode will likely never happen as it is highly discouraged so, as a result, it is written in its current form so that it is more readable for future readers. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-05-13mergetool--lib: create gui_mode functionDenton Liu1-5/+8
Before, in `get_configured_merge_tool`, we would test the value of the first argument directly, which corresponded to whether we were using guitool. However, since `$GIT_MERGETOOL_GUI` is available as an environment variable, create the `gui_mode` function which increases the clarify of functions which use it. While we're at it, add a space before `()` in function definitions to fix the style. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-05-13mergetool: use get_merge_tool functionDenton Liu1-1/+4
In git-mergetool, the logic for getting which merge tool to use is duplicated in git-mergetool--lib, except for the fact that it needs to know whether the tool was guessed or not. Rewrite `get_merge_tool` to return whether or not the tool was guessed through the return code and make git-mergetool call this function instead of duplicating the logic. Note that 1 was chosen to be the return code of when a tool is guessed because it seems like a slightly more abnormal condition than getting a tool that's explicitly specified but this is completely arbitrary. Also, let `$GIT_MERGETOOL_GUI` be set to determine whether or not the guitool will be selected. This change is not completely backwards compatible as there may be external users of git-mergetool--lib. However, only one user, git-diffall[1], was found from searching GitHub and Google, and this tool is superseded by `git difftool --dir-diff` anyway. It seems very unlikely that there exists an external caller that would take into account the return code of `get_merge_tool` as it would always return 0 before this change so this change probably does not affect any external users. [1]: https://github.com/thenigan/git-diffall Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-04-04mergetools: add support for smerge (Sublime Merge)David Aguilar1-0/+1
Teach difftool and mergetool about the Sublime Merge "smerge" command. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-25mergetool: accept -g/--[no-]gui as argumentsDenton Liu1-5/+11
In line with how difftool accepts a -g/--[no-]gui option, make mergetool accept the same option in order to use the `merge.guitool` variable to find the default mergetool instead of `merge.tool`. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Anmol Mago <anmolmago@gmail.com> Signed-off-by: Brian Ho <briankyho@gmail.com> Signed-off-by: David Lu <david.lu97@outlook.com> Signed-off-by: Ryan Wang <shirui.wang@hotmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-11-29mergetool: honor mergetool.$tool.trustExitCode for built-in toolsDavid Aguilar1-11/+45
Built-in merge tools contain a hard-coded assumption about whether or not a tool's exit code can be trusted to determine the success or failure of a merge. Tools whose exit codes are not trusted contain calls to check_unchanged() in their merge_cmd() functions. A problem with this is that the trustExitCode configuration is not honored for built-in tools. Teach built-in tools to honor the trustExitCode configuration. Extend run_merge_cmd() so that it is responsible for calling check_unchanged() when a tool's exit code cannot be trusted. Remove check_unchanged() calls from scriptlets since they are no longer responsible for calling it. When no configuration is present, exit_code_trustable() is checked to see whether the exit code should be trusted. The default implementation returns false. Tools whose exit codes can be trusted override exit_code_trustable() to true. Reported-by: Dun Peal <dunpealer@gmail.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-03Merge branch 'nf/mergetool-prompt'Junio C Hamano1-1/+1
UI consistency improvements. * nf/mergetool-prompt: difftool/mergetool: make the form of yes/no questions consistent
2016-04-25difftool/mergetool: make the form of yes/no questions consistentNikola Forró1-1/+1
Every yes/no question in difftool/mergetool scripts has slightly different form, and none of them is consistent with the form git itself uses. Make the form of all the questions consistent with the form used by git. Reviewed-by: John Keeping <john@keeping.me.uk> Signed-off-by: Nikola Forró <nforro@redhat.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-04-04mergetools: create mergetool_find_win32_cmd() helper function for winmergeJacob Nisnevich1-0/+25
Signed-off-by: Jacob Nisnevich <jacob.nisnevich@gmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-19mergetool-lib: fix default tool selectionMichael J Gruber1-0/+1
When no diff nor merge tool is specified (config, option), mergetool-lib is supposed to choose a default tool from a set of tools. That set is constructed dynamically depending on the environment (graphical, editor setting) as a space separated string of tool names. 719518f (mergetool--lib: set IFS for difftool and mergetool, 2015-05-20) introduced a newline as IFS which breaks the parsing of the space separated list into items, resulting in a failed search for an available tool. Set IFS to a space locally for the tool search. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-20mergetool--lib: set IFS for difftool and mergetoolDavid Aguilar1-0/+3
git-sh-setup sets IFS but it is not used by git-difftool--helper. Set IFS in git-mergetool--lib so that the mergetool scriptlets, difftool, and mergetool do not need to do so. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-11-21mergetool--lib: remove use of $status globalDavid Aguilar1-14/+5
Remove return statements and rework check_unchanged() so that the exit status from the last evaluated expression bubbles up to the callers. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-11-21mergetool--lib: remove no-op assignment to $status from setup_user_toolJunio C Hamano1-1/+0
Even though setup_user_tool assigns the exit status from "eval $merge_tool_cmd" to $status, the variable is overwritten by the function it calls next, check_unchanged, without ever getting looked at by anybody. And "return $status" at the end of this function returns the value check_unchanged assigned to it (which is the same as the value the function returns). Which makes the assignment a no-op. Remove it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-11-18Merge branch 'da/difftool'Junio C Hamano1-0/+1
Fix-up to a new feature in 'master'. * da/difftool: difftool: honor --trust-exit-code for builtin tools
2014-11-14difftool: honor --trust-exit-code for builtin toolsDavid Aguilar1-0/+1
run_merge_tool() was not setting $status, which prevented the exit code for builtin tools from being forwarded to the caller. Capture the exit status and add a test to guarantee the behavior. Reported-by: Adria Farres <14farresa@gmail.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-10-21mergetool: rename bc3 to bcJunio C Hamano1-1/+1
Beyond Compare version 4 works the same way as version 3, so rename the existing "bc3" adaptor to just "bc", while keeping "bc3" as a backward compatible wrapper. Noticed-by: Olivier Croquette <ocroquette@free.fr> Helped-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-26remove #!interpreter line from shell librariesJonathan Nieder1-2/+1
In a shell snippet meant to be sourced by other shell scripts, an opening #! line does more harm than good. The harm: - When the shell library is sourced, the interpreter and options from the #! line are not used. Specifying a particular shell can confuse the reader into thinking it is safe for the shell library to rely on idiosyncrasies of that shell. - Using #! instead of a plain comment drops a helpful visual clue that this is a shell library and not a self-contained script. - Tools such as lintian can use a #! line to tell when an installation script has failed by forgetting to set a script executable. This check does not work if shell libraries also start with a #! line. The good: - Text editors notice the #! line and use it for syntax highlighting if you try to edit the installed scripts (without ".sh" suffix) in place. The use of the #! for file type detection is not needed because Git's shell libraries are meant to be edited in source form (with ".sh" suffix). Replace the opening #! lines with comments. This involves tweaking the test harness's valgrind support to find shell libraries by looking for "# " in the first line instead of "#!" (see v1.7.6-rc3~7, 2011-06-17). Suggested by Russ Allbery through lintian. Thanks to Jeff King and Clemens Buchacher for further analysis. Tested by searching for non-executable scripts with #! line: find . -name .git -prune -o -type f -not -executable | while read file do read line <"$file" case $line in '#!'*) echo "$file" ;; esac done The only remaining scripts found are templates for shell scripts (unimplemented.sh, wrap-for-bin.sh) and sample input used in tests (t/t4034/perl/{pre,post}). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-14mergetool--lib: Fix typo in the merge/difftool helpStefan Saasen1-1/+1
The help text for the `tool` flag should mention: --tool=<tool> instead of: --tool-<tool> Signed-off-by: Stefan Saasen <ssaasen@atlassian.com> Reviewed-by: David Aguilar <davvid@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-10-13mergetools/diffmerge: support DiffMerge as a git mergetoolStefan Saasen1-1/+2
DiffMerge is a non-free (but gratis) tool that supports OS X, Windows and Linux. See http://www.sourcegear.com/diffmerge/ DiffMerge includes a script `/usr/bin/diffmerge` that can be used to launch the graphical compare tool. This change adds mergetool support for DiffMerge and adds 'diffmerge' as an option to the mergetool help. Signed-off-by: Stefan Saasen <ssaasen@atlassian.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-07-29many small typofixesOndřej Bílka1-1/+1
Signed-off-by: Ondřej Bílka <neleai@seznam.cz> Reviewed-by: Marc Branchaud <marcnarc@xiplink.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-17mergetool--lib: refactor {diff,merge}_cmd logicJohn Keeping1-47/+35
Instead of needing a wrapper to call the diff/merge command, simply provide the diff_cmd and merge_cmd functions for user-specified tools in the same way as we do for built-in tools. Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-02doc: generate a list of valid merge toolsDavid Aguilar1-1/+2
Use the show_tool_names() function to build lists of all the built-in tools supported by difftool and mergetool. This frees us from needing to update the documentation whenever a new tool is added. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-02mergetool--lib: list user configured tools in '--tool-help'John Keeping1-1/+40
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-02mergetool--lib: add functions for finding available toolsDavid Aguilar1-36/+65
Refactor show_tool_help() so that the tool-finding logic is broken out into a separate show_tool_names() function. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-29mergetool--lib: improve the help text in guess_merge_tool()David Aguilar1-1/+7
This code path is only activated when the user does not have a valid configured tool. Add a message to guide new users towards configuring a default tool. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-29mergetool--lib: simplify command expressionsDavid Aguilar1-23/+15
Update variable assignments to always use $(command "$arg") in their RHS instead of "$(command "$arg")" as the latter is harder to read. Make get_merge_tool_cmd() simpler by avoiding "echo" and $(command) substitutions completely. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-28mergetools: simplify how we handle "vim" and "defaults"David Aguilar1-30/+31
Remove the exceptions for "vim" and "defaults" in the mergetool library so that every filename in mergetools/ matches 1:1 with the name of a valid built-in tool. Define the trivial fallback definition of shell functions in-line in git-mergetool-lib script, instead of dot-sourcing them from another file. The result is much easier to follow. [jc: squashed in an update from John Keeping as well] Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-27mergetool--lib: don't call "exit" in setup_toolJohn Keeping1-3/+20
This will make it easier to use setup_tool in places where we expect that the selected tool will not support the current mode. We need to introduce a new return code for setup_tool to differentiate between the case of "the selected tool is invalid" and "the selected tool is not a built-in" since we must call setup_tool when a custom 'merge.<tool>.path' is configured for a built-in tool but avoid failing when the configured tool is not a built-in. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-27mergetool--lib: improve show_tool_help() outputDavid Aguilar1-5/+21
Check the can_diff and can_merge functions before deciding whether to add the tool to the available/unavailable lists. This makes "--tool-help" context-sensitive so that "git mergetool --tool-help" displays merge tools only and "git difftool --tool-help" displays diff tools only. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-25git-mergetool: don't hardcode 'mergetool' in show_tool_helpJohn Keeping1-2/+4
When using show_tool_help from git-difftool we will want it to print "git difftool" not "git mergetool" so use "git ${TOOL_MODE}tool". Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-25git-mergetool: remove redundant assignmentJohn Keeping1-1/+0
TOOL_MODE is set at the top of git-mergetool.sh so there is no need to set it again in show_tool_help. Removing this lets us re-use show_tool_help in git-difftool. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-25git-mergetool: move show_tool_help to mergetool--libJohn Keeping1-0/+37
This is the first step in unifying "git difftool --tool-help" and "git mergetool --tool-help". Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-10-01Merge branch 'da/mergetool-custom'Junio C Hamano1-2/+38
The actual external command to run for mergetool backend can be specified with difftool/mergetool.$name.cmd configuration variables, but this mechanism was ignored for the backends we natively support. * da/mergetool-custom: mergetool--lib: Allow custom commands to override built-ins
2012-09-25mergetool--lib: Allow custom commands to override built-insDavid Aguilar1-2/+38
Allow users to override the default commands provided by the mergetools/* scriptlets. Users occasionally run into problems where they expect to be able to override the built-in tool names. The documentation does not explicitly mention that built-ins cannot be overridden, so it's easy to assume that it should work. Lift this restriction so that built-in tools are handled the same way as user-configured tools. Add tests to guarantee this behavior. A nice benefit of this change is that it protects users from having future versions of git trump their custom configuration with a new built-in tool. C.f.: http://stackoverflow.com/questions/7435002/mergetool-from-gitconfig-being-ignored http://thread.gmane.org/gmane.comp.version-control.msysgit/13188 http://thread.gmane.org/gmane.comp.version-control.git/148267 Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-27Merge branch 'da/difftool-updates'Junio C Hamano1-1/+1
"git difftool --dir-diff" learned to use symbolic links to prepare temporary copy of the working tree when available. * da/difftool-updates: difftool: silence warning Add Code Compare v2.80.4 as a merge / diff tool for Windows mergetool,difftool: Document --tool-help consistently difftool: Disable --symlinks on cygwin difftool: Handle compare() returning -1 difftool: Wrap long lines for readability difftool: Check all return codes from compare() difftool: Handle finding mergetools/ in a path with spaces difftool: Use symlinks when diffing against the worktree difftool: Call the temp directory "git-difftool" difftool: Move option values into a hash difftool: Eliminate global variables difftool: Simplify print_tool_help()
2012-08-10Add Code Compare v2.80.4 as a merge / diff tool for WindowsSebastian Schuberth1-1/+1
Code Compare is a commercial file comparison tool for Windows, see http://www.devart.com/codecompare/ Version 2.80.4 added support for command line arguments preceded by a dash instead of a slash. This is required for Git for Windows because slashes in command line arguments get mangled with according to these rules: http://www.mingw.org/wiki/Posix_path_conversion Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-23mergetool: support --tool-help option like difftool doesJunio C Hamano1-1/+5
This way we do not have to risk the list of tools going out of sync between the implementation and the documentation. In the same spirit as bf73fc2 (difftool: print list of valid tools with '--tool-help', 2012-03-29), trim the list of merge backends in the documentation. We do not want to have a complete list of valid tools; we only want a list to help people guess what kind of things the tools do to be specified there, and refer them to --tool-help for a complete list. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-09-19Merge branch 'maint'Junio C Hamano1-1/+1
* maint: git-mergetool: check return value from read
2011-09-19git-mergetool: check return value from readJay Soffian1-1/+1
Mostly fixed already by 6b44577 (mergetool: check return value from read, 2011-07-01). Catch two uses it missed. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-19mergetool--lib: Refactor tools into separate filesDavid Aguilar1-333/+52
Individual merge tools are now defined in a mergetools/$tool file which is sourced at runtime. The individual files are installed into $(git --exec-path)/mergetools/. New tools can be added by creating a new file instead of editing the git-mergetool--lib.sh scriptlet. http://thread.gmane.org/gmane.comp.version-control.git/134906/focus=135006 Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-19mergetool--lib: Make style consistent with gitDavid Aguilar1-53/+100
Use the predominant conditional style where "then" appears alone on the line after the test expression. Remove spaces after ">" output redirections. Remove unnecessary parentheses around the kdiff3 commands. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-05misc-sh: fix up whitespace in some other .sh files.Jon Seymour1-3/+3
I found that the patched 4 files were different when this filter is applied. expand -i | unexpand --first-only This patch contains the corrected files. Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-29Merge branch 'da/git-prefix-everywhere' into nextJunio C Hamano1-0/+7
* da/git-prefix-everywhere: t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests git-mergetool--lib: Make vimdiff retain the current directory git: Remove handling for GIT_PREFIX setup: Provide GIT_PREFIX to built-ins
2011-05-26git-mergetool--lib: Make vimdiff retain the current directoryDavid Aguilar1-0/+7
When using difftool with vimdiff it can be unexpected that the current directory changes to the root of the project. Tell vim to chdir to the value of $GIT_PREFIX to fix this. Care is taken to quote the variable so that vim expands it. This avoids problems when directory names contain spaces. Signed-off-by: David Aguilar <davvid@gmail.com> Reported-by: Frédéric Heitzmann <frederic.heitzmann@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-01Pass empty file to p4merge where no base is suitable.Ciaran Jessup1-6/+3
Modify the p4merge client command to pass a reference to an empty file instead of the local file when no base revision available. In the situation where a merge tries to add a file from one branch into a branch that already contains that file (by name), p4merge currently seems to have successfully automatically resolved the 'conflict' when it is opened (correctly if the files differed by just whitespace for example) but leaves the save button disabled. This means the user of the p4merge client cannot commit the resolved changes back to disk and merely exits, leaving the original (merge-conflicted) file intact on the disk. Provide an empty base file to p4merge so that it leaves the save button enabled. This will allow saving of the auto-resolution to disk. Signed-off-by: Ciaran Jessup <ciaranj@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-19Merge branch 'ss/mergetool--lib'Junio C Hamano1-104/+121
* ss/mergetool--lib: mergetool--lib: Add Beyond Compare 3 as a tool mergetool--lib: Sort tools alphabetically for easier lookup
2011-02-28mergetool--lib: Add Beyond Compare 3 as a toolSebastian Schuberth1-2/+20
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-28mergetool--lib: Sort tools alphabetically for easier lookupSebastian Schuberth1-110/+109
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-25mergetool-lib: call vim in readonly mode for diffsMichael J Gruber1-2/+2
When [g]vimdiff is called for files which are opened already, the editor complains about the existing swap file. But we do not want to write anything when called from difftool. So, make difftool use "-R" for the vim family. This - prevents the use of a swap file and - marks the buffers readonly. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29mergetool-lib: make the three-way diff the default for vim/gvimDan McGee1-3/+15
The original vimdiff/gvimdiff configuration is now available by using 'vimdiff2' or 'gvimdiff2' as the preferred merge tool. Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-15mergetool-lib: add a three-way diff view for vim/gvimDan McGee1-2/+7
When the base version is available, use a three-way, four panel view by default. This shows the (local, base, remote) revisions up top and the merged result by itself in the lower pane. All revisions will still scroll together by default, and the cursor still defaults to the merged result edit pane. Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-15mergetool-lib: combine vimdiff and gvimdiff run blocksDan McGee1-14/+3
They are nearly identical outside of the foreground flag, which can safely be passed to both vim and gvim. The merge tool itself is named in $merge_tool_path. Signed-off-by: Dan McGee <dpmcgee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-20mergetool: Remove explicit references to /dev/ttyCharles Bailey1-1/+1
mergetool used /dev/tty to switch back to receiving input from the user via inside a block with a redirected stdin. This harms testability, so change mergetool to save its original stdin to an alternative fd in this block and restore it for those sub-commands that need the original stdin. Includes additional compatibility fix from Jonathan Nieder. Tested-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-29add shebang line to git-mergetool--lib.shJeff King1-0/+1
Even though this script is expected to be sourced instead of executed on its own, the #!/bin/sh line provides simple documentation about what format the file is in. In particular, the lack of such a line was confusing the valgrind support of our test scripts, which assumed that any executable without a #!-line should be intercepted and run through valgrind. So during valgrind-enabled tests, any script sourcing this file actually sourced the valgrind interception script instead. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-25Merge branch 'rs/work-around-grep-opt-insanity'Junio C Hamano1-7/+6
* rs/work-around-grep-opt-insanity: Protect scripted Porcelains from GREP_OPTIONS insanity mergetool--lib: simplify guess_merge_tool() Conflicts: git-instaweb.sh
2009-11-23mergetool--lib: simplify guess_merge_tool()René Scharfe1-7/+6
Use a case statement instead of calling grep to find out if the editor's name contains the string "vim". Remove the check for emacs, as this branch did the same as the default one anyway. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-28mergetool--lib: add p4merge as a pre-configured mergetool optionScott Chacon1-2/+15
Add p4merge to the set of built-in diff/merge tools, and update bash completion and documentation. Signed-off-by: Scott Chacon <schacon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-24mergetool--lib: add support for araxis mergeDavid Aguilar1-2/+23
Araxis merge is now a built-in diff/merge tool. This adds araxis to git-completion and updates the documentation to mention araxis. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-09mergetool--lib: specialize diff options for emerge and ecmergeDavid Aguilar1-3/+3
The ecmerge documentation mentions the following form: ecmerge --mode=diff2 $1 $2 Since git-difftool is about diffing, we should use that instead of --mode=merge2. Likewise, this drops the $MERGED argument to emerge, as discussed on the git list ($gmane/117930). Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-12mergetool--lib: simplify API usage by removing more global variablesDavid Aguilar1-51/+58
The mergetool--lib scriplet was tricky to use because it relied upon the existance of several global shell variables. This removes more global variables so that things are simpler for callers. A side effect is that some variables are recomputed each time run_merge_tool() is called, but the overhead for recomputing them is justified by the simpler implementation. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-08difftool/mergetool: refactor commands to use git-mergetool--libDavid Aguilar1-0/+378
This consolidates the common functionality from git-mergetool and git-difftool--helper into a single git-mergetool--lib scriptlet. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>