path: root/
AgeCommit message (Collapse)Author
2019-05-13mergetool: use get_merge_tool functionDenton Liu
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]: Signed-off-by: Denton Liu <> Signed-off-by: Junio C Hamano <>
2016-08-15difftool: always honor fatal error exit codesJohn Keeping
At the moment difftool's "trust exit code" logic always suppresses the exit status of the diff utility we invoke. This is useful because we don't want to exit just because diff returned "1" because the files differ, but it's confusing if the shell returns an error because the selected diff utility is not found. POSIX specifies 127 as the exit status for "command not found", 126 for "command found but is not executable" and values greater than 128 if the command terminated because it received a signal [1] and at least bash and dash follow this specification, while diff utilities generally use "1" for the exit status we want to ignore. Handle any value of 126 or greater as a special value indicating that some form of fatal error occurred. [1] Signed-off-by: John Keeping <> Signed-off-by: Junio C Hamano <>
2016-04-25difftool/mergetool: make the form of yes/no questions consistentNikola Forró
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 <> Signed-off-by: Nikola Forró <> Acked-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2014-11-21difftool--helper: add explicit exit statementDavid Aguilar
git-difftool--helper returns a zero exit status unless --trust-exit-code is in effect. Add an explicit exit statement to make this clearer. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2014-10-28difftool: add support for --trust-exit-codeDavid Aguilar
Teach difftool to exit when a diff tool returns a non-zero exit code when either --trust-exit-code is specified or difftool.trustExitCode is true. Forward exit codes from invoked diff tools to the caller when --trust-exit-code is used. Suggested-by: Adri Farr <> Helped-by: Johannes Sixt <> Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2014-10-27difftool--helper: exit when reading a prompt answer failsJohannes Sixt
An attempt to quit difftool by hitting Ctrl-D (EOF) at its prompt does not quit it, but is treated as if 'yes' was answered to the prompt and all following prompts, which is contrary to the user's intent. Fix the error check. Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
2013-12-06difftool: display the number of files in the diff queue in the promptZoltan Klinger
When --prompt option is set, git-difftool displays a prompt for each modified file to be viewed in an external diff program. At that point, it could be useful to display a counter and the total number of files in the diff queue. Below is the current difftool prompt for the first of 5 modified files: Viewing: 'diff.c' Launch 'vimdiff' [Y/n]: Consider the modified prompt: Viewing (1/5): 'diff.c' Launch 'vimdiff' [Y/n]: The current GIT_EXTERNAL_DIFF mechanism does not tell the number of paths in the diff queue nor the current counter. To make this "counter/total" info available for GIT_EXTERNAL_DIFF programs without breaking existing ones by doing the following: - Keep track of the number of paths shown so far in diff_options; - Export two new environment variables from run_external_diff() to show the total number of paths (from diff_queue_struct) and the current value of the counter (from diff_options); and - Update git-difftool--helper to use these two environment variables. Signed-off-by: Zoltan Klinger <> Signed-off-by: Junio C Hamano <>
2013-02-10difftool--helper: fix printf usageDavid Aguilar
Do not use a random string as if it is a format string for printf when showing it literally; instead feed it to '%s' format. Reported-by: Asheesh Laroia <> Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2012-04-23difftool: teach difftool to handle directory diffsTim Henigan
When 'difftool' is called to compare a range of commits that modify more than one file, it opens a separate instance of the diff tool for each file that changed. The new '--dir-diff' option copies all the modified files to a temporary location and runs a directory diff on them in a single instance of the diff tool. Signed-off-by: Tim Henigan <> Signed-off-by: Junio C Hamano <>
2011-10-10git-difftool: allow skipping file by typing 'n' at promptSitaram Chamarty
This is useful if you forgot to restrict the diff to the paths you want to see, or selecting precisely the ones you want is too much typing. [jc: with a change to return from the function upon 'n' by Charles Bailey and a small tweak in stdin_doesnot_contain() in the test] Signed-off-by: Sitaram Chamarty <> Signed-off-by: Junio C Hamano <>
2011-08-19difftool--helper: Make style consistent with gitDavid Aguilar
Use the predominant conditional style where "then" appears alone on the line after the test expression. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2010-12-16difftool: provide basename to external toolsMichael J Gruber
Currently, only configured diff helpers get the basename of the file being compared. Tools specified with "git difftool -x" only get the names of temporary files for the different versions. Export BASE so that an external tool can read the name from the environment. Rather than using a third argument, this avoids breaking existing scripts which may somewhat carelessly be using "$@" rather than "$1" "$2". Signed-off-by: Michael J Gruber <> Signed-off-by: Junio C Hamano <>
2010-01-22Make difftool.prompt fall back to mergetool.promptSebastian Schuberth
The documentation states that "git-difftool falls back to git-mergetool config variables when the difftool equivalents have not been defined". Until now, this was not the case for "difftool.prompt". Signed-off-by: Sebastian Schuberth <> Acked-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2010-01-16difftool: Update copyright notices to list each year separatelyDavid Aguilar
This is advises. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2010-01-15difftool: Use eval to expand '--extcmd' expressionsDavid Aguilar
It was not possible to pass quoted commands to '--extcmd'. By using 'eval' we ensure that expressions with spaces and quotes are supported. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2010-01-10difftool: Allow specifying unconfigured commands with --extcmdDavid Aguilar
git-difftool requires difftool.<tool>.cmd configuration even when tools use the standard "$diffcmd $from $to" form. This teaches git-difftool to run these tools in lieu of configuration by allowing the command to be specified on the command line. Reference: Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2010-01-10difftool--helper: Remove use of the GIT_MERGE_TOOL variableDavid Aguilar
An undocumented mis-feature in git-difftool is that it allows you to specify a default difftool by setting GIT_MERGE_TOOL. This behavior was never documented and was included as an oversight back when git-difftool was maintained outside of git. git-mergetool never honored GIT_MERGE_TOOL so neither should git-difftool. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2010-01-10difftool--helper: Update copyright and remove distracting commentsDavid Aguilar
Some of the comments in git-difftool--helper are not needed because the code is sufficiently readable without them. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2009-04-12mergetool--lib: simplify API usage by removing more global variablesDavid Aguilar
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 <> Signed-off-by: Junio C Hamano <>
2009-04-08difftool/mergetool: refactor commands to use git-mergetool--libDavid Aguilar
This consolidates the common functionality from git-mergetool and git-difftool--helper into a single git-mergetool--lib scriptlet. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2009-04-08difftool: add support for a difftool.prompt config variableDavid Aguilar
difftool now supports difftool.prompt so that users do not have to pass --no-prompt or hit enter each time a diff tool is launched. The --prompt flag overrides the configuration variable. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>
2009-04-08difftool: move 'git-difftool' out of contribDavid Aguilar
This prepares 'git-difftool' and its documentation for mainstream use. 'git-difftool-helper' became 'git-difftool--helper' since users should not use it directly. 'git-difftool' was added to the list of commands as an ancillaryinterrogator. Signed-off-by: David Aguilar <> Signed-off-by: Junio C Hamano <>