Commit graph

26 commits

Author SHA1 Message Date
David Aguilar a427ef7acc mergetool--lib: Allow custom commands to override built-ins
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-09-25 09:04:39 -07:00
Junio C Hamano cae0977221 Merge branch 'th/difftool-diffall'
Rolls the two-directory-diff logic from diffall script (in contrib/) into
"git difftool" framework.

By Tim Henigan
* th/difftool-diffall:
  difftool: print list of valid tools with '--tool-help'
  difftool: teach difftool to handle directory diffs
  difftool: eliminate setup_environment function
  difftool: stop appending '.exe' to git
  difftool: remove explicit change of PATH
  difftool: exit(0) when usage is printed
  difftool: add '--no-gui' option
  difftool: parse options using Getopt::Long
2012-05-07 13:28:44 -07:00
Tim Henigan bf73fc212a difftool: print list of valid tools with '--tool-help'
Since bc7a96a (mergetool--lib: Refactor tools into separate files,
2011-08-18), it is possible to add a new diff tool by creating a simple
script in the '$(git --exec-path)/mergetools' directory.  Updating the
difftool help text is still a manual process, and the documentation can
easily go out of sync.

This commit teaches difftool the '--tool-help' option, which:
  - Reads the list of valid tools from 'mergetools/*'
  - Determines which of them are actually installed
  - Determines which are capable of diffing (i.e. not just a merge tool)
  - Prints the resulting list for the user

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-23 12:00:42 -07:00
Tim Henigan 7e0abcec10 difftool: teach difftool to handle directory diffs
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 <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-23 11:59:34 -07:00
Tim Henigan 850896042a difftool: add '--no-gui' option
This commit teaches difftool to handle the '--no-gui' option. This option
negates the existing '--gui' option. The last setting given on the command
line wins.

This allows a user to configure "[alias] mdt = difftool --gui", but still
have the ability to override the setting without error:

$ git mdt --no-gui

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23 11:46:25 -07:00
David Aguilar d50b2c73b6 t7800: Test difftool passing arguments to diff
git-difftool relies on the ability to forward unknown arguments
to the git-diff command.  Add a test to ensure that this works
as advertised.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-19 09:41:34 -07:00
Junio C Hamano 15a31e7885 t7800: avoid arithmetic expansion notation
The construct "var=$(( something ..." is interpreted by some shells as
arithmetic expansion, even when it clearly is not, e.g.

	var=$((foo; bar) | baz)

Avoid the issue by giving an extra SP to help the parser, i.e.

	var=$( (foo; bar) | baz )

Noticed by Michael J Gruber.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-14 11:11:30 -07:00
Sitaram Chamarty ba959de165 git-difftool: allow skipping file by typing 'n' at prompt
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 <sitaram@atc.tcs.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-10 10:21:11 -07:00
Junio C Hamano 3f4ab62714 test: consolidate definition of $LF
As we seem to need this variable that holds a single LF character
in many places, define it in test-lib.sh and let the test scripts
use it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-11 13:02:47 -07:00
Elijah Newren bc0f35ca23 t7800 (difftool): add missing &&
Also remove a call to 'git config --unset difftool.prompt', since that is
already unset by restore_test_defaults.

Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-06 13:26:13 -07:00
Ævar Arnfjörð Bjarmason 2c4f302607 t/t7800-difftool.sh: Skip with prereq on no PERL
Change t/t7800-difftool.sh to to skip with the the three-arg prereq
form of test_expect_success instead of bailing out.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-18 12:42:45 -07:00
Ævar Arnfjörð Bjarmason fadb5156e4 tests: Skip tests in a way that makes sense under TAP
SKIP messages are now part of the TAP plan. A TAP harness now knows
why a particular test was skipped and can report that information. The
non-TAP harness built into Git's test-lib did nothing special with
these messages, and is unaffected by these changes.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-25 10:08:20 -07:00
David Aguilar 42accaec01 difftool: Fix '--gui' when diff.guitool is unconfigured
When diff.guitool is unconfigured and "--gui" is specified
git-difftool dies with the following error message:

	config diff.guitool: command returned error: 1

Catch the error so that the "--gui" flag is a no-op when
diff.guitool is unconfigured.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28 09:29:12 -07:00
David Aguilar a88183f168 t7800-difftool.sh: Test mergetool.prompt fallback
4cacc621 made difftool fall back to mergetool.prompt
when difftool.prompt is unconfigured.  This adds a test.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-22 22:07:29 -08:00
David Aguilar c8a5672ea5 difftool: Update copyright notices to list each year separately
This is http://www.gnu.org/licenses/gpl-howto.html advises.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15 21:40:08 -08:00
David Aguilar 9f3d54d193 difftool: Use eval to expand '--extcmd' expressions
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 <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15 15:04:45 -08:00
David Aguilar f47f1e2ce8 difftool: Add '-x' and as an alias for '--extcmd'
This adds '-x' as a shorthand for the '--extcmd' option.
Arguments to '--extcmd' can be specified separately, which
was not originally possible.

This also fixes the brief help text so that it mentions
both '-x' and '--extcmd'.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15 15:04:31 -08:00
David Aguilar a9e11220c2 t7800-difftool.sh: Simplify the --extcmd test
Instead of running 'grep', 'echo', and 'wc' we simply compare
git-difftool's output against a known good value.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15 15:04:20 -08:00
David Aguilar 1c6f5b52b7 difftool: Allow specifying unconfigured commands with --extcmd
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: http://article.gmane.org/gmane.comp.version-control.git/133377
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-09 22:41:30 -08:00
David Aguilar 61ed71dcff difftool--helper: Remove use of the GIT_MERGE_TOOL variable
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 <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-09 22:41:29 -08:00
David Aguilar 4cefa495ca git-difftool: Add '--gui' for selecting a GUI tool
Users might prefer to have git-difftool use a different
tool when run from a Git GUI.

This teaches git-difftool to honor 'diff.guitool' when
the '--gui' option is specified.  This allows users to
configure their preferred command-line diff tool in
'diff.tool' and a GUI diff tool in 'diff.guitool'.

Reference: http://article.gmane.org/gmane.comp.version-control.git/133386
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-03 00:29:35 -08:00
David Aguilar 23218bbd2e t7800-difftool: Set a bogus tool for use by tests
If a difftool test has an error then running the git test suite
may end up invoking a GUI diff tool.  We now guard against this
by setting a difftool.bogus-tool.cmd variable.

The tests already used --tool=bogus-tool in various places so
this is simply ensuring that nothing ever falls back and
finds a real diff tool.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-03 00:29:10 -08:00
Markus Heidelberg 3319df6f3a t7800-difftool: fix the effectless GIT_DIFFTOOL_PROMPT test
GIT_DIFFTOOL_PROMPT doesn't have any effect if overridden with --prompt.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-24 17:21:24 -07:00
Jeff King a766829458 t7800: respect NO_PERL
Difftool is written in perl, so we don't build it if NO_PERL
is set.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-24 09:24:35 -07:00
David Aguilar a904392eae difftool: add support for a difftool.prompt config variable
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 <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-07 22:19:56 -07:00
David Aguilar f92f2038a5 difftool: add various git-difftool tests
t7800-difftool.sh tests the various command-line flags,
git-config variables, and environment settings supported by
git-difftool.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-07 22:19:56 -07:00