Skip to content

Commit

Permalink
Merge branch 'da/difftool'
Browse files Browse the repository at this point in the history
* da/difftool:
  mergetool--lib: simplify API usage by removing more global variables
  Fix misspelled mergetool.keepBackup
  difftool/mergetool: refactor commands to use git-mergetool--lib
  mergetool: use $( ... ) instead of `backticks`
  bash completion: add git-difftool
  difftool: add support for a difftool.prompt config variable
  difftool: add various git-difftool tests
  difftool: move 'git-difftool' out of contrib
  difftool/mergetool: add diffuse as merge and diff tool
  difftool: add a -y shortcut for --no-prompt
  difftool: use perl built-ins when testing for msys
  difftool: remove the backup file feature
  difftool: remove merge options for opendiff, tkdiff, kdiff3 and xxdiff
  git-mergetool: add new merge tool TortoiseMerge
  git-mergetool/difftool: make (g)vimdiff workable under Windows
  doc/merge-config: list ecmerge as a built-in merge tool
  • Loading branch information
gitster committed Apr 18, 2009
2 parents 2d430c7 + 47d6592 commit bd15ef0
Show file tree
Hide file tree
Showing 15 changed files with 825 additions and 486 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ git-diff
git-diff-files
git-diff-index
git-diff-tree
git-difftool
git-difftool--helper
git-describe
git-fast-export
git-fast-import
Expand Down Expand Up @@ -79,6 +81,7 @@ git-merge-recursive
git-merge-resolve
git-merge-subtree
git-mergetool
git-mergetool--lib
git-mktag
git-mktree
git-name-rev
Expand Down
21 changes: 21 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,27 @@ diff.suppressBlankEmpty::
A boolean to inhibit the standard behavior of printing a space
before each empty output line. Defaults to false.

diff.tool::
Controls which diff tool is used. `diff.tool` overrides
`merge.tool` when used by linkgit:git-difftool[1] and has
the same valid values as `merge.tool` minus "tortoisemerge"
and plus "kompare".

difftool.<tool>.path::
Override the path for the given tool. This is useful in case
your tool is not in the PATH.

difftool.<tool>.cmd::
Specify the command to invoke the specified diff tool.
The specified command is evaluated in shell with the following
variables available: 'LOCAL' is set to the name of the temporary
file containing the contents of the diff pre-image and 'REMOTE'
is set to the name of the temporary file containing the contents
of the diff post-image.

difftool.prompt::
Prompt before each invocation of the diff tool.

diff.wordRegex::
A POSIX Extended Regular Expression used to determine what is a "word"
when performing word-by-word difference calculations. Character
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,37 @@ git-difftool(1)

NAME
----
git-difftool - compare changes using common merge tools
git-difftool - Show changes using common diff tools

SYNOPSIS
--------
'git difftool' [--tool=<tool>] [--no-prompt] ['git diff' options]
'git difftool' [--tool=<tool>] [-y|--no-prompt|--prompt] [<'git diff' options>]

DESCRIPTION
-----------
'git-difftool' is a git command that allows you to compare and edit files
between revisions using common merge tools. At its most basic level,
'git-difftool' does what 'git-mergetool' does but its use is for non-merge
situations such as when preparing commits or comparing changes against
the index.

'git difftool' is a frontend to 'git diff' and accepts the same
arguments and options.

See linkgit:git-diff[1] for the full list of supported options.
between revisions using common diff tools. 'git difftool' is a frontend
to 'git-diff' and accepts the same options and arguments.

OPTIONS
-------
-y::
--no-prompt::
Do not prompt before launching a diff tool.

--prompt::
Prompt before each invocation of the diff tool.
This is the default behaviour; the option is provided to
override any configuration settings.

-t <tool>::
--tool=<tool>::
Use the merge resolution program specified by <tool>.
Use the diff tool specified by <tool>.
Valid merge tools are:
kdiff3, kompare, tkdiff, meld, xxdiff, emerge,
vimdiff, gvimdiff, ecmerge, and opendiff
kdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff,
ecmerge, diffuse and opendiff
+
If a merge resolution program is not specified, 'git-difftool'
If a diff tool is not specified, 'git-difftool'
will use the configuration variable `diff.tool`. If the
configuration variable `diff.tool` is not set, 'git-difftool'
will pick a suitable default.
Expand All @@ -42,7 +44,7 @@ can configure the absolute path to kdiff3 by setting
`difftool.kdiff3.path`. Otherwise, 'git-difftool' assumes the
tool is available in PATH.
+
Instead of running one of the known merge tool programs,
Instead of running one of the known diff tools,
'git-difftool' can be customized to run an alternative program
by specifying the command line to invoke in a configuration
variable `difftool.<tool>.cmd`.
Expand All @@ -56,29 +58,27 @@ is set to the name of the temporary file containing the contents
of the diff post-image. `$BASE` is provided for compatibility
with custom merge tool commands and has the same value as `$LOCAL`.

--no-prompt::
Do not prompt before launching a diff tool.
See linkgit:git-diff[1] for the full list of supported options.

CONFIG VARIABLES
----------------
'git-difftool' falls back to 'git-mergetool' config variables when the
difftool equivalents have not been defined.

diff.tool::
The default merge tool to use.
The default diff tool to use.

difftool.<tool>.path::
Override the path for the given tool. This is useful in case
your tool is not in the PATH.

difftool.<tool>.cmd::
Specify the command to invoke the specified merge tool.
Specify the command to invoke the specified diff tool.
+
See the `--tool=<tool>` option above for more details.

merge.keepBackup::
The original, unedited file content can be saved to a file with
a `.orig` extension. Defaults to `true` (i.e. keep the backup files).
difftool.prompt::
Prompt before each invocation of the diff tool.

SEE ALSO
--------
Expand Down
54 changes: 54 additions & 0 deletions Documentation/git-mergetool--lib.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
git-mergetool--lib(1)
=====================

NAME
----
git-mergetool--lib - Common git merge tool shell scriptlets

SYNOPSIS
--------
'TOOL_MODE=(diff|merge) . "$(git --exec-path)/git-mergetool--lib"'

DESCRIPTION
-----------

This is not a command the end user would want to run. Ever.
This documentation is meant for people who are studying the
Porcelain-ish scripts and/or are writing new ones.

The 'git-mergetool--lib' scriptlet is designed to be sourced (using
`.`) by other shell scripts to set up functions for working
with git merge tools.

Before sourcing 'git-mergetool--lib', your script must set `TOOL_MODE`
to define the operation mode for the functions listed below.
'diff' and 'merge' are valid values.

FUNCTIONS
---------
get_merge_tool::
returns a merge tool.

get_merge_tool_cmd::
returns the custom command for a merge tool.

get_merge_tool_path::
returns the custom path for a merge tool.

run_merge_tool::
launches a merge tool given the tool name and a true/false
flag to indicate whether a merge base is present.
'$MERGED', '$LOCAL', '$REMOTE', and '$BASE' must be defined
for use by the merge tool.

Author
------
Written by David Aguilar <[email protected]>

Documentation
--------------
Documentation by David Aguilar and the git-list <[email protected]>.

GIT
---
Part of the linkgit:git[1] suite
3 changes: 2 additions & 1 deletion Documentation/git-mergetool.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ OPTIONS
--tool=<tool>::
Use the merge resolution program specified by <tool>.
Valid merge tools are:
kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff
kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,
diffuse, tortoisemerge and opendiff
+
If a merge resolution program is not specified, 'git-mergetool'
will use the configuration variable `merge.tool`. If the
Expand Down
3 changes: 2 additions & 1 deletion Documentation/merge-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ merge.stat::
merge.tool::
Controls which merge resolution program is used by
linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
"tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff",
"diffuse", "ecmerge", "tortoisemerge", and
"opendiff". Any other value is treated is custom merge tool
and there must be a corresponding mergetool.<tool>.cmd option.

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,14 @@ TEST_PROGRAMS =

SCRIPT_SH += git-am.sh
SCRIPT_SH += git-bisect.sh
SCRIPT_SH += git-difftool--helper.sh
SCRIPT_SH += git-filter-branch.sh
SCRIPT_SH += git-lost-found.sh
SCRIPT_SH += git-merge-octopus.sh
SCRIPT_SH += git-merge-one-file.sh
SCRIPT_SH += git-merge-resolve.sh
SCRIPT_SH += git-mergetool.sh
SCRIPT_SH += git-mergetool--lib.sh
SCRIPT_SH += git-parse-remote.sh
SCRIPT_SH += git-pull.sh
SCRIPT_SH += git-quiltimport.sh
Expand All @@ -298,6 +300,7 @@ SCRIPT_SH += git-submodule.sh
SCRIPT_SH += git-web--browse.sh

SCRIPT_PERL += git-add--interactive.perl
SCRIPT_PERL += git-difftool.perl
SCRIPT_PERL += git-archimport.perl
SCRIPT_PERL += git-cvsexportcommit.perl
SCRIPT_PERL += git-cvsimport.perl
Expand Down
1 change: 1 addition & 0 deletions command-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ git-diff mainporcelain common
git-diff-files plumbinginterrogators
git-diff-index plumbinginterrogators
git-diff-tree plumbinginterrogators
git-difftool ancillaryinterrogators
git-fast-export ancillarymanipulators
git-fast-import ancillarymanipulators
git-fetch mainporcelain common
Expand Down
26 changes: 22 additions & 4 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,26 @@ _git_diff ()
__git_complete_file
}

__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff
"

_git_difftool ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--tool=*)
__gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
return
;;
--*)
__gitcomp "--tool="
return
;;
esac
COMPREPLY=()
}

__git_fetch_options="
--quiet --verbose --append --upload-pack --force --keep --depth=
--tags --no-tags
Expand Down Expand Up @@ -1172,10 +1192,7 @@ _git_mergetool ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--tool=*)
__gitcomp "
kdiff3 tkdiff meld xxdiff emerge
vimdiff gvimdiff ecmerge opendiff
" "" "${cur##--tool=}"
__gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
return
;;
--*)
Expand Down Expand Up @@ -1901,6 +1918,7 @@ _git ()
config) _git_config ;;
describe) _git_describe ;;
diff) _git_diff ;;
difftool) _git_difftool ;;
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
fsck) _git_fsck ;;
Expand Down
Loading

0 comments on commit bd15ef0

Please sign in to comment.