aboutsummaryrefslogtreecommitdiff
path: root/git-mergetool--lib.sh
Commit message (Collapse)AuthorAge
* Merge branch 'nf/mergetool-prompt'Junio C Hamano2016-05-03
|\ | | | | | | | | | | | | UI consistency improvements. * nf/mergetool-prompt: difftool/mergetool: make the form of yes/no questions consistent
| * difftool/mergetool: make the form of yes/no questions consistentNikola Forró2016-04-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | mergetools: create mergetool_find_win32_cmd() helper function for winmergeJacob Nisnevich2016-04-04
|/ | | | | | 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>
* mergetool-lib: fix default tool selectionMichael J Gruber2015-06-19
| | | | | | | | | | | | | | | | | 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>
* mergetool--lib: set IFS for difftool and mergetoolDavid Aguilar2015-05-20
| | | | | | | | | 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>
* mergetool--lib: remove use of $status globalDavid Aguilar2014-11-21
| | | | | | | | 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>
* mergetool--lib: remove no-op assignment to $status from setup_user_toolJunio C Hamano2014-11-21
| | | | | | | | | | | | | | 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>
* Merge branch 'da/difftool'Junio C Hamano2014-11-18
|\ | | | | | | | | | | | | Fix-up to a new feature in 'master'. * da/difftool: difftool: honor --trust-exit-code for builtin tools
| * difftool: honor --trust-exit-code for builtin toolsDavid Aguilar2014-11-14
| | | | | | | | | | | | | | | | | | | | | | 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>
* | mergetool: rename bc3 to bcJunio C Hamano2014-10-21
|/ | | | | | | | | | 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>
* remove #!interpreter line from shell librariesJonathan Nieder2013-11-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* mergetool--lib: Fix typo in the merge/difftool helpStefan Saasen2013-10-14
| | | | | | | | | | | | | | 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>
* mergetools/diffmerge: support DiffMerge as a git mergetoolStefan Saasen2013-10-13
| | | | | | | | | | | | | | | | 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>
* many small typofixesOndřej Bílka2013-07-29
| | | | | | 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>
* mergetool--lib: refactor {diff,merge}_cmd logicJohn Keeping2013-06-17
| | | | | | | | | | 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>
* doc: generate a list of valid merge toolsDavid Aguilar2013-02-02
| | | | | | | | | | 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>
* mergetool--lib: list user configured tools in '--tool-help'John Keeping2013-02-02
| | | | | Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* mergetool--lib: add functions for finding available toolsDavid Aguilar2013-02-02
| | | | | | | | 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>
* mergetool--lib: improve the help text in guess_merge_tool()David Aguilar2013-01-29
| | | | | | | | | 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>
* mergetool--lib: simplify command expressionsDavid Aguilar2013-01-29
| | | | | | | | | | 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>
* mergetools: simplify how we handle "vim" and "defaults"David Aguilar2013-01-28
| | | | | | | | | | | | | | | 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>
* mergetool--lib: don't call "exit" in setup_toolJohn Keeping2013-01-27
| | | | | | | | | | | | | | | 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>
* mergetool--lib: improve show_tool_help() outputDavid Aguilar2013-01-27
| | | | | | | | | | | 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>
* git-mergetool: don't hardcode 'mergetool' in show_tool_helpJohn Keeping2013-01-25
| | | | | | | | | 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>
* git-mergetool: remove redundant assignmentJohn Keeping2013-01-25
| | | | | | | | | | 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>
* git-mergetool: move show_tool_help to mergetool--libJohn Keeping2013-01-25
| | | | | | | | | 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>
* Merge branch 'da/mergetool-custom'Junio C Hamano2012-10-01
|\ | | | | | | | | | | | | | | | | | | 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
| * mergetool--lib: Allow custom commands to override built-insDavid Aguilar2012-09-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'da/difftool-updates'Junio C Hamano2012-08-27
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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()
| * Add Code Compare v2.80.4 as a merge / diff tool for WindowsSebastian Schuberth2012-08-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | mergetool: support --tool-help option like difftool doesJunio C Hamano2012-07-23
|/ | | | | | | | | | | | | | 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>
* Merge branch 'maint'Junio C Hamano2011-09-19
|\ | | | | | | | | * maint: git-mergetool: check return value from read
| * git-mergetool: check return value from readJay Soffian2011-09-19
| | | | | | | | | | | | | | | | 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>
* | mergetool--lib: Refactor tools into separate filesDavid Aguilar2011-08-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | mergetool--lib: Make style consistent with gitDavid Aguilar2011-08-19
| | | | | | | | | | | | | | | | | | | | 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>
* | misc-sh: fix up whitespace in some other .sh files.Jon Seymour2011-08-05
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'da/git-prefix-everywhere' into nextJunio C Hamano2011-06-29
|\ \ | |/ |/| | | | | | | | | | | * 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
| * git-mergetool--lib: Make vimdiff retain the current directoryDavid Aguilar2011-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Pass empty file to p4merge where no base is suitable.Ciaran Jessup2011-05-01
|/ | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'ss/mergetool--lib'Junio C Hamano2011-03-19
|\ | | | | | | | | | | * ss/mergetool--lib: mergetool--lib: Add Beyond Compare 3 as a tool mergetool--lib: Sort tools alphabetically for easier lookup
| * mergetool--lib: Add Beyond Compare 3 as a toolSebastian Schuberth2011-02-28
| | | | | | | | | | | | 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>
| * mergetool--lib: Sort tools alphabetically for easier lookupSebastian Schuberth2011-02-28
| | | | | | | | | | | | 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>
* | mergetool-lib: call vim in readonly mode for diffsMichael J Gruber2011-02-25
|/ | | | | | | | | | | | | 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>
* mergetool-lib: make the three-way diff the default for vim/gvimDan McGee2010-09-29
| | | | | | | | 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>
* mergetool-lib: add a three-way diff view for vim/gvimDan McGee2010-09-15
| | | | | | | | | | | 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>
* mergetool-lib: combine vimdiff and gvimdiff run blocksDan McGee2010-09-15
| | | | | | | | | 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>
* mergetool: Remove explicit references to /dev/ttyCharles Bailey2010-08-20
| | | | | | | | | | | | | | | 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>
* add shebang line to git-mergetool--lib.shJeff King2010-01-29
| | | | | | | | | | | | | | | | 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>
* Merge branch 'rs/work-around-grep-opt-insanity'Junio C Hamano2009-11-25
|\ | | | | | | | | | | | | | | | | * rs/work-around-grep-opt-insanity: Protect scripted Porcelains from GREP_OPTIONS insanity mergetool--lib: simplify guess_merge_tool() Conflicts: git-instaweb.sh
| * mergetool--lib: simplify guess_merge_tool()René Scharfe2009-11-23
| | | | | | | | | | | | | | | | | | 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>